Exemplo n.º 1
0
def main():
    """Main function"""

    module = HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           display_name=dict(type='str'),
                           name=dict(required=True, type='str')),
        supports_check_mode=True,
    )

    config = Config(module, "smn")

    state = module.params['state']

    if not module.params.get("id"):
        module.params['id'] = get_resource_id(config)

    fetch = None
    link = self_link(module)
    # the link will include Nones if required format parameters are missed
    if not re.search('/None/|/None$', link):
        client = config.client(get_region(module), "smn", "project")
        fetch = fetch_resource(module, client, link)
    changed = False

    if fetch:
        if state == 'present':
            expect = _get_resource_editable_properties(module)
            current_state = response_to_hash(module, fetch)
            current = {'display_name': current_state['display_name']}
            if are_different_dicts(expect, current):
                if not module.check_mode:
                    fetch = update(config)
                    fetch = response_to_hash(module, fetch)
                changed = True
            else:
                fetch = current_state
        else:
            if not module.check_mode:
                delete(config)
                fetch = {}
            changed = True
    else:
        if state == 'present':
            if not module.check_mode:
                fetch = create(config)
                fetch = response_to_hash(module, fetch)
            changed = True
        else:
            fetch = {}

    fetch.update({'changed': changed})

    module.exit_json(**fetch)
Exemplo n.º 2
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           timeouts=dict(type='dict',
                                         options=dict(
                                             create=dict(default='30m',
                                                         type='str'),
                                             update=dict(default='30m',
                                                         type='str'),
                                             delete=dict(default='30m',
                                                         type='str'),
                                         ),
                                         default=dict()),
                           availability_zone=dict(type='str', required=True),
                           name=dict(type='str', required=True),
                           volume_type=dict(type='str', required=True),
                           backup_id=dict(type='str'),
                           description=dict(type='str'),
                           enable_full_clone=dict(type='bool'),
                           enable_scsi=dict(type='bool'),
                           enable_share=dict(type='bool'),
                           encryption_id=dict(type='str'),
                           enterprise_project_id=dict(type='str'),
                           image_id=dict(type='str'),
                           size=dict(type='int'),
                           snapshot_id=dict(type='str')),
        supports_check_mode=True,
    )
Exemplo n.º 3
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present',
                       choices=['present', 'absent'],
                       type='str'),
            timeouts=dict(type='dict',
                          options=dict(create=dict(default='15m',
                                                   type='str'), ),
                          default=dict()),
            subnet_id=dict(type='str', required=True),
            admin_state_up=dict(type='bool'),
            allowed_address_pairs=dict(
                type='list',
                elements='dict',
                options=dict(ip_address=dict(type='str'),
                             mac_address=dict(type='str')),
            ),
            extra_dhcp_opts=dict(type='list',
                                 elements='dict',
                                 options=dict(name=dict(type='str'),
                                              value=dict(type='str'))),
            ip_address=dict(type='str'),
            name=dict(type='str'),
            security_groups=dict(type='list', elements='str')),
        supports_check_mode=True,
    )
Exemplo n.º 4
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           timeouts=dict(type='dict',
                                         options=dict(
                                             create=dict(default='5m',
                                                         type='str'),
                                             update=dict(default='5m',
                                                         type='str'),
                                         ),
                                         default=dict()),
                           type=dict(type='str', required=True),
                           dedicated_bandwidth=dict(
                               type='dict',
                               options=dict(charge_mode=dict(type='str',
                                                             required=True),
                                            name=dict(type='str',
                                                      required=True),
                                            size=dict(type='int',
                                                      required=True))),
                           enterprise_project_id=dict(type='str'),
                           ip_version=dict(type='int'),
                           ipv4_address=dict(type='str'),
                           port_id=dict(type='str'),
                           shared_bandwidth_id=dict(type='str')),
        supports_check_mode=True,
    )
Exemplo n.º 5
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           subnet_id=dict(type='str', required=True),
                           ip_address=dict(type='str')),
        supports_check_mode=True,
    )
Exemplo n.º 6
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           name=dict(type='str', required=True),
                           enterprise_project_id=dict(type='str'),
                           vpc_id=dict(type='str')),
        supports_check_mode=True,
    )
Exemplo n.º 7
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           destination=dict(type='str', required=True),
                           next_hop=dict(type='str', required=True),
                           vpc_id=dict(type='str', required=True),
                           type=dict(type='str', default='peering'),
                           id=dict(type='str')),
        supports_check_mode=True,
    )
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           direction=dict(type='str', required=True),
                           security_group_id=dict(type='str', required=True),
                           description=dict(type='str'),
                           ethertype=dict(type='str'),
                           port_range_max=dict(type='int'),
                           port_range_min=dict(type='int'),
                           protocol=dict(type='str'),
                           remote_group_id=dict(type='str'),
                           remote_ip_prefix=dict(type='str')),
        supports_check_mode=True,
    )
Exemplo n.º 9
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present', choices=['present', 'absent'],
                       type='str'),
            timeouts=dict(type='dict', options=dict(
                create=dict(default='15m', type='str'),
                update=dict(default='15m', type='str'),
            ), default=dict()),
            cidr=dict(type='str', required=True),
            gateway_ip=dict(type='str', required=True),
            name=dict(type='str', required=True),
            vpc_id=dict(type='str', required=True),
            availability_zone=dict(type='str'),
            dhcp_enable=dict(type='bool'),
            dns_address=dict(type='list', elements='str')
        ),
        supports_check_mode=True,
    )
Exemplo n.º 10
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present',
                       choices=['present', 'absent'],
                       type='str'),
            timeouts=dict(type='dict',
                          options=dict(create=dict(default='15m',
                                                   type='str'), ),
                          default=dict()),
            local_vpc_id=dict(type='str', required=True),
            name=dict(type='str', required=True),
            peering_vpc=dict(type='dict',
                             required=True,
                             options=dict(vpc_id=dict(type='str',
                                                      required=True),
                                          project_id=dict(type='str'))),
            description=dict(type='str')),
        supports_check_mode=True,
    )