From 74197a188721cdb2d44293a75687faca28b75dd8 Mon Sep 17 00:00:00 2001 From: suraj Date: Sat, 30 May 2020 10:39:16 -0500 Subject: [PATCH] Minor Cleanup --- clients/instance/ibm-pi-image.go | 7 ++++--- clients/instance/ibm-pi-instance.go | 25 ++++++++++++------------- clients/instance/ibm-pi-network.go | 9 +++++---- clients/instance/ibm-pi-snapshot.go | 10 +++++----- clients/instance/ibm-pi-volume.go | 27 ++++++++++++++------------- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/clients/instance/ibm-pi-image.go b/clients/instance/ibm-pi-image.go index f2949f6a..f57304a9 100644 --- a/clients/instance/ibm-pi-image.go +++ b/clients/instance/ibm-pi-image.go @@ -6,6 +6,7 @@ import ( "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_images" "github.com/IBM-Cloud/power-go-client/power/models" "log" + "time" ) type IBMPIImageClient struct { @@ -23,7 +24,7 @@ func NewIBMPIImageClient(sess *ibmpisession.IBMPISession, powerinstanceid string func (f *IBMPIImageClient) Get(id, powerinstanceid string) (*models.Image, error) { - params := p_cloud_images.NewPcloudCloudinstancesImagesGetParams().WithCloudInstanceID(powerinstanceid).WithImageID(id) + params := p_cloud_images.NewPcloudCloudinstancesImagesGetParamsWithTimeout(30 * time.Second).WithCloudInstanceID(powerinstanceid).WithImageID(id) resp, err := f.session.Power.PCloudImages.PcloudCloudinstancesImagesGet(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { @@ -35,7 +36,7 @@ func (f *IBMPIImageClient) Get(id, powerinstanceid string) (*models.Image, error func (f *IBMPIImageClient) GetAll(powerinstanceid string) (*models.Images, error) { - params := p_cloud_images.NewPcloudCloudinstancesImagesGetallParams().WithCloudInstanceID(powerinstanceid) + params := p_cloud_images.NewPcloudCloudinstancesImagesGetallParamsWithTimeout(30 * time.Second).WithCloudInstanceID(powerinstanceid) resp, err := f.session.Power.PCloudImages.PcloudCloudinstancesImagesGetall(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { log.Printf("Failed to perform the operation... %v", err) @@ -73,7 +74,7 @@ func (f *IBMPIImageClient) Create(name, imageid string, powerinstanceid string) // Delete ... func (f *IBMPIImageClient) Delete(id string, powerinstanceid string) error { - params := p_cloud_images.NewPcloudCloudinstancesImagesDeleteParams().WithCloudInstanceID(powerinstanceid).WithImageID(id) + params := p_cloud_images.NewPcloudCloudinstancesImagesDeleteParamsWithTimeout(30 * time.Second).WithCloudInstanceID(powerinstanceid).WithImageID(id) _, err := f.session.Power.PCloudImages.PcloudCloudinstancesImagesDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return errors.ToError(err) diff --git a/clients/instance/ibm-pi-instance.go b/clients/instance/ibm-pi-instance.go index 0018c39c..3e080ec6 100644 --- a/clients/instance/ibm-pi-instance.go +++ b/clients/instance/ibm-pi-instance.go @@ -7,7 +7,6 @@ import ( "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_p_vm_instances" "github.com/IBM-Cloud/power-go-client/power/client/p_cloud_s_a_p" "github.com/IBM-Cloud/power-go-client/power/models" - "log" ) @@ -27,7 +26,7 @@ func NewIBMPIInstanceClient(sess *ibmpisession.IBMPISession, powerinstanceid str //Get information about a single pvm only func (f *IBMPIInstanceClient) Get(id, powerinstanceid string) (*models.PVMInstance, error) { - params := p_cloud_p_vm_instances.NewPcloudPvminstancesGetParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesGetParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesGet(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { log.Printf("Failed to perform the operation... %v", err) @@ -40,7 +39,7 @@ func (f *IBMPIInstanceClient) Get(id, powerinstanceid string) (*models.PVMInstan func (f *IBMPIInstanceClient) GetAll(powerinstanceid string) (*models.PVMInstances, error) { - params := p_cloud_p_vm_instances.NewPcloudPvminstancesGetallParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesGetallParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesGetall(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { log.Printf("Failed to perform the operation... %v", err) @@ -54,7 +53,7 @@ func (f *IBMPIInstanceClient) GetAll(powerinstanceid string) (*models.PVMInstanc 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) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesPostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithBody(powerdef.Body) log.Printf("Printing the params to be passed %+v", params) @@ -89,7 +88,7 @@ func (f *IBMPIInstanceClient) Create(powerdef *p_cloud_p_vm_instances.PcloudPvmi func (f *IBMPIInstanceClient) Delete(id, powerinstanceid string) error { log.Printf("Calling the Power PVM Delete Method") - params := p_cloud_p_vm_instances.NewPcloudPvminstancesDeleteParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesDeleteParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) _, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { @@ -103,7 +102,7 @@ func (f *IBMPIInstanceClient) Delete(id, powerinstanceid string) error { func (f *IBMPIInstanceClient) Update(id, powerinstanceid string, powerupdateparams *p_cloud_p_vm_instances.PcloudPvminstancesPutParams) (*models.PVMInstanceUpdateResponse, error) { log.Printf("Calling the Power PVM Update Instance Method") - params := p_cloud_p_vm_instances.NewPcloudPvminstancesPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(powerupdateparams.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesPutParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(powerupdateparams.Body) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesPut(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { @@ -118,7 +117,7 @@ func (f *IBMPIInstanceClient) Action(poweractionparams *p_cloud_p_vm_instances.P log.Printf("Calling the Power PVM Action Method") log.Printf("the params are %s - powerinstance id is %s", id, powerinstanceid) - params := p_cloud_p_vm_instances.NewPcloudPvminstancesActionPostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(poweractionparams.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesActionPostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(poweractionparams.Body) log.Printf("printing the poweraction params %+v", params) @@ -134,7 +133,7 @@ func (f *IBMPIInstanceClient) Action(poweractionparams *p_cloud_p_vm_instances.P // Generate the Console URL func (f *IBMPIInstanceClient) PostConsoleURL(id, powerinstanceid string) (models.Object, error) { - params := p_cloud_p_vm_instances.NewPcloudPvminstancesConsolePostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesConsolePostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id) postok, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesConsolePost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) @@ -148,7 +147,7 @@ func (f *IBMPIInstanceClient) PostConsoleURL(id, powerinstanceid string) (models func (f *IBMPIInstanceClient) CaptureInstanceToImageCatalog(id, powerinstanceid string, picaptureparams *p_cloud_p_vm_instances.PcloudPvminstancesCapturePostParams) (models.Object, error) { - params := p_cloud_p_vm_instances.NewPcloudPvminstancesCapturePostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(picaptureparams.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesCapturePostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithBody(picaptureparams.Body) postok, _, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesCapturePost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return nil, errors.ToError(err) @@ -160,7 +159,7 @@ func (f *IBMPIInstanceClient) CaptureInstanceToImageCatalog(id, powerinstanceid // Create a snapshot of the instance func (f *IBMPIInstanceClient) CreatePvmSnapShot(snapshotdef *p_cloud_p_vm_instances.PcloudPvminstancesSnapshotsPostParams, pvminstanceid, powerinstanceid string) (*models.SnapshotCreateResponse, error) { log.Printf("Calling the Power PVM Snaphshot Method and printing the following data %s - %s - %s", snapshotdef.Body.Description, snapshotdef.Body.Name, snapshotdef.Body.VolumeIds) - params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsPostParamsWithTimeout(f.session.Timeout).WithPvmInstanceID(pvminstanceid).WithCloudInstanceID(powerinstanceid).WithBody(snapshotdef.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsPostParamsWithTimeout(30).WithPvmInstanceID(pvminstanceid).WithCloudInstanceID(powerinstanceid).WithBody(snapshotdef.Body) snapshotpostaccepted, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesSnapshotsPost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) log.Printf("*** Printing the error from the snapshot call *** %s", err) @@ -179,7 +178,7 @@ func (f *IBMPIInstanceClient) CreatePvmSnapShot(snapshotdef *p_cloud_p_vm_instan func (f *IBMPIInstanceClient) CreateClone(clonedef *p_cloud_p_vm_instances.PcloudPvminstancesClonePostParams, pvminstanceid, powerinstanceid string) (*models.PVMInstance, error) { log.Printf("Calling the Power PVM Clone Method") - params := p_cloud_p_vm_instances.NewPcloudPvminstancesClonePostParamsWithTimeout(f.session.Timeout).WithPvmInstanceID(pvminstanceid).WithCloudInstanceID(powerinstanceid).WithBody(clonedef.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesClonePostParamsWithTimeout(30).WithPvmInstanceID(pvminstanceid).WithCloudInstanceID(powerinstanceid).WithBody(clonedef.Body) clonePost, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesClonePost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { @@ -195,7 +194,7 @@ func (f *IBMPIInstanceClient) GetSnapShotVM(powerinstanceid, pvminstanceid strin log.Printf("Calling the GetSnapshot for vm Method..") log.Printf("The input pvmid name is %s and to the cloudinstance id %s", pvminstanceid, powerinstanceid) - params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsGetallParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(pvminstanceid) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsGetallParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(pvminstanceid) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesSnapshotsGetall(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { @@ -210,7 +209,7 @@ func (f *IBMPIInstanceClient) GetSnapShotVM(powerinstanceid, pvminstanceid strin func (f *IBMPIInstanceClient) RestoreSnapShotVM(powerinstanceid, pvminstanceid, snapshotid, restoreAction string, restoreparams *p_cloud_p_vm_instances.PcloudPvminstancesSnapshotsRestorePostParams) (*models.Snapshot, error) { log.Printf("Performing the snapshot restore for lpar with instanceid [%s] and snapshotid [%s] ", pvminstanceid, snapshotid) - params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(pvminstanceid).WithSnapshotID(snapshotid).WithRestoreFailAction(&restoreAction).WithBody(restoreparams.Body) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(pvminstanceid).WithSnapshotID(snapshotid).WithRestoreFailAction(&restoreAction).WithBody(restoreparams.Body) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesSnapshotsRestorePost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload.SnapshotID != nil { diff --git a/clients/instance/ibm-pi-network.go b/clients/instance/ibm-pi-network.go index 6b2ec4aa..ba8aadd2 100644 --- a/clients/instance/ibm-pi-network.go +++ b/clients/instance/ibm-pi-network.go @@ -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_networks" @@ -129,15 +130,15 @@ func (f *IBMPINetworkClient) GetPort(id string, powerinstanceid string, network_ //Create -func (f *IBMPINetworkClient) CreatePort(id string, powerinstanceid string, networportdef *p_cloud_networks.PcloudNetworksPortsPostParams) (*models.NetworkPort, error) { - params := p_cloud_networks.NewPcloudNetworksPortsPostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithNetworkID(id).WithBody(networportdef.Body) +func (f *IBMPINetworkClient) CreatePort(id string, powerinstanceid string, networkportdef *p_cloud_networks.PcloudNetworksPortsPostParams) (*models.NetworkPort, error) { + params := p_cloud_networks.NewPcloudNetworksPortsPostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithNetworkID(id).WithBody(networkportdef.Body) resp, err := f.session.Power.PCloudNetworks.PcloudNetworksPortsPost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) - if err != nil || resp.Payload == nil { log.Printf("Failed to create the network port") + return nil, errors.ToError(err) } - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to create the network port for cloud instance id [%s] ", powerinstanceid) } // Delete diff --git a/clients/instance/ibm-pi-snapshot.go b/clients/instance/ibm-pi-snapshot.go index ef66c510..6fda3ef2 100644 --- a/clients/instance/ibm-pi-snapshot.go +++ b/clients/instance/ibm-pi-snapshot.go @@ -28,7 +28,7 @@ func (f *IBMPISnapshotClient) Get(id, powerinstanceid string) (*models.Snapshot, log.Printf("Calling the Snapshotget Method..") log.Printf("The input snapshot name is %s and to the cloudinstance id %s", id, powerinstanceid) - params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsGetParams().WithCloudInstanceID(powerinstanceid).WithSnapshotID(id) + params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsGetParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithSnapshotID(id) resp, err := f.session.Power.PCloudSnapshots.PcloudCloudinstancesSnapshotsGet(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { @@ -41,7 +41,7 @@ func (f *IBMPISnapshotClient) Get(id, powerinstanceid string) (*models.Snapshot, // Delete ... func (f *IBMPISnapshotClient) Delete(id string, powerinstanceid string) error { //var cloudinstanceid = f.session.PowerServiceInstance - params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsDeleteParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithSnapshotID(id) + params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsDeleteParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithSnapshotID(id) _, err := f.session.Power.PCloudSnapshots.PcloudCloudinstancesSnapshotsDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return errors.ToError(err) @@ -52,7 +52,7 @@ func (f *IBMPISnapshotClient) Delete(id string, powerinstanceid string) error { // Update.. func (f *IBMPISnapshotClient) Update(id, powerinstanceid string, snapshotdef *models.SnapshotUpdate) (models.Object, error) { - params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithSnapshotID(id).WithBody(snapshotdef) + params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsPutParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithSnapshotID(id).WithBody(snapshotdef) resp, err := f.session.Power.PCloudSnapshots.PcloudCloudinstancesSnapshotsPut(params, ibmpisession.NewAuth(f.session, powerinstanceid)) @@ -68,7 +68,7 @@ func (f *IBMPISnapshotClient) Update(id, powerinstanceid string, snapshotdef *mo func (f *IBMPISnapshotClient) GetAll(id, powerinstanceid string) (*models.Snapshots, error) { log.Printf("Calling the Power Snapshots GetAll Method") - params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsGetallParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid) + params := p_cloud_snapshots.NewPcloudCloudinstancesSnapshotsGetallParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid) resp, err := f.session.Power.PCloudSnapshots.PcloudCloudinstancesSnapshotsGetall(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return nil, errors.ToError(err) @@ -81,7 +81,7 @@ func (f *IBMPISnapshotClient) GetAll(id, powerinstanceid string) (*models.Snapsh func (f *IBMPISnapshotClient) Create(pvminstanceid, powerinstanceid, snapshotid, restorefailAction string) (*models.Snapshot, error) { log.Printf("Calling the Power Snapshots Restore Method") - params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithCloudInstanceID(pvminstanceid).WithSnapshotID(snapshotid).WithRestoreFailAction(&restorefailAction) + params := p_cloud_p_vm_instances.NewPcloudPvminstancesSnapshotsRestorePostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithCloudInstanceID(pvminstanceid).WithSnapshotID(snapshotid).WithRestoreFailAction(&restorefailAction) resp, err := f.session.Power.PCloudPVMInstances.PcloudPvminstancesSnapshotsRestorePost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return nil, fmt.Errorf("Failed to create the restore") diff --git a/clients/instance/ibm-pi-volume.go b/clients/instance/ibm-pi-volume.go index 9e38f5c1..927aca76 100644 --- a/clients/instance/ibm-pi-volume.go +++ b/clients/instance/ibm-pi-volume.go @@ -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_volumes" @@ -26,14 +27,14 @@ func (f *IBMPIVolumeClient) Get(id, powerinstanceid string) (*models.Volume, err log.Printf("Calling the VolumeGet Method..") log.Printf("The input volume name is %s and to the cloudinstance id %s", id, powerinstanceid) - params := p_cloud_volumes.NewPcloudCloudinstancesVolumesGetParams().WithCloudInstanceID(powerinstanceid).WithVolumeID(id) + params := p_cloud_volumes.NewPcloudCloudinstancesVolumesGetParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithVolumeID(id) resp, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesGet(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil || resp.Payload == nil { log.Printf("Failed to perform the operation... %v", err) return nil, errors.ToError(err) } - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to get the volume with id [%s] ", id) } //Create @@ -56,18 +57,18 @@ func (f *IBMPIVolumeClient) Create(volumename string, volumesize float64, volume return nil, errors.ToError(err) } - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to create the volume of size [%f] with name [%s] ", volumesize, volumename) } // Delete ... func (f *IBMPIVolumeClient) Delete(id string, powerinstanceid string) error { //var cloudinstanceid = f.session.PowerServiceInstance - params := p_cloud_volumes.NewPcloudCloudinstancesVolumesDeleteParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithVolumeID(id) + params := p_cloud_volumes.NewPcloudCloudinstancesVolumesDeleteParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithVolumeID(id) _, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return errors.ToError(err) } - return nil + return fmt.Errorf("Faied to delete the volume [%s] ", id) } // Update.. @@ -77,7 +78,7 @@ func (f *IBMPIVolumeClient) Update(id, volumename string, volumesize float64, vo patchbody.Name = &volumename patchbody.Size = volumesize patchbody.Shareable = &volumeshare - params := p_cloud_volumes.NewPcloudCloudinstancesVolumesPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithVolumeID(id).WithBody(&patchbody) + params := p_cloud_volumes.NewPcloudCloudinstancesVolumesPutParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithVolumeID(id).WithBody(&patchbody) resp, err := f.session.Power.PCloudVolumes.PcloudCloudinstancesVolumesPut(params, ibmpisession.NewAuth(f.session, powerinstanceid)) @@ -94,14 +95,14 @@ func (f *IBMPIVolumeClient) Attach(id, volumename string, powerinstanceid string log.Printf("Calling the Power Volume Attach method") - params := p_cloud_volumes.NewPcloudPvminstancesVolumesPostParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithVolumeID(volumename) + params := p_cloud_volumes.NewPcloudPvminstancesVolumesPostParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithVolumeID(volumename) resp, err := f.session.Power.PCloudVolumes.PcloudPvminstancesVolumesPost(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return nil, errors.ToError(err) } log.Printf("Successfully attached the volume to the instance") - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to attach the volume [%s] to the pvm instance [%s]", volumename, id) } @@ -110,13 +111,13 @@ func (f *IBMPIVolumeClient) Attach(id, volumename string, powerinstanceid string func (f *IBMPIVolumeClient) Detach(id, volumename string, powerinstanceid string) (models.Object, error) { log.Printf("Calling the Power Volume Detach method") - params := p_cloud_volumes.NewPcloudPvminstancesVolumesDeleteParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithVolumeID(volumename) + params := p_cloud_volumes.NewPcloudPvminstancesVolumesDeleteParamsWithTimeout(30).WithCloudInstanceID(powerinstanceid).WithPvmInstanceID(id).WithVolumeID(volumename) resp, err := f.session.Power.PCloudVolumes.PcloudPvminstancesVolumesDelete(params, ibmpisession.NewAuth(f.session, powerinstanceid)) if err != nil { return nil, errors.ToError(err) } - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to detach the volume [%s ] for pvm instance with id [%s] ", volumename, id) } @@ -125,7 +126,7 @@ func (f *IBMPIVolumeClient) Detach(id, volumename string, powerinstanceid string func (f *IBMPIVolumeClient) GetAll(id, cloud_instance_id string) (*models.Volumes, error) { log.Printf("Calling the Power Volumes GetAll Method") - params := p_cloud_volumes.NewPcloudPvminstancesVolumesGetallParamsWithTimeout(f.session.Timeout).WithPvmInstanceID(id).WithCloudInstanceID(cloud_instance_id) + params := p_cloud_volumes.NewPcloudPvminstancesVolumesGetallParamsWithTimeout(30).WithPvmInstanceID(id).WithCloudInstanceID(cloud_instance_id) resp, err := f.session.Power.PCloudVolumes.PcloudPvminstancesVolumesGetall(params, ibmpisession.NewAuth(f.session, cloud_instance_id)) if err != nil { return nil, errors.ToError(err) @@ -138,10 +139,10 @@ func (f *IBMPIVolumeClient) GetAll(id, cloud_instance_id string) (*models.Volume func (f *IBMPIVolumeClient) SetBootVolume(id, volumename, cloud_instance_id string) (models.Object, error) { log.Printf("Setting the Boot Volume for this %s instance as ", cloud_instance_id) - params := p_cloud_volumes.NewPcloudPvminstancesVolumesSetbootPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(cloud_instance_id).WithPvmInstanceID(id).WithVolumeID(volumename) + params := p_cloud_volumes.NewPcloudPvminstancesVolumesSetbootPutParamsWithTimeout(30).WithCloudInstanceID(cloud_instance_id).WithPvmInstanceID(id).WithVolumeID(volumename) resp, err := f.session.Power.PCloudVolumes.PcloudPvminstancesVolumesSetbootPut(params, ibmpisession.NewAuth(f.session, cloud_instance_id)) if err != nil { return nil, errors.ToError(err) } - return resp.Payload, nil + return resp.Payload, fmt.Errorf("Failed to set the boot volume for cloud instance id [%s] ", cloud_instance_id) }