Search code examples
apache-cloudstack

Programmatically Deploy Server in CloudStack


Sorry if this is a silly question, but I am new to working with CloudStack. Is there a function that I could call to automatically build out a server using a template already in CloudStack?

Example being I have a CentOS template on the server and when I click a button on a web page and give it the appropriate information to pass, that my CloudStack server automatically deploys that new server.


Solution

  • CloudStack's UI is basically a front-end for CloudStack's API, so when you click a button on the UI to deploy a VM what the UI is doing is calling deployVirtualMachine [1] on the API. For this to work you will have to make other calls first to get unique IDs for several parameters of the deployVirtualMachine call (e.g. templateId).

    See [1] for documentation on that specific call (assuming you're working on version 4.3 of CloudStack) and [2] for a complete list of the user API. In [3] you will find a developer's guide to CloudStack's API (version 4.0.2).

    [1] http://cloudstack.apache.org/docs/api/apidocs-4.3/user/deployVirtualMachine.html

    [2] http://cloudstack.apache.org/docs/api/apidocs-4.3/TOC_User.html

    [3] http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.2/html/API_Developers_Guide/index.html