def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        network_acl=dict(required=True, aliases=['acl']),
        rule_position=dict(required=True, type='int', aliases=['number']),
        vpc=dict(required=True),
        cidr=dict(default='0.0.0.0/0'),
        protocol=dict(choices=['tcp', 'udp', 'icmp', 'all', 'by_number'], default='tcp'),
        protocol_number=dict(type='int', choices=list(range(0, 256))),
        traffic_type=dict(choices=['ingress', 'egress'], aliases=['type'], default='ingress'),
        action_policy=dict(choices=['allow', 'deny'], aliases=['action'], default='allow'),
        icmp_type=dict(type='int'),
        icmp_code=dict(type='int'),
        start_port=dict(type='int', aliases=['port']),
        end_port=dict(type='int'),
        state=dict(choices=['present', 'absent'], default='present'),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        tags=dict(type='list', aliases=['tag']),
        poll_async=dict(type='bool', default=True),
    ))

    required_together = cs_required_together()
    required_together.extend([
        ['icmp_type', 'icmp_code'],
    ])

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(
            ['icmp_type', 'start_port'],
            ['icmp_type', 'end_port'],
        ),
        supports_check_mode=True
    )

    acs_network_acl_rule = AnsibleCloudStackNetworkAclRule(module)

    state = module.params.get('state')
    if state == 'absent':
        network_acl_rule = acs_network_acl_rule.absent_network_acl_rule()
    else:
        network_acl_rule = acs_network_acl_rule.present_network_acl_rule()

    result = acs_network_acl_rule.get_result(network_acl_rule)

    module.exit_json(**result)
Exemple #2
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        vpc=dict(required=True),
        state=dict(choices=['present', 'absent'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        zone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_vpn_gw = AnsibleCloudStackVpnGateway(module)

    state = module.params.get('state')
    if state == "absent":
        vpn_gateway = acs_vpn_gw.absent_vpn_gateway()
    else:
        vpn_gateway = acs_vpn_gw.present_vpn_gateway()

    result = acs_vpn_gw.get_result(vpn_gateway)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        role=dict(required=True),
        name=dict(required=True),
        permission=dict(choices=['allow', 'deny'], default='deny'),
        description=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        parent=dict(),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(
            ['permission', 'parent'],
        ),
        supports_check_mode=True
    )

    acs_role_perm = AnsibleCloudStackRolePermission(module)

    state = module.params.get('state')
    if state in ['absent']:
        role_permission = acs_role_perm.remove_role_perm()
    else:
        role_permission = acs_role_perm.create_or_update_role_perm()

    result = acs_role_perm.get_result(role_permission)
    module.exit_json(**result)
Exemple #4
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            format=dict(type='str', required=True),
            name=dict(type='str', required=True),
            url=dict(type='str', required=True),
            state=dict(choices=['upload', 'attached', 'list'],
                       default='upload'),
            zone=dict(),
            domain=dict(),
            account=dict(),
            project=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    my_upload = UploadVolume(module)

    state = module.params.get('state')

    if state == 'upload':
        upload = my_upload.upload_volume()
    else:
        pass

    result = my_upload.get_result(upload)

    module.exit_json(**result)
Exemple #5
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True, aliases=['ip_address']),
        url=dict(),
        password=dict(no_log=True),
        username=dict(),
        hypervisor=dict(choices=CS_HYPERVISORS),
        allocation_state=dict(choices=['enabled', 'disabled', 'maintenance']),
        pod=dict(),
        cluster=dict(),
        host_tags=dict(type='list', aliases=['host_tag']),
        zone=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_host = AnsibleCloudStackHost(module)

    state = module.params.get('state')
    if state == 'absent':
        host = acs_host.absent_host()
    else:
        host = acs_host.present_host()

    result = acs_host.get_result(host)

    module.exit_json(**result)
