Skip to content

Commit

Permalink
Feature/vapp properties added (apache#62)
Browse files Browse the repository at this point in the history
- This PR adds vApp Properties field for VMWare related configs and also nicnetworklist paramters from Cloudstack API
- Also code on main branch is not compilble due to an extra argument passed to one of the function's of code. This PR also resolves that.

Co-authored-by: Zeeshan Saeed <[email protected]>
  • Loading branch information
2 people authored and poddm committed Oct 31, 2023
1 parent 07c4286 commit 0ae900a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cloudstack/data_source_cloudstack_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
)

//basic acceptance to check if the display_name attribute has same value in
//the created instance and its data source respectively.
// basic acceptance to check if the display_name attribute has same value in
// the created instance and its data source respectively.
func TestAccInstanceDataSource_basic(t *testing.T) {
resourceName := "cloudstack_instance.my_instance"
datasourceName := "data.cloudstack_instance.my_instance_test"
Expand Down
31 changes: 31 additions & 0 deletions cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ func resourceCloudStackInstance() *schema.Resource {
Optional: true,
},

"properties": {
Type: schema.TypeMap,
Optional: true,
},

"nicnetworklist": {
Type: schema.TypeMap,
Optional: true,
},

"expunge": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -218,6 +228,27 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{})
}
p.SetDetails(vmDetails)
}

// Set VM Properties
vmProperties := make(map[string]string)
if properties, ok := d.GetOk("properties"); ok {
for k, v := range properties.(map[string]interface{}) {
vmProperties[k] = v.(string)
}
p.SetProperties(vmProperties)
}

// SetNicNetworkList
if nicnetworklist, ok := d.GetOk("nicnetworklist"); ok {
nicNetworkDetails := []map[string]string{
{
"nic": nicnetworklist.(map[string]interface{})["nic"].(string),
"network": nicnetworklist.(map[string]interface{})["network"].(string),
},
}
p.SetNicnetworklist(nicNetworkDetails)
}

// Set the name
name, hasName := d.GetOk("name")
if hasName {
Expand Down
2 changes: 1 addition & 1 deletion cloudstack/resource_cloudstack_network_offering.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func resourceCloudStackNetworkOfferingCreate(d *schema.ResourceData, meta interf
traffic_type := d.Get("traffic_type").(string)

// Create a new parameter struct
p := cs.NetworkOffering.NewCreateNetworkOfferingParams(display_text, guest_ip_type, name, []string{}, traffic_type)
p := cs.NetworkOffering.NewCreateNetworkOfferingParams(display_text, guest_ip_type, name, traffic_type)

if guest_ip_type == "Shared" {
p.SetSpecifyvlan(true)
Expand Down

0 comments on commit 0ae900a

Please sign in to comment.