VMware, Inc. 139
Chapter 7 VMware vSphere Platform Operations
BecausethelistofvirtualmachinesregisteredtoavCenterservercanbeverylong,responsestoaGET
.../vmslistrequestpresentthelistasaseriesofpages.Thedefaultpagesizeis100VmObjectRefelements,each
representingasinglevirtualmachine.ThedefaultresponsetoaGET.../vmslistrequest
returnsthefirstpage
ofthelist.Youcanaddqueryparameterstotherequesttospecifyapagesizeandapagenumber.Thesyntax
forthequeryspecificationis:
GET API-URL/admin/extension/vimServer/id/vmsList?page=
p
&pageSize=
s
where prepresentsanintegerpagenumber(startingwith1)ands representsanintegerpagesize.Therequest
showninExample 7‐30couldberewrittenasshowninExample 7‐31toreturnthefirsttenentriesinthe
vmsList.
Example 7-31. vmsList with Page Number and Page Size Query
Request:
GET http://vcloud.example.com/api/v1.0/admin/extension/vimServer/100/vmsList?page=1&pageSize=10
Toreturnthecompletelistofvirtualmachines,makeadditionalrequeststhatincrementthevalueofpage.
Import a Virtual Machine as a vApp
ToimportavirtualmachineasavApp,asystemadministratorcanmakearequesttotheimportVmAsVApp
linkintheVimServerresponsebodywhosevmslistcontainedtheVmObjectRefthatrepresentsthevirtual
machine.Example 7‐32importsthevirtualmachineshowninExample 7‐30fromthevCenterserver
representedbythe
VimServerelementshowninExample 7‐3onpage 121.Therequestbodyisan
ImportVmAsVAppParamselementwhosesourceMoveattributespecifieswhetherornotthesourcevirtual
machineshouldberemovedfromvCenteraftertheimportiscomplete.Therequestbodyalsospecifiesthe
managedobjectreferenceofthevirtualmachineto
import,andthehrefofthevDCtowhichtheimportgoes.
TheresponseisanunresolvedvAppbodycontainingataskthattrackstheimport.
Example 7-32. Import a Virtual Machine as a vApp
Request:
POST http://vcloud.example.com/api/v1.0/admin/extension/vimServer/100/importVmAsVapp
Content-type: application/vnd.vmware.admin.importVmAsVAppParams+xml
...
<ImportVmAsVAppParams xmlns="http://www.vmware.com/vcloud/extension/v1" name="ImportedWin2K8"
sourceMove="false">
<VmMoRef>vm-642</VmMoRef>
<Vdc href="http://vcloud.example.com/api/v1.0/vdc/2"/>
</ImportVmAsVAppParams>
Response:
201 Created
Content-Type: application/vnd.vmware.vcloud.vApp+xml
<VApp status="0" name="ImportedWin2K8" type="application/vnd.vmware.vcloud.vApp+xml"
href="http://vcloud.example.com/api/v1.0/vApp/vapp-102" ...>
...
<Description/>
<Tasks>
<Task ... operation=”Busy Virtual Application Win2K8” ...>
...
</Task>
</Tasks>
</VApp>