| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
from __future__ import absolute_import, division, print_function |
| 7 |
__metaclass__ = type |
| 8 |
|
| 9 |
ANSIBLE_METADATA = {'metadata_version': '1.1', |
| 10 |
'status': ['preview'], |
| 11 |
'supported_by': 'community'} |
| 12 |
|
| 13 |
DOCUMENTATION = r''' |
| 14 |
--- |
| 15 |
module: intersight_vnic_template |
| 16 |
short_description: Manage vNIC Templates for Cisco Intersight |
| 17 |
description: |
| 18 |
- Create, update, and delete vNIC Templates on Cisco Intersight. |
| 19 |
- vNIC Templates define network interface configurations that can be used by LAN Connectivity policies. |
| 20 |
- Templates provide a standardized way to configure vNICs with consistent network and adapter policies. |
| 21 |
- vNIC Templates are only applicable for FI-Attached (Fabric Interconnect) deployments. |
| 22 |
- For more information see L(Cisco Intersight,https://intersight.com/apidocs/vnic/VnicTemplate/get/). |
| 23 |
extends_documentation_fragment: intersight |
| 24 |
options: |
| 25 |
state: |
| 26 |
description: |
| 27 |
- If C(present), will verify the resource is present and will create if needed. |
| 28 |
- If C(absent), will verify the resource is absent and will delete if needed. |
| 29 |
type: str |
| 30 |
choices: [present, absent] |
| 31 |
default: present |
| 32 |
organization: |
| 33 |
description: |
| 34 |
- The name of the Organization this resource is assigned to. |
| 35 |
- Policies created within a Custom Organization are applicable only to devices in the same Organization. |
| 36 |
- Use 'default' for the default organization. |
| 37 |
type: str |
| 38 |
default: default |
| 39 |
name: |
| 40 |
description: |
| 41 |
- The name assigned to the vNIC Template. |
| 42 |
- Must be unique within the organization. |
| 43 |
- The name must be between 1 and 62 alphanumeric characters, allowing special characters :-_. |
| 44 |
type: str |
| 45 |
required: true |
| 46 |
description: |
| 47 |
description: |
| 48 |
- The user-defined description for the vNIC Template. |
| 49 |
- Description can contain letters(a-z, A-Z), numbers(0-9), hyphen(-), period(.), colon(:), or an underscore(_). |
| 50 |
type: str |
| 51 |
aliases: [descr] |
| 52 |
tags: |
| 53 |
description: |
| 54 |
- List of tags in Key:<user-defined key> Value:<user-defined value> format. |
| 55 |
type: list |
| 56 |
elements: dict |
| 57 |
enable_override: |
| 58 |
description: |
| 59 |
- When enabled, the configuration of the derived instances may override the template configuration. |
| 60 |
type: bool |
| 61 |
default: false |
| 62 |
switch_id: |
| 63 |
description: |
| 64 |
- The fabric port to which the vNIC will be associated. |
| 65 |
type: str |
| 66 |
choices: ['A', 'B'] |
| 67 |
default: 'A' |
| 68 |
failover_enabled: |
| 69 |
description: |
| 70 |
- Enables automatic vNIC failover to the secondary Fabric Interconnect |
| 71 |
if the primary path fails. |
| 72 |
- Failover applies only to Cisco VICs that are connected to a Fabric Interconnect cluster. |
| 73 |
type: bool |
| 74 |
default: false |
| 75 |
cdn_source: |
| 76 |
description: |
| 77 |
- Source of the CDN. It can either be user specified or be the same as the vNIC name. |
| 78 |
type: str |
| 79 |
choices: ['vnic', 'user'] |
| 80 |
default: 'vnic' |
| 81 |
cdn_value: |
| 82 |
description: |
| 83 |
- CDN value when cdn_source is 'user'. |
| 84 |
type: str |
| 85 |
mac_pool_name: |
| 86 |
description: |
| 87 |
- The MAC pool that is assigned to the vNIC Template. |
| 88 |
- Required when state is 'present'. |
| 89 |
type: str |
| 90 |
fabric_eth_network_group_policy_name: |
| 91 |
description: |
| 92 |
- Relationship to the Fabric Ethernet Group Policy. |
| 93 |
- Required when state is 'present'. |
| 94 |
type: str |
| 95 |
fabric_eth_network_control_policy_name: |
| 96 |
description: |
| 97 |
- Relationship to the Fabric Ethernet Network Control Policy. |
| 98 |
- Required when state is 'present'. |
| 99 |
type: str |
| 100 |
eth_qos_policy_name: |
| 101 |
description: |
| 102 |
- Relationship to the Ethernet QoS Policy. |
| 103 |
- Required when state is 'present'. |
| 104 |
type: str |
| 105 |
eth_adapter_policy_name: |
| 106 |
description: |
| 107 |
- Relationship to the Ethernet Adapter Policy. |
| 108 |
- Required when state is 'present'. |
| 109 |
type: str |
| 110 |
iscsi_boot_policy_name: |
| 111 |
description: |
| 112 |
- Relationship to the boot iSCSI Policy. |
| 113 |
type: str |
| 114 |
pin_group_name: |
| 115 |
description: |
| 116 |
- Pingroup name associated to vNIC for static pinning. |
| 117 |
- LCP deploy will resolve pingroup name and fetches the corresponding uplink port/port channel to pin the vNIC traffic. |
| 118 |
type: str |
| 119 |
connection_type: |
| 120 |
description: |
| 121 |
- Type of connection for the vNIC. |
| 122 |
type: str |
| 123 |
choices: ['none', 'usnic', 'vmq', 'sriov'] |
| 124 |
default: 'none' |
| 125 |
usnic_settings: |
| 126 |
description: |
| 127 |
- USNIC settings when connection_type is 'usnic'. |
| 128 |
- Required when connection_type is 'usnic'. |
| 129 |
type: dict |
| 130 |
suboptions: |
| 131 |
count: |
| 132 |
description: |
| 133 |
- Number of usNIC interfaces to be created. |
| 134 |
- When usNIC is enabled, the valid values are from 1 to 225. |
| 135 |
- When usNIC is disabled, the default value is 0. |
| 136 |
type: int |
| 137 |
default: 0 |
| 138 |
cos: |
| 139 |
description: |
| 140 |
- Class of Service to be used for traffic on the usNIC. |
| 141 |
type: int |
| 142 |
choices: [0, 1, 2, 3, 4, 5, 6] |
| 143 |
default: 5 |
| 144 |
usnic_adapter_policy_name: |
| 145 |
description: |
| 146 |
- Ethernet Adapter policy to be associated with the usNICs. |
| 147 |
- Required when connection_type is 'usnic'. |
| 148 |
type: str |
| 149 |
vmq_settings: |
| 150 |
description: |
| 151 |
- VMQ settings when connection_type is 'vmq'. |
| 152 |
type: dict |
| 153 |
suboptions: |
| 154 |
enabled: |
| 155 |
description: |
| 156 |
- Enable VMQ. |
| 157 |
type: bool |
| 158 |
default: true |
| 159 |
multi_queue_support: |
| 160 |
description: |
| 161 |
- Enables Virtual Machine Multi-Queue feature on the virtual interface. |
| 162 |
- VMMQ allows configuration of multiple I/O queues for a single VM and thus distributes traffic across multiple CPU cores in a VM. |
| 163 |
type: bool |
| 164 |
default: false |
| 165 |
num_interrupts: |
| 166 |
description: |
| 167 |
- The number of interrupt resources to be allocated. |
| 168 |
- Recommended value is the number of CPU threads or logical processors available in the server. |
| 169 |
type: int |
| 170 |
default: 16 |
| 171 |
num_vmqs: |
| 172 |
description: |
| 173 |
- The number of hardware Virtual Machine Queues to be allocated. |
| 174 |
- The number of VMQs per adapter must be one more than the maximum number of VM NICs. |
| 175 |
type: int |
| 176 |
default: 4 |
| 177 |
num_sub_vnics: |
| 178 |
description: |
| 179 |
- Number of sub vNICs (0-64). |
| 180 |
- Only applicable when multi_queue_support is true. |
| 181 |
type: int |
| 182 |
default: 64 |
| 183 |
vmmq_adapter_policy_name: |
| 184 |
description: |
| 185 |
- Name of the VMMQ Adapter Policy. |
| 186 |
- Only applicable when multi_queue_support is true. |
| 187 |
type: str |
| 188 |
sriov_settings: |
| 189 |
description: |
| 190 |
- SR-IOV settings when connection_type is 'sriov'. |
| 191 |
type: dict |
| 192 |
suboptions: |
| 193 |
enabled: |
| 194 |
description: |
| 195 |
- Enable SR-IOV. |
| 196 |
type: bool |
| 197 |
default: true |
| 198 |
vf_count: |
| 199 |
description: |
| 200 |
- Number of Virtual Functions (1-64). |
| 201 |
type: int |
| 202 |
default: 64 |
| 203 |
rx_count_per_vf: |
| 204 |
description: |
| 205 |
- Receive Queue Count per VF (1-8). |
| 206 |
type: int |
| 207 |
default: 4 |
| 208 |
tx_count_per_vf: |
| 209 |
description: |
| 210 |
- Transmit Queue Count per VF (1-8). |
| 211 |
type: int |
| 212 |
default: 1 |
| 213 |
comp_count_per_vf: |
| 214 |
description: |
| 215 |
- Completion Queue Count per VF (1-16). |
| 216 |
type: int |
| 217 |
default: 5 |
| 218 |
int_count_per_vf: |
| 219 |
description: |
| 220 |
- Interrupt Count per VF (1-16). |
| 221 |
type: int |
| 222 |
default: 8 |
| 223 |
author: |
| 224 |
- Ron Gershburg (@rgershbu) |
| 225 |
''' |
| 226 |
|
| 227 |
EXAMPLES = r''' |
| 228 |
- name: Create a basic vNIC Template |
| 229 |
cisco.intersight.intersight_vnic_template: |
| 230 |
api_private_key: "{{ api_private_key }}" |
| 231 |
api_key_id: "{{ api_key_id }}" |
| 232 |
organization: "default" |
| 233 |
name: "basic-vnic-template" |
| 234 |
description: "Basic vNIC template for production servers" |
| 235 |
enable_override: false |
| 236 |
switch_id: "A" |
| 237 |
failover_enabled: false |
| 238 |
cdn_source: "vnic" |
| 239 |
mac_pool_name: "default-mac-pool" |
| 240 |
fabric_eth_network_group_policy_name: "default-network-group" |
| 241 |
fabric_eth_network_control_policy_name: "default-network-control" |
| 242 |
eth_qos_policy_name: "default-qos-policy" |
| 243 |
eth_adapter_policy_name: "default-adapter-policy" |
| 244 |
connection_type: "none" |
| 245 |
tags: |
| 246 |
- Key: "Environment" |
| 247 |
Value: "Production" |
| 248 |
- Key: "Site" |
| 249 |
Value: "DataCenter-A" |
| 250 |
state: present |
| 251 |
|
| 252 |
- name: Create a vNIC Template with custom CDN |
| 253 |
cisco.intersight.intersight_vnic_template: |
| 254 |
api_private_key: "{{ api_private_key }}" |
| 255 |
api_key_id: "{{ api_key_id }}" |
| 256 |
organization: "default" |
| 257 |
name: "custom-cdn-template" |
| 258 |
description: "vNIC template with custom CDN value" |
| 259 |
enable_override: true |
| 260 |
switch_id: "B" |
| 261 |
failover_enabled: true |
| 262 |
cdn_source: "user" |
| 263 |
cdn_value: "Management-NIC" |
| 264 |
mac_pool_name: "mgmt-mac-pool" |
| 265 |
fabric_eth_network_group_policy_name: "mgmt-network-group" |
| 266 |
fabric_eth_network_control_policy_name: "mgmt-network-control" |
| 267 |
eth_qos_policy_name: "mgmt-qos-policy" |
| 268 |
eth_adapter_policy_name: "mgmt-adapter-policy" |
| 269 |
iscsi_boot_policy_name: "mgmt-iscsi-boot-policy" |
| 270 |
connection_type: "none" |
| 271 |
state: present |
| 272 |
|
| 273 |
- name: Create a vNIC Template with USNIC |
| 274 |
cisco.intersight.intersight_vnic_template: |
| 275 |
api_private_key: "{{ api_private_key }}" |
| 276 |
api_key_id: "{{ api_key_id }}" |
| 277 |
name: "usnic-template" |
| 278 |
description: "vNIC template with USNIC configuration" |
| 279 |
enable_override: false |
| 280 |
switch_id: "A" |
| 281 |
mac_pool_name: "hpc-mac-pool" |
| 282 |
fabric_eth_network_group_policy_name: "hpc-network-group" |
| 283 |
fabric_eth_network_control_policy_name: "hpc-network-control" |
| 284 |
eth_qos_policy_name: "hpc-qos-policy" |
| 285 |
eth_adapter_policy_name: "hpc-adapter-policy" |
| 286 |
connection_type: "usnic" |
| 287 |
usnic_settings: |
| 288 |
count: 0 |
| 289 |
cos: 5 |
| 290 |
usnic_adapter_policy_name: "hpc-adapter-policy" |
| 291 |
state: present |
| 292 |
|
| 293 |
- name: Create a vNIC Template with VMQ |
| 294 |
cisco.intersight.intersight_vnic_template: |
| 295 |
api_private_key: "{{ api_private_key }}" |
| 296 |
api_key_id: "{{ api_key_id }}" |
| 297 |
name: "vmq-template" |
| 298 |
description: "vNIC template with VMQ configuration" |
| 299 |
enable_override: false |
| 300 |
switch_id: "A" |
| 301 |
mac_pool_name: "vm-mac-pool" |
| 302 |
fabric_eth_network_group_policy_name: "vm-network-group" |
| 303 |
fabric_eth_network_control_policy_name: "vm-network-control" |
| 304 |
eth_qos_policy_name: "vm-qos-policy" |
| 305 |
eth_adapter_policy_name: "vm-adapter-policy" |
| 306 |
connection_type: "vmq" |
| 307 |
vmq_settings: |
| 308 |
enabled: true |
| 309 |
multi_queue_support: false |
| 310 |
num_interrupts: 16 |
| 311 |
num_vmqs: 4 |
| 312 |
state: present |
| 313 |
|
| 314 |
- name: Create a vNIC Template with VMQ multi-queue support |
| 315 |
cisco.intersight.intersight_vnic_template: |
| 316 |
api_private_key: "{{ api_private_key }}" |
| 317 |
api_key_id: "{{ api_key_id }}" |
| 318 |
name: "vmq-multiqueue-template" |
| 319 |
description: "vNIC template with VMQ multi-queue configuration" |
| 320 |
enable_override: true |
| 321 |
switch_id: "B" |
| 322 |
mac_pool_name: "vm-mac-pool" |
| 323 |
fabric_eth_network_group_policy_name: "vm-network-group" |
| 324 |
fabric_eth_network_control_policy_name: "vm-network-control" |
| 325 |
eth_qos_policy_name: "vm-qos-policy" |
| 326 |
eth_adapter_policy_name: "vm-adapter-policy" |
| 327 |
connection_type: "vmq" |
| 328 |
vmq_settings: |
| 329 |
enabled: true |
| 330 |
multi_queue_support: true |
| 331 |
num_sub_vnics: 64 |
| 332 |
vmmq_adapter_policy_name: "vmmq-adapter-policy" |
| 333 |
state: present |
| 334 |
|
| 335 |
- name: Create a vNIC Template with SR-IOV |
| 336 |
cisco.intersight.intersight_vnic_template: |
| 337 |
api_private_key: "{{ api_private_key }}" |
| 338 |
api_key_id: "{{ api_key_id }}" |
| 339 |
name: "sriov-template" |
| 340 |
description: "vNIC template with SR-IOV configuration" |
| 341 |
enable_override: false |
| 342 |
switch_id: "A" |
| 343 |
mac_pool_name: "sriov-mac-pool" |
| 344 |
fabric_eth_network_group_policy_name: "sriov-network-group" |
| 345 |
fabric_eth_network_control_policy_name: "sriov-network-control" |
| 346 |
eth_qos_policy_name: "sriov-qos-policy" |
| 347 |
eth_adapter_policy_name: "sriov-adapter-policy" |
| 348 |
connection_type: "sriov" |
| 349 |
sriov_settings: |
| 350 |
enabled: true |
| 351 |
vf_count: 64 |
| 352 |
rx_count_per_vf: 4 |
| 353 |
tx_count_per_vf: 1 |
| 354 |
comp_count_per_vf: 5 |
| 355 |
int_count_per_vf: 8 |
| 356 |
state: present |
| 357 |
|
| 358 |
- name: Create a vNIC Template with pin group |
| 359 |
cisco.intersight.intersight_vnic_template: |
| 360 |
api_private_key: "{{ api_private_key }}" |
| 361 |
api_key_id: "{{ api_key_id }}" |
| 362 |
organization: "default" |
| 363 |
name: "vnic-pinned-template" |
| 364 |
description: "vNIC template with static pinning" |
| 365 |
enable_override: false |
| 366 |
switch_id: "A" |
| 367 |
failover_enabled: false |
| 368 |
mac_pool_name: "default-mac-pool" |
| 369 |
fabric_eth_network_group_policy_name: "default-network-group" |
| 370 |
fabric_eth_network_control_policy_name: "default-network-control" |
| 371 |
eth_qos_policy_name: "default-qos-policy" |
| 372 |
eth_adapter_policy_name: "default-adapter-policy" |
| 373 |
pin_group_name: "pingroup-a" |
| 374 |
connection_type: "none" |
| 375 |
state: present |
| 376 |
|
| 377 |
- name: Delete a vNIC Template |
| 378 |
cisco.intersight.intersight_vnic_template: |
| 379 |
api_private_key: "{{ api_private_key }}" |
| 380 |
api_key_id: "{{ api_key_id }}" |
| 381 |
name: "old-vnic-template" |
| 382 |
state: absent |
| 383 |
''' |
| 384 |
|
| 385 |
RETURN = r''' |
| 386 |
api_response: |
| 387 |
description: The API response output returned by the specified resource. |
| 388 |
returned: always |
| 389 |
type: dict |
| 390 |
sample: |
| 391 |
"api_response": { |
| 392 |
"Name": "test-vnic-template", |
| 393 |
"ObjectType": "vnic.VnicTemplate", |
| 394 |
"EnableOverride": false, |
| 395 |
"SwitchId": "A", |
| 396 |
"FailoverEnabled": false, |
| 397 |
"Cdn": { |
| 398 |
"Source": "vnic" |
| 399 |
}, |
| 400 |
"MacPool": { |
| 401 |
"Name": "default-mac-pool", |
| 402 |
"ObjectType": "macpool.Pool" |
| 403 |
}, |
| 404 |
"Tags": [ |
| 405 |
{ |
| 406 |
"Key": "Environment", |
| 407 |
"Value": "Production" |
| 408 |
} |
| 409 |
] |
| 410 |
} |
| 411 |
''' |
| 412 |
|
| 413 |
|
| 414 |
from ansible.module_utils.basic import AnsibleModule |
| 415 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec |
| 416 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight_vnic_utils import ( |
| 417 |
validate_cdn_config, validate_usnic_settings, validate_vmq_settings, validate_sriov_settings, |
| 418 |
build_cdn_config, build_connection_settings, resolve_policy_moids_from_mappings, |
| 419 |
get_common_policy_mappings, get_iscsi_boot_policy_mapping, get_fabric_network_policy_mappings, |
| 420 |
get_mac_pool_policy_mapping, get_common_settings_argument_spec |
| 421 |
) |
| 422 |
|
| 423 |
|
| 424 |
def get_template_policy_mappings(module): |
| 425 |
""" |
| 426 |
Get policy mappings for vNIC Template configuration. |
| 427 |
""" |
| 428 |
# Start with common policies |
| 429 |
policy_mappings = get_common_policy_mappings() |
| 430 |
|
| 431 |
# Add fabric network policies (vNIC templates are FI-attached only) |
| 432 |
policy_mappings.update(get_fabric_network_policy_mappings()) |
| 433 |
|
| 434 |
# Add MAC pool (always required for templates) |
| 435 |
policy_mappings.update(get_mac_pool_policy_mapping()) |
| 436 |
|
| 437 |
# iSCSI boot policy is optional - only add if specified |
| 438 |
if module.params.get('iscsi_boot_policy_name'): |
| 439 |
policy_mappings.update(get_iscsi_boot_policy_mapping()) |
| 440 |
|
| 441 |
return policy_mappings |
| 442 |
|
| 443 |
|
| 444 |
def resolve_policy_moids(intersight, policy_cache, module): |
| 445 |
""" |
| 446 |
Resolve all policy MOIDs for vNIC Template configuration. |
| 447 |
""" |
| 448 |
policy_mappings = get_template_policy_mappings(module) |
| 449 |
organization_name = module.params['organization'] |
| 450 |
return resolve_policy_moids_from_mappings(intersight, policy_cache, module, module.params, policy_mappings, organization_name) |
| 451 |
|
| 452 |
|
| 453 |
def validate_input(module): |
| 454 |
""" |
| 455 |
Validate module input parameters |
| 456 |
""" |
| 457 |
if module.params['state'] == 'present': |
| 458 |
# Validate required fields for vNIC Template creation |
| 459 |
required_fields = [ |
| 460 |
'mac_pool_name', |
| 461 |
'fabric_eth_network_group_policy_name', |
| 462 |
'fabric_eth_network_control_policy_name', |
| 463 |
'eth_qos_policy_name', |
| 464 |
'eth_adapter_policy_name' |
| 465 |
] |
| 466 |
for field in required_fields: |
| 467 |
if not module.params.get(field): |
| 468 |
module.fail_json(msg=f"{field} is required when state is 'present'") |
| 469 |
|
| 470 |
# Validate CDN configuration |
| 471 |
validate_cdn_config(module, module.params) |
| 472 |
|
| 473 |
connection_type = module.params.get('connection_type', 'none') |
| 474 |
|
| 475 |
# Validate connection type specific settings |
| 476 |
template_name = module.params.get('name', 'unknown') |
| 477 |
if connection_type == 'usnic': |
| 478 |
usnic_settings = module.params.get('usnic_settings') |
| 479 |
validate_usnic_settings(module, usnic_settings, template_name) |
| 480 |
elif connection_type == 'vmq': |
| 481 |
vmq_settings = module.params.get('vmq_settings', {}) |
| 482 |
validate_vmq_settings(module, vmq_settings, template_name) |
| 483 |
elif connection_type == 'sriov': |
| 484 |
sriov_settings = module.params.get('sriov_settings', {}) |
| 485 |
validate_sriov_settings(module, sriov_settings, template_name) |
| 486 |
|
| 487 |
|
| 488 |
def main(): |
| 489 |
argument_spec = intersight_argument_spec.copy() |
| 490 |
argument_spec.update( |
| 491 |
state=dict(type='str', choices=['present', 'absent'], default='present'), |
| 492 |
organization=dict(type='str', default='default'), |
| 493 |
name=dict(type='str', required=True), |
| 494 |
description=dict(type='str', aliases=['descr']), |
| 495 |
tags=dict(type='list', elements='dict'), |
| 496 |
enable_override=dict(type='bool', default=False), |
| 497 |
eth_qos_policy_name=dict(type='str'), |
| 498 |
eth_adapter_policy_name=dict(type='str'), |
| 499 |
pin_group_name=dict(type='str'), |
| 500 |
) |
| 501 |
# Add connection settings argument specs |
| 502 |
argument_spec.update(get_common_settings_argument_spec()) |
| 503 |
|
| 504 |
module = AnsibleModule( |
| 505 |
argument_spec, |
| 506 |
supports_check_mode=True, |
| 507 |
) |
| 508 |
|
| 509 |
if module.params['state'] == 'present': |
| 510 |
validate_input(module) |
| 511 |
|
| 512 |
intersight = IntersightModule(module) |
| 513 |
intersight.result['api_response'] = {} |
| 514 |
intersight.result['trace_id'] = '' |
| 515 |
|
| 516 |
# Resource path used to configure vNIC Template |
| 517 |
resource_path = '/vnic/VnicTemplates' |
| 518 |
# Define API body used in compares or create |
| 519 |
intersight.api_body = { |
| 520 |
'Organization': { |
| 521 |
'Name': intersight.module.params['organization'], |
| 522 |
}, |
| 523 |
'Name': intersight.module.params['name'] |
| 524 |
} |
| 525 |
|
| 526 |
if intersight.module.params['state'] == 'present': |
| 527 |
intersight.set_tags_and_description() |
| 528 |
|
| 529 |
# Add vNIC Template specific parameters |
| 530 |
intersight.api_body['EnableOverride'] = intersight.module.params['enable_override'] |
| 531 |
intersight.api_body['SwitchId'] = intersight.module.params['switch_id'] |
| 532 |
intersight.api_body['FailoverEnabled'] = intersight.module.params['failover_enabled'] |
| 533 |
|
| 534 |
# Add CDN configuration |
| 535 |
intersight.api_body['Cdn'] = build_cdn_config(intersight.module.params) |
| 536 |
|
| 537 |
# Cache for policy MOIDs to avoid redundant API calls |
| 538 |
policy_cache = {} |
| 539 |
|
| 540 |
# Resolve and add policy MOIDs |
| 541 |
policy_moids = resolve_policy_moids(intersight, policy_cache, intersight.module) |
| 542 |
intersight.api_body.update(policy_moids) |
| 543 |
|
| 544 |
# Add connection type specific settings |
| 545 |
organization_name = intersight.module.params['organization'] |
| 546 |
connection_settings = build_connection_settings(intersight, policy_cache, intersight.module, intersight.module.params, organization_name) |
| 547 |
intersight.api_body.update(connection_settings) |
| 548 |
|
| 549 |
# Add pin group name if specified |
| 550 |
if intersight.module.params.get('pin_group_name'): |
| 551 |
intersight.api_body['PinGroupName'] = intersight.module.params['pin_group_name'] |
| 552 |
|
| 553 |
intersight.configure_policy_or_profile(resource_path=resource_path) |
| 554 |
|
| 555 |
module.exit_json(**intersight.result) |
| 556 |
|
| 557 |
|
| 558 |
if __name__ == '__main__': |
| 559 |
main() |