Exemplo n.º 1
0
#! /usr/bin/env python
from henmanager import HenManager
from auxiliary.hen import Node, SwitchNode, VLAN, Port

manager = HenManager()
manager.initLogging()
nodes = manager.getNodes("switch")

theSwitch = None
for node in nodes.values():
    #    print node
    if (node.getNodeID() == "switch10"):
        print node.getNodeID()
        theSwitch = node.getInstance()
#print theSwitch

# get name
print "Get Switch name : " + theSwitch.getSwitchName()
# get name - via snmp
#print "Get Switch name (via snmp) : " + theSwitch.getSwitchName(True)
# get description
print "Get Switch description : " + theSwitch.getSwitchDescription()
# get uptime
print "Get Switch uptime : " + theSwitch.getSwitchUptime()
# get contact
#print "Get Switch contact : " + theSwitch.getSwitchContact()
# get port status (need to cast to a string since return is an int)
print "Get Switch port 1 status " + str(theSwitch.getPortStatus(1))

#print "Set Switch name : "
#theSwitch.setSwitchName("switch10",True)
Exemplo n.º 2
0
Arquivo: filed.py Projeto: sohonet/HEN
 def __init__(self):
     self.__manager = HenManager()
Exemplo n.º 3
0
from auxiliary.protocol import Protocol
import datetime

powerdaemon = Protocol(None)
powerdaemon.open(DaemonLocations.powerDaemon[0],
                 DaemonLocations.powerDaemon[1])
version = powerdaemon.doSynchronousCall("get_config_version", "")
print "Version is " + str(version[0][2])
tics = os.stat('/usr/local/hen/etc/physical/topology.xml')[ST_MTIME]
t = datetime.datetime.fromtimestamp(tics)
lastAccess = str(t.strftime('%Y-%m-%d'))
print "Last access time is " + lastAccess
if (str(lastAccess) != str(version[0][2])):
    print "Setting new config"
    from henmanager import HenManager
    hm = HenManager()
    payload = lastAccess + "," + pickle.dumps(hm.getNodes("all"))
    print "Result is:" + str(
        powerdaemon.doSynchronousCall("set_config", payload))


def addLink(tag, action, old, new):
    print "AddLink got " + tag, action, old, new


def removeLink(tag, action, old, new):
    print "RemoveLink got " + tag, action, old, new


def changePowerState(tag, action, node, attr):
    print "changePowerState got " + tag, action, node, attr
Exemplo n.º 4
0
 def __init__(self, host, port):
     self.__prot = auxiliary.protocol.Protocol(None)
     self.__host = host
     self.__port = port
     self.__data = ""
     self.__hm = HenManager()
Exemplo n.º 5
0
sys.path = []
sys.path.append("/usr/local/hen/lib/")
for i in temp:
    sys.path.append(i)

from henmanager import HenManager

###########################################################################################
#   Main execution
###########################################################################################
print "Content-Type: text/xml"
print ""
print ""

print "<row>"
manager = HenManager("/usr/local/hen/etc/configs/config")
racks = manager.getInfrastructures("rack")
nodes = manager.getNodes("all", "all")

rackNodes = {}

for key in racks.keys():
    rackNodes[key] = []

for nodeTypeDictionary in nodes.values():
    for node in nodeTypeDictionary.values():
        location = node.getPhysicalLocation()
        if (location != None):
            if rackNodes.has_key(location.getRackName()):
                s = '<node id="' + str(node.getNodeID())
                s += '" type="physicallocation-' + str(node.getNodeType())
Exemplo n.º 6
0
 def reloadHenDB(self):
     self.__henManager = HenManager()
     return 0