Cloudstack process Analysis of creating VM source code

Source: Internet
Author: User
Tags cloudstack

Online Search Cloudstack Source article is still very few, not as much as OpenStack, spent two days, will cloudstack create the source of the VM read it again, exclamation points: Create a VM process, query operation database really many. A few days ago listen to cloudstack people say, Cloudstack Management Server installed in a 16g/4c physical machine, running six months, will hang off, then that Khan ah ...

First, attach the process diagram

The following steps follow each step:

1. The Com.cloud.api.ApiServlet.processRequest (httpservletrequest, httpservletresponse) function handles all requests. Specific processing login, log out request other requests for forwarding, into the next step

2, Com.cloud.api.ApiServer.handleRequest (Map, String, StringBuffer)

Receiving a request to create a VM, the parsing parameter instantiates the class of the API based on the parameter "command" and assigns the request parameter to the object created by the class, and for the VM creation, the instantiated class is:

Org.apache.cloudstack.api.command.user.vm.DeployVMCmd.

Because it inherits from Baseasynccreatecmd, you need to call the Deployvmcmd create function first, and then call the Execute function

Note: Based on annotation assignment: Com.cloud.api.ApiDispatcher.processParameters (Basecmd, map<string, string>), rights Management is also done through annotations.

3, Org.apache.cloudstack.api.command.user.vm.DeployVMCmd.create ()

3.1 Check zone, serviceoffering, TemplateID, diskoffering, zone whether local storage is enabled, get IPv4, IPv6 address, Judge is basic zone, or advanced zone

3.2 If the basic zone, you need to call the function

Com.cloud.vm.UserVmManagerImpl.createBasicSecurityGroupVirtualMachine (Datacenter,serviceoffering, Virtualmachinetemplate, List<long>, account, String, string, long, long, string, Hypervisortype, HttpMethod, String, String, Map<long, Ipaddresses>, ipaddresses, Boolean, String, List<long>, Map<string, string> )

3.3 If the advanced zone, first determine whether the zone is enabled for security groups, and if security groups are enabled, call the function

Com.cloud.vm.UserVmManagerImpl.createAdvancedSecurityGroupVirtualMachine (DataCenter, serviceoffering, Virtualmachinetemplate, List<long>, List<long>, account, String, string, long, long, string, Hypervisortype , HttpMethod, String, String, Map<long, Ipaddresses>, Ipaddresses, Boolean, String, List<long> String, string>)

If security groups are not enabled, call the function:

Com.cloud.vm.UserVmManagerImpl.createAdvancedVirtualMachine (DataCenter, serviceoffering, Virtualmachinetemplate, List<long>, Account, String, string, long, long, string, Hypervisortype, HttpMethod, String, String, Map<long, Ip Addresses>, ipaddresses, Boolean, String, List<long>, map<string, string>)

To create a VM in basic zone for example, read the source code

4. function

Com.cloud.vm.UserVmManagerImpl.createBasicSecurityGroupVirtualMachine (Datacenter,serviceoffering, Virtualmachinetemplate, List<long>, account, String, string, long, long, string, Hypervisortype, HttpMethod, String, String, Map<long, Ipaddresses>, ipaddresses, Boolean, String, List<long>, Map<string, string> )

(4.1) According to ZoneID get the default network within the zone, execute the SQL

Select *from networks where Data_center_id=1 and account_id=1 and guesttype= ' Shared ' and traffic_type= ' Guest ';

Save the query to the default network to memory for later use. (need to join the virtual machine to the network for management)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.