Ejemplo 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)
Ejemplo n.º 2
0
def main():
    """Main function"""

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

    state = module.params['state']

    if (not module.params.get("id")) and module.params.get("name"):
        module.params['id'] = get_id_by_name(session)

    fetch = None
    link = self_link(session)
    # the link will include Nones if required format parameters are missed
    if not re.search('/None/|/None$', link):
        fetch = fetch_resource(session, link)
        if fetch:
            fetch = fetch.get('vpc')
    changed = False

    if fetch:
        if state == 'present':
            expect = _get_editable_properties(module)
            current_state = response_to_hash(module, fetch)
            if are_dicts_different(expect, current_state):
                if not module.check_mode:
                    fetch = update(session, self_link(session), [200])
                    fetch = response_to_hash(module, fetch.get('vpc'))
                changed = True
            else:
                fetch = current_state
        else:
            if not module.check_mode:
                delete(session, self_link(session))
                fetch = {}
            changed = True
    else:
        if state == 'present':
            if not module.check_mode:
                fetch = create(session, collection(session), [200])
                fetch = response_to_hash(module, fetch.get('vpc'))
            changed = True
        else:
            fetch = {}

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

    module.exit_json(**fetch)
Ejemplo 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='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,
    )
Ejemplo n.º 4
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           filters=dict(required=True,
                                        type='list',
                                        elements='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,
    )
Ejemplo n.º 5
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present',
                       choices=['present', 'absent'],
                       type='str'),
            filters=dict(required=True, type='list', elements='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,
    )
Ejemplo n.º 6
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,
    )
Ejemplo n.º 7
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,
    )
Ejemplo n.º 8
0
def build_module():
    return HwcModule(
        argument_spec=dict(state=dict(default='present',
                                      choices=['present', 'absent'],
                                      type='str'),
                           filters=dict(required=True,
                                        type='list',
                                        elements='str'),
                           subnet_id=dict(type='str', required=True),
                           ip_address=dict(type='str')),
        supports_check_mode=True,
    )
Ejemplo n.º 9
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present', choices=['present', 'absent'],
                       type='str'),
            filters=dict(required=True, type='list', elements='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')
        ),
        supports_check_mode=True,
    )
Ejemplo n.º 10
0
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,
    )
Ejemplo n.º 11
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,
    )
Ejemplo n.º 12
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(default='present',
                       choices=['present', 'absent'],
                       type='str'),
            configuration_name=dict(type='str', required=True),
            instance_id=dict(type='str'),
            flavor_id=dict(type='str'),
            image_id=dict(type='str'),
            disks=dict(type='list',
                       elements='dict',
                       options=dict(
                           disk_type=dict(type='str',
                                          required=True,
                                          choices=['SYS', 'DATA']),
                           volume_type=dict(type='str', required=True),
                           size=dict(type='int', required=True),
                       )),
            ssh_key_name=dict(type='str'),
            admin_pass=dict(type='str'),
            user_data=dict(type='str'),
            server_metadata=dict(type='dict'),
            public_ip=dict(type='dict',
                           options=dict(
                               type=dict(type='str', required=True),
                               bandwidth=dict(
                                   type='dict',
                                   options=dict(charge_mode=dict(
                                       type='str',
                                       required=True,
                                       choices=['bandwidth', 'traffic']),
                                                share=dict(type='str',
                                                           required=True),
                                                size=dict(type='int',
                                                          required=True))),
                           )),
        ),
        supports_check_mode=True,
    )
Ejemplo n.º 13
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(type='str', default='present', choices=['present', 'absent']),
            group_name=dict(type='str', required=True),
            configuration_id=dict(type='str'),
            desire_instance_number =dict(type='int'),
            min_instance_number =dict(type='int'),
            max_instance_number =dict(type='int'),
            cool_down_time=dict(type='int'),
            health_periodic_audit_time=dict(type='int', choices=[5, 15, 50, 180]),
            available_zones=dict(type='list', elements='str'),
            vpc_id=dict(type='str', required=True),
            networks=dict(type='list', required=True),
            security_group=dict(type='str'),
            instance_terminate_policy=dict(type='str', choices=[
                'OLD_CONFIG_OLD_INSTANCE', 'OLD_CONFIG_NEW_INSTANCE', 'OLD_INSTANCE', 'NEW_INSTANCE']
            ),
            delete_publicip=dict(type='bool'),
        ),
        supports_check_mode=True,
    )
Ejemplo n.º 14
0
def build_module():
    return HwcModule(
        argument_spec=dict(
            state=dict(type='str',
                       default='present',
                       choices=['present', 'absent']),
            group_id=dict(type='str', required=True),
            policy_name=dict(type='str', required=True),
            policy_type=dict(type='str',
                             required=True,
                             choices=['ALARM', 'SCHEDULED', 'RECURRENCE']),
            alarm_id=dict(type='str'),
            scheduled_policy=dict(type='dict',
                                  options=dict(
                                      launch_time=dict(type='str',
                                                       required=True),
                                      recurrence_type=dict(type='str',
                                                           choices=[
                                                               'Daily',
                                                               'Weekly',
                                                               'Monthly'
                                                           ]),
                                      recurrence_value=dict(type='str'),
                                      start_time=dict(type='str'),
                                      end_time=dict(type='str'),
                                  )),
            policy_action=dict(type='dict',
                               options=dict(
                                   operation=dict(
                                       type='str',
                                       choices=['ADD', 'REMOVE', 'SET']),
                                   instance_number=dict(type='int', default=1),
                               )),
            cool_down_time=dict(type='int'),
        ),
        supports_check_mode=True,
    )