|
|
|
@ -38,12 +38,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
|
|
|
|
@ -74,12 +74,14 @@ options:
|
|
|
|
|
- desired admin state of the created router .
|
|
|
|
|
required: false
|
|
|
|
|
default: true
|
|
|
|
|
examples:
|
|
|
|
|
- code: "quantum_router: state=present login_username=admin login_password=admin login_tenant_name=admin name=router1"
|
|
|
|
|
description: "Creates a router for tenant admin"
|
|
|
|
|
requirements: ["quantumclient", "keystoneclient"]
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
|
# Creates a router for tenant admin
|
|
|
|
|
quantum_router: state=present login_username=admin login_password=admin login_tenant_name=admin name=router1"
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
_os_keystone = None
|
|
|
|
|
_os_tenant_id = None
|
|
|
|
|
|
|
|
|
@ -175,26 +177,28 @@ def main():
|
|
|
|
|
name = dict(required=True),
|
|
|
|
|
tenant_name = dict(default=None),
|
|
|
|
|
state = dict(default='present', choices=['absent', 'present']),
|
|
|
|
|
admin_state_up = dict(default='true', choices=BOOLEANS),
|
|
|
|
|
admin_state_up = dict(type='bool', default=True),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
quantum = _get_quantum_client(module, module.params)
|
|
|
|
|
_set_tenant_id(module)
|
|
|
|
|
|
|
|
|
|
if module.params['state'] == 'present':
|
|
|
|
|
router_id = _get_router_id(module, quantum)
|
|
|
|
|
if not router_id:
|
|
|
|
|
router_id = _create_router(module, quantum)
|
|
|
|
|
module.exit_json(changed = True, result = "Created" , id = router_id)
|
|
|
|
|
module.exit_json(changed=True, result="Created", id=router_id)
|
|
|
|
|
else:
|
|
|
|
|
module.exit_json(changed = False, result = "success" , id = router_id)
|
|
|
|
|
module.exit_json(changed=False, result="success" , id=router_id)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
router_id = _get_router_id(module, quantum)
|
|
|
|
|
if not router_id:
|
|
|
|
|
module.exit_json(changed = False, result = "success")
|
|
|
|
|
module.exit_json(changed=False, result="success")
|
|
|
|
|
else:
|
|
|
|
|
_delete_router(module, quantum, 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>>
|
|
|
|
|