forked from IBM-Cloud/power-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Hostgroup client and add stratos validation (IBM-Cloud#361)
* Update Hostgroup client and add stratos validation * Update name to hostGroup pattern * Rename file
- Loading branch information
1 parent
824e362
commit 123a02f
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
v "github.com/IBM-Cloud/power-go-client/clients/instance" | ||
ps "github.com/IBM-Cloud/power-go-client/ibmpisession" | ||
"github.com/IBM/go-sdk-core/v5/core" | ||
) | ||
|
||
func main() { | ||
//session Inputs | ||
// < IAM TOKEN > | ||
// token := "" | ||
apiKey := "" | ||
region := " < REGION > " | ||
zone := " < ZONE > " | ||
accountID := " < ACCOUNT ID > " | ||
url := region + ".power-iaas.test.cloud.ibm.com" | ||
|
||
// dr location inputs | ||
piID := " < POWER INSTANCE ID > " | ||
|
||
// authenticator := &core.BearerTokenAuthenticator{ | ||
// BearerToken: token, | ||
// } | ||
authenticator := &core.IamAuthenticator{ | ||
ApiKey: apiKey, | ||
// Uncomment for test environment | ||
URL: "https://iam.test.cloud.ibm.com", | ||
} | ||
|
||
// Create the session | ||
options := &ps.IBMPIOptions{ | ||
Authenticator: authenticator, | ||
UserAccount: accountID, | ||
Zone: zone, | ||
URL: url, | ||
Debug: true, | ||
} | ||
session, err := ps.NewIBMPISession(options) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
powerClient := v.NewIBMPHostgroupsClient(context.Background(), session, piID) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
getAllAvailableHost, err := powerClient.GetAvailableHosts() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("***************[0]****************** %+v \n", getAllAvailableHost) | ||
|
||
getHostgroups, err := powerClient.GetHostGroups() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("***************[1]****************** %+v \n", getHostgroups) | ||
} |