VMware VCLOUD SDK 1.0 - FOR PHP DEVELOPERS GUIDE Manual

Vcloud sdk for php developer’s guide
Hide thumbs Also See for VCLOUD SDK 1.0 - FOR PHP DEVELOPERS GUIDE:

Advertisement

Quick Links

vCloud SDK for PHP Developer's Guide
VMware vCloud SDK 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-000363-00

Advertisement

Table of Contents
loading

Summary of Contents for VMware VCLOUD SDK 1.0 - FOR PHP DEVELOPERS GUIDE

  • Page 1 SDK for PHP Developer’s Guide VMware vCloud SDK 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.
  • Page 2 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.
  • Page 3: Table Of Contents

    Contents About This Book 5 About the vCloud SDK for PHP 7 vCloud Object Taxonomy 7 vCloud Organizations 7 vCloud SDK for PHP Design 9 Creating a Data Object 10 Creating an SDK Object 10 Using a Different HTTP Library 12 Using the HTML Reference Material 12 Setting Up for PHP Development 13 Prerequisites 13 Download and Install the vCloud SDK for PHP 14 Hello vCloud: A Structured Workflow Example 15 Using the Example Programs 17 Configuring a Runtime Environment for the Examples 17 Running the Examples 17 Index 19 VMware, Inc.
  • Page 4 SDK for PHP Developer’s Guide VMware, Inc.
  • Page 5: About This Book

    Revision History This guide is revised with each release of the product or when necessary. A revised version can contain minor  or major changes. Table 1 summarizes the significant changes in each version of this guide. Table 1. Revision History Revision Description 01NOV10 Version 1.0. Amendments and minor corrections to Beta content. 31AUG10 Version 1.0 (Beta) Intended Audience This guide is intended for software developers who are building vCloud API applications, including  interactive clients of VMware Cloud Director. This guide assumes you are familiar with the PHP  programming language, Representational State Transfer (REST) and RESTful programming conventions, the  Open Virtualization Format Specification (OVFS), and VMware virtual machine technology. Familiarity with  other technologies such as XML, HTTP, and the Windows or Linux operating systems is also assumed. VMware Technical Publications Glossary VMware Technical Publications provides a glossary of terms that might be unfamiliar to you. For definitions  of terms as they are used in VMware technical documentation go to http://www.vmware.com/support/pubs. Document Feedback VMware welcomes your suggestions for improving our documentation. Send your feedback to  docfeedback@vmware.com. Technical Support and Education Resources The following sections describe the technical support resources available to you. To access the current versions  of other VMware books, go to http://www.vmware.com/support/pubs. VMware, Inc.
  • Page 6 SDK for PHP Developer’s Guide Online and Telephone Support To use online support to submit technical support requests, view your product and contract information, and  register your products, go to http://communities.vmware.com/community/developer. Support Offerings To find out how VMware support offerings can help meet your business needs, go to  http://www.vmware.com/support/services. VMware Professional Services VMware Education Services courses offer extensive hands‐on labs, case study examples, and course materials  designed to be used as on‐the‐job reference tools. Courses are available onsite, in the classroom, and live  online. For onsite pilot programs and implementation best practices, VMware Consulting Services provides  offerings to help you assess, plan, build, and manage your virtual environment. To access information about  education classes, certification programs, and consulting services, go to http://www.vmware.com/services.  VMware, Inc.
  • Page 7: About The Vcloud Sdk For Php

    PUT requests are used to create or modify an object, and HTTP DELETE requests are typically used to delete  an object. The vCloud SDK for PHP is a PHP language binding for the vCloud API. It provides a PHP class library and  a set of example applications. The classes and functions in the library encapsulate the interfaces, objects, and  operations that the vCloud API supports, while preserving its RESTful approach and compatibility with the  HTTP protocol family. This vCloud SDK for PHP Developer’s Guide provides information about setting up the SDK in a development  environment, and information about running the example applications included in the SDK. This chapter includes the following topics:  “vCloud Object Taxonomy” on page 7  “vCloud SDK for PHP Design” on page 9 vCloud Object Taxonomy The vCloud SDK for PHP defines a set of objects common to cloud computing environments. Figure 1‐1 shows  the principal object types. vCloud Organizations A vCloud contains one or more organizations. A vCloud organization is a unit of administration for a  collection of users, groups, and computing resources. Users authenticate at the organization level, supplying  credentials established by an organization administrator when the user was created or imported. vCloud Users and Groups An organization can contain an arbitrary number of users and groups. Users can be created by the  organization administrator or imported from a directory service such as LDAP. Groups must be imported  from the directory service. Permissions within an organization are controlled through the assignment of rights  and roles to users and groups. vCloud Networks An organization can be provisioned with one or more networks. These organization networks can be  configured to provide services such as DHCP, NAT, and firewalls. VMware, Inc.
  • Page 8 Catalogitem vApp vApp Catalogitem template Catalogitem Media Media Network users groups TasksList Network vCloud Virtual Datacenters A vCloud virtual datacenter (vDC) is an allocation mechanism for resources such as networks, storage, CPU,  and memory. In a vDC, computing resources are fully virtualized, and can be allocated based on demand,  service level requirements, or a combination of the two. There are two kinds of vDCs:  Provider vDCs. These vDCs contain all the resources available from the vCloud service provider.  Provider vDCs are created and managed by vCloud system administrators.   Organization vDCs. These vDCs provide an environment where virtual systems can be stored, deployed,  and operated. They also provide storage for virtual media, such as floppy disks and CD ROMs. An organization administrator specifies how resources from a provider vDC are distributed to the vDCs in an  organization. vCloud Catalogs Catalogs contain references to virtual systems and media images. A catalog can be shared to make it visible to  other members of an organization, and can be published to make it visible to other organizations. A vCloud  system administrator specifies which organizations can publish catalogs, and an organization administrator  controls access to catalogs by organization members. vCloud Tasks Long‐running operations initiated by members of an organization create tasks, which are kept on the  organization’s tasks list. VMware, Inc.
  • Page 9: Vcloud Sdk For Php Design

    Package Name Package Contents VMware_VCloud_API Classes representing objects defined in the vCloud user  API and administrative API VMware_VCloud_API_OVF Classes representing objects defined in the OVF  specification VMware_VCloud_API_Extension Classes representing objects defined in the vCloud API  vSphere Platform Extensions VMware_VCloud_API_Version Classes representing objects that contain vCloud API  version information  SDK packages, listed in Table 1‐2. These packages contain classes that implement vCloud API operations.  Each of the classes maps to a vCloud resource entity. Classes manage the resource entity lifecycle (create,  retrieve, update, and delete, often abbreviated as CRUD). This package also implements various utility  functions associated with connecting to a vCloud instance, marshalling requests, unmarshalling  responses, and so on. Objects of these classes are referred to as vCloud SDK objects. Table 1-2. VMware_VCloud_SDK Packages Package Name Package Contents VMware_VCloud_SDK Classes that implement operations defined in the  vCloud user API and administrative API VMware_VCloud_SDK_Extension Classes that implement operations defined in the  vCloud API vSphere Platform Extensions VMware_VCloud_SDK_HTTP Classes that support HTTP client operations. VMware, Inc.
  • Page 10: Creating A Data Object

    // create an object that represents the first organization in the list $sdkOrg = $service->createSDKObj($orgRefs[0]); Table 1‐3 summarizes the types of SDK objects you can create and provides information to help you choose  the creation parameters (the container for the object, and a method to use). The table omits the  VMware_VCloud_SDK_ part of the package names in the SDK Object and Container Object columns.  To use the information in the table to create an SDK object Retrieve an array of object references by specifying a container object and a creation method. references Column2 Column3 -> For any reference in the array, create an SDK object using the selected reference. Column1 =$service->createSDKObj($ reference Example 1‐3 applies this formula to creating an Org object. VMware, Inc.
  • Page 11 Extension_VMWProviderVdc Extension getVMWProviderVdcRefs() ExternalNetwork Admin getExternalNetworkRefs() Group AdminOrg getGroupRefs() Media getMediaRefs() Network getOrgNetworkRefs() Service getOrgRefs(), getSystemOrgRef(),  getAdminSystemOrgRef() Role Admin getRoleRefs() Service None See “Creating Top‐Level Objects” on  page 12 User AdminOrg getUserRefs() VApp getVAppRefs() VApp VApp getContainedVAppRefs() VAppTemplate getVAppTemplateRefs() getVdcRefs() VApp getContainedVmRefs() VMware, Inc.
  • Page 12: Using A Different Http Library

    $sdkExtObj = $service->createSDKExtensionObj(); Using a Different HTTP Library Example programs included in the vCloud SDK for PHP require the PEAR HTTP_Request2 package. To use a  different HTTP library, create an HTTP client object that implements the  VMware_VCloud_SDK_Http_Client_Interface interface, and then can call the  VMware_VCloud_SDK_Service::getService() method specifying that client. $service = VMware_VCloud_SDK_Service::getService($myHTTPClient); Using the HTML Reference Material The reference documentation in the in the docs folder of the vCloud SDK for PHP download provides detailed  information on classes and functions.  To use the HTML documentation Open the docs folder in the download and open the file index.html in a browser. Select VMware_VCloud_API from the Packages drop‐down menu. Select a class (for example, VMware_VCloud_API_AdminOrgType) in the left‐hand pane. Go to the Method Summary section in the right‐hand pane and click the link for the __construct()  method. The method summary lists the constructors for required and optional attributes and elements of the class,  sorted by type. You can click the name of any element, then go to its method summary to get information  about its constructors. For example, VMware_VCloud_API_AdminOrgType requires a  VMware_VCloud_API_OrgSettingsType element. You can click the element name to see its method  summary, and click its __construct() method to see the details of how to construct it. VMware, Inc.
  • Page 13: Setting Up For Php Development

    Setting Up for PHP Development This chapter describes how to prepare for using the vCloud SDK for PHP, and how to download the SDK and  use it. This chapter includes the following topics:  “Prerequisites” on page 13  “Download and Install the vCloud SDK for PHP” on page 14 Prerequisites The vCloud SDK for PHP requires the following software to be installed on the computer where you install  the SDK:  PHP 5.3.1 or later.  The PEAR HTTP_Request2 package, version 0.5.1, available from  (http://pear.php.net/package/HTTP_Request2/download. This document and the SDK reference documentation assume that you are familiar with the PHP  programming language and have access to an installation of VMware vCloud Director. In addition, you should  consider the following:  Although the vCloud SDK for PHP reference documentation provides information about the vCloud API  XML schemas, which define the objects and operations that the SDK supports, familiarity with the details  of the underlying objects and operations, as described in the vCloud API Programming Guide, can help you  understand the structure of vCloud API objects, and how the methods in this SDK operate on those  objects.  Before you can run the examples, you must use the vCloud Director web console or the vCloud API to  create an organization, catalog, and vDC that the examples can use. The organization must have a user  account with rights to run the examples. The predefined CatalogAuthor role should provide all the  necessary rights. For more information about roles and rights, see the VMware Cloud Director  Administratorʹs Guide.  Several of the example programs require you to have an OVF package available on the client host. This  package must be uncompressed, and can specify one or more vmdk files. For more information about OVF,  see the vCloud API Programming Guide. VMware, Inc.
  • Page 14: Download And Install The Vcloud Sdk For Php

    You can download the vCloud SDK for PHP from the VMware website. The SDK is distributed as a  compressed archive in two forms.   vcloudPHP_1.0.0.build.tar.gz, a compressed archive in tar format, where build is a build number.  vcloudPHP_1.0.0.build.zip, a compressed archive in zip format. To download and install the vCloud SDK for PHP In a browser, go to http://www.vmware.com/go/vcloudsdkforphp. In the Resources area of the vCloud SDK for PHP Community page, click the Download button. On the Download page, log in with your VMware customer credentials. Review the license agreement. Click Yes to accept it and continue with the download, or click No to exit  without downloading. Choose a download option, then click the link for the distribution format you want. The vCloud SDK for  PHP is distributed as a compressed archive in two forms.   vcloudPHP_1.0.0.build.tar.gz, a compressed archive in tar format, where build is a build number.  vcloudPHP_1.0.0.build.zip, a compressed archive in zip format. When the download completes, uncompress the download package into any convenient folder on your  computer. Uncompressed, either archive requires about 32 MB of disk space. The package includes the  following folders:  docs: vCloud SDK for PHP reference documentation (vCloud SDK for PHP Reference Guide) in HTML  format.   library: A collection of class libraries and functions that encapsulate vCloud API objects and  operations.  samples: Example code demonstrating common use cases associated with programmatically  managing virtual infrastructure.  VMware, Inc.
  • Page 15: Hello Vcloud: A Structured Workflow Example

    --help To run the helloVCloud.php example, use the following command: php helloVCloud.php -s server user@vcloudOrganization password config =orgName =vdcName =catalogName =item =vAppName The following options are required:  server is the hostname or IP address of a vCloud Director server.  username is the name of a vCloud Director user, in the form user@vcloudOrganization, who has rights to  create and operate vApps.  password is the user’s password. The following options are optional:  config is a set of HTTP connection parameters in the form of a PHP array. If you omit this option,  helloVCloud.php accepts any server certificate. The following specification of config enables certificate  validation, using a certificate stored in /tmp/cert.crt: -c='ssl_verify_peer=>true, ssl_verify_host=>true, ssl_cafile=>/tmp/cert.crt'  orgName is the name of the organization to which the user is authenticating.  vdcName is the name of a vDC in that organization where the user can instantiate and deploy the vApp.  catalogName is the name of a catalog in the user’s organization. VMware, Inc.
  • Page 16 SDK for PHP Developer’s Guide  item is value of the name attribute of a CatalogItem element that references the vApp template you plan to  instantiate. This CatalogItem must be contained by the catalog specified by catalogName.  vAppName is the name to give to the vApp that this sample creates. All options but -s, -u, and -p must be separated from their arguments by an equals sign. For example: php helloVCloud.php -s vcloud.example.com -u user@exampleOrg -p Pa55w0rd -o=exampleOrg -d=exampleVdc -g=exampleCatalog -i=exampleTemplate -a=MyVapp You can use the vCloud Director Web Console or the vCloud REST API to find appropriate values in your  vCloud for orgName, vdcName, catalogName, and item. See the Cloud Director Userʹs Guide, or the chapter on  browsing in the vCloud API Programming Guide. VMware, Inc.
  • Page 17: Using The Example Programs

    This chapter includes the following topics:  “Configuring a Runtime Environment for the Examples” on page 17  “Running the Examples” on page 17 Configuring a Runtime Environment for the Examples The samples folder includes a file named config.php that provides values for parameters used in the  examples. These parameters include the credentials that the examples use for logging in, names for objects  such as catalogs and vDCs that the examples create, and other values that you are required to specify when  creating a vCloud API object. You must edit this file before you can run any of the examples. Some parameters  are initialized to a default value. Parameters that you are required to set are initialized with a place‐holder  value of please set. Comments in the file provide more information about the parameters and how to obtain  appropriate values for them. Running the Examples Some of the example programs require system administrator privileges to run. Others can be run by any user  who can create and operate a vApp. To run any of the examples Edit config.php to provide required parameter values. Run the example in a shell window using a command of the form, where example is the name of the  example program: example .php VMware, Inc.
  • Page 18 Uploads an OVF package to create a vApp template. Table 4‐2 lists the example programs that require system administrator privileges to run. Table 4-2. Example Programs That Require System Administrator Privileges Example Name Description addOrgNetwork.php Adds a network to an organization createAdminOrg.php Creates an organization createAdminVdc.php Creates a vDC extCreateExternalNetwork.php Creates an external network from vSphere resources extCreateNetworkPool_PG.php Creates a network pool from vSphere resources extCreateProviderVdc.php Creates a provider vDC from vSphere resources extDisableVimServer.php Disables a vCenter server registered for use with vCloud Director  extImportVmAsVApp.php Imports a virtual machine from vCenter to create a vApp in the  specified vDC extPrepareHost.php Prepares an ESX/ESXi host for use with vCloud Director extRegisterVimServer.php Registers a vCenter server for use with vCloud Director VMware, Inc.
  • Page 19: Index

    PEAR HTTP_Request2 package 13 PHP versions supported 13 sample programs privileges required to run 18 runtime environment for 17 sample programs, privileges required to run 18 SSL certificate validation 15 Tasks, about 8 technical support resources 5 vDC, about 8 VMware, Inc.
  • Page 20 SDK for PHP Developer’s Guide VMware, Inc.

This manual is also suitable for:

Vcloud sdk 1.0

Table of Contents