cleanup of core.api, core.emulator, core.pnodes

This commit is contained in:
bharnden 2018-10-11 14:49:22 -07:00
parent aa91bb67a1
commit 05a5574155
3 changed files with 10 additions and 10 deletions

View file

@ -91,7 +91,7 @@ class CoreTlvDataObj(CoreTlvData):
"""
@classmethod
def pack(cls, obj):
def pack(cls, value):
"""
Convenience method for packing custom object data.
@ -99,7 +99,7 @@ class CoreTlvDataObj(CoreTlvData):
:return: length of data and the packed data itself
:rtype: tuple
"""
value = cls.get_value(obj)
value = cls.get_value(value)
return super(CoreTlvDataObj, cls).pack(value)
@classmethod
@ -244,7 +244,7 @@ class CoreTlvDataUint16List(CoreTlvData):
:return: unint 16 list
:rtype: list
"""
return tuple(map(lambda (x): int(x), value.split()))
return tuple(int(x) for x in value.split())
class CoreTlvDataIpv4Addr(CoreTlvDataObj):
@ -266,7 +266,7 @@ class CoreTlvDataIpv4Addr(CoreTlvDataObj):
return obj.addr
@staticmethod
def new_obj(value):
def new_obj(obj):
"""
Retrieve Ipv4 address from a string representation.
@ -274,7 +274,7 @@ class CoreTlvDataIpv4Addr(CoreTlvDataObj):
:return: Ipv4 address
:rtype: core.misc.ipaddress.IpAddress
"""
return IpAddress(af=socket.AF_INET, address=value)
return IpAddress(af=socket.AF_INET, address=obj)
class CoreTlvDataIPv6Addr(CoreTlvDataObj):
@ -380,7 +380,7 @@ class CoreTlv(object):
tlv_type, tlv_len = struct.unpack(cls.header_format, data[:cls.header_len])
header_len = cls.header_len
if tlv_len == 0:
tlv_type, zero, tlv_len = struct.unpack(cls.long_header_format, data[:cls.long_header_len])
tlv_type, _zero, tlv_len = struct.unpack(cls.long_header_format, data[:cls.long_header_len])
header_len = cls.long_header_len
tlv_size = header_len + tlv_len
# for 32-bit alignment

View file

@ -262,7 +262,7 @@ class EmuSession(Session):
# network to network
if net_one and net_two:
logger.info("adding link from network to network: %s", net_one.name, net_two.name)
logger.info("adding link from network to network: %s - %s", net_one.name, net_two.name)
if nodeutils.is_node(net_two, NodeTypes.RJ45):
interface = net_two.linknet(net_one)
else:
@ -326,7 +326,7 @@ class EmuSession(Session):
:return: nothing
"""
# get node objects identified by link data
node_one, node_two, net_one, net_two, tunnel = self._link_nodes(node_one_id, node_two_id)
node_one, node_two, net_one, net_two, _tunnel = self._link_nodes(node_one_id, node_two_id)
if node_one:
node_one.lock.acquire()
@ -388,7 +388,7 @@ class EmuSession(Session):
:return: nothing
"""
# get node objects identified by link data
node_one, node_two, net_one, net_two, tunnel = self._link_nodes(node_one_id, node_two_id)
node_one, node_two, net_one, net_two, _tunnel = self._link_nodes(node_one_id, node_two_id)
if node_one:
node_one.lock.acquire()

View file

@ -35,7 +35,7 @@ class PhysicalNode(PyCoreNode):
with self.lock:
while self._mounts:
source, target = self._mounts.pop(-1)
_source, target = self._mounts.pop(-1)
self.umount(target)
for netif in self.netifs():