mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 04:34:24 -07:00
Add support for primary and secondary redundancy types. Require cdn name for user-defined names. (#35505)
This commit is contained in:
parent
3d614bfe84
commit
f5022de5d6
1 changed files with 54 additions and 26 deletions
|
@ -59,6 +59,14 @@ options:
|
||||||
- "none - Legacy vNIC template behavior. Select this option if you do not want to use redundancy."
|
- "none - Legacy vNIC template behavior. Select this option if you do not want to use redundancy."
|
||||||
choices: [none, primary, secondary]
|
choices: [none, primary, secondary]
|
||||||
default: none
|
default: none
|
||||||
|
peer_redundancy_template:
|
||||||
|
description:
|
||||||
|
- The Peer Redundancy Template.
|
||||||
|
- The name of the vNIC template sharing a configuration with this template.
|
||||||
|
- If the redundancy_type is primary, the name of the secondary template should be provided.
|
||||||
|
- If the redundancy_type is secondary, the name of the primary template should be provided.
|
||||||
|
- Secondary templates can only configure non-shared properties (name, description, and mac_pool).
|
||||||
|
aliases: [ peer_redundancy_templ ]
|
||||||
target:
|
target:
|
||||||
description:
|
description:
|
||||||
- The possible target for vNICs created from this template.
|
- The possible target for vNICs created from this template.
|
||||||
|
@ -188,6 +196,7 @@ def main():
|
||||||
description=dict(type='str', aliases=['descr'], default=''),
|
description=dict(type='str', aliases=['descr'], default=''),
|
||||||
fabric=dict(type='str', default='A', choices=['A', 'B', 'A-B', 'B-A']),
|
fabric=dict(type='str', default='A', choices=['A', 'B', 'A-B', 'B-A']),
|
||||||
redundancy_type=dict(type='str', default='none', choices=['none', 'primary', 'secondary']),
|
redundancy_type=dict(type='str', default='none', choices=['none', 'primary', 'secondary']),
|
||||||
|
peer_redundancy_template=dict(type='str', aliases=['peer_redundancy_templ'], default=''),
|
||||||
target=dict(type='str', default='adapter', choices=['adapter', 'vm']),
|
target=dict(type='str', default='adapter', choices=['adapter', 'vm']),
|
||||||
template_type=dict(type='str', default='initial-template', choices=['initial-template', 'updating-template']),
|
template_type=dict(type='str', default='initial-template', choices=['initial-template', 'updating-template']),
|
||||||
vlans_list=dict(type='list'),
|
vlans_list=dict(type='list'),
|
||||||
|
@ -205,6 +214,9 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec,
|
argument_spec,
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
|
required_if=[
|
||||||
|
['cdn_source', 'user-defined', ['cdn_name']],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
ucs = UCSModule(module)
|
ucs = UCSModule(module)
|
||||||
|
|
||||||
|
@ -246,16 +258,19 @@ def main():
|
||||||
kwargs = dict(descr=module.params['description'])
|
kwargs = dict(descr=module.params['description'])
|
||||||
kwargs['switch_id'] = module.params['fabric']
|
kwargs['switch_id'] = module.params['fabric']
|
||||||
kwargs['redundancy_pair_type'] = module.params['redundancy_type']
|
kwargs['redundancy_pair_type'] = module.params['redundancy_type']
|
||||||
kwargs['target'] = module.params['target']
|
kwargs['peer_redundancy_templ_name'] = module.params['peer_redundancy_template']
|
||||||
kwargs['templ_type'] = module.params['template_type']
|
|
||||||
kwargs['cdn_source'] = module.params['cdn_source']
|
|
||||||
kwargs['admin_cdn_name'] = module.params['cdn_name']
|
|
||||||
kwargs['mtu'] = module.params['mtu']
|
|
||||||
kwargs['ident_pool_name'] = module.params['mac_pool']
|
kwargs['ident_pool_name'] = module.params['mac_pool']
|
||||||
kwargs['qos_policy_name'] = module.params['qos_policy']
|
# do not check shared props if this is a secondary template
|
||||||
kwargs['nw_ctrl_policy_name'] = module.params['network_control_policy']
|
if module.params['redundancy_type'] != 'secondary':
|
||||||
kwargs['pin_to_group_name'] = module.params['pin_group']
|
kwargs['target'] = module.params['target']
|
||||||
kwargs['stats_policy_name'] = module.params['stats_policy']
|
kwargs['templ_type'] = module.params['template_type']
|
||||||
|
kwargs['cdn_source'] = module.params['cdn_source']
|
||||||
|
kwargs['admin_cdn_name'] = module.params['cdn_name']
|
||||||
|
kwargs['mtu'] = module.params['mtu']
|
||||||
|
kwargs['qos_policy_name'] = module.params['qos_policy']
|
||||||
|
kwargs['nw_ctrl_policy_name'] = module.params['network_control_policy']
|
||||||
|
kwargs['pin_to_group_name'] = module.params['pin_group']
|
||||||
|
kwargs['stats_policy_name'] = module.params['stats_policy']
|
||||||
if (mo.check_prop_match(**kwargs)):
|
if (mo.check_prop_match(**kwargs)):
|
||||||
# top-level props match, check next level mo/props
|
# top-level props match, check next level mo/props
|
||||||
if not module.params.get('vlans_list'):
|
if not module.params.get('vlans_list'):
|
||||||
|
@ -273,23 +288,36 @@ def main():
|
||||||
if not props_match:
|
if not props_match:
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
# create if mo does not already exist
|
# create if mo does not already exist
|
||||||
mo = VnicLanConnTempl(
|
# secondary template only sets non shared props
|
||||||
parent_mo_or_dn=module.params['org_dn'],
|
if module.params['redundancy_type'] == 'secondary':
|
||||||
name=module.params['name'],
|
mo = VnicLanConnTempl(
|
||||||
descr=module.params['description'],
|
parent_mo_or_dn=module.params['org_dn'],
|
||||||
switch_id=module.params['fabric'],
|
name=module.params['name'],
|
||||||
redundancy_pair_type=module.params['redundancy_type'],
|
descr=module.params['description'],
|
||||||
target=module.params['target'],
|
switch_id=module.params['fabric'],
|
||||||
templ_type=module.params['template_type'],
|
redundancy_pair_type=module.params['redundancy_type'],
|
||||||
cdn_source=module.params['cdn_source'],
|
peer_redundancy_templ_name=module.params['peer_redundancy_template'],
|
||||||
admin_cdn_name=module.params['cdn_name'],
|
ident_pool_name=module.params['mac_pool'],
|
||||||
mtu=module.params['mtu'],
|
)
|
||||||
ident_pool_name=module.params['mac_pool'],
|
else:
|
||||||
qos_policy_name=module.params['qos_policy'],
|
mo = VnicLanConnTempl(
|
||||||
nw_ctrl_policy_name=module.params['network_control_policy'],
|
parent_mo_or_dn=module.params['org_dn'],
|
||||||
pin_to_group_name=module.params['pin_group'],
|
name=module.params['name'],
|
||||||
stats_policy_name=module.params['stats_policy'],
|
descr=module.params['description'],
|
||||||
)
|
switch_id=module.params['fabric'],
|
||||||
|
redundancy_pair_type=module.params['redundancy_type'],
|
||||||
|
peer_redundancy_templ_name=module.params['peer_redundancy_templ'],
|
||||||
|
target=module.params['target'],
|
||||||
|
templ_type=module.params['template_type'],
|
||||||
|
cdn_source=module.params['cdn_source'],
|
||||||
|
admin_cdn_name=module.params['cdn_name'],
|
||||||
|
mtu=module.params['mtu'],
|
||||||
|
ident_pool_name=module.params['mac_pool'],
|
||||||
|
qos_policy_name=module.params['qos_policy'],
|
||||||
|
nw_ctrl_policy_name=module.params['network_control_policy'],
|
||||||
|
pin_to_group_name=module.params['pin_group'],
|
||||||
|
stats_policy_name=module.params['stats_policy'],
|
||||||
|
)
|
||||||
|
|
||||||
if module.params.get('vlans_list'):
|
if module.params.get('vlans_list'):
|
||||||
for vlan in module.params['vlans_list']:
|
for vlan in module.params['vlans_list']:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue