コード例 #1
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=missing_required_lib('infinisdk'))

    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 {0} 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)
コード例 #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)
コード例 #3
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=missing_required_lib('infinisdk'))
    if not HAS_MUNCH:
        module.fail_json(msg=missing_required_lib('munch'), exception=MUNCH_IMP_ERR)

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

    if module.params['state'] == 'present':
        update_client(module, export)
    else:
        delete_client(module, export)
コード例 #4
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=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'
            )

    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)
コード例 #5
0
ファイル: infini_fs.py プロジェクト: vlours/community.general
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)