@@ -38,20 +38,6 @@ import (
38
38
39
39
var _ Cloud = & powerVSCloud {}
40
40
41
- var (
42
- // TODO: Never seen these catalog values changing, lets add code to get these values in future for the sake of better design.
43
-
44
- // This can be found in the IBM Cloud catalog, command used to get this information is
45
- // $ ibmcloud catalog service-marketplace| grep power-iaas
46
- // abd259f0-9990-11e8-acc8-b9f54a8f1661 power-iaas
47
- powerVSServiceID = "abd259f0-9990-11e8-acc8-b9f54a8f1661"
48
-
49
- // PlanID can be fetched via command:
50
- // $ ibmcloud catalog service abd259f0-9990-11e8-acc8-b9f54a8f1661 | grep plan
51
- // power-virtual-server-group plan f165dd34-3a40-423b-9d95-e90a23f724dd
52
- powerVSPlanID = "f165dd34-3a40-423b-9d95-e90a23f724dd"
53
- )
54
-
55
41
const (
56
42
PollTimeout = 120 * time .Second
57
43
PollInterval = 5 * time .Second
@@ -92,28 +78,24 @@ func NewPowerVSCloud(cloudInstanceID, zone string, debug bool) (Cloud, error) {
92
78
func newPowerVSCloud (cloudInstanceID , zone string , debug bool ) (Cloud , error ) {
93
79
apikey := os .Getenv ("IBMCLOUD_API_KEY" )
94
80
81
+ authenticator := & core.IamAuthenticator {ApiKey : apikey }
82
+
95
83
serviceClientOptions := & resourcecontrollerv2.ResourceControllerV2Options {
96
- Authenticator : & core. IamAuthenticator { ApiKey : apikey } ,
84
+ Authenticator : authenticator ,
97
85
}
98
- serviceClient , err := resourcecontrollerv2 .NewResourceControllerV2UsingExternalConfig (serviceClientOptions )
86
+ serviceClient , err := resourcecontrollerv2 .NewResourceControllerV2 (serviceClientOptions )
99
87
if err != nil {
100
- return nil , fmt .Errorf ("errored while creating NewResourceControllerV2UsingExternalConfig : %v" , err )
88
+ return nil , fmt .Errorf ("errored while creating NewResourceControllerV2 : %v" , err )
101
89
}
102
- resourceInstanceList , _ , err := serviceClient .ListResourceInstances (& resourcecontrollerv2.ListResourceInstancesOptions {
103
- GUID : & cloudInstanceID ,
104
- ResourceID : & powerVSServiceID ,
105
- ResourcePlanID : & powerVSPlanID ,
90
+ resourceInstance , _ , err := serviceClient .GetResourceInstance (& resourcecontrollerv2.GetResourceInstanceOptions {
91
+ ID : & cloudInstanceID ,
106
92
})
107
- if err != nil {
108
- return nil , fmt .Errorf ("errored while listing the Power VS service instance with ID: %s, err: %v" , cloudInstanceID , err )
109
- }
110
93
111
- if len ( resourceInstanceList . Resources ) == 0 {
112
- return nil , fmt .Errorf ("no Power VS service instance found with ID: %s" , cloudInstanceID )
94
+ if err != nil {
95
+ return nil , fmt .Errorf ("errored while getting the Power VS service instance with ID: %s, err: %v " , cloudInstanceID , err )
113
96
}
114
97
115
- authenticator := & core.IamAuthenticator {ApiKey : apikey }
116
- piOptions := ibmpisession.IBMPIOptions {Authenticator : authenticator , Debug : debug , UserAccount : * resourceInstanceList .Resources [0 ].AccountID , Zone : zone }
98
+ piOptions := ibmpisession.IBMPIOptions {Authenticator : authenticator , Debug : debug , UserAccount : * resourceInstance .AccountID , Zone : zone }
117
99
piSession , err := ibmpisession .NewIBMPISession (& piOptions )
118
100
if err != nil {
119
101
return nil , err
0 commit comments