Пример #1
0
    def __init__(self, hostname, username, password, timeout=60,
                 ssl_verify=False, protocol='https'):
        """Initializer function for PDU module
        """
        self._hostname = hostname
        self._username = username
        self._password = password
        self._timeout = timeout
        self._ssl_verify = ssl_verify
        self._protocol = protocol

        dis_cert_verify = True if ssl_verify is False else False

        # Initialize Raritan RPC agent
        self._agent = Agent(proto=self._protocol, host=self._hostname,
                            user=self._username, passwd=self._password,
                            disable_certificate_verification=dis_cert_verify,
                            timeout=self._timeout)
        self._pdu = pdumodel.Pdu("model/pdu/0", self._agent)
        self._inlet = pdumodel.Inlet("/model/inlet/0", self._agent)
 def _get_handler(self):
     agent = rpc.Agent("https", self._context.host, self._context.user,
                       self._context.password)
     return pdumodel.Pdu('model/pdu/0', agent)
Пример #3
0
sys.path.append("pdu-python-api")
from raritan.rpc import Agent, pdumodel, firmware, sensors

ip = "10.39.36.112"
user = "******"
pw = "pass"
try:
    ip = sys.argv[1]
    user = sys.argv[2]
    pw = sys.argv[3]
except IndexError:
    pass  # use defaults

agent = Agent("https", ip, user, pw, disable_certificate_verification=True)
pdu = pdumodel.Pdu("/model/pdu/0", agent)
firmware_proxy = firmware.Firmware("/firmware", agent)

inlets = pdu.getInlets()
ocps = pdu.getOverCurrentProtectors()
outlets = pdu.getOutlets()

print("PDU: %s" % (ip))
print("Firmware version: %s" % (firmware_proxy.getVersion()))
print("Number of inlets: %d" % (len(inlets)))
print("Number of over current protectors: %d" % (len(ocps)))
print("Number of outlets: %d" % (len(outlets)))

outlet = outlets[1]

outlet_metadata = outlet.getMetaData()