You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2023/06/19 14:45:18 UTC
[cloudstack-terraform-provider] branch main updated: Feature/vapp properties added (#62)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git
The following commit(s) were added to refs/heads/main by this push:
new 7f7d1ec Feature/vapp properties added (#62)
7f7d1ec is described below
commit 7f7d1ecaaad3b36f5ce0ce6e81541246d092e9d2
Author: Zeeshan Saeed <62...@users.noreply.github.com>
AuthorDate: Mon Jun 19 19:45:12 2023 +0500
Feature/vapp properties added (#62)
- 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 <ze...@afiniti.com>
---
cloudstack/data_source_cloudstack_instance_test.go | 4 +--
cloudstack/resource_cloudstack_instance.go | 31 ++++++++++++++++++++++
cloudstack/resource_cloudstack_network_offering.go | 2 +-
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/cloudstack/data_source_cloudstack_instance_test.go b/cloudstack/data_source_cloudstack_instance_test.go
index e27b1e1..f9d531a 100644
--- a/cloudstack/data_source_cloudstack_instance_test.go
+++ b/cloudstack/data_source_cloudstack_instance_test.go
@@ -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"
diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go
index f083181..4278cc5 100644
--- a/cloudstack/resource_cloudstack_instance.go
+++ b/cloudstack/resource_cloudstack_instance.go
@@ -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,
@@ -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 {
diff --git a/cloudstack/resource_cloudstack_network_offering.go b/cloudstack/resource_cloudstack_network_offering.go
index a414ff3..4f141cc 100644
--- a/cloudstack/resource_cloudstack_network_offering.go
+++ b/cloudstack/resource_cloudstack_network_offering.go
@@ -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)