harikrishna-patnala commented on a change in pull request #5008:
URL: https://github.com/apache/cloudstack/pull/5008#discussion_r698972958



##########
File path: 
api/src/main/java/org/apache/cloudstack/api/command/user/volume/ChangeOfferingForVolumeCmd.java
##########
@@ -0,0 +1,141 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.volume;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.offering.DiskOffering;
+import com.cloud.storage.Volume;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.UserCmd;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+@APICommand(name = ChangeOfferingForVolumeCmd.APINAME,
+        description = "Change disk offering of the volume and also an option 
to auto migrate if required to apply the new disk offering",
+        responseObject = VolumeResponse.class,
+        requestHasSensitiveInfo = false,
+        responseHasSensitiveInfo = false,
+        authorized = { RoleType.Admin, RoleType.ResourceAdmin, 
RoleType.DomainAdmin, RoleType.User},
+        since = "4.16")
+public class ChangeOfferingForVolumeCmd extends BaseAsyncCmd implements 
UserCmd {
+
+    public static final String APINAME = "changeOfferingForVolume";
+    public static final Logger s_logger = 
Logger.getLogger(ChangeOfferingForVolumeCmd.class.getName());
+    private static final String s_name = "changeofferingforvolumeresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ID, entityType = VolumeResponse.class, 
required = true, type = CommandType.UUID, description = "the ID of the volume")
+    private Long id;
+
+    @Parameter(name = ApiConstants.DISK_OFFERING_ID,
+            entityType = DiskOfferingResponse.class,
+            type = CommandType.UUID,
+            required = true,
+            description = "new disk offering id")
+    private Long newDiskOfferingId;
+
+    @Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, required = 
false, description = "New volume size in GB for the custom disk offering")
+    private Long size;
+
+    @Parameter(name = ApiConstants.MIN_IOPS, type = CommandType.LONG, required 
= false, description = "New minimum number of IOPS for the custom disk 
offering")
+    private Long minIops;
+
+    @Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, required 
= false, description = "New maximum number of IOPS for the custom disk 
offering")
+    private Long maxIops;
+
+    @Parameter(name = ApiConstants.AUTO_MIGRATE, type = CommandType.BOOLEAN, 
required = false, description = "Flag for automatic migration of the volume " +
+            "with new disk offering whenever migration is required to apply 
the offering")
+    private Boolean autoMigrate;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getNewDiskOfferingId() {
+        return newDiskOfferingId;
+    }
+
+    public Long getSize() {
+        return size;
+    }
+
+    public Long getMinIops() {
+        return minIops;
+    }
+
+    public Long getMaxIops() {
+        return maxIops;
+    }
+
+    public boolean getAutoMigrate() {
+        return autoMigrate == null ? true : autoMigrate;

Review comment:
       The new API changeOfferingForVolume is supposed to keep the volume in 
the proper state as per the provided disk offering. So if migration of volume 
is required (as per the new disk offering) it has to be migrated, otherwise, 
API will fail. There is an option in UI also to tick/untick the flag. I think 
default true is fine. Let me know your comments too.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to