Skip to content

Commit db7d52d

Browse files
alaa-bishkenmoini
andauthored
Add mac address for vm creation (#272)
* Update ntnx_vms.py Add the ability to optionally set MAC Address for a network interface * Update vms.py Add optional mac_address definition to _build_spec_networks * fix spec * sanity fix Co-authored-by: Ken Moini <ken@kenmoini.com>
1 parent 62eb4f4 commit db7d52d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

plugins/doc_fragments/ntnx_vms_base.py

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ class ModuleDocFragment(object):
9090
- Optionally assign static IP to the VM
9191
type: str
9292
required: false
93+
mac_address:
94+
description:
95+
- Optionally assign a MAC Address to the VM
96+
type: str
97+
required: false
9398
is_connected:
9499
description:
95100
- Connect or disconnect the VM to the subnet

plugins/module_utils/prism/spec/vms.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class DefaultVMSpec:
1818
subnet=dict(
1919
type="dict", options=entity_by_spec, mutually_exclusive=mutually_exclusive
2020
),
21+
mac_address=dict(type="str", required=False),
2122
private_ip=dict(type="str", required=False),
2223
is_connected=dict(type="bool", default=True),
2324
)

plugins/module_utils/prism/vms.py

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ def _build_spec_networks(self, payload, networks):
239239
if network.get("private_ip"):
240240
nic["ip_endpoint_list"] = [{"ip": network["private_ip"]}]
241241

242+
if network.get("mac_address"):
243+
nic["mac_address"] = network["mac_address"]
244+
242245
nic["is_connected"] = network["is_connected"]
243246
if network.get("subnet"):
244247

0 commit comments

Comments
 (0)