Exemple #6
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            affinty_type=dict(removed_in_version='2.9'),
            affinity_type=dict(),
            description=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            domain=dict(),
            account=dict(),
            project=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(['affinity_type', 'affinty_type'], ),
        supports_check_mode=True)

    acs_ag = AnsibleCloudStackAffinityGroup(module)

    state = module.params.get('state')
    if state in ['absent']:
        affinity_group = acs_ag.remove_affinity_group()
    else:
        affinity_group = acs_ag.create_affinity_group()

    result = acs_ag.get_result(affinity_group)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        vm=dict(required=True, aliases=['name']),
        vm_guest_ip=dict(aliases=['secondary_ip']),
        network=dict(),
        vpc=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        zone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True,
        required_if=([
            ('state', 'absent', ['vm_guest_ip'])
        ])
    )

    acs_instance_nic_secondaryip = AnsibleCloudStackInstanceNicSecondaryIp(module)
    state = module.params.get('state')

    if state == 'absent':
        nic = acs_instance_nic_secondaryip.absent_nic_ip()
    else:
        nic = acs_instance_nic_secondaryip.present_nic_ip()

    result = acs_instance_nic_secondaryip.get_result(nic)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True, aliases=['display_name']),
        vm=dict(required=True),
        description=dict(),
        zone=dict(),
        snapshot_memory=dict(type='bool', default=False),
        state=dict(choices=['present', 'absent', 'revert'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag']),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_vmsnapshot = AnsibleCloudStackVmSnapshot(module)

    state = module.params.get('state')
    if state in ['revert']:
        snapshot = acs_vmsnapshot.revert_vm_to_snapshot()
    elif state in ['absent']:
        snapshot = acs_vmsnapshot.remove_snapshot()
    else:
        snapshot = acs_vmsnapshot.create_snapshot()

    result = acs_vmsnapshot.get_result(snapshot)
    module.exit_json(**result)
Exemple #9
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            url=dict(),
            name=dict(required=True),
            zone=dict(required=True),
            provider=dict(),
            force_recreate=dict(type='bool', default=False),
            state=dict(choices=['present', 'absent'], default='present'),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           required_if=[
                               ('state', 'present', ['url', 'provider']),
                           ],
                           supports_check_mode=True)

    acis_do = AnsibleCloudstackImageStore(module)

    state = module.params.get('state')
    if state == "absent":
        image_store = acis_do.absent_image_store()
    else:
        image_store = acis_do.present_image_store()

    result = acis_do.get_result(image_store)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        ip_address=dict(aliases=['public_ip']),
        vms=dict(required=True, aliases=['vm'], type='list'),
        state=dict(choices=['present', 'absent'], default='present'),
        zone=dict(),
        domain=dict(),
        project=dict(),
        account=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_lb_rule_member = AnsibleCloudStackLBRuleMember(module)

    state = module.params.get('state')
    if state in ['absent']:
        rule = acs_lb_rule_member.remove_members()
    else:
        rule = acs_lb_rule_member.add_members()

    result = acs_lb_rule_member.get_result(rule)
    module.exit_json(**result)
Exemple #11
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        uuid=dict(aliases=['id']),
        name=dict(required=True),
        description=dict(),
        role_type=dict(choices=['User', 'DomainAdmin', 'ResourceAdmin', 'Admin'], default='User'),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_role = AnsibleCloudStackRole(module)
    state = module.params.get('state')
    if state == 'absent':
        role = acs_role.absent_role()
    else:
        role = acs_role.present_role()

    result = acs_role.get_result(role)

    module.exit_json(**result)
Exemple #12
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        vm=dict(required=True, aliases=['name']),
        network=dict(required=True),
        vpc=dict(),
        ip_address=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        zone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True,
    )

    acs_nic = AnsibleCloudStackInstanceNic(module)

    state = module.params.get('state')
    if state == 'absent':
        nic = acs_nic.absent_nic()
    else:
        nic = acs_nic.present_nic()

    result = acs_nic.get_result(nic)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        state=dict(default='present', choices=['present', 'absent']),
        domain=dict(),
        account=dict(),
        project=dict(),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_ig = AnsibleCloudStackInstanceGroup(module)

    state = module.params.get('state')
    if state in ['absent']:
        instance_group = acs_ig.absent_instance_group()
    else:
        instance_group = acs_ig.present_instance_group()

    result = acs_ig.get_result(instance_group)

    module.exit_json(**result)
Exemple #14
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            uuid=dict(default=None, aliases=["id"]),
            name=dict(required=True),
            description=dict(default=None),
            role_type=dict(choices=["User", "DomainAdmin", "ResourceAdmin", "Admin"], default="User"),
            state=dict(choices=["present", "absent"], default="present"),
        )
    )

    module = AnsibleModule(
        argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True
    )

    try:
        acs_role = AnsibleCloudStackRole(module)
        state = module.params.get("state")
        if state == "absent":
            role = acs_role.absent_role()
        else:
            role = acs_role.present_role()

        result = acs_role.get_result(role)

    except CloudStackException as e:
        module.fail_json(msg="CloudStackException: %s" % str(e))

    module.exit_json(**result)
