From 0f263f7b747ff7d7446dd1bb98c9db36e5d0a56d Mon Sep 17 00:00:00 2001 From: "Kavya.Handadi" Date: Thu, 19 Dec 2019 12:49:07 +0530 Subject: [PATCH] Support for classic Infrastructure: Added Resource controller --- ibm/resource_ibm_compute_vm_instance.go | 21 +++++++++++++++++++-- ibm/resource_ibm_network_vlan.go | 12 ++++++++++++ ibm/resource_ibm_storage_block.go | 17 ++++++++++++++--- ibm/resource_ibm_storage_file.go | 22 +++++++++++++++++++++- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/ibm/resource_ibm_compute_vm_instance.go b/ibm/resource_ibm_compute_vm_instance.go index a355ddb7d0..d0b2e72a39 100644 --- a/ibm/resource_ibm_compute_vm_instance.go +++ b/ibm/resource_ibm_compute_vm_instance.go @@ -517,6 +517,21 @@ func resourceIBMComputeVmInstance() *schema.Resource { ForceNew: true, DiffSuppressFunc: applyOnce, }, + ResourceControllerURL: { + Type: schema.TypeString, + Computed: true, + Description: "The URL of the IBM Cloud dashboard that can be used to explore and view details about this instance", + }, + ResourceName: { + Type: schema.TypeString, + Computed: true, + Description: "The name of the resource", + }, + ResourceStatus: { + Type: schema.TypeString, + Computed: true, + Description: "The status of the resource", + }, }, } } @@ -1036,7 +1051,7 @@ func resourceIBMComputeVmInstanceRead(d *schema.ResourceData, meta interface{}) "allowedNetworkStorage[id,nasType]," + "notes,userData[value],tagReferences[id,tag[name]]," + "datacenter[id,name,longName]," + - "sshKeys," + + "sshKeys,status[keyName,name]," + "primaryNetworkComponent[networkVlan[id],subnets," + "primaryVersion6IpAddressRecord[subnet,guestNetworkComponentBinding[ipAddressId]]," + "primaryIpAddressRecord[subnet,guestNetworkComponentBinding[ipAddressId]]," + @@ -1247,7 +1262,9 @@ func resourceIBMComputeVmInstanceRead(d *schema.ResourceData, meta interface{}) } } - + d.Set(ResourceControllerURL, fmt.Sprintf("https://cloud.ibm.com/gen1/infrastructure/virtual-server/%s/details#main", d.Id())) + d.Set(ResourceName, *result.Hostname) + d.Set(ResourceStatus, *result.Status.Name) err = readSecondaryIPAddresses(d, meta, result.PrimaryIpAddress) return err } diff --git a/ibm/resource_ibm_network_vlan.go b/ibm/resource_ibm_network_vlan.go index 666eead7c2..355ed4e23c 100644 --- a/ibm/resource_ibm_network_vlan.go +++ b/ibm/resource_ibm_network_vlan.go @@ -128,6 +128,16 @@ func resourceIBMNetworkVlan() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, + ResourceControllerURL: { + Type: schema.TypeString, + Computed: true, + Description: "The URL of the IBM Cloud dashboard that can be used to explore and view details about this instance", + }, + ResourceName: { + Type: schema.TypeString, + Computed: true, + Description: "The name of the resource", + }, }, } } @@ -263,6 +273,8 @@ func resourceIBMNetworkVlanRead(d *schema.ResourceData, meta interface{}) error } d.Set("tags", tags) } + d.Set(ResourceControllerURL, fmt.Sprintf("https://cloud.ibm.com/classic/network/vlans/%s", d.Id())) + d.Set(ResourceName, *vlan.Name) return nil } diff --git a/ibm/resource_ibm_storage_block.go b/ibm/resource_ibm_storage_block.go index c2c4d4c4a3..6d977a7730 100644 --- a/ibm/resource_ibm_storage_block.go +++ b/ibm/resource_ibm_storage_block.go @@ -3,11 +3,10 @@ package ibm import ( "fmt" "log" - "strconv" - "time" - "regexp" + "strconv" "strings" + "time" "github.com/hashicorp/terraform/helper/schema" "github.com/softlayer/softlayer-go/datatypes" @@ -209,6 +208,16 @@ func resourceIBMStorageBlock() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + ResourceControllerURL: { + Type: schema.TypeString, + Computed: true, + Description: "The URL of the IBM Cloud dashboard that can be used to explore and view details about this instance", + }, + ResourceName: { + Type: schema.TypeString, + Computed: true, + Description: "The name of the resource", + }, }, } } @@ -396,6 +405,8 @@ func resourceIBMStorageBlockRead(d *schema.ResourceData, meta interface{}) error } d.Set("target_address", storage.IscsiTargetIpAddresses) + d.Set(ResourceControllerURL, fmt.Sprintf("https://cloud.ibm.com/classic/storage/block/%s", d.Id())) + d.Set(ResourceName, *storage.ServiceResourceName) return nil } diff --git a/ibm/resource_ibm_storage_file.go b/ibm/resource_ibm_storage_file.go index d76bb55761..cffb203592 100644 --- a/ibm/resource_ibm_storage_file.go +++ b/ibm/resource_ibm_storage_file.go @@ -214,6 +214,21 @@ func resourceIBMStorageFile() *schema.Resource { Default: false, ForceNew: true, }, + ResourceControllerURL: { + Type: schema.TypeString, + Computed: true, + Description: "The URL of the IBM Cloud dashboard that can be used to explore and view details about this instance", + }, + ResourceName: { + Type: schema.TypeString, + Computed: true, + Description: "The name of the resource", + }, + ResourceStatus: { + Type: schema.TypeString, + Computed: true, + Description: "The status of the resource", + }, }, } } @@ -301,7 +316,7 @@ func resourceIBMStorageFileRead(d *schema.ResourceData, meta interface{}) error storage, err := services.GetNetworkStorageService(sess). Id(storageId). - Mask(storageDetailMask). + Mask(storageDetailMask + ",volumeStatus"). GetObject() if err != nil { @@ -408,6 +423,11 @@ func resourceIBMStorageFileRead(d *schema.ResourceData, meta interface{}) error schds[i] = s } d.Set("snapshot_schedule", schds) + d.Set(ResourceControllerURL, fmt.Sprintf("https://cloud.ibm.com/classic/storage/file/%s", d.Id())) + + d.Set(ResourceName, *storage.ServiceResourceName) + + d.Set(ResourceStatus, *storage.VolumeStatus) return nil }