VMware, Inc.
139
Chapter 7 VMware vSphere Platform Operations
Because
the
list
of
virtual
machines
registered
to
a
vCenter
server
can
be
very
long,
responses
to
a
GET
.../vmslist
request
present
the
list
as
a
series
of
pages.
The
default
page
size
is
100
VmObjectRef
elements,
each
representing
a
single
virtual
machine.
The
default
response
to
a
GET
.../vmslist
request
returns
the
first
page
of
the
list.
You
can
add
query
parameters
to
the
request
to
specify
a
page
size
and
a
page
number.
The
syntax
for
the
query
specification
is:
GET API-URL/admin/extension/vimServer/id/vmsList?page=
p
&pageSize=
s
where
p
represents
an
integer
page
number
(starting
with
1
)
and
s
represents
an
integer
page
size.
The
request
shown
in
Example 7
‐
30
could
be
rewritten
as
shown
in
Example 7
‐
31
to
return
the
first
ten
entries
in
the
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
To
return
the
complete
list
of
virtual
machines,
make
additional
requests
that
increment
the
value
of
page
.
Import a Virtual Machine as a vApp
To
import
a
virtual
machine
as
a
vApp,
a
system
administrator
can
make
a
request
to
the
importVmAsVApp
link
in
the
VimServer
response
body
whose
vmslist
contained
the
VmObjectRef
that
represents
the
virtual
machine.
Example 7
‐
32
imports
the
virtual
machine
shown
in
Example 7
‐
30
from
the
vCenter
server
represented
by
the
VimServer
element
shown
in
Example 7
‐
3
on
page 121
.
The
request
body
is
an
ImportVmAsVAppParams
element
whose
sourceMove
attribute
specifies
whether
or
not
the
source
virtual
machine
should
be
removed
from
vCenter
after
the
import
is
complete.
The
request
body
also
specifies
the
managed
object
reference
of
the
virtual
machine
to
import,
and
the
href
of
the
vDC
to
which
the
import
goes.
The
response
is
an
unresolved
vApp
body
containing
a
task
that
tracks
the
import.
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.importVmAsVApxml
...
<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>
Summary of Contents for VCLOUD API 1.0 - TECHNICAL NOTE
Page 10: ...vCloud API Programming Guide 10 VMware Inc...
Page 20: ...vCloud API Programming Guide 20 VMware Inc...
Page 32: ...vCloud API Programming Guide 32 VMware Inc...
Page 90: ...vCloud API Programming Guide 90 VMware Inc...
Page 150: ...vCloud API Programming Guide 150 VMware Inc...
Page 170: ...vCloud API Programming Guide 170 VMware Inc...