def export_lc_logs(idrac, module):
    """
    Export Lifecycle Controller Log to the given file share

    Keyword arguments:
    idrac  -- iDRAC handle
    module -- Ansible module
    """

    msg = {}
    msg['changed'] = False
    msg['failed'] = False
    err = False

    try:
        lclog_file_name_format = "%ip_%Y%m%d_%H%M%S_LC_Log.log"

        myshare = FileOnShare(remote=module.params['share_name'],
                              isFolder=True,
                              creds=UserCredentials(module.params['share_user'],
                                                    module.params['share_pwd']))
        lc_log_file = myshare.new_file(lclog_file_name_format)

        msg['msg'] = idrac.log_mgr.lclog_export(lc_log_file)

        if "Status" in msg['msg'] and msg['msg']['Status'] != "Success":
            msg['failed'] = True

    except Exception as e:
        err = True
        msg['msg'] = "Error: %s" % str(e)
        msg['failed'] = True

    return msg, err
def export_tech_support_report(idrac, module):
    """
    Export Tech Support Report (TSR)

    Keyword arguments:
    idrac  -- iDRAC handle
    module -- Ansible module
    """

    msg = {}
    msg['changed'] = False
    msg['failed'] = False
    err = False

    try:
        tsr_file_name_format = "%ip_%Y%m%d_%H%M%S_tsr.zip"

        myshare = FileOnShare(remote=module.params['share_name'],
                              isFolder=True)
        myshare.addcreds(
            UserCredentials(module.params['share_user'],
                            module.params['share_pwd']))
        tsr_file_name = myshare.new_file(tsr_file_name_format)

        msg['msg'] = idrac.config_mgr.export_tsr(tsr_file_name)

        if "Status" in msg['msg'] and msg['msg']['Status'] != "Success":
            msg['failed'] = True

    except Exception as e:
        err = True
        msg['msg'] = "Error: %s" % str(e)
        msg['failed'] = True

    return msg, err
Exemple #3
0
def import_server_config_profile(idrac, module):
    """
    Import Server Configuration Profile from a network share

    Keyword arguments:
    idrac  -- iDRAC handle
    module -- Ansible module
    """

    msg = {}
    msg['changed'] = False
    msg['failed'] = False
    msg['msg'] = {}
    err = False

    try:
        if module.check_mode:
            msg['changed'] = True
        else:
            myshare = FileOnShare(remote=module.params['share_name'],
                                  mount_point=module.params['share_mnt'],
                                  isFolder=True)
            myshare.addcreds(
                UserCredentials(module.params['share_user'],
                                module.params['share_pwd']))
            scp_file_path = myshare.new_file(module.params['scp_file'])

            scp_components = SCPTargetEnum.ALL

            if module.params['scp_components'] == 'IDRAC':
                scp_components = SCPTargetEnum.iDRAC
            elif module.params['scp_components'] == 'BIOS':
                scp_components = SCPTargetEnum.BIOS
            elif module.params['scp_components'] == 'NIC':
                scp_components = SCPTargetEnum.NIC
            elif module.params['scp_components'] == 'RAID':
                scp_components = SCPTargetEnum.RAID

            msg['msg'] = idrac.config_mgr.scp_import(
                scp_share_path=scp_file_path,
                components=scp_components,
                format_file=ExportFormatEnum.XML,
                reboot=module.params['reboot'],
                job_wait=module.params['job_wait'])

            if "Status" in msg['msg']:
                if msg['msg']['Status'] == "Success":
                    msg['changed'] = True
                else:
                    msg['failed'] = True

    except Exception as e:
        err = True
        msg['msg'] = "Error: %s" % str(e)
        msg['failed'] = True

    return msg, err
def export_server_config_profile(idrac, module):
    """
    Export Server Configuration Profile to a network share

    Keyword arguments:
    idrac  -- iDRAC handle
    module -- Ansible module
    """

    msg = {}
    msg['changed'] = False
    msg['failed'] = False
    err = False

    try:
        scp_file_name_format = "%ip_%Y%m%d_%H%M%S_" + \
            module.params['scp_components'] + "_SCP.xml"

        myshare = FileOnShare(remote=module.params['share_name'],
                              isFolder=True)
        myshare.addcreds(
            UserCredentials(module.params['share_user'],
                            module.params['share_pwd']))
        scp_file_name = myshare.new_file(scp_file_name_format)

        scp_components = TypeHelper.convert_to_enum(
            module.params['scp_components'], SCPTargetEnum)

        export_format = ExportFormatEnum.XML
        if module.params['export_format'] == 'JSON':
            export_format = ExportFormatEnum.JSON

        export_method = ExportMethodEnum.Default
        if module.params['export_method'] == 'Clone':
            export_method = ExportMethodEnum.Clone

        msg['msg'] = idrac.config_mgr.scp_export(
            scp_share_path=scp_file_name,
            components=scp_components,
            format_file=export_format,
            method=export_method,
            job_wait=module.params['job_wait'])

        if 'Status' in msg['msg'] and msg['msg']['Status'] != "Success":
            msg['failed'] = True

    except Exception as e:
        err = True
        msg['msg'] = "Error: %s" % str(e)
        msg['failed'] = True

    return msg, err
