# -*- coding: utf-8 -*-
#
-__version__ = '1.1'
-
import sys
import os
import re
# -*- coding: utf-8 -*-
#
-__version__ = '1.1'
-
from linkobject import LinkObject
NAMESPACE_TYPE = 6
NOT_CONNECTED_TYPE = 7
- def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+ def __init__(self, label, device_type=DEFAULT_TYPE, metadata={}):
self.label = label
- self.type = type
+ self.device_type = device_type
self.metadata = metadata
+
+ def __repr__(self):
+ return "{\"label\":\"" + self.label + \
+ "\",\"device_type\":\"" + repr(self.device_type) + \
+ "\",\"meta\":" + self._blank_dict(self.metadata) + "}"
+
# -*- coding: utf-8 -*-
#
-
class LinkObject(object):
DEFAULT_TYPE = 1
- def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+ def __init__(self, label, metadata={}):
self.label = label
- self.type = type
self.metadata = metadata
@apply
def set(self, attr, attr_value):
self.metadata[attr] = attr_value
- @apply
- def type():
- def get(self):
- return self.type
-
- def set(self, type):
- self.type = type
-
def __str__(self):
return self.label
def __repr__(self):
return "{\"label\":\"" + self.label + \
- "\",\"type\":\"" + repr(self.type) + \
"\",\"meta\":" + self._blank_dict(self.metadata) + "}"
def _blank_dict(self, dict_object):
repr(format_name)
else:
return "\"\""
-
+
+ def get_linkpair_linkid(self):
+ return str(self.device1).replace(" ", "_") + "__" + \
+ str(self.device2).replace(" ", "_") + "__" + \
+ str(self.port1).replace(" ", "_") + "__" + \
+ str(self.port2).replace(" ", "_")
+
def to_json(self):
return "{\"device1\":" + repr(self.device1) + "," + \
"\"device2\":" + repr(self.device2) + "," + \
# -*- coding: utf-8 -*-
#
-__version__ = '1.1'
-
from linkobject import LinkObject
class Port(LinkObject):
DEFAULT_TYPE = 1
- def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+ def __init__(self, label, port_type=DEFAULT_TYPE, metadata={}):
self.label = label
- self.type = type
+ self.port_type = port_type
self.metadata = metadata
+
+
+ def __repr__(self):
+ return "{\"label\":\"" + self.label + \
+ "\",\"port_type\":\"" + repr(self.port_type) + \
+ "\",\"meta\":" + self._blank_dict(self.metadata) + "}"
+