Skip to content

Commit

Permalink
Support for classic Infrastructure: Added Resource controller
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya498 authored and hkantare committed Dec 19, 2019
1 parent 6d03ddc commit 0f263f7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
21 changes: 19 additions & 2 deletions ibm/resource_ibm_compute_vm_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
}
Expand Down Expand Up @@ -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]]," +
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions ibm/resource_ibm_network_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
}
Expand Down Expand Up @@ -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
}
Expand Down
17 changes: 14 additions & 3 deletions ibm/resource_ibm_storage_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
},
}
}
Expand Down Expand Up @@ -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
}
Expand Down
22 changes: 21 additions & 1 deletion ibm/resource_ibm_storage_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 0f263f7

Please sign in to comment.