Exemple #15
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        vpc=dict(required=True),
        state=dict(choices=['present', 'absent'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        zone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_vpn_gw = AnsibleCloudStackVpnGateway(module)

    state = module.params.get('state')
    if state == "absent":
        vpn_gateway = acs_vpn_gw.absent_vpn_gateway()
    else:
        vpn_gateway = acs_vpn_gw.present_vpn_gateway()

    result = acs_vpn_gw.get_result(vpn_gateway)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            vpn_customer_gateway=dict(),
            vpc=dict(required=True),
            domain=dict(),
            account=dict(),
            project=dict(),
            zone=dict(),
            passive=dict(type='bool', default=False),
            force=dict(type='bool', default=False),
            state=dict(choices=['present', 'absent'], default='present'),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           required_if=[
                               ('state', 'present', ['vpn_customer_gateway']),
                           ],
                           supports_check_mode=True)

    acs_vpn_conn = AnsibleCloudStackVpnConnection(module)

    state = module.params.get('state')
    if state == "absent":
        vpn_conn = acs_vpn_conn.absent_vpn_connection()
    else:
        vpn_conn = acs_vpn_conn.present_vpn_connection()

    result = acs_vpn_conn.get_result(vpn_conn)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        description=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        project=dict(),
        account=dict(),
        domain=dict(),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_sg = AnsibleCloudStackSecurityGroup(module)

    state = module.params.get('state')
    if state in ['absent']:
        sg = acs_sg.remove_security_group()
    else:
        sg = acs_sg.create_security_group()

    result = acs_sg.get_result(sg)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(choices=['present', 'absent'], default='present'),
            domain=dict(),
            account=dict(),
            project=dict(),
            cidrs=dict(type='list', aliases=['cidr']),
            esp_policy=dict(),
            esp_lifetime=dict(type='int'),
            gateway=dict(),
            ike_policy=dict(),
            ike_lifetime=dict(type='int'),
            ipsec_psk=dict(no_log=True),
            dpd=dict(type='bool'),
            force_encap=dict(type='bool'),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_vpn_cgw = AnsibleCloudStackVpnCustomerGateway(module)

    state = module.params.get('state')
    if state == "absent":
        vpn_customer_gateway = acs_vpn_cgw.absent_vpn_customer_gateway()
    else:
        vpn_customer_gateway = acs_vpn_cgw.present_vpn_customer_gateway()

    result = acs_vpn_cgw.get_result(vpn_customer_gateway)
    module.exit_json(**result)
Exemple #19
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            path=dict(required=True),
            state=dict(choices=['present', 'absent'], default='present'),
            network_domain=dict(),
            clean_up=dict(type='bool', default=False),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_dom = AnsibleCloudStackDomain(module)

    state = module.params.get('state')
    if state in ['absent']:
        domain = acs_dom.absent_domain()
    else:
        domain = acs_dom.present_domain()

    result = acs_dom.get_result(domain)

    module.exit_json(**result)
Exemple #20
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            ip_address=dict(required=True),
            vm=dict(),
            vm_guest_ip=dict(),
            network=dict(),
            vpc=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            zone=dict(),
            domain=dict(),
            account=dict(),
            project=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_static_nat = AnsibleCloudStackStaticNat(module)

    state = module.params.get('state')
    if state in ['absent']:
        ip_address = acs_static_nat.absent_static_nat()
    else:
        ip_address = acs_static_nat.present_static_nat()

    result = acs_static_nat.get_result(ip_address)

    module.exit_json(**result)
Exemple #21
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            vm=dict(required=True, aliases=['name']),
            network=dict(required=True),
            vpc=dict(),
            ip_address=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            domain=dict(),
            account=dict(),
            project=dict(),
            zone=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True,
    )

    acs_nic = AnsibleCloudStackInstanceNic(module)

    state = module.params.get('state')
    if state == 'absent':
        nic = acs_nic.absent_nic()
    else:
        nic = acs_nic.present_nic()

    result = acs_nic.get_result(nic)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            description=dict(),
            vpc=dict(required=True),
            state=dict(choices=['present', 'absent'], default='present'),
            zone=dict(),
            domain=dict(),
            account=dict(),
            project=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    try:
        acs_network_acl = AnsibleCloudStackNetworkAcl(module)

        state = module.params.get('state')
        if state == 'absent':
            network_acl = acs_network_acl.absent_network_acl()
        else:
            network_acl = acs_network_acl.present_network_acl()

        result = acs_network_acl.get_result(network_acl)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #23
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        display_text=dict(),
        state=dict(choices=['present', 'absent', 'active', 'suspended'], default='present'),
        domain=dict(),
        account=dict(),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag']),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_project = AnsibleCloudStackProject(module)

    state = module.params.get('state')
    if state in ['absent']:
        project = acs_project.absent_project()

    elif state in ['active', 'suspended']:
        project = acs_project.state_project(state=state)

    else:
        project = acs_project.present_project()

    result = acs_project.get_result(project)
    module.exit_json(**result)
Exemple #24
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True, aliases=['ip_address']),
        url=dict(),
        password=dict(no_log=True),
        username=dict(),
        hypervisor=dict(choices=CS_HYPERVISORS),
        allocation_state=dict(choices=['enabled', 'disabled', 'maintenance']),
        pod=dict(),
        cluster=dict(),
        host_tags=dict(type='list', aliases=['host_tag']),
        zone=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_host = AnsibleCloudStackHost(module)

    state = module.params.get('state')
    if state == 'absent':
        host = acs_host.absent_host()
    else:
        host = acs_host.present_host()

    result = acs_host.get_result(host)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            description=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            project=dict(),
            account=dict(),
            domain=dict(),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_sg = AnsibleCloudStackSecurityGroup(module)

    state = module.params.get('state')
    if state in ['absent']:
        sg = acs_sg.remove_security_group()
    else:
        sg = acs_sg.create_security_group()

    result = acs_sg.get_result(sg)
    module.exit_json(**result)
Exemple #26
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            state=dict(default='present', choices=['present', 'absent']),
            domain=dict(),
            account=dict(),
            project=dict(),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    try:
        acs_ig = AnsibleCloudStackInstanceGroup(module)

        state = module.params.get('state')
        if state in ['absent']:
            instance_group = acs_ig.absent_instance_group()
        else:
            instance_group = acs_ig.present_instance_group()

        result = acs_ig.get_result(instance_group)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #27
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            ip_address=dict(aliases=['public_ip']),
            vms=dict(required=True, aliases=['vm'], type='list'),
            state=dict(choices=['present', 'absent'], default='present'),
            zone=dict(),
            domain=dict(),
            project=dict(),
            account=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_lb_rule_member = AnsibleCloudStackLBRuleMember(module)

    state = module.params.get('state')
    if state in ['absent']:
        rule = acs_lb_rule_member.remove_members()
    else:
        rule = acs_lb_rule_member.add_members()

    result = acs_lb_rule_member.get_result(rule)
    module.exit_json(**result)
