Skip to content

Commit 0cbeca2

Browse files
PWX-24576: Implement clouddrive Expand API in CloudOps (#113)
* PWX-24576: Implement clouddrive Expand API in CloudOps * PWX-24576 : Fix review comments * PWX-24576 : Fix review comments
1 parent 45c0db2 commit 0cbeca2

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

oracle/oracle.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io/ioutil"
99
"net/http"
1010
"os"
11+
"strconv"
1112
"strings"
1213
"sync"
1314
"time"
@@ -787,6 +788,45 @@ func nodePoolContainsNode(s []containerengine.Node, e string) bool {
787788
return false
788789
}
789790

791+
792+
func (o *oracleOps) Expand(volumeID string, newSizeInGiB uint64) (uint64, error) {
793+
logrus.Debug("Expand volume to size ", newSizeInGiB, " GiB")
794+
795+
volume, err := o.storage.GetVolume(context.Background(), core.GetVolumeRequest{VolumeId: &volumeID})
796+
if err != nil {
797+
return 0, err
798+
}
799+
800+
currentsize := uint64(*volume.SizeInGBs)
801+
802+
if (currentsize > newSizeInGiB) || (currentsize == newSizeInGiB) {
803+
return currentsize, errors.New("Can not change Volume size from " + strconv.Itoa(int(currentsize)) + " GiB to " + strconv.Itoa(int(newSizeInGiB)) + " GiB")
804+
}
805+
806+
req := core.UpdateVolumeRequest{
807+
VolumeId: &volumeID,
808+
UpdateVolumeDetails: core.UpdateVolumeDetails{
809+
SizeInGBs: common.Int64(int64(newSizeInGiB)),
810+
},
811+
}
812+
813+
updateVolResp, err := o.storage.UpdateVolume(context.Background(), req)
814+
if err != nil {
815+
return 0, err
816+
}
817+
818+
oracleVol, err := o.waitVolumeStatus(*updateVolResp.Id, core.VolumeLifecycleStateAvailable)
819+
if err != nil {
820+
return 0, err
821+
}
822+
updatedVol, ok := oracleVol.(*core.Volume)
823+
if !ok {
824+
return 0, errors.New("Marshelling failed for Oracle volume")
825+
}
826+
827+
return uint64(*updatedVol.SizeInGBs), nil
828+
}
829+
790830
func (o *oracleOps) SetClusterVersion(version string, timeout time.Duration) error {
791831
logrus.Println("Setting Cluster version to", version)
792832
req := containerengine.UpdateClusterRequest{

0 commit comments

Comments
 (0)