|
|
|
@ -37,12 +37,12 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- Password of login user
|
|
|
|
|
required: true
|
|
|
|
|
default: True
|
|
|
|
|
default: 'yes'
|
|
|
|
|
login_tenant_name:
|
|
|
|
|
description:
|
|
|
|
|
- The tenant name of the login user
|
|
|
|
|
required: true
|
|
|
|
|
default: True
|
|
|
|
|
default: 'yes'
|
|
|
|
|
auth_url:
|
|
|
|
|
description:
|
|
|
|
|
- The keystone url for authentication
|
|
|
|
@ -135,7 +135,6 @@ def _get_net_id(quantum, module):
|
|
|
|
|
return None
|
|
|
|
|
return networks['networks'][0]['id']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_port_id(quantum, module, router_id, network_id):
|
|
|
|
|
kwargs = {
|
|
|
|
|
'device_id': router_id,
|
|
|
|
@ -183,26 +182,27 @@ def main():
|
|
|
|
|
|
|
|
|
|
quantum = _get_quantum_client(module, module.params)
|
|
|
|
|
router_id = _get_router_id(module, quantum)
|
|
|
|
|
|
|
|
|
|
if not router_id:
|
|
|
|
|
module.fail_json(msg = "failed to get the router id, please check the router name")
|
|
|
|
|
module.fail_json(msg="failed to get the router id, please check the router name")
|
|
|
|
|
|
|
|
|
|
network_id = _get_net_id(quantum, module)
|
|
|
|
|
if not network_id:
|
|
|
|
|
module.fail_json(msg = "failed to get the network id, please check the network name and make sure it is external")
|
|
|
|
|
module.fail_json(msg="failed to get the network id, please check the network name and make sure it is external")
|
|
|
|
|
|
|
|
|
|
if module.params['state'] == 'present':
|
|
|
|
|
port_id = _get_port_id(quantum, module, router_id, network_id)
|
|
|
|
|
if not port_id:
|
|
|
|
|
_add_gateway_router(quantum, module, router_id, network_id)
|
|
|
|
|
module.exit_json(changed = True, result = "created")
|
|
|
|
|
module.exit_json(changed = False, result = "success")
|
|
|
|
|
module.exit_json(changed=True, result="created")
|
|
|
|
|
module.exit_json(changed=False, result="success")
|
|
|
|
|
|
|
|
|
|
if module.params['state'] == 'absent':
|
|
|
|
|
port_id = _get_port_id(quantum, module, router_id, network_id)
|
|
|
|
|
if not port_id:
|
|
|
|
|
module.exit_json(changed = False, result = "Success")
|
|
|
|
|
module.exit_json(changed=False, result="Success")
|
|
|
|
|
_remove_gateway_router(quantum, module, router_id)
|
|
|
|
|
module.exit_json(changed = True, result = "Deleted")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=True, result="Deleted")
|
|
|
|
|
|
|
|
|
|
# this is magic, see lib/ansible/module.params['common.py
|
|
|
|
|
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
|
|
|
|