Exemple #28
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            id=dict(),
            name=dict(required=True),
            gateway=dict(),
            netmask=dict(),
            start_ip=dict(),
            end_ip=dict(),
            zone=dict(),
            state=dict(choices=['present', 'enabled', 'disabled', 'absent'],
                       default='present'),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_pod = AnsibleCloudStackPod(module)
    state = module.params.get('state')
    if state in ['absent']:
        pod = acs_pod.absent_pod()
    else:
        pod = acs_pod.present_pod()

    result = acs_pod.get_result(pod)

    module.exit_json(**result)
Exemple #29
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            resource_type=dict(required=True,
                               choices=RESOURCE_TYPES.keys(),
                               aliases=['type']),
            limit=dict(default=-1, aliases=['max'], type='int'),
            domain=dict(default=None),
            account=dict(default=None),
            project=dict(default=None),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    try:
        acs_resource_limit = AnsibleCloudStackResourceLimit(module)
        resource_limit = acs_resource_limit.update_resource_limit()
        result = acs_resource_limit.get_result(resource_limit)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #30
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            ip_address=dict(required=False),
            state=dict(choices=['present', 'absent'], default='present'),
            vpc=dict(),
            network=dict(),
            zone=dict(),
            domain=dict(),
            account=dict(),
            project=dict(),
            tags=dict(type='list', aliases=['tag']),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           required_if=[
                               ('state', 'absent', ['ip_address',
                                                    'tags'], True),
                           ],
                           mutually_exclusive=(['vpc', 'network'], ),
                           supports_check_mode=True)

    acs_ip_address = AnsibleCloudStackIPAddress(module)

    state = module.params.get('state')
    if state in ['absent']:
        ip_address = acs_ip_address.disassociate_ip_address()
    else:
        ip_address = acs_ip_address.present_ip_address()

    result = acs_ip_address.get_result(ip_address)
    module.exit_json(**result)
Exemple #31
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            id=dict(required=True, type='int'),
            name=dict(),
            endpoint=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           required_if=[
                               ('state', 'present', ['name', 'endpoint']),
                           ],
                           supports_check_mode=True)

    try:
        acs_region = AnsibleCloudStackRegion(module)

        state = module.params.get('state')
        if state == 'absent':
            region = acs_region.absent_region()
        else:
            region = acs_region.present_region()

        result = acs_region.get_result(region)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #32
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        ip_address=dict(required=False),
        state=dict(choices=['present', 'absent'], default='present'),
        vpc=dict(),
        network=dict(),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        tags=dict(type='list', aliases=['tag']),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        required_if=[
            ('state', 'absent', ['ip_address', 'tags'], True),
        ],
        supports_check_mode=True
    )

    acs_ip_address = AnsibleCloudStackIPAddress(module)

    state = module.params.get('state')
    if state in ['absent']:
        ip_address = acs_ip_address.disassociate_ip_address()
    else:
        ip_address = acs_ip_address.present_ip_address()

    result = acs_ip_address.get_result(ip_address)
    module.exit_json(**result)
Exemple #33
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        ip_address=dict(required=True),
        vm=dict(),
        vm_guest_ip=dict(),
        network=dict(),
        vpc=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_static_nat = AnsibleCloudStackStaticNat(module)

    state = module.params.get('state')
    if state in ['absent']:
        ip_address = acs_static_nat.absent_static_nat()
    else:
        ip_address = acs_static_nat.present_static_nat()

    result = acs_static_nat.get_result(ip_address)

    module.exit_json(**result)
Exemple #34
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        path=dict(required=True),
        state=dict(choices=['present', 'absent'], default='present'),
        network_domain=dict(),
        clean_up=dict(type='bool', default=False),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_dom = AnsibleCloudStackDomain(module)

    state = module.params.get('state')
    if state in ['absent']:
        domain = acs_dom.absent_domain()
    else:
        domain = acs_dom.present_domain()

    result = acs_dom.get_result(domain)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        affinty_type=dict(removed_in_version='2.9'),
        affinity_type=dict(),
        description=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(
            ['affinity_type', 'affinty_type'],
        ),
        supports_check_mode=True
    )

    acs_ag = AnsibleCloudStackAffinityGroup(module)

    state = module.params.get('state')
    if state in ['absent']:
        affinity_group = acs_ag.remove_affinity_group()
    else:
        affinity_group = acs_ag.create_affinity_group()

    result = acs_ag.get_result(affinity_group)

    module.exit_json(**result)
