コード例 #1
0
ファイル: idrac_firmware.py プロジェクト: kokasha/layer2_demo
def main():
    module = AnsibleModule(
        argument_spec={
            "idrac_ip": {"required": True, "type": 'str'},
            "idrac_user": {"required": True, "type": 'str'},
            "idrac_password": {"required": True, "type": 'str', "aliases": ['idrac_pwd'], "no_log": True},
            "idrac_port": {"required": False, "default": 443, "type": 'int'},

            "share_name": {"required": True, "type": 'str'},
            "share_user": {"required": False, "type": 'str'},
            "share_password": {"required": False, "type": 'str', "aliases": ['share_pwd'], "no_log": True},
            "share_mnt": {"required": True, "type": 'str'},

            "catalog_file_name": {"required": False, "type": 'str', "default": "Catalog.xml"},
            "reboot": {"required": False, "type": 'bool', "default": False},
            "job_wait": {"required": False, "type": 'bool', "default": True},
        },

        supports_check_mode=False)

    try:
        # Validate the catalog file
        _validate_catalog_file(module.params['catalog_file_name'])
        # Connect to iDRAC and update firmware
        with iDRACConnection(module.params) as idrac:
            update_status = update_firmware(idrac, module)
    except (ImportError, ValueError, RuntimeError) as e:
        module.fail_json(msg=str(e))

    module.exit_json(msg='Successfully updated the firmware.', update_status=update_status)
コード例 #2
0
def main():
    module = AnsibleModule(argument_spec={
        "idrac_ip": {
            "required": True,
            "type": 'str'
        },
        "idrac_user": {
            "required": True,
            "type": 'str'
        },
        "idrac_password": {
            "required": True,
            "type": 'str',
            "aliases": ['idrac_pwd'],
            "no_log": True
        },
        "idrac_port": {
            "required": False,
            "default": 443,
            "type": 'int'
        },
        "command": {
            "required": False,
            "type": 'str',
            "choices": ['export', 'import'],
            "default": 'export'
        },
        "job_wait": {
            "required": True,
            "type": 'bool'
        },
        "share_name": {
            "required": True,
            "type": 'str'
        },
        "share_user": {
            "required": False,
            "type": 'str'
        },
        "share_password": {
            "required": False,
            "type": 'str',
            "aliases": ['share_pwd'],
            "no_log": True
        },
        "scp_components": {
            "required": False,
            "choices": ['ALL', 'IDRAC', 'BIOS', 'NIC', 'RAID'],
            "default": 'ALL'
        },
        "scp_file": {
            "required": False,
            "type": 'str'
        },
        "shutdown_type": {
            "required": False,
            "choices": ['Graceful', 'Forced', 'NoReboot'],
            "default": 'Graceful'
        },
        "end_host_power_state": {
            "required": False,
            "choices": ['On', 'Off'],
            "default": 'On'
        },
        "export_format": {
            "required": False,
            "type": 'str',
            "choices": ['JSON', 'XML'],
            "default": 'XML'
        },
        "export_use": {
            "required": False,
            "type": 'str',
            "choices": ['Default', 'Clone', 'Replace'],
            "default": 'Default'
        }
    },
                           required_if=[["command", "import", ["scp_file"]]],
                           supports_check_mode=False)

    try:
        changed = False
        with iDRACConnection(module.params) as idrac:
            command = module.params['command']
            if command == 'import':
                scp_status = run_import_server_config_profile(idrac, module)
                if "No changes were applied" not in scp_status.get(
                        'Message', ""):
                    changed = True
            else:
                scp_status = run_export_server_config_profile(idrac, module)
        module.exit_json(
            changed=changed,
            msg="Successfully {0}ed the Server Configuration Profile.".format(
                command),
            scp_status=scp_status)
    except (ImportError, ValueError, RuntimeError) as e:
        module.fail_json(msg=str(e))