Skip to content

Commit 9d54061

Browse files
committed
Support additional parameters for cloudstack_nic resource
1 parent ed7ac8c commit 9d54061

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

cloudstack/resource_cloudstack_nic.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ func resourceCloudStackNIC() *schema.Resource {
5353
Required: true,
5454
ForceNew: true,
5555
},
56+
"mac_address": {
57+
Type: schema.TypeString,
58+
Optional: true,
59+
Computed: true,
60+
},
61+
"dhcp_options": {
62+
Type: schema.TypeMap,
63+
Optional: true,
64+
},
5665
},
5766
}
5867
}
@@ -66,11 +75,25 @@ func resourceCloudStackNICCreate(d *schema.ResourceData, meta interface{}) error
6675
d.Get("virtual_machine_id").(string),
6776
)
6877

69-
// If there is a ipaddres supplied, add it to the parameter struct
78+
// If there is an ipaddress supplied, add it to the parameter struct
7079
if ipaddress, ok := d.GetOk("ip_address"); ok {
7180
p.SetIpaddress(ipaddress.(string))
7281
}
7382

83+
// If there is a macaddress supplied, add it to the parameter struct
84+
if macaddress, ok := d.GetOk("mac_address"); ok {
85+
p.SetMacaddress(macaddress.(string))
86+
}
87+
88+
// If there are dhcp options supplied, add them to the parameter struct
89+
if dhcpOptions, ok := d.GetOk("dhcp_options"); ok {
90+
dhcpOpts := make(map[string]string)
91+
for k, v := range dhcpOptions.(map[string]interface{}) {
92+
dhcpOpts[k] = v.(string)
93+
}
94+
p.SetDhcpoptions(dhcpOpts)
95+
}
96+
7497
// Create and attach the new NIC
7598
r, err := Retry(10, retryableAddNicFunc(cs, p))
7699
if err != nil {

0 commit comments

Comments
 (0)