Skip to content

Commit

Permalink
Merge pull request #18 from surajsub/master
Browse files Browse the repository at this point in the history
Update to the power-go-client
  • Loading branch information
surajsub authored May 11, 2020
2 parents 99b7f4e + 57f5eea commit 8e43ae7
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions clients/instance/ibm-pi-instance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package instance

import (
"fmt"
"github.com/IBM-Cloud/power-go-client/errors"
"github.com/IBM-Cloud/power-go-client/ibmpisession"
"github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances"
Expand Down Expand Up @@ -36,7 +37,7 @@ func (f *IBMPIInstanceClient) Get(id, powerinstanceid string) (*models.PVMInstan

//Create

func (f *IBMPIInstanceClient) Create(powerdef *p_cloud_p_vm_instances.PcloudPvminstancesPostParams, powerinstanceid string) (*models.PVMInstanceList, *models.PVMInstanceList, *models.PVMInstanceList, error) {
func (f *IBMPIInstanceClient) Create(powerdef *p_cloud_p_vm_instances.PcloudPvminstancesPostParams, powerinstanceid string) (*models.PVMInstanceList, error) {

log.Printf("Calling the Power PVM Create Method")
params := p_cloud_p_vm_instances.NewPcloudPvminstancesPostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithBody(powerdef.Body)
Expand All @@ -47,25 +48,27 @@ func (f *IBMPIInstanceClient) Create(powerdef *p_cloud_p_vm_instances.PcloudPvmi

if err != nil {
log.Printf("failed to process the request..")
return nil, nil, nil, errors.ToError(err)
}

log.Printf("Printing the response.. %s", postok.Payload)

if postAccepted.Payload == nil {
log.Printf("The postaccepted failed to return the results")
return nil, nil, nil, errors.ToError(err)
return nil, errors.ToError(err)
}

//if postcreated.Payload

if len(postok.Payload) > 0 && len(postcreated.Payload) > 0 && len(postAccepted.Payload) > 0 {
if postok != nil && len(postok.Payload) > 0 {
log.Printf("Looks like we have an instance created....")
log.Printf("Checking if the instance name is right ")
log.Printf("Printing the instanceid %s", *postok.Payload[0].PvmInstanceID)
return &postok.Payload, nil
}
if postcreated != nil && len(postcreated.Payload) > 0 {
log.Printf("Printing the instanceid %s", *postcreated.Payload[0].PvmInstanceID)
return &postcreated.Payload, nil
}
if postAccepted != nil && len(postAccepted.Payload) > 0 {

log.Printf("Printing the instanceid %s", *postAccepted.Payload[0].PvmInstanceID)
return &postAccepted.Payload, nil
}

return &postok.Payload, nil, nil, nil
//return &postok.Payload, nil
return nil, fmt.Errorf("No response Returned ")
}

// PVM Instances Delete
Expand Down

0 comments on commit 8e43ae7

Please sign in to comment.