Exemple #36
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        description=dict(),
        vpc=dict(required=True),
        state=dict(choices=['present', 'absent'], default='present'),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_network_acl = AnsibleCloudStackNetworkAcl(module)

    state = module.params.get('state')
    if state == 'absent':
        network_acl = acs_network_acl.absent_network_acl()
    else:
        network_acl = acs_network_acl.present_network_acl()

    result = acs_network_acl.get_result(network_acl)

    module.exit_json(**result)
Exemple #37
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True, aliases=['display_name']),
        vm=dict(required=True),
        description=dict(),
        zone=dict(),
        snapshot_memory=dict(type='bool', default=False),
        state=dict(choices=['present', 'absent', 'revert'], default='present'),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag']),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_vmsnapshot = AnsibleCloudStackVmSnapshot(module)

    state = module.params.get('state')
    if state in ['revert']:
        snapshot = acs_vmsnapshot.revert_vm_to_snapshot()
    elif state in ['absent']:
        snapshot = acs_vmsnapshot.remove_snapshot()
    else:
        snapshot = acs_vmsnapshot.create_snapshot()

    result = acs_vmsnapshot.get_result(snapshot)
    module.exit_json(**result)
Exemple #38
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True, aliases=['url']),
            password=dict(default=None, no_log=True),
            username=dict(default=None),
            hypervisor=dict(choices=CS_HYPERVISORS, default=None),
            allocation_state=dict(default=None),
            pod=dict(default=None),
            cluster=dict(default=None),
            host_tags=dict(default=None, type='list'),
            zone=dict(default=None),
            state=dict(choices=['present', 'absent'], default='present'),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    try:
        acs_host = AnsibleCloudStackHost(module)

        state = module.params.get('state')
        if state == 'absent':
            host = acs_host.absent_host()
        else:
            host = acs_host.present_host()

        result = acs_host.get_result(host)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #39
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        id=dict(required=True, type='int'),
        name=dict(),
        endpoint=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        required_if=[
            ('state', 'present', ['name', 'endpoint']),
        ],
        supports_check_mode=True
    )

    acs_region = AnsibleCloudStackRegion(module)

    state = module.params.get('state')
    if state == 'absent':
        region = acs_region.absent_region()
    else:
        region = acs_region.present_region()

    result = acs_region.get_result(region)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        uuid=dict(default=None, aliases=['id']),
        name=dict(required=True),
        description=dict(default=None),
        role_type=dict(choices=['User', 'DomainAdmin', 'ResourceAdmin', 'Admin'], default='User'),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    try:
        acs_role = AnsibleCloudStackRole(module)
        state = module.params.get('state')
        if state == 'absent':
            role = acs_role.absent_role()
        else:
            role = acs_role.present_role()

        result = acs_role.get_result(role)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #41
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        id=dict(),
        name=dict(required=True),
        gateway=dict(),
        netmask=dict(),
        start_ip=dict(),
        end_ip=dict(),
        zone=dict(),
        state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_pod = AnsibleCloudStackPod(module)
    state = module.params.get('state')
    if state in ['absent']:
        pod = acs_pod.absent_pod()
    else:
        pod = acs_pod.present_pod()

    result = acs_pod.get_result(pod)

    module.exit_json(**result)
Exemple #42
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            display_text=dict(),
            state=dict(choices=['present', 'absent', 'active', 'suspended'],
                       default='present'),
            domain=dict(),
            account=dict(),
            poll_async=dict(type='bool', default=True),
            tags=dict(type='list', aliases=['tag']),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_project = AnsibleCloudStackProject(module)

    state = module.params.get('state')
    if state in ['absent']:
        project = acs_project.absent_project()

    elif state in ['active', 'suspended']:
        project = acs_project.state_project(state=state)

    else:
        project = acs_project.present_project()

    result = acs_project.get_result(project)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            vm=dict(required=True, aliases=['name']),
            vm_guest_ip=dict(aliases=['secondary_ip']),
            network=dict(),
            vpc=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            domain=dict(),
            account=dict(),
            project=dict(),
            zone=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True,
                           required_if=([('state', 'absent', ['vm_guest_ip'])
                                         ]))

    acs_instance_nic_secondaryip = AnsibleCloudStackInstanceNicSecondaryIp(
        module)
    state = module.params.get('state')

    if state == 'absent':
        nic = acs_instance_nic_secondaryip.absent_nic_ip()
    else:
        nic = acs_instance_nic_secondaryip.present_nic_ip()

    result = acs_instance_nic_secondaryip.get_result(nic)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        service_offering=dict(),
        state=dict(choices=['present', 'started', 'stopped', 'restarted', 'absent'], default="present"),
        domain=dict(),
        account=dict(),
        project=dict(),
        zone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_router = AnsibleCloudStackRouter(module)

    state = module.params.get('state')
    if state in ['absent']:
        router = acs_router.absent_router()
    else:
        router = acs_router.present_router()

    result = acs_router.get_result(router)

    module.exit_json(**result)
