Exemplo n.º 1
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            client         = dict(required=True),
            access_mode    = dict(choices=['RO', 'RW'], default='RW'),
            no_root_squash = dict(type='bool', default='no'),
            state          = dict(default='present', choices=['present', 'absent']),
            export         = dict(required=True)
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_MUNCH:
        module.fail_json(msg='the python munch library is required for this module')

    system     = get_system(module)
    export     = get_export(module, system)

    if module.params['state'] == 'present':
        update_client(module, export)
    else:
        delete_client(module, export)
Exemplo n.º 2
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present', choices=['present', 'absent']),
             filesystem=dict(required=True),
             client_list=dict(type='list')))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))
    if not HAS_MUNCH:
        module.fail_json(msg=missing_required_lib('munch'),
                         exception=MUNCH_IMP_ERR)

    state = module.params['state']
    system = get_system(module)
    filesystem = get_filesystem(module, system)
    export = get_export(module, filesystem, system)

    if filesystem is None:
        module.fail_json(
            msg='Filesystem {0} not found'.format(module.params['filesystem']))

    if state == 'present':
        update_export(module, export, filesystem, system)
    elif export and state == 'absent':
        delete_export(module, export)
    elif export is None and state == 'absent':
        module.exit_json(changed=False)
Exemplo n.º 3
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present',
                        choices=['stat', 'present', 'absent']),
             pool=dict(required=True),
             size=dict()))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))
    if not HAS_CAPACITY:
        module.fail_json(msg=missing_required_lib('capacity'),
                         exception=CAPACITY_IMP_ERR)

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except Exception:
            module.fail_json(
                msg=
                'size (Physical Capacity) should be defined in MB, GB, TB or PB units'
            )

    execute_state(module)
Exemplo n.º 4
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present', choices=['present', 'absent']),
             wwns=dict(type='list'),
             volume=dict()))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')

    state = module.params['state']
    system = get_system(module)
    host = get_host(module, system)

    if module.params['volume']:
        try:
            system.volumes.get(name=module.params['volume'])
        except Exception:
            module.fail_json(
                msg='Volume {} not found'.format(module.params['volume']))

    if host and state == 'present':
        update_host(module, host)
    elif host and state == 'absent':
        delete_host(module, host)
    elif host is None and state == 'absent':
        module.exit_json(changed=False)
    else:
        create_host(module, system)
Exemplo n.º 5
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            client=dict(required=True),
            access_mode=dict(choices=['RO', 'RW'], default='RW'),
            no_root_squash=dict(type='bool', default='no'),
            state=dict(default='present', choices=['present', 'absent']),
            export=dict(required=True)
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_MUNCH:
        module.fail_json(msg='the python munch library is required for this module')

    system = get_system(module)
    export = get_export(module, system)

    if module.params['state'] == 'present':
        update_client(module, export)
    else:
        delete_client(module, export)
Exemplo n.º 6
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present', choices=['present', 'absent']),
            filesystem=dict(required=True),
            client_list=dict(type='list')
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_MUNCH:
        module.fail_json(msg='the python munch library is required for this module')

    state = module.params['state']
    system = get_system(module)
    filesystem = get_filesystem(module, system)
    export = get_export(module, filesystem, system)

    if filesystem is None:
        module.fail_json(msg='Filesystem {} not found'.format(module.params['filesystem']))

    if state == 'present':
        update_export(module, export, filesystem, system)
    elif export and state == 'absent':
        delete_export(module, export)
    elif export is None and state == 'absent':
        module.exit_json(changed=False)
Exemplo n.º 7
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present', choices=['present', 'absent']),
            wwns=dict(type='list'),
            volume=dict()
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')

    state = module.params['state']
    system = get_system(module)
    host = get_host(module, system)

    if module.params['volume']:
        try:
            system.volumes.get(name=module.params['volume'])
        except:
            module.fail_json(msg='Volume {} not found'.format(module.params['volume']))

    if host and state == 'present':
        update_host(module, host)
    elif host and state == 'absent':
        delete_host(module, host)
    elif host is None and state == 'absent':
        module.exit_json(changed=False)
    else:
        create_host(module, system)
Exemplo n.º 8
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            parent_volume_name=dict(required=False),
            pool=dict(required=False),
            size=dict(),
            snapshot_lock_expires_at=dict(),
            snapshot_lock_only=dict(type='bool', default=False),
            state=dict(default='present', choices=['stat', 'present', 'absent']),
            thin_provision=dict(type='bool', default=True),
            volume_type=dict(default='master', choices=['master', 'snapshot']),
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except Exception:
            module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')

    check_options(module)
    execute_state(module)
Exemplo n.º 9
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present',
                       choices=['stat', 'present', 'absent']),
        ))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))

    execute_state(module)
Exemplo n.º 10
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present', choices=['present', 'absent']),
             size=dict(),
             vsize=dict(),
             ssd_cache=dict(type='bool', default=True)))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_CAPACITY:
        module.fail_json(
            msg='The capacity python library is required for this module')

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except Exception:
            module.fail_json(
                msg=
                'size (Physical Capacity) should be defined in MB, GB, TB or PB units'
            )

    if module.params['vsize']:
        try:
            Capacity(module.params['vsize'])
        except Exception:
            module.fail_json(
                msg=
                'vsize (Virtual Capacity) should be defined in MB, GB, TB or PB units'
            )

    state = module.params['state']
    system = get_system(module)
    pool = get_pool(module, system)

    if state == 'present' and not pool:
        create_pool(module, system)
    elif state == 'present' and pool:
        update_pool(module, system, pool)
    elif state == 'absent' and pool:
        delete_pool(module, pool)
    elif state == 'absent' and not pool:
        module.exit_json(changed=False)
