VMware vCloud vCloud Director 1.0 User guide

  • Hello! I am an AI chatbot trained to assist you with the VMware vCloud vCloud Director 1.0 User guide. I’ve already reviewed the document and can help you find the information you need or explain it in simple terms. Just ask your questions, and providing more details will help me assist you more effectively!
vCloud API Programming Guide
vCloud API 1.0
This document supports the version of each product listed and
supports all subsequent versions until the document is replaced
by a new edition. To check for more recent editions of this
document, see http://www.vmware.com/support/pubs.
EN-000180-01
VMware, Inc.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
2 VMware, Inc.
vCloud API Programming Guide
You can find the most up-to-date technical documentation on the VMware Web site at:
http://www.vmware.com/support/
The VMware Web site also provides the latest product updates.
If you have comments about this documentation, submit your feedback to:
docfeedback@vmware.com
Copyright © 2009, 2011 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and
intellectual property laws. VMware products are covered by one or more patents listed at
http://www.vmware.com/go/patents.
VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks
and names mentioned herein may be trademarks of their respective companies.
VMware, Inc. 3
Contents
AboutThisBook 11
1 IntroducingtheVMwarevCloudAPI 13
vCloudObjectTaxonomy 13
vCloudOrganizations 13
Objects,References,andRepresentations 15
LinksandLinkRelations 15
vCloudClientWorkflowOverview 17
Requests 17
Responses 18
ConfiguringthevCloudAPIURL 19
RelatedPublications 19
AbouttheExamples 19
2 HellovCloud:AStructuredRESTWorkflowExample 21
LoggingInandGettinganOrganizationList 21
BrowsinganOrganization 22
FindingavAppTemplate 23
GettingInformationAboutavDC 24
InstantiatingtheTemplateinthevDC 24
DeployingandPoweringOnthevApp 26
GettingInformationAboutthevApp 27
DisplayingtheConsole 29
RetrieveaScreenTicket 29
UsetheTicketwithvmwarevmrc 30
DeletingthevApp 30
LoggingOut 30
Movingonto
AdditionalUseCases 31
3 Browsing 33
SummaryofBrowsingRequests 33
DiscoveringtheContentsofanOrganization,Catalog,orvDC 34
ListtheOrganizationsinavCloud 34
ListtheContentsofanOrganization 34
ListtheContentsofaCatalog 35
GetInformationAboutaCatalogItem 36
ListtheContentsofavDC 37
GettingMoreInformationAboutanObject 38
GetInformationAboutaMediaImage 38
Get
InformationAboutavAppTemplate 39
GetInformationAboutavApporVirtualMachine 40
GetInformationAboutaNetwork 40
4 Provisioning 41
SummaryofProvisioningRequests 41
UploadOVFtoCreateavAppTemplate 42
vCloud API Programming Guide
4 VMware, Inc.
RestrictionsonUploadedContent 43
InitiatetheUpload 43
IncludingaManifest 45
UploadingtheFiles 45
ViewtheOVFDescriptorofavAppTemplate 47
DownloadavAppTemplateasOVF 47
EnableavAppTemplateforDownload 48
DisableavAppTemplateforDownload 49
UploadaMediaImage 50
CopyingandMoving 50
CopyorMoveaMediaImage 51
CopyorMovea
vAppTemplate 51
CopyorMoveavApp 52
ChangingaNameorDescription 53
ChangetheNameorDescriptionofavAppTemplate 53
ChangetheNameorDescriptionofavApp 53
ChangetheNameorDescriptionofaMediaImage 54
DeleteavAppTemplate,vApp,orMediaImage 54
CatalogingvAppTemplatesandMediaImages 54
AddanItemtoa
Catalog 54
RemoveanItemfromaCatalog 56
CatalogLinksinaVAppTemplateorMediaImage 56
ControllingAccess 56
ControlAccesstoCatalogs 56
5 DatacenterOperations 59
SummaryofDatacenterOperationsRequests 59
vAppLifecycle 60
InstantiateavAppTemplate 61
AboutInstantiationParameters 62
AboutvAppNetworks 62
InstantiatingavAppTemplateUsingDefaultParameters 62
InstantiatingavAppTemplateUsingAdditionalParameters 62
RetrieveorModifytheCustomizationSectionofavAppTemplate 64
ComposeavApp 65
FindingVirtualMachineURLstoUseinaCompositionItem 66
RecomposeavAppto
AddorRemoveVirtualMachines 67
CaptureavApptoCreateavAppTemplate 68
ReconfiguringvAppsandVirtualMachines 69
ReconfigureavApp 69
ReconfigureaVirtualMachine 73
DeployingandControllingvAppsandVirtualMachines 80
DeployavApporVirtualMachine 80
UndeployavApporVirtualMachine 81
PowerOnavApporVirtualMachine 81
PowerOffavApp
orVirtualMachine 82
ResetavApporVirtualMachine 82
SuspendavApporVirtualMachine 83
DiscardtheSuspendedStateofavApporVirtualMachine 83
ShutDownavApporVirtualMachine 8 4
RebootavApporVirtualMachine 84
ListMediaDevicesofaVirtualMachine 85
InsertMediaIntoaVirtualMachine 85
EjectMediafrom
aVirtualMachine 86
GetaScreenThumbnailforaVirtualMachine 86
VMware, Inc. 5
Contents
GetaScreenTicketforaVirtualMachine 87
ProvideUserInputRequestedbyaVirtualMachine 87
ControlAccesstovApps 89
RetrieveaTask 89
6 AdministrativeOperations 91
SummaryofAdministrativeRequests 91
AdministratorCredentialsandPrivileges 93
AdministrativeObjectsandURLs 93
GetanAdministrativeViewofaCloud 93
OrganizationAdministration 94
CreateanOrganization 95
GetanAdministrativeViewofanOrganization 96
ListAllTasksOwnedbyanOrganization 97
ModifyanOrganization 97
EnableorDisableanOrganization 98
RemoveanOrganization 9 9
NetworkAdministration 99
ViewthePropertiesofanExternal
Network 99
AddaNetworktoanOrganization 100
GetanAdministrativeViewofanOrganizationNetwork 101
ModifyanOrganizationNetwork 101
RemoveanOrganizationNetwork 102
vDCAdministration 102
ExaminetheContentsofaProvidervDC 103
ListtheOrganizationvDCsSupportedbyaProvidervDC 104
AllocateavDCtoanOrganization 104
GetanAdministrativeViewofavDC 106
Modify
avDC 106
EnableorDisableavDC 107
RemoveavDC 107
CatalogAdministration 107
CreateaCatalog 107
GetanAdministrativeViewofaCatalog 108
PublishaCatalog 109
ModifyCatalogMetadata 109
RemoveaCatalog 110
UserAdministration 110
CreateorImportaUser 110
GetanAdministrativeViewofaUser 112
ModifyUserMetadata 112
RemoveaUser 113
GroupAdministration 113
ImportaGroup 113
ViewGroupMetadata 114
ModifyGroupMetadata 114
RemoveaGroup 114
RoleAdministration 114
CreateaRole 114
ViewRoleMetadata 115
ModifyaRole 116
RemoveaRole 116
ViewaRight 116
vCloud API Programming Guide
6 VMware, Inc.
7 VMwarevSpherePlatformOperations 117
SummaryofvSpherePlatformOperationsRequests 117
ListvSpherePlatformOperationsandObjectsforavCloud 119
ListProvidervDCsinavCloud 120
ListExternalNetworksinavCloud 120
ListNetworkPoolsinavCloud 120
ListvCenterServersRegisteredtoavCloud 120
GetInformationAboutavCenterServer 120
ListAvailableResourcePoolsonavCenterServer 121
ModifyvCenterServerSettings 122
RegisteravCenterServerandvShieldManager 122
UnregisteravCenterServerandvShieldManager 123
ForceReconnectiontoavCenterServer 124
ListESX/ESXiHostsinavCloud 124
GetInformationAboutaHost 124
PrepareaHost 125
UnprepareaHost 126
EnableorDisableaHost 126
RepairaHost 126
UpgradeaHostAgent 127
CreateaProvidervDC 127
ExaminethevSphereObjectsinaProvidervDC 131
ModifyaProvidervDC 131
EnableorDisableaProvidervDC 132
RemoveaProvidervDC 132
CreateanExternalNetwork 133
GetInformationAboutanExternalNetwork 134
ModifyanExternalNetwork 135
RemoveanExternalNetwork 135
CreateaNetworkPool 136
GetInformationAboutaNetworkPool 137
ModifyaNetworkPool 137
Removea
NetworkPool 138
ImportaVirtualMachinefromvCenter 138
DiscovertheVirtualMachinesinavCenter 138
ImportaVirtualMachineasavApp 139
ImportaVirtualMachineasavAppTemplate 140
8 XMLRepresentationsinthevCloud API 141
AboutObjectRepresentations 141
Schema 141
ContentType 142
ObjectReferencePrototype 142
CommonDatatypes 142
PrimitiveXMLDatatypes 142
ComplexTypes 143
CommonAttributes 143
name 144
href 144
type 144
status 144
XMLNamespaceIdentifiers 145
CommonElements 146
Description 146
Error 146
VMware, Inc. 7
Contents
Link 147
APIVersioning 147
SupportedVersions 148
VersionInfo 148
Extensibility 148
VCloudExtension 149
9 UserAPIReference 151
OrgList 151
Org 151
Vdc 152
StorageCapacity 153
ComputeCapacity 153
AvailableNetworks 153
ResourceEntities 154
ResourceEntity 154
OrgNetwork 154
Configuration 155
Catalog 160
CatalogItems 160
CatalogItem 160
Media 161
VAppTemplate 161
Children 162
VApp 162
Vm 163
Section 163
LeaseSettingsSection 164
StartupSection 164
CustomizationSection 164
NetworkConfigSection 165
NetworkConnectionSection 165
VirtualHardwareSection 167
OperatingSystemSection 167
GuestCustomizationSection 167
RasdItemsList 168
ScreenTicket 168
TasksList 168
Tasks 168
Task 168
10 RequestParametersReference 171
UploadVAppTemplateParams 171
InstantiateVAppTemplateParams 172
InstantiationParams 172
ComposeVAppParams 173
Item 173
NetworkAssignment 174
RecomposeVAppParams 174
DeployVAppParams 175
UndeployVAppParams 175
CaptureVAppParams 175
CloneMediaParams 176
CloneVAppTemplateParams 176
vCloud API Programming Guide
8 VMware, Inc.
CloneVAppParams 176
MediaInsertOrEjectParams 177
VmPendingQuestion 177
VmQuestionAnswer 177
ControlAccessParams 177
AccessSettings 178
11 AdministrativeAPIReference 179
VCloud 179
OrganizationReferences 180
ProviderVdcReferences 180
RightReferences 180
RoleReferences 180
Networks 180
ExternalNetwork 180
AdminOrg 180
Settings 181
Users 185
Groups 185
Catalogs 185
Catalog 186
Vdcs 186
ProviderVdc 186
ComputeCapacity 187
StorageCapacity 188
NetworkPoolReferences 188
NetworkPoolReference 188
VdcReferences 188
AdminVdc 188
AllocationModel 190
User 190
Group 191
Role 191
RightReferences 191
RightReference 191
Right 192
12 vSpherePlatformExtensionsReference 193
VMWExtension 193
VMWProviderVdcReferences 194
VMWExternalNetworkReferences 194
VMWNetworkPoolReferences 194
VMWVimServerReferences 194
VMWHostReferences 194
VimServer 194
VmObjectRefsList 195
VimObjectRef 195
ResourcePoolList 196
ResourcePool 196
ShieldManager 196
VMWProviderVdc 197
VMWNetworkPool 198
FencePoolType 198
PortGroupPoolType 198
VlanPoolType 198
VMware, Inc. 9
Contents
VMWExternalNetwork 199
VlanRange 199
VMWHostReferences 199
Host 199
RequestParameters 200
PrepareHostParams 200
RegisterVimServerParams 200
ImportVmAsVAppParams 201
ImportVmAsVAppTemplateParams 201
A OVFandthevCloudAPI 203
AboutOVF 203
AboutOVFPackages 204
AboutOVAFiles 204
HowthevCloudAPIUsesOVF 204
VirtualMachines 204
VirtualDiskFiles 205
Networks 205
B AnIntroductiontoRESTforvCloudAPIUsers 207
HowRESTWorks 207
UsingthevCloudRESTAPI 207
RESTfulWorkflowPatterns 208
ForMoreInformationAboutREST 208
Index 209
vCloud API Programming Guide
10 VMware, Inc.
VMware, Inc. 11
ThevCloudAPIProgrammingGuideprovidesinformationaboutversion1.0ofthevCloudAPI.
VMwareprovidesmanydifferentAPIsandSDKsforvariousapplicationsandgoals.Thisbookprovides
informationaboutthevCloudAPIfordevelopersthatareinterestedincreatingRESTfulclientsofVMware
CloudDirector.
Toviewthecurrent
versionofthisbookaswellasallVMwareAPIandSDKdocumentation,goto
http://www.vmware.com/support/pubs/sdk_pubs.html.
Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor
ormajorchanges.Table 1summarizesthesignificantchangesineachversionofthisbook.
Intended Audience
ThisguideisintendedforsoftwaredeveloperswhoarebuildingVMwareReadyCloudServices,including
interactiveclientsofVMwareCloudDirector.ThisguideassumesyouarefamiliarwithRepresentationalState
Transfer(REST)andRESTfulprogrammingconventions,theOpenVirtualizationFormatSpecification,and
VMwareVirtualmachinetechnology.Familiaritywithotherwidelydeployed
technologiessuchasXML,
HTTP,andtheWindowsorLinuxoperatingsystemsisalsoassumed.
VMware Technical Publications Glossary
VMwareTechnicalPublicationsprovidesaglossaryoftermsthatmightbeunfamiliartoyou.Fordefinitions
oftermsastheyareusedinVMwaretechnicaldocumentationgotohttp://www.vmware.com/support/pubs.
Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Sendyourfeedbackto
About This Book
Table 1. Revision History
Revision Date Description
08MAR11 GuestCustomizationSectionnotallowedinInstantiationParams
30AUG10 Version1.0
vCloud API Programming Guide
12 VMware, Inc.
Technical Support and Education Resources
Thefollowingsectionsdescribethetechnicalsupportresourcesavailabletoyou.Toaccessthecurrentversions
ofotherVMwarebooks,gotohttp://www.vmware.com/support/pubs.
Online and Telephone Support
Touseonlinesupporttosubmittechnicalsupportrequests,viewyourproductandcontractinformation,and
registeryourproducts,gotohttp://www.vmware.com/support.
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto
http://www.vmware.com/support/services.
VMware Professional Services
VMwareEducationServicescoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerials
designedtobeusedasonthejobreferencetools.Coursesareavailableonsite,intheclassroom,andlive
online.Foronsitepilotprograms andimplementationbestpractices,VMwareConsultingServicesprovides
offeringsto helpyouassess,plan,
build,andmanageyourvirtualenvironment.Toaccessinformationabout
educationclasses,certificationprograms,andconsultingservices,gotohttp://www.vmware.com/services.
VMware, Inc. 13
1
TheVMwarevCloudAPIprovidessupportfordeveloperswhoarebuildinginteractiveclientsofVMware
CloudDirectorusingaRESTfulapplicationdevelopmentstyle.vCloudAPIclientsandserverscommunicate
overHTTP,exchangingrepresentationsofvCloudobjects.TheserepresentationstaketheformofXML
elements.HTTPGETrequestsareusedtoretrieve
thecurrentrepresentationofanobject,HTTPPOSTand
PUTrequestsareusedtocreateormodifyanobject,andHTTPDELETErequestsaretypicallyusedtodelete
anobject.
ThischapterintroducesthevCloudAPIandincludesthefollowingtopics:
“vCloudObjectTaxonomy”onpage 13
“Objects,References,andRepresentations”onpage 15
“LinksandLinkRelations”onpage 15
“vCloudClientWorkflowOverviewonpage 17
“A b o u t theExamples”onpage 19
vCloud Object Taxonomy
ThevCloudAPIdefinesasetofobjectscommontocloudcomputingenvironments.Figure 11illustratesthe
principalobjecttypes.
vCloud Organizations
AvCloudcontainsoneormoreorganizations.AvCloudorganizationisaunitofadministrationfora
collectionofusers,groups,andcomputingresources.Usersauthenticateattheorganizationlevel,supplying
credentialsestablishedbyanorganizationadministratorwhentheuserwascreatedorimported.
vCloud Users and Groups
Anorganizationcancontainanarbitrarynumberofusersandgroups.Userscanbecreatedbythe
organizationadministratororimportedfromadirectoryservicesuchasLDAP.Groupsmustbeimported
fromthedirectoryservice.Permissionswithinanorganizationarecontrolledthroughtheassignmentofrights
androlestousers
andgroups.
vCloud Networks
Anorganizationcanbeprovisionedwithoneormorenetworks.Theseorganizationnetworkscanbe
configuredtoprovideservicessuchasDHCP,NAT,andfirewalls.
Introducing the VMware vCloud API
1
vCloud API Programming Guide
14 VMware, Inc.
Figure 1-1. vCloud Object Taxonomy
vCloud Virtual Datacenters
AvCloudvirtualdatacenter(vDC)isanallocationmechanismforresourcessuchasnetworks,storage,CPU,
andmemory.InavDC,computingresourcesarefullyvirtualized,andcanbeallocatedbasedondemand,
servicelevelrequirements,oracombinationofthetwo.
TherearetwokindsofvDCs:
ProvidervDCs.ThesevDCscontainalltheresourcesavailablefromthevCloudserviceprovider.
ProvidervDCsarecreatedandmanagedbyvCloudsystemadministrators.
OrganizationvDCs.ThesevDCsprovideanenvironmentwherevirtualsystemscanbestored,deployed,
andoperated.Theyalsoprovidestorageforvirtualmedia,suchasfloppydisksandCDROMs.
AnorganizationadministratorspecifieshowresourcesfromaprovidervDCaredistributedtothevDCsinan
organization.
vCloud Catalogs
Catalogscontainreferencestovirtualsystemsandmediaimages.Acatalogcanbesharedtomakeitvisibleto
othermembersofanorganization,andcanbepublishedtomakeitvisibletootherorganizations.AvCloud
systemadministratorspecifieswhichorganizationscanpublishcatalogs,andanorganizationadministrator
controlsaccess
tocatalogsbyorganizationmembers.
vCloud Tasks
Longrunningoperationsinitiatedbymembersofanorganizationcreatetasks,whicharekeptonthe
organization’staskslist.
Catalog 2
Catalogitem
em
em
em
Catalog 1
Catalog 3
vDC2
Catalogitem
Catalogitem
Catalogitem
Catalogitem
users
Media
vApp
template
Media
vApp
TasksList
Organization
vDC1
Media
vApp
template
Media
vApp
Network
Network
Catalogitem
em
em
em
groups
VMware, Inc. 15
Chapter 1 Introducing the VMware vCloud API
Virtual Systems and Media Images in a vCloud
VirtualsystemsandmediaimagesarestoredinavDCandcanbeincludedinacatalog.Mediaimagesare
storedintheirnativerepresentation(ISOorfloppy).Virtualsystemsarestoredastemplates,usinganopen
standardformat(OVF1.0).Thesetemplatescanberetrievedfromcatalogsandtransformedinto
virtual
systems,calledvApps,throughaprocesscalledinstantiation,whichbindsatemplate’sabstractresource
requirementstoresourcesavailableinavDC.AvAppcontainsoneormoreindividualvirtualmachines(Vm
elements),alongwithparametersthatdefineoperationaldetailssuchas:
Howthecontainedvirtualmachinesareconnectedtoeachotherandtoexternalnetworks.
Theorderinwhichindividualvirtualmachinesarepoweredonoroff.
Enduserlicenseagreementtermsforeachvirtualmachine.
Deploymentleaseterms(typicallyinheritedfromthecontainingorganization)thatconstrainthevApp’s
consumptionofvDCresources
Accesscontrolinformationspecifyingwhichusersandgroupscanperformoperationssuchasdeploy,
poweron,modify,andsuspendonthevAppandthevirtualmachinesitcontains.
Objects, References, and Representations
ThevCloudAPIrepresentsobjectsinthevCloudasXMLdocumentsinwhichobjectpropertiesareencoded
aselementsandattributeswithtypedvaluesandanexplicitobjecthierarchydefinedbyanXMLschema.
EveryobjectinavCloudisuniquelyidentifiedbyaURL.ThisURLisconstructedbythe
serverandreturned
inthevalueofthehrefattributeoftheXMLelementthatrepresentstheobject.Italsoappearsinvarious
elementsofLinkTypeandReferenceType.ThisURLservesasauniqueidentifierthatpersistsforthelifeof
theobjectandisneverreused.AlthoughURLs
haveawellknownsyntaxandawellunderstood
interpretation,aclientshouldtreateachhrefasanopaquestring.Therulesthatgovernconstructionofhref
stringsbytheservermightchangeinfuturereleases.
Objecttypes,specifiedasMIMEcontenttypes,areincludedintheXMLrepresentationsoffirst
classobjects
suchastheonesshowninFigure 11.Formoreinformation,see“ContentTypeonpage 142.
Links and Link Relations
ThevCloudAPImakesextensiveuseoflinks(URLs)toprovidereferencestoobjectsandtheactionsthatthey
support.Theselinksaretheprimarymechanismbywhichaservertellsaclienthowtoaccessandoperateon
anobject.Linksarecreatedbytheserver,andarereadonly
attheclient.(Ifaclientrequestbodyincludesa
link,theserverignoresit.)
IntheXMLrepresentationofavCloudobject,eachlinkisdefinedinaLinkelementthathasthefollowing
form:
<Link rel="
relationship
" type="application/vnd.vmware.vcloud.type+xml" href="
URL
" name="
string
"/>
TherelattributevaluedefinestherelationshipoftheobjectwhoseXMLrepresentationcontainstheLink
toatargetobject.TherelationshipalsoindicatestheHTTPrequesttypetousewhenmakingarequest
withthehrefattributeofthelink,asshowninTable 11:
Table 1-1. Link Relationships and HTTP Request Types
rel Attribute Value Relation Description HTTP Request
add addsanitemtothiscontainer POST
alternate alinktoanalternaterepresentationofthisobject GET
catalogItem alinktothecatalogItemthatcontainsareferencetothisobject. GET
controlAccess applyaccesscontrols POST
copy notsupportedinthisrelease N/A
deploy deploythisobject POST
vCloud API Programming Guide
16 VMware, Inc.
Thetypeattributevaluedefinesthemediatype(HTTPContentType)oftherequestorresponse
document.Thisattributeispresentonlyforlinkstoobjects.Itisnotpresentforlinkstoactions.
ThehrefattributevalueisaURL,whichshouldbeconsideredanopaqueidentifier(onethattheclient
shouldnotattempttoparseorinterpret).Anhrefuniquelyidentifies,andpersistsforthelifeof,the
referencedobject.Theseidentifiersareneverreused.
ThenameattributevalueoftheLinkisthesameasthenameofthereferencedobject.Actionlinksdonot
includeanameattribute.
disable disablethisobject POST
discardState discardthesuspendedstateofthisvirtualmachine POST
down thereferencedobjectiscontainedbythisobject GET
download:alternate notsupportedinthisrelease N/A
download:default defaultdownloadlocationforthisfile GET
edit modifiesthisobject PUT
enable enablethisobject POST
extension notsupportedinthisrelease N/A
media:ejectMedia ejectvirtualmediafromavirtualdevice POST
media:insertMedia insertvirtualmediainavirtualdevice POST
move not
supportedinthisrelease N/A
ova notsupportedinthisrelease N/A
ovf theOVFrepresentationofthisvAppTemplate GET
power:powerOff poweroffthereferencedobject POST
power:powerOn poweronthisobject POST
power:reboot rebootthisobject POST
power:reset resetthisobject POST
power:shutdown shutdownthisobject POST
power:suspend suspendthisobject POST
publish publishthiscatalog POST
recompose recomposethisvApp POST
reconnect reconnectthisvCenterServer POST
register registerthisvCenterServer POST
remove removethisobject DELETE
repair repairthishost POST
screen:acquireTicket acquire
ascreenticketforthisvirtualmachine GET
screen:thumbnail thumbnailviewofavirtualmachinescreen,inpngformat GET
task:cancel notsupportedinthisrelease N/A
undeploy undeploythisobject POST
unregister unregisterthisvCenterServer POST
up thereferencedobjectcontainsthisobject GET
upgrade upgradethishost POST
upload:alternate notsupportedinthisrelease N/A
upload:default defaultuploadlocationforthisfile PUT
Table 1-1. Link Relationships and HTTP Request Types (Continued)
rel Attribute Value Relation Description HTTP Request
VMware, Inc. 17
Chapter 1 Introducing the VMware vCloud API
Linksprovideawayfortheservertoinformaclientaboutobjectrelationshipsandtheoperationsthatobjects
support.Forexample,acontainersuchasanorganizationorcatalogcanreturnlinkstotheobjectsitcontains,
andavirtualsystem(avApporVm)cancontainactionlinks
thatenableoperationssuchaspowerstatechanges
orvirtualdevicereconfiguration.Linkstoactionsandcontainedobjectsareomittedfromresponsesifthe
requestwasmadebyauserwhohasinsufficientprivilegestoaccesstheobjectorperformtheaction.Action
linksarealsoomittedwhentheactioncannot
beperformed(poweringonavirtualmachinethatisalready
poweredon,forexample).
vCloud Client Workflow Overview
ClientsofthevCloudAPIimplementaRESTfulworkflow,makingHTTPrequeststotheserverandretrieving
theinformationtheyneedfromtheserversresponses.
Requests
ClientsmakeHTTPrequeststovCloudURLs,hrefattributevalueswhicharetypicallyprovidedbytheserver
inresponsetoGETrequestsbytheclient.EveryvCloudhasawellknownURLfromwhichaclientcangetthe
serversloginURLandthelistofvCloudAPIversionsthatthe
serversupports,alongwithadditional
information(see“AP I Versioning”onpage 147).Afteraclienthasloggedin,allvCloudAPIURLscanbe
discoveredbymakingGETrequeststoURLslistedintheloginresponseandtheURLscontainedinresponses
tothoserequests.
Request Headers
Allrequestsfromauthenticatedclientsmustincludeanauthenticationheader.SeeAuthentication”on
page 18.
RequeststhatincludeadocumentbodymuststartwiththeappropriateHTTPContentTypeheader.Thetype
attributeofaresponsebodyindicatesthecontenttypeofthedocument.Forexample,thisresponsefragment
indicatesthatthe
contenttypeassociatedwithaCatalogItem entityis
application/vnd.vmware.vcloud.catalogItem+xml.
<CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
href="http://vcloud.example.com/api/v1.0/catalogItem/221" name="Ubuntu Template with
vsftpd"/>
AnyrequestthatincludesaCatalogItemrequiresthefollowingContentTypeheader:
Content-Type: application/vnd.vmware.vcloud.catalogItem+xml
Whenitappearsas thevalueofaContentTypeheaderorthetypeattributeofanelementinthevCloudAPI,
thisstringiscaseinsensitiveinrequests,andcanbereturnedineithermixedcaseorlowercasecharactersin
responses.
Formoreinformation,see“ContentTypeonpage 142.
Request Bodies
ThisreleaseofCloudDirectorusesavalidatingXMLparserthatrequireselementsinarequestbodytoagree
inbothorderandnumberwiththeschema.Requestbodiesarerejectedasinvalidunlesstheymeetthe
followingcriteria:
XMLnamespaceattributesmustbesuppliedforallnamespacesrepresentedbyelementsintherequest.
See“XMLNamespaceIdentifiers”onpage 145.
Ifmultiplenamespacesarerepresentedintherequest,XMLnamespaceattributesmustincludean
identifyingprefix,andthatprefixmustbeusedwithelementsfromthatnamespace.See“XML
NamespacePrefixesinRequestandResponseBodies”onpage 146.
N
OTEWhenaclientusesalinktoreferenceanobject,onlythehrefattributeisrequired.Thenameandtype
areignored.
vCloud API Programming Guide
18 VMware, Inc.
Allrequiredelementsmustappearinrequestbodies.Allelementsthatappearinrequestbodiesmust
appearintheorderestablishedbytheschema,andwithcontentthatconformstothetypeconstraint
specifiedintheschema.See“SchemaValidationonpage 142.
Authentication
HTTPcommunicationsbetweenavCloudclientandserveraretypicallysecuredwithSSL.Inaddition,the
vCloudAPIimplementsBasicHTTPAuthentication,asdefinedbyRFC2617,whichenablesaclienttoobtain
atokenthatitcanusetoauthenticateindividualHTTPrequests.
Toobtainanduseanauthenticationtoken,
aclientmustfirstdiscovertheserversloginURL,andthenPOST
aloginrequesttothatURL,supplyingthecredentialsofanauthorizeduser.
To obtain and use an authentication token
1MakeanAPIversionrequesttoavCloudservicetoobtaintheloginURLforthatservice.Formore
information,see“A P I Versioningonpage 147.
2Make
anHTTPPOSTrequesttotheloginURL,asshowninExample 21onpage 21.
Iftheauthenticationheaderismissing,theserverreturnsHTTPresponsecode401.
Ifthecredentialssuppliedintheauthenticationheaderareinvalid,theserverreturnsHTTPresponse
code401.
Iftherequestissuccessful,theserverreturnsHTTPresponsecode200(OK)andheadersthatinclude
anauthorizationheaderoftheform:
x-vcloud-authorization:
token
ThisheadermustbeincludedineachsubsequentvCloudAPIrequest.
TheresponsebodyisanOrgListelement,whichisalistofallorganizationsthattheusercanaccess.
Theauthenticationtokenexpiresafteraconfigurableintervalofclientinactivity.Thedefaultis30minutesafter
thetokeniscreated.After
thetokenexpires,allrequestsfailwithHTTPresponsecode401untiltheclientlogs
inagaintoobtainanewtoken.
Responses
AllresponsesincludeanHTTPstatuscodeand,unlessthestatuscodeis204(NoContent),aContentType
header.Responsecontentdependsontherequest.Someresponsesincludeadocumentbody,someinclude
onlyaURL,andsomeareempty.
Status Codes
Table 12liststhesubsetofHTTPstatuscodesthatavCloudAPIclientcanexpectinaresponse.
N
OTECertainadministrativeoperationshavespecialauthenticationrequirements.Formoreinformation,see
AdministratorCredentialsandPrivileges”onpage 93.
Table 1-2. HTTP Status Codes Returned by the vCloud API
Status Code Status Description
200OK Therequestisvalidandwascompleted.Theresponseincludesadocumentbody.
201Created Therequestisvalid.TherequestedobjectwascreatedandcanbefoundattheURLspecifiedin
theLocationheader.
202Accepted Therequestisvalidandataskwascreatedtohandleit.Thisresponse
isusuallyaccompanied
byataskURL.
204NoContent Therequestisvalidandwascompleted.Theresponsedoesnotincludeabody.
303SeeOther TheresponsetotherequestcanbefoundattheURLspecifiedintheLocationheader .
400BadRequest Therequestbodyismalformed,incomplete,or
otherwiseinvalid.
VMware, Inc. 19
Chapter 1 Introducing the VMware vCloud API
Configuring the vCloud API URL
ThebaseURLusedinhrefvaluesincludesthefullyqualifieddomainnameoftheserverhost.Incaseswhere
thishostnamecannotberesolvedfromtheclient(forexample,iftheCloudDirectorinstallationincludes
multipleserverhoststhatyouaccessthroughaloadbalancer)youcanspecifyaURL
fortheservertousewhen
constructinghrefstrings.Formoreinformation,seeConfiguretheExternalRESTAPIBaseURIintheCloud
DirectorAdministratorʹsGuide.
Related Publications
TheVMwareCloudDirectorAdministratorʹsGuideandVMwareCloudDirectorUser’sGuidecontaindetailed
informationaboutmanyoftheobjectsandoperationsreferredtointhisguide.MostusersofthevCloudAPI
willfindtheinformationinthosedocumentsvaluablewhendevelopingclientapplications.Toaccessthe
currentversions
oftheseandotherVMwarebooks,gotohttp://www.vmware.com/support/pubs.
About the Examples
ThisguideincludesmanyexamplesofHTTPrequestsandresponses.Theseexamplesareintendedtoshow
theworkflowandcontentassociatedwithspecifictypesofoperationssuchasbrowsing,managinginventory,
andoperatingvirtualsystems.Examplerequestsgenerallyconformtotheruleslistedin“RequestBodies”on
page 17.Mostexampleresponses
showonlythoseelementsandattributesthatarerelevanttotheoperation
beingdiscussed.Ellipses(…)indicateomittedcontentwithinresponsebodies.
HTTPContentTypeheadersareshownwhereneededforallexamplesthatarenotfragmentsofsomelarger
examplethatincludesthisheader.Althoughtheexamplesshowthesestrings
usingthecharactercaseinwhich
theyaredefinedbytheimplementation,thesestringsarecaseinsensitiveinrequests,andcanbereturnedin
eithermixedcaseorlowercasecharactersinresponses.OtherHTTPheaders,suchasDate,ContentLength,
andServer,areomittedbecausetheyarenotrelevantto
thespecificsofanyexample.TheXMLversionand
encodingheader(<?xml version="1.0" encoding="UTF-8"?>)isnotincludedinmostexamples,although
itisarequiredpartofallrequestsandresponsesthatcontainanXMLbody.
Inaddition:
UnsecuredURLs(http://)areusedintheexamples.Inpractice,mostsiteswillrequiretheuseofSSL
(https://).
ObjectIDsshowninhrefattributevaluesappearassmallintegers(forexamplevapp-7ororg/3).Inthe
vCloudAPIsupportedbyCloudDirector,objectIDsare10digitdecimalintegers(forexample
vapp-124237959ororg/5738592905).
401Unauthorized Anauthorizationheaderwasexpectedbutnotfound.
403Forbidden Therequestinguserdoesnothaveadequateprivilegestoaccessoneormoreobjectsspecified
intherequest.
404NotFound Oneormoreobjectsspecifiedintherequestcouldnotbefoundinthespecifiedcontainer.
405MethodNot
Allowed
TheHTTP
methodspecifiedintherequestisnotsupportedforthisobject.
500InternalServer
Error
Therequestwasreceivedbutcouldnotbecompletedduetoaninternalerrorattheserver.
501NotImplemented Therequestisnotimplementedbytheserver.
503Service
Unavailable
Oneormoreservicesneededto
completetherequestarenotavailableontheserver.
Table 1-2. HTTP Status Codes Returned by the vCloud API (Continued)
Status Code Status Description
vCloud API Programming Guide
20 VMware, Inc.
/