mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
Rename MSC modules to MSO nomenclature (#50959)
* msc_tenant: improve docs * Rename MSC modules to MSO * Rename MSC-related objects to MSO nomenclature * Add missing doc fragments
This commit is contained in:
parent
7a1ceb6988
commit
a79441ca30
21 changed files with 493 additions and 491 deletions
|
@ -73,7 +73,7 @@ def update_qs(params):
|
|||
return '?' + urlencode(accepted_params)
|
||||
|
||||
|
||||
def msc_argument_spec():
|
||||
def mso_argument_spec():
|
||||
return dict(
|
||||
host=dict(type='str', required=True, aliases=['hostname']),
|
||||
port=dict(type='int', required=False),
|
||||
|
@ -87,7 +87,7 @@ def msc_argument_spec():
|
|||
)
|
||||
|
||||
|
||||
class MSCModule(object):
|
||||
class MSOModule(object):
|
||||
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
@ -131,7 +131,7 @@ class MSCModule(object):
|
|||
self.module.fail_json(msg="Parameter 'password' is required for authentication")
|
||||
|
||||
def login(self):
|
||||
''' Log in to MSC '''
|
||||
''' Log in to MSO '''
|
||||
|
||||
# Perform login request
|
||||
self.url = urljoin(self.baseuri, 'auth/login')
|
||||
|
@ -144,7 +144,7 @@ class MSCModule(object):
|
|||
timeout=self.params['timeout'],
|
||||
use_proxy=self.params['use_proxy'])
|
||||
|
||||
# Handle MSC response
|
||||
# Handle MSO response
|
||||
if auth['status'] != 201:
|
||||
self.response = auth['msg']
|
||||
self.status = auth['status']
|
||||
|
@ -155,7 +155,7 @@ class MSCModule(object):
|
|||
self.headers['Authorization'] = 'Bearer {token}'.format(**payload)
|
||||
|
||||
def request(self, path, method=None, data=None, qs=None):
|
||||
''' Generic HTTP method for MSC requests. '''
|
||||
''' Generic HTTP method for MSO requests. '''
|
||||
self.path = path
|
||||
|
||||
if method is not None:
|
||||
|
@ -198,14 +198,14 @@ class MSCModule(object):
|
|||
except Exception:
|
||||
payload = json.loads(info['body'])
|
||||
if 'code' in payload:
|
||||
self.fail_json(msg='MSC Error {code}: {message}'.format(**payload), data=data, info=info, payload=payload)
|
||||
self.fail_json(msg='MSO Error {code}: {message}'.format(**payload), data=data, info=info, payload=payload)
|
||||
else:
|
||||
self.fail_json(msg='MSC Error:'.format(**payload), data=data, info=info, payload=payload)
|
||||
self.fail_json(msg='MSO Error:'.format(**payload), data=data, info=info, payload=payload)
|
||||
|
||||
return {}
|
||||
|
||||
def query_objs(self, path, key=None, **kwargs):
|
||||
''' Query the MSC REST API for objects in a path '''
|
||||
''' Query the MSO REST API for objects in a path '''
|
||||
found = []
|
||||
objs = self.request(path, method='GET')
|
||||
|
||||
|
@ -223,7 +223,7 @@ class MSCModule(object):
|
|||
return found
|
||||
|
||||
def get_obj(self, path, **kwargs):
|
||||
''' Get a specific object from a set of MSC REST objects '''
|
||||
''' Get a specific object from a set of MSO REST objects '''
|
||||
objs = self.query_objs(path, **kwargs)
|
||||
if len(objs) == 0:
|
||||
return {}
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_label
|
||||
module: mso_label
|
||||
short_description: Manage labels
|
||||
description:
|
||||
- Manage labels on Cisco ACI Multi-Site.
|
||||
|
@ -45,13 +45,13 @@ options:
|
|||
type: str
|
||||
choices: [ absent, present, query ]
|
||||
default: present
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a new label
|
||||
msc_label:
|
||||
host: msc_host
|
||||
mso_label:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
label: Belgium
|
||||
|
@ -60,8 +60,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove a label
|
||||
msc_label:
|
||||
host: msc_host
|
||||
mso_label:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
label: Belgium
|
||||
|
@ -69,8 +69,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a label
|
||||
msc_label:
|
||||
host: msc_host
|
||||
mso_label:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
label: Belgium
|
||||
|
@ -79,8 +79,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all labels
|
||||
msc_label:
|
||||
host: msc_host
|
||||
mso_label:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -92,11 +92,11 @@ RETURN = r'''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
label=dict(type='str', required=False, aliases=['name', 'label_name']),
|
||||
label_id=dict(type='str', required=False),
|
||||
|
@ -118,24 +118,24 @@ def main():
|
|||
label_type = module.params['type']
|
||||
state = module.params['state']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
path = 'labels'
|
||||
|
||||
# Query for existing object(s)
|
||||
if label_id is None and label is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif label_id is None:
|
||||
msc.existing = msc.get_obj(path, displayName=label)
|
||||
if msc.existing:
|
||||
label_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, displayName=label)
|
||||
if mso.existing:
|
||||
label_id = mso.existing['id']
|
||||
elif label is None:
|
||||
msc.existing = msc.get_obj(path, id=label_id)
|
||||
mso.existing = mso.get_obj(path, id=label_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=label_id)
|
||||
existing_by_name = msc.get_obj(path, displayName=label)
|
||||
mso.existing = mso.get_obj(path, id=label_id)
|
||||
existing_by_name = mso.get_obj(path, displayName=label)
|
||||
if existing_by_name and label_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided label '{0}' with id '{1}' does not match existing id '{2}'.".format(label, label_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided label '{0}' with id '{1}' does not match existing id '{2}'.".format(label, label_id, existing_by_name['id']))
|
||||
|
||||
# If we found an existing object, continue with it
|
||||
if label_id:
|
||||
|
@ -145,15 +145,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE')
|
||||
mso.existing = mso.request(path, method='DELETE')
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
id=label_id,
|
||||
|
@ -161,21 +161,21 @@ def main():
|
|||
type=label_type,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_role
|
||||
module: mso_role
|
||||
short_description: Manage roles
|
||||
description:
|
||||
- Manage roles on Cisco ACI Multi-Site.
|
||||
|
@ -70,13 +70,13 @@ options:
|
|||
type: str
|
||||
choices: [ absent, present, query ]
|
||||
default: present
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a new role
|
||||
msc_role:
|
||||
host: msc_host
|
||||
mso_role:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
role: readOnly
|
||||
|
@ -93,8 +93,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove a role
|
||||
msc_role:
|
||||
host: msc_host
|
||||
mso_role:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
role: readOnly
|
||||
|
@ -102,8 +102,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a role
|
||||
msc_role:
|
||||
host: msc_host
|
||||
mso_role:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
role: readOnly
|
||||
|
@ -112,8 +112,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all roles
|
||||
msc_role:
|
||||
host: msc_host
|
||||
mso_role:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -125,11 +125,11 @@ RETURN = r'''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
role=dict(type='str', required=False, aliases=['name', 'role_name']),
|
||||
role_id=dict(type='str', required=False),
|
||||
|
@ -173,24 +173,24 @@ def main():
|
|||
permissions = module.params['permissions']
|
||||
state = module.params['state']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
path = 'roles'
|
||||
|
||||
# Query for existing object(s)
|
||||
if role_id is None and role is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif role_id is None:
|
||||
msc.existing = msc.get_obj(path, name=role)
|
||||
if msc.existing:
|
||||
role_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, name=role)
|
||||
if mso.existing:
|
||||
role_id = mso.existing['id']
|
||||
elif role is None:
|
||||
msc.existing = msc.get_obj(path, id=role_id)
|
||||
mso.existing = mso.get_obj(path, id=role_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=role_id)
|
||||
existing_by_name = msc.get_obj(path, name=role)
|
||||
mso.existing = mso.get_obj(path, id=role_id)
|
||||
existing_by_name = mso.get_obj(path, name=role)
|
||||
if existing_by_name and role_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided role '{0}' with id '{1}' does not match existing id '{2}'.".format(role, role_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided role '{0}' with id '{1}' does not match existing id '{2}'.".format(role, role_id, existing_by_name['id']))
|
||||
|
||||
# If we found an existing object, continue with it
|
||||
if role_id:
|
||||
|
@ -200,15 +200,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE')
|
||||
mso.existing = mso.request(path, method='DELETE')
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
id=role_id,
|
||||
|
@ -218,21 +218,21 @@ def main():
|
|||
permissions=permissions,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_schema
|
||||
module: mso_schema
|
||||
short_description: Manage schemas
|
||||
description:
|
||||
- Manage schemas on Cisco ACI Multi-Site.
|
||||
|
@ -46,13 +46,13 @@ options:
|
|||
type: str
|
||||
choices: [ absent, present, query ]
|
||||
default: present
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a new schema
|
||||
msc_schema:
|
||||
host: msc_host
|
||||
mso_schema:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
schema: Schema 1
|
||||
|
@ -71,8 +71,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove schemas
|
||||
msc_schema:
|
||||
host: msc_host
|
||||
mso_schema:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
schema: Schema 1
|
||||
|
@ -80,8 +80,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a schema
|
||||
msc_schema:
|
||||
host: msc_host
|
||||
mso_schema:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
schema: Schema 1
|
||||
|
@ -90,8 +90,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all schemas
|
||||
msc_schema:
|
||||
host: msc_host
|
||||
mso_schema:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -103,11 +103,11 @@ RETURN = r'''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
schema=dict(type='str', required=False, aliases=['name', 'schema_name']),
|
||||
schema_id=dict(type='str', required=False),
|
||||
|
@ -136,24 +136,24 @@ def main():
|
|||
sites = module.params['sites']
|
||||
state = module.params['state']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
path = 'schemas'
|
||||
|
||||
# Query for existing object(s)
|
||||
if schema_id is None and schema is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif schema_id is None:
|
||||
msc.existing = msc.get_obj(path, displayName=schema)
|
||||
if msc.existing:
|
||||
schema_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, displayName=schema)
|
||||
if mso.existing:
|
||||
schema_id = mso.existing['id']
|
||||
elif schema is None:
|
||||
msc.existing = msc.get_obj(path, id=schema_id)
|
||||
mso.existing = mso.get_obj(path, id=schema_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=schema_id)
|
||||
existing_by_name = msc.get_obj(path, displayName=schema)
|
||||
mso.existing = mso.get_obj(path, id=schema_id)
|
||||
existing_by_name = mso.get_obj(path, displayName=schema)
|
||||
if existing_by_name and schema_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided schema '{1}' with id '{2}' does not match existing id '{3}'.".format(schema, schema_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided schema '{1}' with id '{2}' does not match existing id '{3}'.".format(schema, schema_id, existing_by_name['id']))
|
||||
|
||||
if schema_id:
|
||||
path = 'schemas/{id}'.format(id=schema_id)
|
||||
|
@ -162,15 +162,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE')
|
||||
mso.existing = mso.request(path, method='DELETE')
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
id=schema_id,
|
||||
|
@ -179,21 +179,21 @@ def main():
|
|||
sites=sites,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_site
|
||||
module: mso_site
|
||||
short_description: Manage sites
|
||||
description:
|
||||
- Manage sites on Cisco ACI Multi-Site.
|
||||
|
@ -76,18 +76,18 @@ options:
|
|||
type: str
|
||||
choices: [ absent, present, query ]
|
||||
default: present
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a new site
|
||||
msc_site:
|
||||
host: msc_host
|
||||
mso_site:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
site: north_europe
|
||||
description: North European Datacenter
|
||||
apic_username: msc_admin
|
||||
apic_username: mso_admin
|
||||
apic_password: AnotherSecretPassword
|
||||
apic_site_id: 12
|
||||
urls:
|
||||
|
@ -105,8 +105,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove a site
|
||||
msc_site:
|
||||
host: msc_host
|
||||
mso_site:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
site: north_europe
|
||||
|
@ -114,8 +114,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a site
|
||||
msc_site:
|
||||
host: msc_host
|
||||
mso_site:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
site: north_europe
|
||||
|
@ -124,8 +124,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all sites
|
||||
msc_site:
|
||||
host: msc_host
|
||||
mso_site:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -137,7 +137,7 @@ RETURN = r'''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -146,7 +146,7 @@ def main():
|
|||
longitude=dict(type='float'),
|
||||
)
|
||||
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
apic_password=dict(type='str', no_log=True),
|
||||
apic_site_id=dict(type='str'),
|
||||
|
@ -180,27 +180,27 @@ def main():
|
|||
state = module.params['state']
|
||||
urls = module.params['urls']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
path = 'sites'
|
||||
|
||||
# Convert labels
|
||||
labels = msc.lookup_labels(module.params['labels'], 'site')
|
||||
labels = mso.lookup_labels(module.params['labels'], 'site')
|
||||
|
||||
# Query for msc.existing object(s)
|
||||
# Query for mso.existing object(s)
|
||||
if site_id is None and site is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif site_id is None:
|
||||
msc.existing = msc.get_obj(path, name=site)
|
||||
if msc.existing:
|
||||
site_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, name=site)
|
||||
if mso.existing:
|
||||
site_id = mso.existing['id']
|
||||
elif site is None:
|
||||
msc.existing = msc.get_obj(path, id=site_id)
|
||||
mso.existing = mso.get_obj(path, id=site_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=site_id)
|
||||
existing_by_name = msc.get_obj(path, name=site)
|
||||
mso.existing = mso.get_obj(path, id=site_id)
|
||||
existing_by_name = mso.get_obj(path, name=site)
|
||||
if existing_by_name and site_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided site '{0}' with id '{1}' does not match existing id '{2}'.".format(site, site_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided site '{0}' with id '{1}' does not match existing id '{2}'.".format(site, site_id, existing_by_name['id']))
|
||||
|
||||
# If we found an existing object, continue with it
|
||||
if site_id:
|
||||
|
@ -210,15 +210,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE', qs=dict(force='true'))
|
||||
mso.existing = mso.request(path, method='DELETE', qs=dict(force='true'))
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
apicSiteId=apic_site_id,
|
||||
|
@ -236,24 +236,24 @@ def main():
|
|||
long=longitude,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
if 'password' in msc.existing:
|
||||
msc.existing['password'] = '******'
|
||||
if 'password' in mso.existing:
|
||||
mso.existing['password'] = '******'
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_tenant
|
||||
module: mso_tenant
|
||||
short_description: Manage tenants
|
||||
description:
|
||||
- Manage tenants on Cisco ACI Multi-Site.
|
||||
|
@ -43,13 +43,13 @@ options:
|
|||
type: str
|
||||
users:
|
||||
description:
|
||||
- A list of allowed users for this tenant.
|
||||
- Using this property will replace any existing allowed users.
|
||||
- A list of associated users for this tenant.
|
||||
- Using this property will replace any existing associated users.
|
||||
type: list
|
||||
sites:
|
||||
description:
|
||||
- A list of allowed sites for this tenant.
|
||||
- Using this property will replace any existing allowed sites.
|
||||
- A list of associated sites for this tenant.
|
||||
- Using this property will replace any existing associated sites.
|
||||
type: list
|
||||
state:
|
||||
description:
|
||||
|
@ -58,13 +58,13 @@ options:
|
|||
type: str
|
||||
choices: [ absent, present, query ]
|
||||
default: present
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a new tenant
|
||||
msc_tenant:
|
||||
host: msc_host
|
||||
mso_tenant:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
tenant: north_europe
|
||||
|
@ -75,8 +75,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove a tenant
|
||||
msc_tenant:
|
||||
host: msc_host
|
||||
mso_tenant:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
tenant: north_europe
|
||||
|
@ -84,8 +84,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a tenant
|
||||
msc_tenant:
|
||||
host: msc_host
|
||||
mso_tenant:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
tenant: north_europe
|
||||
|
@ -94,8 +94,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all tenants
|
||||
msc_tenant:
|
||||
host: msc_host
|
||||
mso_tenant:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -107,11 +107,11 @@ RETURN = r'''
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
description=dict(type='str'),
|
||||
display_name=dict(type='str'),
|
||||
|
@ -137,28 +137,28 @@ def main():
|
|||
tenant_id = module.params['tenant_id']
|
||||
state = module.params['state']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
# Convert sites and users
|
||||
sites = msc.lookup_sites(module.params['sites'])
|
||||
users = msc.lookup_users(module.params['users'])
|
||||
sites = mso.lookup_sites(module.params['sites'])
|
||||
users = mso.lookup_users(module.params['users'])
|
||||
|
||||
path = 'tenants'
|
||||
|
||||
# Query for existing object(s)
|
||||
if tenant_id is None and tenant is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif tenant_id is None:
|
||||
msc.existing = msc.get_obj(path, name=tenant)
|
||||
if msc.existing:
|
||||
tenant_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, name=tenant)
|
||||
if mso.existing:
|
||||
tenant_id = mso.existing['id']
|
||||
elif tenant is None:
|
||||
msc.existing = msc.get_obj(path, id=tenant_id)
|
||||
mso.existing = mso.get_obj(path, id=tenant_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=tenant_id)
|
||||
existing_by_name = msc.get_obj(path, name=tenant)
|
||||
mso.existing = mso.get_obj(path, id=tenant_id)
|
||||
existing_by_name = mso.get_obj(path, name=tenant)
|
||||
if existing_by_name and tenant_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided tenant '{0}' with id '{1}' does not match existing id '{2}'.".format(tenant, tenant_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided tenant '{0}' with id '{1}' does not match existing id '{2}'.".format(tenant, tenant_id, existing_by_name['id']))
|
||||
|
||||
# If we found an existing object, continue with it
|
||||
if tenant_id:
|
||||
|
@ -168,15 +168,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE')
|
||||
mso.existing = mso.request(path, method='DELETE')
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
description=description,
|
||||
|
@ -187,29 +187,29 @@ def main():
|
|||
userAssociations=users,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
# Ensure displayName is not undefined
|
||||
if msc.sent.get('displayName') is None:
|
||||
msc.sent['displayName'] = tenant
|
||||
if mso.sent.get('displayName') is None:
|
||||
mso.sent['displayName'] = tenant
|
||||
|
||||
# Ensure tenant has at least admin user
|
||||
if msc.sent.get('userAssociations') is None:
|
||||
msc.sent['userAssociations'] = [dict(userId="0000ffff0000000000000020")]
|
||||
if mso.sent.get('userAssociations') is None:
|
||||
mso.sent['userAssociations'] = [dict(userId="0000ffff0000000000000020")]
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: msc_user
|
||||
module: mso_user
|
||||
short_description: Manage users
|
||||
description:
|
||||
- Manage users on Cisco ACI Multi-Site.
|
||||
|
@ -80,13 +80,13 @@ options:
|
|||
notes:
|
||||
- A default installation of ACI Multi-Site ships with admin password 'we1come!' which requires a password change on first login.
|
||||
See the examples of how to change the 'admin' password using Ansible.
|
||||
extends_documentation_fragment: msc
|
||||
extends_documentation_fragment: mso
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Update initial admin password
|
||||
msc_user:
|
||||
host: msc_host
|
||||
mso_user:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: we1come!
|
||||
user_name: admin
|
||||
|
@ -95,8 +95,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Add a new user
|
||||
msc_user:
|
||||
host: msc_host
|
||||
mso_user:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
user_name: dag
|
||||
|
@ -109,8 +109,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Remove a user
|
||||
msc_user:
|
||||
host: msc_host
|
||||
mso_user:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
user_name: dag
|
||||
|
@ -118,8 +118,8 @@ EXAMPLES = r'''
|
|||
delegate_to: localhost
|
||||
|
||||
- name: Query a user
|
||||
msc_user:
|
||||
host: msc_host
|
||||
mso_user:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
user_name: dag
|
||||
|
@ -128,8 +128,8 @@ EXAMPLES = r'''
|
|||
register: query_result
|
||||
|
||||
- name: Query all users
|
||||
msc_user:
|
||||
host: msc_host
|
||||
mso_user:
|
||||
host: mso_host
|
||||
username: admin
|
||||
password: SomeSecretPassword
|
||||
state: query
|
||||
|
@ -140,11 +140,11 @@ EXAMPLES = r'''
|
|||
RETURN = r''' # '''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
||||
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = msc_argument_spec()
|
||||
argument_spec = mso_argument_spec()
|
||||
argument_spec.update(
|
||||
user_id=dict(type='str', required=False),
|
||||
user=dict(type='str', required=False, aliases=['name', 'user_name']),
|
||||
|
@ -179,27 +179,27 @@ def main():
|
|||
account_status = module.params['account_status']
|
||||
state = module.params['state']
|
||||
|
||||
msc = MSCModule(module)
|
||||
mso = MSOModule(module)
|
||||
|
||||
roles = msc.lookup_roles(module.params['roles'])
|
||||
domain = msc.lookup_domain(module.params['domain'])
|
||||
roles = mso.lookup_roles(module.params['roles'])
|
||||
domain = mso.lookup_domain(module.params['domain'])
|
||||
|
||||
path = 'users'
|
||||
|
||||
# Query for existing object(s)
|
||||
if user_id is None and user_name is None:
|
||||
msc.existing = msc.query_objs(path)
|
||||
mso.existing = mso.query_objs(path)
|
||||
elif user_id is None:
|
||||
msc.existing = msc.get_obj(path, username=user_name)
|
||||
if msc.existing:
|
||||
user_id = msc.existing['id']
|
||||
mso.existing = mso.get_obj(path, username=user_name)
|
||||
if mso.existing:
|
||||
user_id = mso.existing['id']
|
||||
elif user_name is None:
|
||||
msc.existing = msc.get_obj(path, id=user_id)
|
||||
mso.existing = mso.get_obj(path, id=user_id)
|
||||
else:
|
||||
msc.existing = msc.get_obj(path, id=user_id)
|
||||
existing_by_name = msc.get_obj(path, username=user_name)
|
||||
mso.existing = mso.get_obj(path, id=user_id)
|
||||
existing_by_name = mso.get_obj(path, username=user_name)
|
||||
if existing_by_name and user_id != existing_by_name['id']:
|
||||
msc.fail_json(msg="Provided user '{0}' with id '{1}' does not match existing id '{2}'.".format(user_name, user_id, existing_by_name['id']))
|
||||
mso.fail_json(msg="Provided user '{0}' with id '{1}' does not match existing id '{2}'.".format(user_name, user_id, existing_by_name['id']))
|
||||
|
||||
# If we found an existing object, continue with it
|
||||
if user_id:
|
||||
|
@ -209,15 +209,15 @@ def main():
|
|||
pass
|
||||
|
||||
elif state == 'absent':
|
||||
msc.previous = msc.existing
|
||||
if msc.existing:
|
||||
mso.previous = mso.existing
|
||||
if mso.existing:
|
||||
if module.check_mode:
|
||||
msc.existing = {}
|
||||
mso.existing = {}
|
||||
else:
|
||||
msc.existing = msc.request(path, method='DELETE')
|
||||
mso.existing = mso.request(path, method='DELETE')
|
||||
|
||||
elif state == 'present':
|
||||
msc.previous = msc.existing
|
||||
mso.previous = mso.existing
|
||||
|
||||
payload = dict(
|
||||
id=user_id,
|
||||
|
@ -234,29 +234,29 @@ def main():
|
|||
# remote=True,
|
||||
)
|
||||
|
||||
msc.sanitize(payload, collate=True)
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
if msc.sent.get('accountStatus') is None:
|
||||
msc.sent['accountStatus'] = 'active'
|
||||
if mso.sent.get('accountStatus') is None:
|
||||
mso.sent['accountStatus'] = 'active'
|
||||
|
||||
if msc.existing:
|
||||
if not issubset(msc.sent, msc.existing):
|
||||
# NOTE: Since MSC always returns '******' as password, we need to assume a change
|
||||
if 'password' in msc.proposed:
|
||||
msc.module.warn("A password change is assumed, as the MSC REST API does not return passwords we do not know.")
|
||||
msc.result['changed'] = True
|
||||
if mso.existing:
|
||||
if not issubset(mso.sent, mso.existing):
|
||||
# NOTE: Since MSO always returns '******' as password, we need to assume a change
|
||||
if 'password' in mso.proposed:
|
||||
mso.module.warn("A password change is assumed, as the MSO REST API does not return passwords we do not know.")
|
||||
mso.result['changed'] = True
|
||||
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||
else:
|
||||
if module.check_mode:
|
||||
msc.existing = msc.proposed
|
||||
mso.existing = mso.proposed
|
||||
else:
|
||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
||||
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||
|
||||
msc.exit_json()
|
||||
mso.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
Loading…
Add table
Add a link
Reference in a new issue