Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDSTACK-9951: Add support for batch/bulk VM deployment option in CS #2140

Closed
wants to merge 2 commits into from
Closed

Conversation

koushik-das
Copy link
Contributor

Added a new API to support bulk deployment of VMs. There is also an option to specify pod or cluster to deploy the VMs.
VMs will be appropriately placed based on selected deployment planner and the existing VM distribution based on count.
For details refer the FS @ https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=70258861

Added a new API to support bulk deployment of VMs. There is also an option to specify pod or cluster to deploy the VMs.
VMs will be appropriately placed based on selected deployment planner and the existing VM distribution based on count.
For details refer the FS @ https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=70258861
@koushik-das
Copy link
Contributor Author

Test bulk deploy of VM ... === TestName: test_bulk_deploy_vm | Status : SUCCESS ===
ok
Test bulk deploy of VM in specific cluster ... === TestName: test_bulk_deploy_vm_with_cluster | Status : SUCCESS ===
ok


Ran 2 tests in 63.674s

OK

@koushik-das koushik-das added this to the 4.11 milestone Jun 9, 2017
@ustcweizhou
Copy link
Contributor

@koushik-das awesome. This is what we need.
one suggestion: is it possible to specify the prefix of vm name/displayname ?

@koushik-das
Copy link
Contributor Author

@ustcweizhou Thanks! Please try it out and provide your feedback.
Adding an option to specify VM name prefix is possible, there is already the 'instance.name' global config which is used as a prefix in single VM deployment. This can be made into a parameter in the new API for bulk VM deployment.

@wido
Copy link
Contributor

wido commented Aug 10, 2017

Could you check the conflict @koushik-das ?

Awesome feature though!

@rohityadavcloud
Copy link
Member

rohityadavcloud commented Aug 31, 2017

@koushik-das can you rebase against latest master and fix the conflict?
Looks like a nice feature to have.

Copy link
Member

@rohityadavcloud rohityadavcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good feature to have, the implementation can be improved and simplified if we restrict the options the bulk API accepted limited to deploying of bulk VMs under the same set of common rules such as network, affinity rules, etc. I would advise extending over the existing deploy VM API and avoid putting hacks in the implementation, and the response may return an array of jobs instead of a single job.

import com.cloud.offering.DiskOffering;
import com.cloud.offering.ServiceOffering;

@APICommand(name = "bulkDeployVirtualMachine", description = "Creates and automatically start multiple virtual machines of similar configuration based on virtualmachinecount.", responseObject = AsyncJobResponse.class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about rename this to, deployBulkVirtualMachine?

authorized = { RoleType.Admin }, since = "4.11")
public class BulkDeployVMCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(BulkDeployVMCmd.class.getName());
private static final String s_name = "bulkdeployvirtualmachineresponse";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consider declaring the APINAME as a static var and use that for both declaration of name and response strings, see this for example: https://github.com/apache/cloudstack/blob/master/api/src/org/apache/cloudstack/api/command/admin/acl/ListRolesCmd.java#L46

@APICommand(name = "bulkDeployVirtualMachine", description = "Creates and automatically start multiple virtual machines of similar configuration based on virtualmachinecount.", responseObject = AsyncJobResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
authorized = { RoleType.Admin }, since = "4.11")
public class BulkDeployVMCmd extends BaseCmd {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to extend the DeployVMCmd class, this has several options same as the deployVM api.

}

private void verifyInputs() {
if (count == null || count <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consider using Preconditions check, or at least throw ServerApiException(ApiErrorCode.PARAM_ERROR, ... ?

@@ -184,10 +184,18 @@
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin })
private String deploymentPlanner;

protected Long podId = null;
protected Long clusterId = null;
protected List<Long> vmIds = new ArrayList<Long>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this hack, consider a different way of implementation.

@@ -39,11 +40,37 @@
public class DeployVMCmdByAdmin extends DeployVMCmd {
public static final Logger s_logger = Logger.getLogger(DeployVMCmdByAdmin.class.getName());

private void processContextParameters() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing this hack, consider a different way of implementation.

if (vmIds != null && !vmIds.isEmpty()) {
boolean wait = true;
int count = 0;
while (wait && count++ < 30) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be configurable?

@rohityadavcloud rohityadavcloud removed this from the 4.11 milestone Dec 19, 2017
@DaanHoogland
Copy link
Contributor

@koushik-das please rebase and re-open if still relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants