Exemple #1
0
def main():
    argument_spec = spectrum_accelerate_spec()
    argument_spec.update(
        dict(state=dict(default='present', choices=['present', 'absent']),
             vol=dict(required=True),
             lun=dict(),
             cluster=dict(),
             host=dict(),
             override=dict()))

    module = AnsibleModule(argument_spec)
    is_pyxcli_installed(module)

    xcli_client = connect_ssl(module)
    # required args
    mapping = False
    try:
        mapped_hosts = xcli_client.cmd.vol_mapping_list(
            vol=module.params.get('vol')).as_list
        for host in mapped_hosts:
            if host['host'] == module.params.get("host", ""):
                mapping = True
    except Exception:
        pass
    state = module.params['state']

    state_changed = False
    if state == 'present' and not mapping:
        state_changed = execute_pyxcli_command(module, 'map_vol', xcli_client)
    if state == 'absent' and mapping:
        state_changed = execute_pyxcli_command(module, 'unmap_vol',
                                               xcli_client)

    module.exit_json(changed=state_changed)
def main():
    argument_spec = spectrum_accelerate_spec()
    argument_spec.update(
        dict(state=dict(default='present', choices=['present', 'absent']),
             host=dict(required=True),
             cluster=dict(),
             domain=dict(),
             iscsi_chap_name=dict(),
             iscsi_chap_secret=dict()))

    module = AnsibleModule(argument_spec)

    is_pyxcli_installed(module)

    xcli_client = connect_ssl(module)
    host = xcli_client.cmd.host_list(
        host=module.params['host']).as_single_element
    state = module.params['state']

    state_changed = False
    if state == 'present' and not host:
        state_changed = execute_pyxcli_command(module, 'host_define',
                                               xcli_client)
    elif state == 'absent' and host:
        state_changed = execute_pyxcli_command(module, 'host_delete',
                                               xcli_client)

    module.exit_json(changed=state_changed)
Exemple #3
0
def main():
    argument_spec = spectrum_accelerate_spec()
    argument_spec.update(
        dict(state=dict(default='present', choices=['present', 'absent']),
             vol=dict(required=True),
             pool=dict(),
             size=dict()))

    module = AnsibleModule(argument_spec)

    is_pyxcli_installed(module)

    xcli_client = connect_ssl(module)
    # required args
    volume = xcli_client.cmd.vol_list(
        vol=module.params.get('vol')).as_single_element
    state = module.params['state']

    state_changed = False
    if state == 'present' and not volume:
        state_changed = execute_pyxcli_command(module, 'vol_create',
                                               xcli_client)
    elif state == 'absent' and volume:
        state_changed = execute_pyxcli_command(module, 'vol_delete',
                                               xcli_client)

    module.exit_json(changed=state_changed)
Exemple #4
0
def main():
    argument_spec = spectrum_accelerate_spec()
    argument_spec.update(
        dict(state=dict(default='present', choices=['present', 'absent']),
             pool=dict(required=True),
             size=dict(),
             snapshot_size=dict(),
             domain=dict(),
             perf_class=dict()))

    module = AnsibleModule(argument_spec)

    is_pyxcli_installed(module)

    xcli_client = connect_ssl(module)
    pool = xcli_client.cmd.pool_list(
        pool=module.params['pool']).as_single_element
    state = module.params['state']

    state_changed = False
    if state == 'present' and not pool:
        state_changed = execute_pyxcli_command(module, 'pool_create',
                                               xcli_client)
    if state == 'absent' and pool:
        state_changed = execute_pyxcli_command(module, 'pool_delete',
                                               xcli_client)

    module.exit_json(changed=state_changed)
Exemple #5
0
def main():
    argument_spec = spectrum_accelerate_spec()
    argument_spec.update(
        dict(state=dict(default='present', choices=['present', 'absent']),
             domain=dict(required=True),
             size=dict(),
             max_dms=dict(),
             max_cgs=dict(),
             ldap_id=dict(),
             max_mirrors=dict(),
             max_pools=dict(),
             max_volumes=dict(),
             perf_class=dict(),
             hard_capacity=dict(),
             soft_capacity=dict()))

    module = AnsibleModule(argument_spec)

    is_pyxcli_installed(module)

    xcli_client = connect_ssl(module)
    domain = xcli_client.cmd.domain_list(
        domain=module.params['domain']).as_single_element
    state = module.params['state']

    state_changed = False
    msg = 'Domain \'{0}\''.format(module.params['domain'])
    if state == 'present' and not domain:
        state_changed = execute_pyxcli_command(module, 'domain_create',
                                               xcli_client)
        msg += " created successfully."
    elif state == 'absent' and domain:
        state_changed = execute_pyxcli_command(module, 'domain_delete',
                                               xcli_client)
        msg += " deleted successfully."
    else:
        msg += " state unchanged."

    module.exit_json(changed=state_changed, msg=msg)