Exemple #1
0
def main():
    module_args = dict(
        states=dict(type='list'),
        detail=dict(type='bool', default=False),
    )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(changed=False, )

    if module.params['states'] and not module.params['detail']:
        module.fail_json(msg='filtering by state requires detail=true')

    jobs = module.api.list_jobs(detail=module.params['detail'])

    if module.params['states']:
        states = [
            getattr(idrac.JOB_STATE, state)
            for state in module.params['states']
        ]
    else:
        states = None

    result['idrac'] = {
        'jobs': [
            job for job in jobs
            if states is None or module.api.get_job_state(job) in states
        ]
    }

    module.exit_json(**result)
Exemple #2
0
def main():
    module_args = dict(
        disk=dict(type='dict'),
        disk_id=dict(type='str'),
    )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(
        changed=False,
    )

    if module.params['disk']:
        did = module.params['disk']['@odata.id']
    elif module.params['disk_id']:
        did = module.params['disk_id']
    else:
        module.fail_json(
            msg='you must provide one of disk or disk_id')

    disk = module.api.get_virtual_disk(did)

    result['idrac'] = {
        'disk': disk,
    }
    module.exit_json(**result)
def main():
    module_args = dict(
        job=dict(type='dict'),
        job_id=dict(type='str'),
    )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(changed=False, )

    if module.params['job']:
        jid = module.params['job']['@odata.id']
    elif module.params['job_id']:
        jid = module.params['job_id']
    else:
        module.fail_json(msg='you must provide one of job or job_id')

    job = module.api.get_job(jid)

    result['idrac'] = {
        'job': job,
    }
    module.exit_json(**result)
Exemple #4
0
def main():
    module = idrac_module.IDRACModule(
        supports_check_mode=False,
    )

    mgr = idrac.IDRAC.from_module(module)

    result = dict(
        changed=False,
    )

    module.exit_json(**result)
Exemple #5
0
def main():
    module_args = dict()

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(changed=False, )

    module.api.reset_manager()

    result['changed'] = True

    module.exit_json(**result)
def main():
    module_args = dict(detail=dict(type='bool', default=False), )

    module = idrac_module.IDRACModule(argument_spec=module_args,
                                      supports_check_mode=True)

    result = dict(changed=False, )

    disks = module.api.list_all_virtual_disks(detail=module.params['detail'])

    result['idrac'] = {
        'disks': disks,
    }

    module.exit_json(**result)
Exemple #7
0
def main():
    module_args = dict(timeout=dict(type='int'), )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=False,
    )

    result = dict(changed=False, )

    try:
        module.api.power_cycle_system(timeout=module.params['timeout'])
    except TimeoutError:
        module.fail_json('Timeout waiting for reboot')

    result['changed'] = True
    module.exit_json(**result)
Exemple #8
0
def main():
    module_args = dict()

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(changed=False, )

    system = module.api.get_system()

    result['idrac'] = {
        'system': system,
    }

    module.exit_json(**result)
def main():
    module_args = dict(reset_type=dict(type='str', required=True), )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=False,
    )

    result = dict(changed=False, )

    try:
        module.api.reset_system(module.params['reset_type'])
    except idrac.OperationFailed as err:
        module.fail_json(msg=str(err))
    except ValueError as err:
        module.fail_json(msg='{}: invalid reset_type'.format(err))

    result['changed'] = True
    module.exit_json(**result)
def main():
    module_args = dict(
        uri=dict(type='str', required=True)
    )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=True,
    )

    result = dict(
        changed=False,
    )

    resource = module.api.get(module.params['uri'])

    result['idrac'] = {
        'resource': resource,
    }

    module.exit_json(**result)
def main():
    module_args = dict(disk=dict(type='list', required=True), )

    module = idrac_module.IDRACModule(argument_spec=module_args,
                                      supports_check_mode=True)

    result = dict(changed=False, )

    for disk in module.api.list_all_virtual_disks():
        detail = module.api.get(disk)
        if any('id' in spec and detail['Id'] == spec.get('id')
               or 'name' in spec and detail['Name'] == spec.get('name')
               for spec in module.params['disk']):
            break
    else:
        module.fail_json(msg='Failed to find any matching disks')

    result['idrac'] = {
        'disk': detail,
    }

    module.exit_json(**result)
def main():
    module_args = dict(
        disk=dict(type='dict'),
        disk_id=dict(type='str'),
        fast=dict(type='bool', default=True),
    )

    module = idrac_module.IDRACModule(
        argument_spec=module_args,
        supports_check_mode=False,
    )

    result = dict(changed=False, )

    if not module.params['disk'] or module.params['disk_id']:
        module.fail_json(msg='Must provide one of disk or disk_id')

    if module.params['disk']:
        disk = module.params['disk']
        disk_id = disk['@odata.id']
    else:
        disk_id = module.params['disk_id']

    try:
        jid = module.api.initialize_virtual_disk(disk_id,
                                                 fast=module.params['fast'])
    except idrac.OperationFailed as err:
        module.fail_json(msg='failed to initialize disk', errors=err.errors)
    result['changed'] = True
    result['idrac'] = {
        'job': {
            'id': jid,
        }
    }

    module.exit_json(**result)