Exemple #5
0
def boot_to_network_iso(idrac, module):
    """
    Boot to a network ISO image

    Keyword arguments:
    idrac  -- iDRAC handle
    module -- Ansible module
    """

    msg = {}
    msg['changed'] = False
    msg['failed'] = False
    msg['msg'] = {}
    err = False

    try:
        if module.check_mode:
            msg['changed'] = True
        else:
            myshare = FileOnShare(remote=module.params['share_name'],
                                  mount_point=module.params['share_mnt'],
                                  isFolder=True,
                                  creds=UserCredentials(module.params['share_user'],
                                                        module.params['share_pwd']))
            iso_image = myshare.new_file(module.params['iso_image'])

            msg['msg'] = idrac.config_mgr.boot_to_network_iso(iso_image,
                                                              module.params['job_wait'])

            if "Status" in msg['msg']:
                if msg['msg']['Status'] == "Success":
                    msg['changed'] = True
                else:
                    msg['failed'] = True

    except Exception as e:
        err = True
        msg['msg'] = "Error: %s" % str(e)
        msg['failed'] = True

    return msg, err
Exemple #6
0
sd = sdkinfra()
sd.importPath()

t1 = time.time()

dprint("Driver SDK", "1.03 Connect to " + ipaddr)
idrac = sd.get_driver(sd.driver_enum.iDRAC, ipaddr, creds, protopref)
if idrac is None:
        print ("Error: Not found a device driver for: " + ipaddr)
        exit()
else:
        print("Connected to " + ipaddr)

dprint("Driver SDK", "5.04 Export SCP")
scp_file = myshare.new_file('fact_%ip_%Y%m%d_%H%M%S.xml')
msg = idrac.config_mgr.scp_export(scp_file, method=ExportMethodEnum.Clone)
print(PrettyPrint.prettify_json(msg))

if msg['Status'] == "Success":
    print("Saved to file :" + msg['file'])
else:
    print("Operation Failed with Message :" + msg['Message'])

dprint("Driver SDK", "5.04 Export SCP Async")
scp_file = myshare.new_file('fact_%ip_%Y%m%d_%H%M%S.xml')
msg = idrac.config_mgr.scp_export(scp_file, job_wait=False)
print(PrettyPrint.prettify_json(msg))
if msg['Status'] == 'Success':
        print("Saving to file :" + msg['file'])
        jobid = msg['Job']['JobId']
Exemple #7
0
    print(catalog.cache_share.mount_point.full_path)
    #catalog.dispose()

if Passed:
    dprint("Driver SDK", "SNMP Trap Destination")
    retVal = idrac.config_mgr.add_trap_destination('omisc.trap.host')
    print(PrettyPrint.prettify_json(retVal))

if Passed:
    dprint("Driver SDK", "5.03 Get System Information")
    idrac.get_entityjson()
    print(PrettyPrint.prettify_json(idrac.get_json_device()))

if Passed:
    dprint("Driver SDK", "5.04 Export SCP")
    scp_file = myshare.new_file('fact_%ip_%Y%m%d_%H%M%S.xml')
    msg = idrac.config_mgr.scp_export(scp_file)
    print(PrettyPrint.prettify_json(msg))

    if msg['Status'] == "Success":
        print("Saved to file :" + msg['file'])
    else:
        print("Operation Failed with Message :" + msg['Message'])

if Passed:
    dprint("Driver SDK", "5.04 Export SCP Async")
    scp_file = myshare.new_file('fact_%ip_%Y%m%d_%H%M%S.xml')
    msg = idrac.config_mgr.scp_export_async(scp_file)
    print(PrettyPrint.prettify_json(msg))
    if msg['Status'] == 'Success':
        print("Saving to file :" + msg['file'])