Skip to content

Commit

Permalink
Update Hostgroup client and add stratos validation (IBM-Cloud#361)
Browse files Browse the repository at this point in the history
* Update Hostgroup client and add stratos validation

* Update name to hostGroup pattern

* Rename file
  • Loading branch information
michaelkad committed Oct 9, 2024
1 parent 824e362 commit 123a02f
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions examples/hostgroups/main.go
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)
}

0 comments on commit 123a02f

Please sign in to comment.