Exemplo n.º 1
0
def enable_session(dm_ip, device_ip):
    stub = create_channel(dm_ip)
    #enable
    stub.SetSessionService(
        importer_pb2.DeviceAccount(IpAddress=device_ip,
                                   sessionEnabled=True,
                                   sessionTimeout=6000))
Exemplo n.º 2
0
def get_thermalsensor_info(dm_ip, device_ip):
    stub = create_channel(dm_ip)
    token = login_device(stub, dm_ip, device_ip)

    # new a DeviceAccount object name: device_account_usertoken
    device_account_usertoken = importer_pb2.DeviceAccount(userToken=token)
    # new a Device object name: device
    device = importer_pb2.Device(IpAddress=device_ip,
                                 deviceAccount=device_account_usertoken,
                                 RedfishAPI='/redfish/v1/Chassis/1/Thermal')
    response = stub.GetDeviceData(device)
    if debug_mode:
        print("DEVICE REDFISH API: " + str(response.deviceData[0]))

    x = str(response.deviceData[0])
    y = json.loads(x)
    #print("TimeStamp: " + y["DataTimestamp"])
    #print("Temperatures: ")
    temperatures = {}

    for temp in y["Temperatures"]:
        json_str = ""
        print("%s %s %s %s" %
              (temp["MemberId"], temp["PhysicalContext"],
               temp["Status"]["HealthRollup"], temp["ReadingCelsius"]))
Exemplo n.º 3
0
def stop_query_device(dm_ip, device_ip):

    stub = create_channel(dm_ip)
    token = login_device(stub, dm_ip, device_ip)

    # new a DeviceAccount object name: device_account_ip_usertoken
    device_account_ip_usertoken = importer_pb2.DeviceAccount(
        IpAddress=device_ip, userToken=token)
    stub.StopQueryDeviceData(device_account_ip_usertoken)
Exemplo n.º 4
0
def login_device(stub, dm_ip, device_ip):
    #login
    # new a DeviceAccount object name: device_account_login
    device_account_login = importer_pb2.DeviceAccount(IpAddress=device_ip,
                                                      actUsername='******',
                                                      actPassword='******')
    response = stub.LoginDevice(device_account_login)
    if debug_mode:
        print("HTTP TOKEN: " + str(response.httptoken))
    return str(response.httptoken)
Exemplo n.º 5
0
def get_chassis_info(dm_ip, device_ip):
    stub = create_channel(dm_ip)
    token = login_device(stub, dm_ip, device_ip)

    # new a DeviceAccount object name: device_account_usertoken
    device_account_usertoken = importer_pb2.DeviceAccount(userToken=token)
    # new a Device object name: device
    device = importer_pb2.Device(IpAddress=device_ip,
                                 deviceAccount=device_account_usertoken,
                                 RedfishAPI='/redfish/v1/Chassis/1')
    response = stub.GetDeviceData(device)
    if debug_mode:
        print("DEVICE REDFISH API: " + str(response.deviceData[0]))

    x = str(response.deviceData[0])
    y = json.loads(x)
    #print("TimeStamp: " + y["DataTimestamp"])
    #print("Chassis-ID: " + y["@odata.id"])
    print(y["SerialNumber"])
Exemplo n.º 6
0
def get_psu_power_info(dm_ip, device_ip):
    stub = create_channel(dm_ip)
    token = login_device(stub, dm_ip, device_ip)

    # new a DeviceAccount object name: device_account_usertoken
    device_account_usertoken = importer_pb2.DeviceAccount(userToken=token)
    # new a Device object name: device
    device = importer_pb2.Device(IpAddress=device_ip,
                                 deviceAccount=device_account_usertoken,
                                 RedfishAPI='/redfish/v1/Chassis/1/Power')
    response = stub.GetDeviceData(device)
    if debug_mode:
        print("DEVICE REDFISH API: " + str(response.deviceData[0]))
    x = str(response.deviceData[0])
    y = json.loads(x)
    for power in y["PowerControl"]:
        print("ID:%s Watts:%s Status:%s State:%s" %
              (power["MemberId"], power["PowerConsumedWatts"],
               power["Status"]["Health"], power["Status"]["State"]))