mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			107 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
| <!-- 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.
 | |
| -->
 | |
| 
 | |
| <section id="asynchronous-commands-example">
 | |
| 	<title>Example</title>
 | |
| 		<para>
 | |
| 			The following shows an example of using an asynchronous command. Assume the API command:</para>
 | |
| 		<programlisting>command=deployVirtualMachine&zoneId=1&serviceOfferingId=1&diskOfferingId=1&templateId=1
 | |
| 		</programlisting>
 | |
| 		<para>CloudStack will immediately return a job ID and any other additional data.</para>
 | |
| 		<programlisting>
 | |
| 		 <deployvirtualmachineresponse> 
 | |
|   			<jobid>1</jobid>
 | |
|  		    <id>100</id>
 | |
| 		 </deployvirtualmachineresponse>
 | |
| 		</programlisting>
 | |
| 		<para>Using the job ID, you can periodically poll for the results by using the queryAsyncJobResult command.</para>
 | |
| 	    <programlisting>command=queryAsyncJobResult&jobId=1</programlisting>
 | |
| 		<para>Three possible results could come from this query.</para>
 | |
| 		<para>Job is still pending:</para>
 | |
| 	    <programlisting>
 | |
| 	     <queryasyncjobresult> 
 | |
|   			<jobid>1</jobid>
 | |
|   			<jobstatus>0</jobstatus>
 | |
|   			<jobprocstatus>1</jobprocstatus>
 | |
| 		 </queryasyncjobresult>
 | |
| 		</programlisting>
 | |
| 		<para>Job has succeeded:</para>
 | |
| 	    <programlisting>
 | |
| 	    	<queryasyncjobresultresponse cloud-stack-version="3.0.1.6">
 | |
|   				<jobid>1</jobid>
 | |
|   				<jobstatus>1</jobstatus>
 | |
|   				<jobprocstatus>0</jobprocstatus>
 | |
|  				<jobresultcode>0</jobresultcode>
 | |
|   				<jobresulttype>object</jobresulttype>
 | |
|   				<jobresult>
 | |
| 				    <virtualmachine>
 | |
| 				    <id>450</id>
 | |
| 				    <name>i-2-450-VM</name>
 | |
| 				    <displayname>i-2-450-VM</displayname>
 | |
| 				    <account>admin</account>
 | |
| 				    <domainid>1</domainid>
 | |
| 				    <domain>ROOT</domain>
 | |
| 				    <created>2011-03-10T18:20:25-0800</created>
 | |
| 				    <state>Running</state>
 | |
| 				    <haenable>false</haenable>
 | |
| 				    <zoneid>1</zoneid>
 | |
| 				    <zonename>San Jose 1</zonename>
 | |
| 				    <hostid>2</hostid>
 | |
| 				    <hostname>905-13.sjc.lab.vmops.com</hostname>
 | |
| 				    <templateid>1</templateid>
 | |
| 				    <templatename>CentOS 5.3 64bit LAMP</templatename>
 | |
| 				    <templatedisplaytext>CentOS 5.3 64bit LAMP</templatedisplaytext>
 | |
| 				    <passwordenabled>false</passwordenabled>
 | |
| 				    <serviceofferingid>1</serviceofferingid>
 | |
| 				    <serviceofferingname>Small Instance</serviceofferingname>
 | |
| 				    <cpunumber>1</cpunumber>
 | |
| 				    <cpuspeed>500</cpuspeed>
 | |
| 				    <memory>512</memory>
 | |
| 				    <guestosid>12</guestosid>
 | |
| 				    <rootdeviceid>0</rootdeviceid>
 | |
| 				    <rootdevicetype>NetworkFilesystem</rootdevicetype>
 | |
| 				    <nic>
 | |
| 				      <id>561</id>
 | |
| 				      <networkid>205</networkid>
 | |
| 				      <netmask>255.255.255.0</netmask>
 | |
| 				      <gateway>10.1.1.1</gateway>
 | |
| 				      <ipaddress>10.1.1.225</ipaddress>
 | |
| 				      <isolationuri>vlan://295</isolationuri>
 | |
| 				      <broadcasturi>vlan://295</broadcasturi>
 | |
| 				      <traffictype>Guest</traffictype>
 | |
| 				      <type>Virtual</type>
 | |
| 				      <isdefault>true</isdefault>
 | |
| 				    </nic>
 | |
| 				    <hypervisor>XenServer</hypervisor>
 | |
| 				   </virtualmachine>
 | |
| 				 </jobresult>
 | |
| 			</queryasyncjobresultresponse>
 | |
| 	    </programlisting>
 | |
| 		<para>Job has failed:</para>
 | |
|     	<programlisting>
 | |
|     		<queryasyncjobresult>
 | |
|   				<jobid>1</jobid> 
 | |
|   				<jobstatus>2</jobstatus> 
 | |
| 	  			<jobprocstatus>0</jobprocstatus>
 | |
| 	  			<jobresultcode>551</jobresultcode>
 | |
| 	  			<jobresulttype>text</jobresulttype>
 | |
| 	  			<jobresult>Unable to deploy virtual machine id = 100 due to not enough capacity</jobresult> 
 | |
| 			</queryasyncjobresult>
 | |
| 		</programlisting>	
 | |
| 	</section>
 |