Exemple #45
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        public_key=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    if not HAS_LIB_SSHPUBKEYS:
        module.fail_json(msg="python library sshpubkeys required: pip install sshpubkeys")

    acs_sshkey = AnsibleCloudStackSshKey(module)
    state = module.params.get('state')
    if state in ['absent']:
        ssh_key = acs_sshkey.remove_ssh_key()
    else:
        public_key = module.params.get('public_key')
        if public_key:
            ssh_key = acs_sshkey.register_ssh_key(public_key)
        else:
            ssh_key = acs_sshkey.create_ssh_key()

    result = acs_sshkey.get_result(ssh_key)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            public_key=dict(),
            domain=dict(),
            account=dict(),
            project=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    if not HAS_LIB_SSHPUBKEYS:
        module.fail_json(
            msg="python library sshpubkeys required: pip install sshpubkeys")

    acs_sshkey = AnsibleCloudStackSshKey(module)
    state = module.params.get('state')
    if state in ['absent']:
        ssh_key = acs_sshkey.remove_ssh_key()
    else:
        public_key = module.params.get('public_key')
        if public_key:
            ssh_key = acs_sshkey.register_ssh_key(public_key)
        else:
            ssh_key = acs_sshkey.create_ssh_key()

    result = acs_sshkey.get_result(ssh_key)
    module.exit_json(**result)
Exemple #47
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            affinty_type=dict(),
            description=dict(),
            state=dict(choices=['present', 'absent'], default='present'),
            domain=dict(),
            account=dict(),
            project=dict(),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    try:
        acs_ag = AnsibleCloudStackAffinityGroup(module)

        state = module.params.get('state')
        if state in ['absent']:
            affinity_group = acs_ag.remove_affinity_group()
        else:
            affinity_group = acs_ag.create_affinity_group()

        result = acs_ag.get_result(affinity_group)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        display_text=dict(),
        state=dict(choices=['enabled', 'present', 'disabled', 'absent'], default='present'),
        service_capabilities=dict(type='list', aliases=['service_capability']),
        service_offering=dict(),
        supported_services=dict(type='list', aliases=['supported_service']),
        service_providers=dict(type='list', aliases=['service_provider']),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_vpc_offering = AnsibleCloudStackVPCOffering(module)

    state = module.params.get('state')
    if state in ['absent']:
        vpc_offering = acs_vpc_offering.delete_vpc_offering()
    else:
        vpc_offering = acs_vpc_offering.create_or_update()

    result = acs_vpc_offering.get_result(vpc_offering)

    module.exit_json(**result)
Exemple #49
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            name=dict(required=True),
            display_text=dict(),
            network_offering=dict(),
            zone=dict(),
            start_ip=dict(),
            end_ip=dict(),
            gateway=dict(),
            netmask=dict(),
            start_ipv6=dict(),
            end_ipv6=dict(),
            cidr_ipv6=dict(),
            gateway_ipv6=dict(),
            vlan=dict(),
            vpc=dict(),
            isolated_pvlan=dict(),
            clean_up=dict(type='bool', default=False),
            network_domain=dict(),
            state=dict(choices=['present', 'absent', 'restarted'],
                       default='present'),
            acl_type=dict(choices=['account', 'domain']),
            project=dict(),
            domain=dict(),
            account=dict(),
            poll_async=dict(type='bool', default=True),
        ))
    required_together = cs_required_together()
    required_together.extend([
        ['netmask', 'gateway'],
    ])

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=required_together,
                           supports_check_mode=True)

    try:
        acs_network = AnsibleCloudStackNetwork(module)

        state = module.params.get('state')
        if state in ['absent']:
            network = acs_network.absent_network()

        elif state in ['restarted']:
            network = acs_network.restart_network()

        else:
            network = acs_network.present_network()

        result = acs_network.get_result(network)

    except CloudStackException as e:
        module.fail_json(msg='CloudStackException: %s' % str(e))

    module.exit_json(**result)
Exemple #50
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(
        dict(
            physical_network=dict(required=True, aliases=['name']),
            zone=dict(),
            domain=dict(),
            vlan=dict(),
            nsps_disabled=dict(type='list'),
            nsps_enabled=dict(type='list'),
            network_speed=dict(choices=['1G', '10G']),
            broadcast_domain_range=dict(choices=['POD', 'ZONE']),
            isolation_method=dict(choices=['VLAN', 'GRE', 'L3']),
            state=dict(choices=['present', 'enabled', 'disabled', 'absent'],
                       default='present'),
            tags=dict(aliases=['tag']),
            poll_async=dict(type='bool', default=True),
        ))

    module = AnsibleModule(argument_spec=argument_spec,
                           required_together=cs_required_together(),
                           supports_check_mode=True)

    acs_network = AnsibleCloudStackPhysicalNetwork(module)
    state = module.params.get('state')
    nsps_disabled = module.params.get('nsps_disabled', [])
    nsps_enabled = module.params.get('nsps_enabled', [])

    if state in ['absent']:
        network = acs_network.absent_network()
    else:
        network = acs_network.present_network()
    if nsps_disabled is not None:
        for name in nsps_disabled:
            acs_network.update_nsp(name=name, state='Disabled')

    if nsps_enabled is not None:
        for nsp_name in nsps_enabled:
            if nsp_name.lower() in ['virtualrouter', 'vpcvirtualrouter']:
                acs_network.set_vrouter_element_state(enabled=True,
                                                      nsp_name=nsp_name)
            elif nsp_name == 'internallbvm':
                acs_network.set_loadbalancer_element_state(enabled=True,
                                                           nsp_name=nsp_name)

            acs_network.update_nsp(name=nsp_name, state='Enabled')

    result = acs_network.get_result(network)

    if nsps_enabled:
        result['nsps_enabled'] = nsps_enabled
    if nsps_disabled:
        result['nsps_disabled'] = nsps_disabled

    module.exit_json(**result)
