# Path: sts/util/convenience.py
# def object_fullname(obj):
#   """Return the fullname of an object"""
#   return obj.__module__ + "." + obj.__class__.__name__
# 
# Path: sts/util/convenience.py
# def class_fullname(cls):
#   """Return the fullname of a class"""
#   return cls.__module__ + "." + cls.__name__
# 
# Path: sts/util/convenience.py
# def load_class(str_full_type):
#   """
#   Load a python class given full qualified name.
#   """
#   type_s = str_full_type.split('.')
#   mod = importlib.import_module('.'.join(type_s[:-1]))
#   cls = getattr(mod, type_s[-1])
#   return cls


import abc
import logging
import sts.util.network_namespace as ns
from itertools import count
from pox.openflow.software_switch import DpPacketOut
from pox.lib.revent import EventMixin
from pox.lib.packet.ethernet import ethernet
from pox.lib.packet.ipv4 import ipv4
from pox.lib.packet.tcp import tcp
from pox.lib.packet.arp import arp
from pox.lib.addresses import EthAddr
from pox.lib.addresses import IPAddr
from sts.util.convenience import object_fullname
from sts.util.convenience import class_fullname
from sts.util.convenience import load_class
      return
    io_worker.consume_receive_buf(packet.hdr_len + packet.payload_len)
    self.log.info("received packet from netns %s: " % str(packet))
    super(NamespaceHost, self).send(self.interfaces[0], packet)

  def receive(self, interface, packet):
    """
    Send an incoming packet from a switch to the Namespace.

    Called by PatchPanel.
    """
    self.log.info("received packet on interface %s: %s. Passing to netns" %
                  (interface.name, str(packet)))
    self.io_worker.send(packet.pack())

  def to_json(self):
    """Serialize to JSON dict"""
    return {'__type__': object_fullname(self),
            'name': self.name,
            'hid': self.hid,
            'cmd': self.cmd,
            'interfaces': [iface.to_json() for iface in self.interfaces]}

  @classmethod
  def from_json(cls, json_hash, create_io_worker):
    name = json_hash['name']
    hid = json_hash['hid']
    cmd = json_hash['cmd']
    interfaces = []
    for iface in json_hash['interfaces']:

# Path: sts/util/convenience.py
# def object_fullname(obj):
#   """Return the fullname of an object"""
#   return obj.__module__ + "." + obj.__class__.__name__
# 
# Path: sts/util/convenience.py
# def class_fullname(cls):
#   """Return the fullname of a class"""
#   return cls.__module__ + "." + cls.__name__
# 
# Path: sts/util/convenience.py
# def load_class(str_full_type):
#   """
#   Load a python class given full qualified name.
#   """
#   type_s = str_full_type.split('.')
#   mod = importlib.import_module('.'.join(type_s[:-1]))
#   cls = getattr(mod, type_s[-1])
#   return cls


# Path: sts/entities/hosts.py
import abc
import logging
import sts.util.network_namespace as ns
from itertools import count
from pox.openflow.software_switch import DpPacketOut
from pox.lib.revent import EventMixin
from pox.lib.packet.ethernet import ethernet
from pox.lib.packet.ipv4 import ipv4
from pox.lib.packet.tcp import tcp
from pox.lib.packet.arp import arp
from pox.lib.addresses import EthAddr
from pox.lib.addresses import IPAddr
from sts.util.convenience import object_fullname
from sts.util.convenience import class_fullname
from sts.util.convenience import load_class

      return
    io_worker.consume_receive_buf(packet.hdr_len + packet.payload_len)
    self.log.info("received packet from netns %s: " % str(packet))
    super(NamespaceHost, self).send(self.interfaces[0], packet)

  def receive(self, interface, packet):
    """
    Send an incoming packet from a switch to the Namespace.

    Called by PatchPanel.
    """
    self.log.info("received packet on interface %s: %s. Passing to netns" %
                  (interface.name, str(packet)))
    self.io_worker.send(packet.pack())

  def to_json(self):
    """Serialize to JSON dict"""
    return {'__type__': object_fullname(self),
            'name': self.name,
            'hid': self.hid,
            'cmd': self.cmd,
            'interfaces': [iface.to_json() for iface in self.interfaces]}

  @classmethod
  def from_json(cls, json_hash, create_io_worker):
    name = json_hash['name']
    hid = json_hash['hid']
    cmd = json_hash['cmd']
    interfaces = []
    for iface in json_hash['interfaces']:

      iface_cls = load_class(iface['__type__'])