cloudstack: cs_network: implement subdomain_access (#34741)

pull/34961/merge
René Moser 7 years ago committed by GitHub
parent 4bc22be614
commit 8fdfda76e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyrigh (c) 2015, René Moser <mail@renemoser.net> # Copyright (c) 2015, René Moser <mail@renemoser.net>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function

@ -1,22 +1,9 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# (c) 2015, René Moser <mail@renemoser.net> # Copyright (c) 2017, René Moser <mail@renemoser.net>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'], 'status': ['stableinterface'],
@ -40,160 +27,129 @@ options:
description: description:
- Display text of the network. - Display text of the network.
- If not specified, C(name) will be used as C(display_text). - If not specified, C(name) will be used as C(display_text).
required: false
default: null
network_offering: network_offering:
description: description:
- Name of the offering for the network. - Name of the offering for the network.
- Required if C(state=present). - Required if C(state=present).
required: false
default: null
start_ip: start_ip:
description: description:
- The beginning IPv4 address of the network belongs to. - The beginning IPv4 address of the network belongs to.
- Only considered on create. - Only considered on create.
required: false
default: null
end_ip: end_ip:
description: description:
- The ending IPv4 address of the network belongs to. - The ending IPv4 address of the network belongs to.
- If not specified, value of C(start_ip) is used. - If not specified, value of C(start_ip) is used.
- Only considered on create. - Only considered on create.
required: false
default: null
gateway: gateway:
description: description:
- The gateway of the network. - The gateway of the network.
- Required for shared networks and isolated networks when it belongs to a VPC. - Required for shared networks and isolated networks when it belongs to a VPC.
- Only considered on create. - Only considered on create.
required: false
default: null
netmask: netmask:
description: description:
- The netmask of the network. - The netmask of the network.
- Required for shared networks and isolated networks when it belongs to a VPC. - Required for shared networks and isolated networks when it belongs to a VPC.
- Only considered on create. - Only considered on create.
required: false
default: null
start_ipv6: start_ipv6:
description: description:
- The beginning IPv6 address of the network belongs to. - The beginning IPv6 address of the network belongs to.
- Only considered on create. - Only considered on create.
required: false
default: null
end_ipv6: end_ipv6:
description: description:
- The ending IPv6 address of the network belongs to. - The ending IPv6 address of the network belongs to.
- If not specified, value of C(start_ipv6) is used. - If not specified, value of C(start_ipv6) is used.
- Only considered on create. - Only considered on create.
required: false
default: null
cidr_ipv6: cidr_ipv6:
description: description:
- CIDR of IPv6 network, must be at least /64. - CIDR of IPv6 network, must be at least /64.
- Only considered on create. - Only considered on create.
required: false
default: null
gateway_ipv6: gateway_ipv6:
description: description:
- The gateway of the IPv6 network. - The gateway of the IPv6 network.
- Required for shared networks. - Required for shared networks.
- Only considered on create. - Only considered on create.
required: false
default: null
vlan: vlan:
description: description:
- The ID or VID of the network. - The ID or VID of the network.
required: false
default: null
vpc: vpc:
description: description:
- Name of the VPC of the network. - Name of the VPC of the network.
required: false
default: null
isolated_pvlan: isolated_pvlan:
description: description:
- The isolated private VLAN for this network. - The isolated private VLAN for this network.
required: false
default: null
clean_up: clean_up:
description: description:
- Cleanup old network elements. - Cleanup old network elements.
- Only considered on C(state=restarted). - Only considered on C(state=restarted).
required: false default: no
default: false type: bool
acl_type: acl_type:
description: description:
- Access control type. - Access control type.
- Only considered on create. - Only considered on create.
required: false
default: account default: account
choices: [ 'account', 'domain' ] choices: [ account, domain ]
subdomain_access:
description:
- Defines whether to allow subdomains to use networks dedicated to their parent domain(s).
- Should be used with C(acl_type=domain).
- Only considered on create.
type: bool
version_added: "2.5"
network_domain: network_domain:
description: description:
- The network domain. - The network domain.
required: false
default: null
state: state:
description: description:
- State of the network. - State of the network.
required: false
default: present default: present
choices: [ 'present', 'absent', 'restarted' ] choices: [ present, absent, restarted ]
zone: zone:
description: description:
- Name of the zone in which the network should be deployed. - Name of the zone in which the network should be deployed.
- If not set, default zone is used. - If not set, default zone is used.
required: false
default: null
project: project:
description: description:
- Name of the project the network to be deployed in. - Name of the project the network to be deployed in.
required: false
default: null
domain: domain:
description: description:
- Domain the network is related to. - Domain the network is related to.
required: false
default: null
account: account:
description: description:
- Account the network is related to. - Account the network is related to.
required: false
default: null
poll_async: poll_async:
description: description:
- Poll async jobs until job has finished. - Poll async jobs until job has finished.
required: false default: yes
default: true type: bool
extends_documentation_fragment: cloudstack extends_documentation_fragment: cloudstack
''' '''
EXAMPLES = ''' EXAMPLES = '''
# create a network - name: Create a network
- local_action: local_action:
module: cs_network module: cs_network
name: my network name: my network
zone: gva-01 zone: gva-01
network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
network_domain: example.com network_domain: example.com
# update a network - name: Update a network
- local_action: local_action:
module: cs_network module: cs_network
name: my network name: my network
display_text: network of domain example.local display_text: network of domain example.local
network_domain: example.local network_domain: example.local
# restart a network with clean up - name: Restart a network with clean up
- local_action: local_action:
module: cs_network module: cs_network
name: my network name: my network
clean_up: yes clean_up: yes
state: restared state: restared
# remove a network - name: Remove a network
- local_action: local_action:
module: cs_network module: cs_network
name: my network name: my network
state: absent state: absent
@ -503,6 +459,7 @@ def main():
isolated_pvlan=dict(), isolated_pvlan=dict(),
clean_up=dict(type='bool', default=False), clean_up=dict(type='bool', default=False),
network_domain=dict(), network_domain=dict(),
subdomain_access=dict(type='bool'),
state=dict(choices=['present', 'absent', 'restarted'], default='present'), state=dict(choices=['present', 'absent', 'restarted'], default='present'),
acl_type=dict(choices=['account', 'domain']), acl_type=dict(choices=['account', 'domain']),
project=dict(), project=dict(),
@ -524,10 +481,10 @@ def main():
acs_network = AnsibleCloudStackNetwork(module) acs_network = AnsibleCloudStackNetwork(module)
state = module.params.get('state') state = module.params.get('state')
if state in ['absent']: if state == 'absent':
network = acs_network.absent_network() network = acs_network.absent_network()
elif state in ['restarted']: elif state == 'restarted':
network = acs_network.restart_network() network = acs_network.restart_network()
else: else:

@ -1,20 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2015 René Moser <mail@renemoser.net> # Copyright (c) 2015, René Moser <mail@renemoser.net>
# # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
class ModuleDocFragment(object): class ModuleDocFragment(object):
@ -25,33 +11,24 @@ options:
api_key: api_key:
description: description:
- API key of the CloudStack API. - API key of the CloudStack API.
required: false
default: null
api_secret: api_secret:
description: description:
- Secret key of the CloudStack API. - Secret key of the CloudStack API.
required: false
default: null
api_url: api_url:
description: description:
- URL of the CloudStack API e.g. https://cloud.example.com/client/api. - URL of the CloudStack API e.g. https://cloud.example.com/client/api.
required: false
default: null
api_http_method: api_http_method:
description: description:
- HTTP method used. - HTTP method used.
required: false default: get
default: 'get' choices: [ get, post ]
choices: [ 'get', 'post' ]
api_timeout: api_timeout:
description: description:
- HTTP timeout. - HTTP timeout.
required: false
default: 10 default: 10
api_region: api_region:
description: description:
- Name of the ini section in the C(cloustack.ini) file. - Name of the ini section in the C(cloustack.ini) file.
required: false
default: cloudstack default: cloudstack
requirements: requirements:
- "python >= 2.6" - "python >= 2.6"
@ -60,14 +37,14 @@ notes:
- Ansible uses the C(cs) library's configuration method if credentials are not - Ansible uses the C(cs) library's configuration method if credentials are not
provided by the arguments C(api_url), C(api_key), C(api_secret). provided by the arguments C(api_url), C(api_key), C(api_secret).
Configuration is read from several locations, in the following order. Configuration is read from several locations, in the following order.
- The C(CLOUDSTACK_ENDPOINT), C(CLOUDSTACK_KEY), C(CLOUDSTACK_SECRET) and The C(CLOUDSTACK_ENDPOINT), C(CLOUDSTACK_KEY), C(CLOUDSTACK_SECRET) and
C(CLOUDSTACK_METHOD). C(CLOUDSTACK_TIMEOUT) environment variables. C(CLOUDSTACK_METHOD). C(CLOUDSTACK_TIMEOUT) environment variables.
- A C(CLOUDSTACK_CONFIG) environment variable pointing to an C(.ini) file, A C(CLOUDSTACK_CONFIG) environment variable pointing to an C(.ini) file.
- A C(cloudstack.ini) file in the current working directory. A C(cloudstack.ini) file in the current working directory.
- A C(.cloudstack.ini) file in the users home directory. A C(.cloudstack.ini) file in the users home directory.
Optionally multiple credentials and endpoints can be specified using ini sections in C(cloudstack.ini). Optionally multiple credentials and endpoints can be specified using ini sections in C(cloudstack.ini).
Use the argument C(api_region) to select the section name, default section is C(cloudstack). Use the argument C(api_region) to select the section name, default section is C(cloudstack).
See https://github.com/exoscale/cs for more information. See https://github.com/exoscale/cs for more information.
- A detailed guide about cloudstack modules can be found on http://docs.ansible.com/ansible/guide_cloudstack.html - A detailed guide about cloudstack modules can be found on http://docs.ansible.com/ansible/guide_cloudstack.html.
- This module supports check mode. - This module supports check mode.
''' '''

Loading…
Cancel
Save