Enable adding VLAN IP ranges for Physical Networks (#54576)
This commit is contained in:
parent
e59c1854eb
commit
6b3246164c
2 changed files with 75 additions and 2 deletions
|
@ -22,7 +22,11 @@ options:
|
||||||
network:
|
network:
|
||||||
description:
|
description:
|
||||||
- The network name or id.
|
- The network name or id.
|
||||||
required: true
|
- Required if I(for_virtual_network) and I(physical_network) are not set.
|
||||||
|
physical_network:
|
||||||
|
description:
|
||||||
|
- The physical network name or id.
|
||||||
|
type: str
|
||||||
start_ip:
|
start_ip:
|
||||||
description:
|
description:
|
||||||
- The beginning IPv4 address in the VLAN IP range.
|
- The beginning IPv4 address in the VLAN IP range.
|
||||||
|
@ -84,6 +88,8 @@ options:
|
||||||
for_virtual_network:
|
for_virtual_network:
|
||||||
description:
|
description:
|
||||||
- true if VLAN is of Virtual type, false if Direct.
|
- true if VLAN is of Virtual type, false if Direct.
|
||||||
|
- If set to C(true) but neither I(physical_network) or I(network) is set CloudStack will try to add the
|
||||||
|
VLAN range to the Physical Network with a Public traffic type.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
extends_documentation_fragment: cloudstack
|
extends_documentation_fragment: cloudstack
|
||||||
|
@ -269,6 +275,8 @@ class AnsibleCloudStackVlanIpRange(AnsibleCloudStack):
|
||||||
'networkid': self.get_network(key='id'),
|
'networkid': self.get_network(key='id'),
|
||||||
'forvirtualnetwork': self.module.params.get('for_virtual_network'),
|
'forvirtualnetwork': self.module.params.get('for_virtual_network'),
|
||||||
}
|
}
|
||||||
|
if self.module.params.get('physical_network'):
|
||||||
|
args['physicalnetworkid'] = self.get_physical_network(key='id')
|
||||||
|
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
res = self.query_api('createVlanIpRange', **args)
|
res = self.query_api('createVlanIpRange', **args)
|
||||||
|
@ -296,7 +304,8 @@ class AnsibleCloudStackVlanIpRange(AnsibleCloudStack):
|
||||||
def main():
|
def main():
|
||||||
argument_spec = cs_argument_spec()
|
argument_spec = cs_argument_spec()
|
||||||
argument_spec.update(dict(
|
argument_spec.update(dict(
|
||||||
network=dict(type='str', required=True),
|
network=dict(type='str'),
|
||||||
|
physical_network=dict(type='str'),
|
||||||
zone=dict(type='str'),
|
zone=dict(type='str'),
|
||||||
start_ip=dict(type='str', required=True),
|
start_ip=dict(type='str', required=True),
|
||||||
end_ip=dict(type='str'),
|
end_ip=dict(type='str'),
|
||||||
|
|
|
@ -369,3 +369,67 @@
|
||||||
that:
|
that:
|
||||||
- ipr_net is successful
|
- ipr_net is successful
|
||||||
- ipr_net is changed
|
- ipr_net is changed
|
||||||
|
|
||||||
|
# Create a new zone - the default one is enabled
|
||||||
|
- name: assure zone for tests
|
||||||
|
cs_zone:
|
||||||
|
name: cs-test-zone
|
||||||
|
state: present
|
||||||
|
dns1: 8.8.8.8
|
||||||
|
network_type: advanced
|
||||||
|
register: cszone
|
||||||
|
|
||||||
|
- name: ensure the zone is disabled
|
||||||
|
cs_zone:
|
||||||
|
name: "{{ cszone.name }}"
|
||||||
|
state: disabled
|
||||||
|
|
||||||
|
- name: setup a network for tests
|
||||||
|
cs_physical_network:
|
||||||
|
name: net01
|
||||||
|
zone: "{{ cszone.name }}"
|
||||||
|
isolation_method: VLAN
|
||||||
|
broadcast_domain_range: ZONE
|
||||||
|
state: present
|
||||||
|
register: public_network
|
||||||
|
|
||||||
|
- name: setup public network traffic
|
||||||
|
cs_traffic_type:
|
||||||
|
physical_network: "{{ public_network.name }}"
|
||||||
|
traffic_type: Public
|
||||||
|
kvm_networklabel: cloudbr1
|
||||||
|
zone: "{{ public_network.zone }}"
|
||||||
|
|
||||||
|
- name: test adding a public IP range
|
||||||
|
cs_vlan_ip_range:
|
||||||
|
end_ip: 10.0.3.250
|
||||||
|
start_ip: 10.0.3.10
|
||||||
|
zone: "{{ cszone.name }}"
|
||||||
|
netmask: 255.255.255.0
|
||||||
|
for_virtual_network: 'yes'
|
||||||
|
gateway: 10.0.3.2
|
||||||
|
vlan: untagged
|
||||||
|
register: public_range
|
||||||
|
- name: verify test adding a public IP range
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- public_range is successful
|
||||||
|
- public_range is changed
|
||||||
|
- public_range.physical_network == public_network.id
|
||||||
|
- public_range.vlan == 'vlan://untagged'
|
||||||
|
- public_range.gateway == '10.0.3.2'
|
||||||
|
- public_range.netmask == '255.255.255.0'
|
||||||
|
- public_range.zone == cszone.name
|
||||||
|
- public_range.start_ip == '10.0.3.10'
|
||||||
|
- public_range.end_ip == '10.0.3.250'
|
||||||
|
|
||||||
|
- name: cleanup the network
|
||||||
|
cs_physical_network:
|
||||||
|
name: net01
|
||||||
|
zone: "{{ cszone.name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: cleanup the zone
|
||||||
|
cs_zone:
|
||||||
|
name: "{{ cszone.name }}"
|
||||||
|
state: absent
|
Loading…
Reference in a new issue