# Path: sts/util/procutils.py
# def popen_filtered(name, args, cwd=None, env=None, redirect_output=True,
#                    shell=False):
#   if shell and type(args) == list:
#     args = ' '.join(args)
#   try:
#     # note: the preexec_fn below makes the process its own session leader.
#     # This means that a CTRL-C on the shell will not be passed on to the process,
#     # which enables us to jump between Fuzzing/Replay and Interactive mode.
#     cmd = subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell,
#                            stderr=subprocess.PIPE, stdin=sys.stdin, cwd=cwd, env=env,
#                            preexec_fn=lambda: os.setsid())
#   except OSError as e:
#     raise OSError("Error launching %s in directory %s: %s (error %d)" % (args, cwd, e.strerror, e.errno))
#   if redirect_output:
#     cmd._stdout_thread = _prefix_thread(cmd.stdout, partial(color_normal, label=name))
#     cmd._stderr_thread = _prefix_thread(cmd.stderr, partial(color_error, label=name))
#   return cmd
# 
# 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/util/convenience.py
# def get_json_attr(obj):
#   """
#   Returns the serialized version of the object if it has to_json() defined
#   """
#   if hasattr(obj, "to_json"):
#     return getattr(obj, "to_json")()
#   else:
#     return obj


import abc
import logging
        import paramiko
      import paramiko
from functools import partial
from pox.openflow.libopenflow_01 import ofp_phy_port
from sts.util.procutils import popen_filtered
from sts.util.convenience import object_fullname
from sts.util.convenience import class_fullname
from sts.util.convenience import load_class
from sts.util.convenience import get_json_attr
    from sts.util.procutils import _prefix_thread
    from sts.util.procutils import color_normal
    from sts.util.procutils import color_error
  def port1(self):
    return self._port1

  @property
  def node2(self):
    return self._node2

  @property
  def port2(self):
    return self._port2

  def __eq__(self, other):
    return ((self.node1 == getattr(other, 'node1', None) and
             self.port1 == getattr(other, 'port1', None) and
             self.node2 == getattr(other, 'node2', None) and
             self.port2 == getattr(other, 'port2', None)) or
             (self.node1 == getattr(other, 'node2', None) and
              self.port1 == getattr(other, 'port2', None) and
              self.node2 == getattr(other, 'node1', None) and
              self.port2 == getattr(other, 'port1', None)))

  def __ne__(self, other):
    return not self.__eq__(other)

  def __repr__(self):
    return "(%s:%s) <-> (%s:%s)" % (self.node1, self.port1,
                                    self.node2, self.port2)

  def to_json(self):
    """Serialize to JSON dict"""

# Path: sts/util/procutils.py
# def popen_filtered(name, args, cwd=None, env=None, redirect_output=True,
#                    shell=False):
#   if shell and type(args) == list:
#     args = ' '.join(args)
#   try:
#     # note: the preexec_fn below makes the process its own session leader.
#     # This means that a CTRL-C on the shell will not be passed on to the process,
#     # which enables us to jump between Fuzzing/Replay and Interactive mode.
#     cmd = subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell,
#                            stderr=subprocess.PIPE, stdin=sys.stdin, cwd=cwd, env=env,
#                            preexec_fn=lambda: os.setsid())
#   except OSError as e:
#     raise OSError("Error launching %s in directory %s: %s (error %d)" % (args, cwd, e.strerror, e.errno))
#   if redirect_output:
#     cmd._stdout_thread = _prefix_thread(cmd.stdout, partial(color_normal, label=name))
#     cmd._stderr_thread = _prefix_thread(cmd.stderr, partial(color_error, label=name))
#   return cmd
# 
# 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/util/convenience.py
# def get_json_attr(obj):
#   """
#   Returns the serialized version of the object if it has to_json() defined
#   """
#   if hasattr(obj, "to_json"):
#     return getattr(obj, "to_json")()
#   else:
#     return obj


# Path: sts/entities/base.py
import abc
import logging
        import paramiko
      import paramiko
from functools import partial
from pox.openflow.libopenflow_01 import ofp_phy_port
from sts.util.procutils import popen_filtered
from sts.util.convenience import object_fullname
from sts.util.convenience import class_fullname
from sts.util.convenience import load_class
from sts.util.convenience import get_json_attr
    from sts.util.procutils import _prefix_thread
    from sts.util.procutils import color_normal
    from sts.util.procutils import color_error

  def port1(self):
    return self._port1

  @property
  def node2(self):
    return self._node2

  @property
  def port2(self):
    return self._port2

  def __eq__(self, other):
    return ((self.node1 == getattr(other, 'node1', None) and
             self.port1 == getattr(other, 'port1', None) and
             self.node2 == getattr(other, 'node2', None) and
             self.port2 == getattr(other, 'port2', None)) or
             (self.node1 == getattr(other, 'node2', None) and
              self.port1 == getattr(other, 'port2', None) and
              self.node2 == getattr(other, 'node1', None) and
              self.port2 == getattr(other, 'port1', None)))

  def __ne__(self, other):
    return not self.__eq__(other)

  def __repr__(self):
    return "(%s:%s) <-> (%s:%s)" % (self.node1, self.port1,
                                    self.node2, self.port2)

  def to_json(self):
    """Serialize to JSON dict"""

    return {'__type__': object_fullname(self),