Exemple #51
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        display_text=dict(),
        network_offering=dict(),
        zone=dict(),
        start_ip=dict(),
        end_ip=dict(),
        gateway=dict(),
        netmask=dict(),
        start_ipv6=dict(),
        end_ipv6=dict(),
        cidr_ipv6=dict(),
        gateway_ipv6=dict(),
        vlan=dict(),
        vpc=dict(),
        isolated_pvlan=dict(),
        clean_up=dict(type='bool', default=False),
        network_domain=dict(),
        subdomain_access=dict(type='bool'),
        state=dict(choices=['present', 'absent', 'restarted'], default='present'),
        acl=dict(),
        acl_type=dict(choices=['account', 'domain']),
        project=dict(),
        domain=dict(),
        account=dict(),
        poll_async=dict(type='bool', default=True),
    ))
    required_together = cs_required_together()
    required_together.extend([
        ['netmask', 'gateway'],
    ])

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=required_together,
        supports_check_mode=True
    )

    acs_network = AnsibleCloudStackNetwork(module)

    state = module.params.get('state')
    if state == 'absent':
        network = acs_network.absent_network()

    elif state == 'restarted':
        network = acs_network.restart_network()

    else:
        network = acs_network.present_network()

    result = acs_network.get_result(network)
    module.exit_json(**result)
Exemple #52
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        ip_address=dict(),
        network=dict(),
        cidrs=dict(type='list', default='0.0.0.0/0', aliases=['cidr']),
        protocol=dict(choices=['tcp', 'udp', 'icmp', 'all'], default='tcp'),
        type=dict(choices=['ingress', 'egress'], default='ingress'),
        icmp_type=dict(type='int'),
        icmp_code=dict(type='int'),
        start_port=dict(type='int', aliases=['port']),
        end_port=dict(type='int'),
        state=dict(choices=['present', 'absent'], default='present'),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag'], default=None),
    ))

    required_together = cs_required_together()
    required_together.extend([
        ['icmp_type', 'icmp_code'],
    ])

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=required_together,
        required_one_of=(
            ['ip_address', 'network'],
        ),
        mutually_exclusive=(
            ['icmp_type', 'start_port'],
            ['icmp_type', 'end_port'],
            ['ip_address', 'network'],
        ),
        supports_check_mode=True
    )

    acs_fw = AnsibleCloudStackFirewall(module)

    state = module.params.get('state')
    if state in ['absent']:
        fw_rule = acs_fw.remove_firewall_rule()
    else:
        fw_rule = acs_fw.create_firewall_rule()

    result = acs_fw.get_result(fw_rule)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        display_text=dict(),
        cpu_number=dict(type='int'),
        cpu_speed=dict(type='int'),
        limit_cpu_usage=dict(type='bool'),
        deployment_planner=dict(),
        domain=dict(),
        host_tags=dict(type='list', aliases=['host_tag']),
        hypervisor_snapshot_reserve=dict(type='int'),
        disk_bytes_read_rate=dict(type='int'),
        disk_bytes_write_rate=dict(type='int'),
        disk_iops_customized=dict(type='bool'),
        disk_iops_read_rate=dict(type='int'),
        disk_iops_write_rate=dict(type='int'),
        disk_iops_max=dict(type='int'),
        disk_iops_min=dict(type='int'),
        is_system=dict(type='bool', default=False),
        is_volatile=dict(type='bool'),
        is_iops_customized=dict(type='bool'),
        memory=dict(type='int'),
        network_rate=dict(type='int'),
        offer_ha=dict(type='bool'),
        provisioning_type=dict(choices=['thin', 'sparse', 'fat']),
        service_offering_details=dict(type='bool'),
        storage_type=dict(choice=['local', 'shared']),
        system_vm_type=dict(choice=['domainrouter', 'consoleproxy', 'secondarystoragevm']),
        storage_tags=dict(type='list', aliases=['storage_tag']),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_so = AnsibleCloudStackServiceOffering(module)

    state = module.params.get('state')
    if state == "absent":
        service_offering = acs_so.absent_service_offering()
    else:
        service_offering = acs_so.present_service_offering()

    result = acs_so.get_result(service_offering)
    module.exit_json(**result)
Exemple #54
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        disk_offering=dict(),
        display_volume=dict(type='bool'),
        max_iops=dict(type='int'),
        min_iops=dict(type='int'),
        size=dict(type='int'),
        snapshot=dict(),
        vm=dict(),
        device_id=dict(type='int'),
        custom_id=dict(),
        force=dict(type='bool', default=False),
        shrink_ok=dict(type='bool', default=False),
        state=dict(choices=['present', 'absent', 'attached', 'detached'], default='present'),
        zone=dict(),
        domain=dict(),
        account=dict(),
        project=dict(),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag']),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(
            ['snapshot', 'disk_offering'],
        ),
        supports_check_mode=True
    )

    acs_vol = AnsibleCloudStackVolume(module)

    state = module.params.get('state')

    if state in ['absent']:
        volume = acs_vol.absent_volume()
    elif state in ['attached']:
        volume = acs_vol.attached_volume()
    elif state in ['detached']:
        volume = acs_vol.detached_volume()
    else:
        volume = acs_vol.present_volume()

    result = acs_vol.get_result(volume)

    module.exit_json(**result)
