summaryrefslogtreecommitdiffstats
path: root/Monitoring/src/main/python/Resource/node.py.old
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/src/main/python/Resource/node.py.old')
-rw-r--r--Monitoring/src/main/python/Resource/node.py.old48
1 files changed, 48 insertions, 0 deletions
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))