Ejemplo n.º 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)
Ejemplo n.º 2
0
import sys, time

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]
Ejemplo n.º 3
0
                      type=int)
addr_grp.add_argument("-p", "--passwd", help="the password", default="raritan")
addr_grp.add_argument("-u", "--user", help="the user name", default="admin")
addr_grp.add_argument(
    "-n",
    "--no_secure",
    dest="secure",
    action="store_false",
    help="protocol to use - type True for https or False for http")

args = parser.parse_args()
# create luaservice manager
agent = Agent(
    "https" if args.secure else "http",
    args.addr + ":" + str(args.port),
    args.user,
    args.passwd,
    debug=False,
    disable_certificate_verification=True)  # No SSL certification verification
mgr = luaservice.Manager("/luaservice", agent)
print("agent created: url " + agent.url)

# option --run
if args.run != None:
    nm = os.path.splitext(os.path.basename(args.run.name))[0]
    print("name " + nm)
    opts = luaservice.ScriptOptions(dict(), False, False)
    scp = args.run.read()
    ret = mgr.setScript(nm, scp, opts)
    if ret != mgr.NO_ERROR:
        print("  set script returns an error: " + err_to_str(ret))
Ejemplo n.º 4
0
    sys.exit(1)

try:
    readline.parse_and_bind('tab: complete')
    history = os.path.join(os.environ["HOME"], ".px2_shell_history")
    try:
        readline.read_history_file(history)
    except IOError:
        pass
    atexit.register(readline.write_history_file, history)
except:
    print("Sorry, no readline support!")

agent = Agent(scheme,
              hostname,
              username,
              password,
              disable_certificate_verification=True)

# selected sysrpc proxies
net_proxy = net.Net("/net", agent)
firmware_proxy = firmware.Firmware("/firmware", agent)
cfg_proxy = cfg.Cfg("/cfg", agent)
session_manager = session.SessionManager("/session", agent)
event_engine = event.Engine("/event_engine", agent)
event_service = event.Service("/eventservice", agent)

# selected modelrpc proxies
core = tfw.CoreCtrl("/model/core", agent)
unit = pdumodel.Unit("/model/unit", agent)
pdu = pdumodel.Pdu("/model/pdu/0", agent)