Exemplo n.º 11
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present',
                        choices=['stat', 'present', 'absent']),
             filesystem=dict(required=True),
             client_list=dict(type='list')))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))
    if not HAS_MUNCH:
        module.fail_json(msg=missing_required_lib('munch'),
                         exception=MUNCH_IMP_ERR)

    execute_state(module)
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(client=dict(required=True),
             access_mode=dict(choices=['RO', 'RW'], default='RW'),
             no_root_squash=dict(type='bool', default='no'),
             state=dict(default='present',
                        choices=['stat', 'present', 'absent']),
             export=dict(required=True)))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))
    if not HAS_MUNCH:
        module.fail_json(msg=missing_required_lib('munch'),
                         exception=MUNCH_IMP_ERR)

    execute_state(module)
Exemplo n.º 13
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present', choices=['present', 'absent']),
            size=dict(),
            vsize=dict(),
            ssd_cache=dict(type='bool', default=True)
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_CAPACITY:
        module.fail_json(msg='The capacity python library is required for this module')

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except:
            module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')

    if module.params['vsize']:
        try:
            Capacity(module.params['vsize'])
        except:
            module.fail_json(msg='vsize (Virtual Capacity) should be defined in MB, GB, TB or PB units')

    state = module.params['state']
    system = get_system(module)
    pool = get_pool(module, system)

    if state == 'present' and not pool:
        create_pool(module, system)
    elif state == 'present' and pool:
        update_pool(module, system, pool)
    elif state == 'absent' and pool:
        delete_pool(module, pool)
    elif state == 'absent' and not pool:
        module.exit_json(changed=False)
Exemplo n.º 14
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(name=dict(required=True),
             state=dict(default='present', choices=['present', 'absent']),
             pool=dict(required=True),
             size=dict()))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))
    if not HAS_CAPACITY:
        module.fail_json(msg=missing_required_lib('capacity'),
                         exception=CAPACITY_IMP_ERR)

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except Exception:
            module.fail_json(
                msg=
                'size (Physical Capacity) should be defined in MB, GB, TB or PB units'
            )

    state = module.params['state']
    system = get_system(module)
    pool = get_pool(module, system)
    filesystem = get_filesystem(module, system)

    if pool is None:
        module.fail_json(
            msg='Pool {0} not found'.format(module.params['pool']))

    if state == 'present' and not filesystem:
        create_filesystem(module, system)
    elif state == 'present' and filesystem:
        update_filesystem(module, filesystem)
    elif state == 'absent' and filesystem:
        delete_filesystem(module, filesystem)
    elif state == 'absent' and not filesystem:
        module.exit_json(changed=False)
Exemplo n.º 15
0
def main():
    """
    Gather auguments and manage mapping of vols to hosts.
    """
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            host=dict(required=True),
            state=dict(default='present',
                       choices=['stat', 'present', 'absent']),
            volume=dict(required=True),
            lun=dict(type=int),
        ))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))

    execute_state(module)
Exemplo n.º 16
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name  = dict(required=True),
            state = dict(default='present', choices=['present', 'absent']),
            pool  = dict(required=True),
            size  = dict()
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')
    if not HAS_CAPACITY:
        module.fail_json(msg='The capacity python library is required for this module')

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except:
            module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')

    state      = module.params['state']
    system     = get_system(module)
    pool       = get_pool(module, system)
    filesystem = get_filesystem(module, system)

    if pool is None:
        module.fail_json(msg='Pool {} not found'.format(module.params['pool']))

    if state == 'present' and not filesystem:
        create_filesystem(module, system)
    elif state == 'present' and filesystem:
        update_filesystem(module, filesystem)
    elif state == 'absent' and filesystem:
        delete_filesystem(module, filesystem)
    elif state == 'absent' and not filesystem:
        module.exit_json(changed=False)
Exemplo n.º 17
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present', choices=['present', 'absent']),
            pool=dict(required=True),
            size=dict()
        )
    )

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg='infinisdk is required for this module')

    if module.params['size']:
        try:
            Capacity(module.params['size'])
        except Exception:
            module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')

    state = module.params['state']
    system = get_system(module)
    pool = get_pool(module, system)
    volume = get_volume(module, system)

    if pool is None:
        module.fail_json(msg='Pool {} not found'.format(module.params['pool']))

    if state == 'present' and not volume:
        create_volume(module, system)
    elif state == 'present' and volume:
        update_volume(module, volume)
    elif state == 'absent' and volume:
        delete_volume(module, volume)
    elif state == 'absent' and not volume:
        module.exit_json(changed=False)
Exemplo n.º 18
0
def main():
    argument_spec = infinibox_argument_spec()
    argument_spec.update(
        dict(
            user_name=dict(required=True),
            user_email=dict(required=False),
            user_password=dict(required=False, no_log=True),
            user_role=dict(required=False,
                           choices=['admin', 'pool_admin', 'read_only']),
            user_enabled=dict(required=False, type='bool'),
            user_pool=dict(required=False),
            state=dict(default='present',
                       choices=['stat', 'reset_password', 'present',
                                'absent']),
        ))

    module = AnsibleModule(argument_spec, supports_check_mode=True)

    if not HAS_INFINISDK:
        module.fail_json(msg=missing_required_lib('infinisdk'))

    check_options(module)
    execute_state(module)