|
| 1 | +package storagemanager |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/libopenstorage/cloudops" |
| 7 | + "github.com/libopenstorage/cloudops/pkg/storagedistribution" |
| 8 | + "github.com/libopenstorage/cloudops/unsupported" |
| 9 | +) |
| 10 | + |
| 11 | +type oracleStorageManager struct { |
| 12 | + cloudops.StorageManager |
| 13 | + decisionMatrix *cloudops.StorageDecisionMatrix |
| 14 | +} |
| 15 | + |
| 16 | +// NewStorageManager returns a Oracle specific implementation of StorageManager interface. |
| 17 | +func NewStorageManager(decisionMatrix cloudops.StorageDecisionMatrix) (cloudops.StorageManager, error) { |
| 18 | + return &oracleStorageManager{ |
| 19 | + StorageManager: unsupported.NewUnsupportedStorageManager(), |
| 20 | + decisionMatrix: &decisionMatrix}, nil |
| 21 | +} |
| 22 | + |
| 23 | +func (o *oracleStorageManager) GetStorageDistribution( |
| 24 | + request *cloudops.StorageDistributionRequest, |
| 25 | +) (*cloudops.StorageDistributionResponse, error) { |
| 26 | + response := &cloudops.StorageDistributionResponse{} |
| 27 | + var currentDriveType string |
| 28 | + for _, userRequest := range request.UserStorageSpec { |
| 29 | + currentDriveType = userRequest.DriveType |
| 30 | + // for request, find how many instances per zone needs to have storage |
| 31 | + // and the storage spec for each of them |
| 32 | + instStorage, instancePerZone, row, err := |
| 33 | + storagedistribution.GetStorageDistributionForPool( |
| 34 | + o.decisionMatrix, |
| 35 | + userRequest, |
| 36 | + request.InstancesPerZone, |
| 37 | + request.ZoneCount, |
| 38 | + ) |
| 39 | + if err != nil { |
| 40 | + return nil, err |
| 41 | + } |
| 42 | + if currentDriveType == "" { |
| 43 | + currentDriveType = instStorage.DriveType |
| 44 | + } |
| 45 | + response.InstanceStorage = append( |
| 46 | + response.InstanceStorage, |
| 47 | + &cloudops.StoragePoolSpec{ |
| 48 | + DriveCapacityGiB: instStorage.DriveCapacityGiB, |
| 49 | + DriveType: currentDriveType, |
| 50 | + InstancesPerZone: instancePerZone, |
| 51 | + DriveCount: instStorage.DriveCount, |
| 52 | + IOPS: determineIOPSForPool(instStorage, row), |
| 53 | + }, |
| 54 | + ) |
| 55 | + } |
| 56 | + return response, nil |
| 57 | +} |
| 58 | +func (o *oracleStorageManager) RecommendStoragePoolUpdate(request *cloudops.StoragePoolUpdateRequest) (*cloudops.StoragePoolUpdateResponse, error) { |
| 59 | + resp, row, err := storagedistribution.GetStorageUpdateConfig(request, o.decisionMatrix) |
| 60 | + if err != nil { |
| 61 | + return nil, err |
| 62 | + } |
| 63 | + if resp == nil || len(resp.InstanceStorage) != 1 { |
| 64 | + return nil, fmt.Errorf("could not find a valid instance storage object") |
| 65 | + } |
| 66 | + resp.InstanceStorage[0].IOPS = determineIOPSForPool(resp.InstanceStorage[0], row) |
| 67 | + if request.CurrentDriveType != "" { |
| 68 | + resp.InstanceStorage[0].DriveType = request.CurrentDriveType |
| 69 | + } |
| 70 | + return resp, nil |
| 71 | +} |
| 72 | + |
| 73 | +func determineIOPSForPool(instStorage *cloudops.StoragePoolSpec, row *cloudops.StorageDecisionMatrixRow) uint64 { |
| 74 | + var iopsPerGB, maxIopsPerVol int64 |
| 75 | + switch row.DriveType { |
| 76 | + case "0_vpus": |
| 77 | + iopsPerGB = 2 |
| 78 | + maxIopsPerVol = 3000 |
| 79 | + case "10_vpus": |
| 80 | + iopsPerGB = 60 |
| 81 | + maxIopsPerVol = 25000 |
| 82 | + case "20_vpus": |
| 83 | + iopsPerGB = 75 |
| 84 | + maxIopsPerVol = 50000 |
| 85 | + case "30_vpus": |
| 86 | + iopsPerGB = 90 |
| 87 | + maxIopsPerVol = 75000 |
| 88 | + case "40_vpus": |
| 89 | + iopsPerGB = 105 |
| 90 | + maxIopsPerVol = 100000 |
| 91 | + case "50_vpus": |
| 92 | + iopsPerGB = 120 |
| 93 | + maxIopsPerVol = 125000 |
| 94 | + case "60_vpus": |
| 95 | + iopsPerGB = 135 |
| 96 | + maxIopsPerVol = 150000 |
| 97 | + case "70_vpus": |
| 98 | + iopsPerGB = 150 |
| 99 | + maxIopsPerVol = 175000 |
| 100 | + case "80_vpus": |
| 101 | + iopsPerGB = 165 |
| 102 | + maxIopsPerVol = 200000 |
| 103 | + case "90_vpus": |
| 104 | + iopsPerGB = 180 |
| 105 | + maxIopsPerVol = 225000 |
| 106 | + case "100_vpus": |
| 107 | + iopsPerGB = 195 |
| 108 | + maxIopsPerVol = 250000 |
| 109 | + case "110_vpus": |
| 110 | + iopsPerGB = 210 |
| 111 | + maxIopsPerVol = 275000 |
| 112 | + case "120_vpus": |
| 113 | + iopsPerGB = 225 |
| 114 | + maxIopsPerVol = 300000 |
| 115 | + } |
| 116 | + |
| 117 | + if instStorage.DriveCapacityGiB*uint64(iopsPerGB) > uint64(maxIopsPerVol) { |
| 118 | + return uint64(maxIopsPerVol) |
| 119 | + } |
| 120 | + return instStorage.DriveCapacityGiB * uint64(iopsPerGB) |
| 121 | +} |
| 122 | + |
| 123 | +func init() { |
| 124 | + cloudops.RegisterStorageManager(cloudops.Oracle, NewStorageManager) |
| 125 | +} |
0 commit comments