Beispiel #1
1
def test_imc_context_manager_no_timeout():
    try:
        import ConfigParser
    except:
        import configparser as ConfigParser

    from imcsdk.imchandle import ImcHandle
    from ..connection import info

    host = 'imc'
    config = ConfigParser.RawConfigParser()
    config.read(info.CONNECTION_CFG_FILEPATH)
    hostname = config.get(host, "hostname")
    username = config.get(host, "username")
    password = config.get(host, "password")

    handle = ImcHandle(hostname, username, password)
    with handle:
        server_dn = get_server_dn(handle)
        mo = handle.query_dn(server_dn, timeout=600)
        usr_lbl = "test-lbl2"
        mo.usr_lbl = usr_lbl
        handle.set_mo(mo, timeout=600)
        mo = handle.query_dn(server_dn)

    assert_equal(mo.usr_lbl, usr_lbl)
Beispiel #2
0
def test_imc_context_manager_no_timeout():
    try:
        import ConfigParser
    except:
        import configparser as ConfigParser

    from imcsdk.imchandle import ImcHandle
    from ..connection import info

    host = 'imc'
    config = ConfigParser.RawConfigParser()
    config.read(info.CONNECTION_CFG_FILEPATH)
    hostname = config.get(host, "hostname")
    username = config.get(host, "username")
    password = config.get(host, "password")

    handle = ImcHandle(hostname, username, password)
    with handle:
        server_dn = get_server_dn(handle)
        mo = handle.query_dn(server_dn, timeout=600)
        usr_lbl = "test-lbl2"
        mo.usr_lbl = usr_lbl
        handle.set_mo(mo, timeout=600)
        mo = handle.query_dn(server_dn)

    assert_equal(mo.usr_lbl, usr_lbl)
Beispiel #3
0
def update_snmp():
    """ Update IMC SNMP and Trap Destination """
    handle = ImcHandle(IMC_HOST, IMC_USER, IMC_PASS)
    handle.login()

    imc_snmp = handle.query_dn('sys/svc-ext/snmp-svc')
    imc_snmp.admin_state = 'enabled'
    imc_snmp.community = 'public'
    handle.set_mo(imc_snmp)

    imc_snmp_trap_dest = handle.query_dn('sys/svc-ext/snmp-svc/snmp-trap-1')
    imc_snmp_trap_dest.admin_state = 'enabled'
    imc_snmp_trap_dest.hostname = '10.10.10.10'
    imc_snmp_trap_dest.version = 'v2c'
    handle.set_mo(imc_snmp_trap_dest)

    handle.logout()
Beispiel #4
0
ip1 = regex.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", o)
hosts = ip1
for host in hosts:
    print("host: ", host)

    try:
        handle = ImcHandle(host, "admin", "ciscopsdt")
        handle.login()

        handle.set_dump_xml()

        print(handle.imc)

        # print("firmware: ", handle.query_dn("sys/rack-unit-1/mgmt/fw-system"))

        firmware_query = handle.query_dn("sys/rack-unit-1/mgmt/fw-system")
        name_query = handle.query_dn("sys/rack-unit-1")
        hostname_query = handle.query_dn("sys")
        # hostname_query = handle.query_classid(class_id="topSystem",need_response=True) #can get the same output through handle.imc()

        print(hostname_query)

        toCSV = [["HostIP", host], ["Product Name", name_query.name],
                 ["Hostname", handle.imc],
                 ["fw_version", firmware_query.version, "\n"]]

        with open('firmware.csv', 'a') as csvFile:
            for row in toCSV:
                for column in row:
                    csvFile.write('%s;' % column)
                csvFile.write('\n')
from imcsdk.imchandle import ImcHandle

# Create a connection handle
handle = ImcHandle("192.168.1.23", "admin", "password")

# Create a connection handle
handle.login()

# Query for the NTP Server
imc_ntp_server_mo = handle.query_dn("sys/svc-ext/ntp-svc")

print "NTP config inicial: "
print imc_ntp_server_mo

# Set NTP Server parameters
imc_ntp_server_mo.ntp_enable = "yes"
imc_ntp_server_mo.ntp_server1 = "5.5.5.5"

# Commit the changes to the IMC
handle.set_mo(imc_ntp_server_mo)
print "NTP config applied"

# Verify changes applied
imc_ntp_server_mo = handle.query_dn("sys/svc-ext/ntp-svc")
print "NTP new config: "
print imc_ntp_server_mo

# Logout from the server
handle.logout()
Beispiel #6
0
from imcsdk.imchandle import ImcHandle
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-i", "--ip", help="IP Address")
parser.add_argument("-u", "--username", help="Username")
parser.add_argument("-p", "--password", help="Password")

args = parser.parse_args()

handle = ImcHandle(ip=args.ip, username=args.username, password=args.password)

handle.login()

rack = handle.query_dn('sys/rack-unit-1')
print "Hostname:", rack.name, "Model:", rack.model, "Serial Number:", rack.serial

storage_controllers = handle.query_classid("storageVirtualDrive")
for storage_controller in storage_controllers:
    print "VD Name:", storage_controller.virtual_drive_name, "VD Status:", storage_controller.vd_status, "Raid Level:", storage_controller.raid_level, "Health:", storage_controller.health

bbus = handle.query_classid("storageRaidBattery")
for bbu in bbus:
    print "BBU Status:", bbu.battery_status, "BBU Health:", bbu.health, "BBU Learn Cycle:", bbu.learn_cycle_status, "Next Learn cycle:", bbu.next_learn_cycle

local_disks = handle.query_classid("StorageLocalDisk")
for local_disk in local_disks:
    print "Disk ID:", local_disk.id, "Disk Serial Number:", local_disk.drive_serial_number, "Disk State:", local_disk.drive_state, "Disk Health:", local_disk.health, "Predicitive failure count:", local_disk.predictive_failure_count

handle.logout()
Beispiel #7
0
from imcsdk.imchandle import ImcHandle

# Create a connection handle
handle = ImcHandle("192.168.1.23", "admin", "password")

# Create a connection handle
handle.login()

# Query for SNMP settings
imc_snmp_mo = handle.query_dn("sys/svc-ext/snmp-svc")

print "SNMP config inicial: "
print imc_snmp_mo

# Set SNMP parameters
imc_snmp_mo.admin_state = "enabled"
imc_snmp_mo.com2_sec = "full"
imc_snmp_mo.community = "private"
imc_snmp_mo.trap_community = "private"
imc_snmp_mo.sys_contact = "Mr XPTO"
imc_snmp_mo.sys_location = "Datacenter Y"

# Commit the changes to the IMC
handle.set_mo(imc_snmp_mo)

# Verify changes applied
imc_snmp_mo = handle.query_dn("sys/svc-ext/snmp-svc")

print "SNMP new config: "
print imc_snmp_mo