Exemple #55
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        state=dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'),
        account_type=dict(choices=['user', 'root_admin', 'domain_admin'], default='user'),
        network_domain=dict(),
        domain=dict(default='ROOT'),
        email=dict(),
        first_name=dict(),
        last_name=dict(),
        username=dict(),
        password=dict(no_log=True),
        timezone=dict(),
        poll_async=dict(type='bool', default=True),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        supports_check_mode=True
    )

    acs_acc = AnsibleCloudStackAccount(module)

    state = module.params.get('state')

    if state in ['absent']:
        account = acs_acc.absent_account()

    elif state in ['enabled', 'unlocked']:
        account = acs_acc.enable_account()

    elif state in ['disabled']:
        account = acs_acc.disable_account()

    elif state in ['locked']:
        account = acs_acc.lock_account()

    else:
        account = acs_acc.present_account()

    result = acs_acc.get_result(account)

    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        security_group=dict(required=True),
        type=dict(choices=['ingress', 'egress'], default='ingress'),
        cidr=dict(default='0.0.0.0/0'),
        user_security_group=dict(),
        protocol=dict(choices=['tcp', 'udp', 'icmp', 'ah', 'esp', 'gre'], default='tcp'),
        icmp_type=dict(type='int'),
        icmp_code=dict(type='int'),
        start_port=dict(type='int', aliases=['port']),
        end_port=dict(type='int'),
        state=dict(choices=['present', 'absent'], default='present'),
        project=dict(),
        poll_async=dict(type='bool', default=True),
    ))
    required_together = cs_required_together()
    required_together.extend([
        ['icmp_type', 'icmp_code'],
    ])

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=required_together,
        mutually_exclusive=(
            ['icmp_type', 'start_port'],
            ['icmp_type', 'end_port'],
            ['icmp_code', 'start_port'],
            ['icmp_code', 'end_port'],
        ),
        supports_check_mode=True
    )

    acs_sg_rule = AnsibleCloudStackSecurityGroupRule(module)

    state = module.params.get('state')
    if state in ['absent']:
        sg_rule = acs_sg_rule.remove_rule()
    else:
        sg_rule = acs_sg_rule.add_rule()

    result = acs_sg_rule.get_result(sg_rule)
    module.exit_json(**result)
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        storage_url=dict(),
        zone=dict(),
        pod=dict(),
        cluster=dict(),
        scope=dict(choices=['zone', 'cluster']),
        hypervisor=dict(choices=CS_HYPERVISORS),
        provider=dict(default='DefaultPrimary'),
        capacity_bytes=dict(type='int'),
        capacity_iops=dict(type='int'),
        managed=dict(type='bool'),
        storage_tags=dict(type='list', aliases=['storage_tag']),
        allocation_state=dict(choices=['enabled', 'disabled', 'maintenance']),
        state=dict(choices=['present', 'absent'], default='present'),
    ))

    required_together = cs_required_together()
    required_together.extend([
        ['pod', 'cluster'],
    ])
    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=required_together,
        required_if=[
            ('state', 'present', ['storage_url']),
        ],
        supports_check_mode=True
    )

    acs_storage_pool = AnsibleCloudStackStoragePool(module)

    state = module.params.get('state')
    if state in ['absent']:
        pool = acs_storage_pool.absent_storage_pool()
    else:
        pool = acs_storage_pool.present_storage_pool()

    result = acs_storage_pool.get_result(pool)
    module.exit_json(**result)
Exemple #58
0
def main():
    argument_spec = cs_argument_spec()
    argument_spec.update(dict(
        name=dict(required=True),
        display_text=dict(),
        url=dict(),
        os_type=dict(),
        zone=dict(),
        cross_zones=dict(type='bool', default=False),
        iso_filter=dict(default='self', choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']),
        domain=dict(),
        account=dict(),
        project=dict(),
        checksum=dict(),
        is_ready=dict(type='bool', default=False),
        bootable=dict(type='bool'),
        is_featured=dict(type='bool'),
        is_dynamically_scalable=dict(type='bool'),
        state=dict(choices=['present', 'absent'], default='present'),
        poll_async=dict(type='bool', default=True),
        tags=dict(type='list', aliases=['tag']),
    ))

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_together=cs_required_together(),
        mutually_exclusive=(
            ['zone', 'cross_zones'],
        ),
        supports_check_mode=True
    )

    acs_iso = AnsibleCloudStackIso(module)

    state = module.params.get('state')
    if state in ['absent']:
        iso = acs_iso.absent_iso()
    else:
        iso = acs_iso.present_iso()

    result = acs_iso.get_result(iso)
    module.exit_json(**result)