|
8 | 8 | "io/ioutil" |
9 | 9 | "net/http" |
10 | 10 | "os" |
| 11 | + "strconv" |
11 | 12 | "strings" |
12 | 13 | "sync" |
13 | 14 | "time" |
@@ -787,6 +788,45 @@ func nodePoolContainsNode(s []containerengine.Node, e string) bool { |
787 | 788 | return false |
788 | 789 | } |
789 | 790 |
|
| 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 | + |
790 | 830 | func (o *oracleOps) SetClusterVersion(version string, timeout time.Duration) error { |
791 | 831 | logrus.Println("Setting Cluster version to", version) |
792 | 832 | req := containerengine.UpdateClusterRequest{ |
|
0 commit comments