diff options
Diffstat (limited to 'Monitoring/src/main/python/Resource')
20 files changed, 502 insertions, 0 deletions
diff --git a/Monitoring/src/main/python/Resource/__init__$py.class b/Monitoring/src/main/python/Resource/__init__$py.class Binary files differnew file mode 100644 index 0000000..e516ea7 --- /dev/null +++ b/Monitoring/src/main/python/Resource/__init__$py.class diff --git a/Monitoring/src/main/python/Resource/__init__.py b/Monitoring/src/main/python/Resource/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Monitoring/src/main/python/Resource/__init__.py diff --git a/Monitoring/src/main/python/Resource/__init__.py.old b/Monitoring/src/main/python/Resource/__init__.py.old new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Monitoring/src/main/python/Resource/__init__.py.old diff --git a/Monitoring/src/main/python/Resource/interface$py.class b/Monitoring/src/main/python/Resource/interface$py.class Binary files differnew file mode 100644 index 0000000..a4209ac --- /dev/null +++ b/Monitoring/src/main/python/Resource/interface$py.class diff --git a/Monitoring/src/main/python/Resource/interface.py b/Monitoring/src/main/python/Resource/interface.py new file mode 100644 index 0000000..e6f28d5 --- /dev/null +++ b/Monitoring/src/main/python/Resource/interface.py @@ -0,0 +1,79 @@ +''' +Created on Jul 11, 2012 + +@author: steger +''' +from Resource.resource import resource + +class interface(resource): + ''' + classdocs + ''' + UNDEFINED = 0 + INGRESS = 1 + EGRESS = 2 + + def __init__(self, name = None, resourceid = None): + resource.__init__(self, name, resourceid) + self._public = False + self._direction = self.UNDEFINED + self._iface = None + self._address = None + self._hostname = None + + def setvalues(self, ifacename, address, ispublic = False, direction = 0, hostname = None): + self.interface = ifacename + self.address = address + self.ispublic = ispublic + self.direction = direction + self.hostname = hostname + + def _get_ispublic(self): + if not self._iface: + raise Exception("No interface name defined yet for %s" % self.resourceid) + if not self._address: + raise Exception("No address defined yet for %s" % self.resourceid) + return self._public + def _set_ispublic(self, ispublic): + if isinstance(ispublic, bool): + self._public = ispublic + else: + self._public = False + + def _get_hostname(self): + return self._hostname + def _set_hostname(self, hostname): + self._hostname = self.ipret(hostname) + + def _get_address(self): + return self._address + def _set_address(self, address): + if isinstance(address, tuple): + self._address = address + else: + self._address = self.ipret(address) + + def _get_interface(self): + return self._iface + def _set_interface(self, iface): + self._iface = self.ipret(iface) + + def _get_direction(self): + return self._direction + def _set_direction(self, direction): + self._direction = direction & (self.INGRESS | self.EGRESS) + + def _get_isvalid(self): + return self.address and self.interface + + direction = property(_get_direction,_set_direction,None) + + ispublic = property(_get_ispublic,_set_ispublic,None) + + isvalid = property(_get_isvalid,None,None) + + hostname = property(_get_hostname,_set_hostname,None) + + address = property(_get_address,_set_address,None) + + interface = property(_get_interface,_set_interface,None) diff --git a/Monitoring/src/main/python/Resource/interface.py.old b/Monitoring/src/main/python/Resource/interface.py.old new file mode 100644 index 0000000..db7b2d3 --- /dev/null +++ b/Monitoring/src/main/python/Resource/interface.py.old @@ -0,0 +1,78 @@ +''' +Created on Jul 11, 2012 + +@author: steger +''' +from Resource.resource import resource + +class interface(resource): + ''' + classdocs + ''' + UNDEFINED = 0 + INGRESS = 1 + EGRESS = 2 + + def __init__(self, name = None, resourceid = None): + resource.__init__(self, name, resourceid) + self._public = False + self._direction = self.UNDEFINED + self._iface = None + self._address = None + self._hostname = None + + def setvalues(self, ifacename, address, ispublic = False, direction = 0, hostname = None): + self.interface = ifacename + self.address = address + self.ispublic = ispublic + self.direction = direction + self.hostname = hostname + + @property + def ispublic(self): + if not self._iface: + raise Exception("No interface name defined yet for %s" % self.resourceid) + if not self._address: + raise Exception("No address defined yet for %s" % self.resourceid) + return self._public + @ispublic.setter + def ispublic(self, ispublic): + if isinstance(ispublic, bool): + self._public = ispublic + else: + self._public = False + + @property + def hostname(self): + return self._hostname + @hostname.setter + def hostname(self, hostname): + self._hostname = self.ipret(hostname) + + @property + def address(self): + return self._address + @address.setter + def address(self, address): + if isinstance(address, tuple): + self._address = address + else: + self._address = self.ipret(address) + + @property + def interface(self): + return self._iface + @interface.setter + def interface(self, iface): + self._iface = self.ipret(iface) + + @property + def direction(self): + return self._direction + @direction.setter + def direction(self, direction): + self._direction = direction & (self.INGRESS | self.EGRESS) + + @property + def isvalid(self): + return self.address and self.interface diff --git a/Monitoring/src/main/python/Resource/link$py.class b/Monitoring/src/main/python/Resource/link$py.class Binary files differnew file mode 100644 index 0000000..c11e052 --- /dev/null +++ b/Monitoring/src/main/python/Resource/link$py.class diff --git a/Monitoring/src/main/python/Resource/link.py b/Monitoring/src/main/python/Resource/link.py new file mode 100644 index 0000000..4204442 --- /dev/null +++ b/Monitoring/src/main/python/Resource/link.py @@ -0,0 +1,33 @@ +''' +Created on May 31, 2012 + +@author: steger +''' +from Resource.resource import resource +from Resource.node import node +from Resource.interface import interface + +class link(resource): + def __init__(self, name = None, resourceid = None, source = None, destination = None): + resource.__init__(self, name, resourceid) + self._source = source + self._destination = destination + + def _get_source(self): + return self._source + def _set_source(self, source): + if isinstance(source, interface): #laki + self._source = source + def _del_source(self): + self._source = None + + def _get_destination(self): + return self._destination + def _set_destination(self, destination): + if isinstance(destination, interface): #laki + self._destination = destination + def _del_destination(self): + self._destination = None + source = property(_get_source,_set_source,_del_source) + + destination = property(_get_destination,_set_destination,_del_destination) diff --git a/Monitoring/src/main/python/Resource/link.py.old b/Monitoring/src/main/python/Resource/link.py.old new file mode 100644 index 0000000..6e32dd9 --- /dev/null +++ b/Monitoring/src/main/python/Resource/link.py.old @@ -0,0 +1,35 @@ +''' +Created on May 31, 2012 + +@author: steger +''' +from Resource.resource import resource +from Resource.node import node + +class link(resource): + def __init__(self, name = None, resourceid = None, source = None, destination = None): + resource.__init__(self, name, resourceid) + self._source = source + self._destination = destination + + @property + def source(self): + return self._source + @source.setter + def source(self, source): + if isinstance(source, node): + self._source = source + @source.deleter + def source(self): + self._source = None + + @property + def destination(self): + return self._destination + @destination.setter + def destination(self, destination): + if isinstance(destination, node): + self._destination = destination + @destination.deleter + def destination(self): + self._destination = None
\ No newline at end of file diff --git a/Monitoring/src/main/python/Resource/node$py.class b/Monitoring/src/main/python/Resource/node$py.class Binary files differnew file mode 100644 index 0000000..373fc57 --- /dev/null +++ b/Monitoring/src/main/python/Resource/node$py.class diff --git a/Monitoring/src/main/python/Resource/node.py b/Monitoring/src/main/python/Resource/node.py new file mode 100644 index 0000000..fe2fc38 --- /dev/null +++ b/Monitoring/src/main/python/Resource/node.py @@ -0,0 +1,49 @@ +''' +Created on May 31, 2012 + +@author: steger +''' +from Resource.resource import resource +from Resource.interface import interface + +class node(resource): + def __init__(self, name = None, resourceid = None): + resource.__init__(self, name, resourceid) + self._public = False + self._interfaces = {} + + def _get_ispublic(self): + if not len(self._interfaces): + raise Exception("No interfaces defined yet for %s" % self.resourceid) + return self._public + + def addinterface(self, iface): + if not isinstance(iface, interface): + raise Exception("Wrong resource type %s is not an interface" % iface) + self._interfaces[iface.interface] = iface + self._public |= iface.ispublic + + def interfaces(self): + for iface in self._interfaces.itervalues(): + if not iface.isvalid: + print "WW: invalid interface:", iface.resourceid + continue + yield iface.interface, iface.address, iface.ispublic, iface.hostname, iface.direction + + def get_ipaddress(self, interfacename): + for ifname, address, _, _, _ in self.interfaces(): + if ifname == interfacename: + return address + raise Exception("%s has no interface %s" % (self.resourceid, interfacename)) + + def get_hostname(self, interfacename): + for ifname, address, _, hostname, _ in self.interfaces(): + if ifname != interfacename: + continue + if hostname: + return hostname + else: + return address + raise Exception("%s has no interface %s" % (self.resourceid, interfacename)) + + ispublic = property(_get_ispublic,None,None) diff --git a/Monitoring/src/main/python/Resource/node.py.old b/Monitoring/src/main/python/Resource/node.py.old new file mode 100644 index 0000000..5a65121 --- /dev/null +++ b/Monitoring/src/main/python/Resource/node.py.old @@ -0,0 +1,48 @@ +''' +Created on May 31, 2012 + +@author: steger +''' +from Resource.resource import resource +from Resource.interface import interface + +class node(resource): + def __init__(self, name = None, resourceid = None): + resource.__init__(self, name, resourceid) + self._public = False + self._interfaces = {} + + @property + def ispublic(self): + if not len(self._interfaces): + raise Exception("No interfaces defined yet for %s" % self.resourceid) + return self._public + + def addinterface(self, iface): + if not isinstance(iface, interface): + raise Exception("Wrong resource type %s is not an interface" % iface) + self._interfaces[iface.interface] = iface + self._public |= iface.ispublic + + def interfaces(self): + for iface in self._interfaces.itervalues(): + if not iface.isvalid: + print "WW: invalid interface:", iface.resourceid + continue + yield iface.interface, iface.address, iface.ispublic, iface.hostname, iface.direction + + def get_ipaddress(self, interfacename): + for ifname, address, _, _, _ in self.interfaces(): + if ifname == interfacename: + return address + raise Exception("%s has no interface %s" % (self.resourceid, interfacename)) + + def get_hostname(self, interfacename): + for ifname, address, _, hostname, _ in self.interfaces(): + if ifname != interfacename: + continue + if hostname: + return hostname + else: + return address + raise Exception("%s has no interface %s" % (self.resourceid, interfacename)) diff --git a/Monitoring/src/main/python/Resource/path$py.class b/Monitoring/src/main/python/Resource/path$py.class Binary files differnew file mode 100644 index 0000000..a575bba --- /dev/null +++ b/Monitoring/src/main/python/Resource/path$py.class diff --git a/Monitoring/src/main/python/Resource/path.py b/Monitoring/src/main/python/Resource/path.py new file mode 100644 index 0000000..6296bc4 --- /dev/null +++ b/Monitoring/src/main/python/Resource/path.py @@ -0,0 +1,9 @@ +''' +Created on Jun 12, 2012 + +@author: steger +''' +from Resource.link import link + +class path(link): + pass
\ No newline at end of file diff --git a/Monitoring/src/main/python/Resource/path.py.old b/Monitoring/src/main/python/Resource/path.py.old new file mode 100644 index 0000000..6296bc4 --- /dev/null +++ b/Monitoring/src/main/python/Resource/path.py.old @@ -0,0 +1,9 @@ +''' +Created on Jun 12, 2012 + +@author: steger +''' +from Resource.link import link + +class path(link): + pass
\ No newline at end of file diff --git a/Monitoring/src/main/python/Resource/resource$py.class b/Monitoring/src/main/python/Resource/resource$py.class Binary files differnew file mode 100644 index 0000000..9bb5d7a --- /dev/null +++ b/Monitoring/src/main/python/Resource/resource$py.class diff --git a/Monitoring/src/main/python/Resource/resource.py b/Monitoring/src/main/python/Resource/resource.py new file mode 100644 index 0000000..e55e104 --- /dev/null +++ b/Monitoring/src/main/python/Resource/resource.py @@ -0,0 +1,41 @@ +''' +Created on May 31, 2012 + +@author: steger +''' + +class resource(object): + def __init__(self, name = None, resourceid = None): + self._name = name + self._resourceid = resourceid + + @staticmethod + def ipret(x): + if not x: + return None + x = str(x) + if len(x): + return x + else: + return None + + def _get_name(self): + if self._name is None: + raise Exception("resource name is not set") + return self._name + def _set_name(self, name): + self._name = self.ipret(name) + def _del_name(self): + self._name = None + + def _get_resourceid(self): + if self._resourceid is None: + raise Exception("resource id is not set") + return self._resourceid + def _set_resourceid(self, resourceid): + self._resourceid = resourceid + def _del_resourceid(self): + self._resourceid = None + resourceid = property(_get_resourceid,_set_resourceid,_del_resourceid) + + name = property(_get_name,_set_name,_del_name) diff --git a/Monitoring/src/main/python/Resource/resource.py.old b/Monitoring/src/main/python/Resource/resource.py.old new file mode 100644 index 0000000..fb093bd --- /dev/null +++ b/Monitoring/src/main/python/Resource/resource.py.old @@ -0,0 +1,44 @@ +''' +Created on May 31, 2012 + +@author: steger +''' + +class resource(object): + def __init__(self, name = None, resourceid = None): + self._name = name + self._resourceid = resourceid + + @staticmethod + def ipret(x): + if not x: + return None + x = str(x) + if len(x): + return x + else: + return None + + @property + def name(self): + if self._name is None: + raise Exception("resource name is not set") + return self._name + @name.setter + def name(self, name): + self._name = self.ipret(name) + @name.deleter + def name(self): + self._name = None + + @property + def resourceid(self): + if self._resourceid is None: + raise Exception("resource id is not set") + return self._resourceid + @resourceid.setter + def resourceid(self, resourceid): + self._resourceid = resourceid + @resourceid.deleter + def resourceid(self): + self._resourceid = None
\ No newline at end of file diff --git a/Monitoring/src/main/python/Resource/slice.py b/Monitoring/src/main/python/Resource/slice.py new file mode 100644 index 0000000..a66a93d --- /dev/null +++ b/Monitoring/src/main/python/Resource/slice.py @@ -0,0 +1,37 @@ +''' +Created on Oct 30, 2012 + +@author: steger +''' + +class slice_pointer(object): + ''' + classdocs + ''' + + def __init__(self, sliceid = None, slicename = ""): + ''' + Constructor + ''' + self._sliceid = sliceid + self._name = slicename + + def _get_sliceid(self): + if self._sliceid is None: + raise Exception("slice id is not set") + return self._sliceid + def _set_sliceid(self, sliceid): + self._sliceid = sliceid + def _del_sliceid(self): + self._sliceid = None + + def _get_name(self): + return self._name + def _set_name(self, name): + self._name = name + def _del_name(self): + self._name = "" + + sliceid = property(_get_sliceid,_set_sliceid,_del_sliceid) + + name = property(_get_name,_set_name,_del_name) diff --git a/Monitoring/src/main/python/Resource/slice.py.old b/Monitoring/src/main/python/Resource/slice.py.old new file mode 100644 index 0000000..002318f --- /dev/null +++ b/Monitoring/src/main/python/Resource/slice.py.old @@ -0,0 +1,40 @@ +''' +Created on Oct 30, 2012 + +@author: steger +''' + +class slice_pointer(object): + ''' + classdocs + ''' + + def __init__(self, sliceid = None, slicename = ""): + ''' + Constructor + ''' + self._sliceid = sliceid + self._name = slicename + + @property + def sliceid(self): + if self._sliceid is None: + raise Exception("slice id is not set") + return self._sliceid + @sliceid.setter + def sliceid(self, sliceid): + self._sliceid = sliceid + @sliceid.deleter + def sliceid(self): + self._sliceid = None + + @property + def name(self): + return self._name + @name.setter + def name(self, name): + self._name = name + @name.deleter + def name(self): + self._name = "" +
\ No newline at end of file |