RackspaceCloudSDKforPHP Getting Started Guide RackspaceCloudSDKforPHP is an SDK that helps PHP developers develop applications based on OpenStack and Rackspace (including public and private clouds) more conveniently. This SDK includes the following components: 1. php-o... "/> <scripttype = Rackspace Cloud SDK for PHP getting started Rackspace Cloud SDK for PHP is a Cloud (including public and private clouds) developed based on OpenStack and Rackspace for PHP developers more conveniently) the application SDK. This SDK includes the following components: 1. php-opencloud language binding (under the "lib" directory) 2. document (in the "docs/" directory) 3. sample code (in the "samples/" directory) how to install the SDK can be obtained through the Rackspace GitHub source. Stable version of the code: 1. click the Tags link 2. select the latest version, click the next step, and click "zipzip ".tar.gz". 3. find the file you just downloaded in your download directory. Remember the directory location and you will use it later. In this example, you will write code to create two 1 gb ecs instances running Ubuntu13.04. You need a text editor to edit the following code. The complete code is as follows: 'Username', 'password' => 'password'); // Connect to compute service $ compute = $ connection-> Compute ('cloudserversopenstack', 'ord '); // find the image $ Image = $ compute-> image (IMAGE_UBUNTU); // Obtain flavor object $ flavor = $ compute-> Flavor (FLAVOR_1GB ); // Create a server for ($ I = 0; $ I <2; $ I ++) {$ Server = $ compute-> server (); // get a blank server $ resp = $ server-> Create (array ('name' => sprintf ('server-% d', $ I ), 'image' => $ image, 'flavor' => $ flavor); // Check if ($ resp-> HttpStatus ()> 204) die ("Errorbuilding server. response is ". $ resp-> HttpBody (); // display the root password printf ("Server [% s] is building. root password is [% s] \ n ", $ server-> Name (), $ server-> adminPass);} understand this program 'Username', 'password' => 'password'). In this way, a '$ connection' object is created using' \ OpenCloud \ Rackspace 'connector. This object requires two parameters: 1. authentication endpoint URL ('rackspace _ us' is a useful constant provided by ** php-opencloud ). 2. an array containing your username and password. Edit the value of ''username''' to map your USERNAME and PASSWORD. // Now, connect to compute service $ compute = $ connection-> Compute ('cloudserversopenstack', 'ord '); create a "Compute" class, connection to the specified service strength in ORD region (in this case, the service is named "cloudServersOpenStack"), Compute () method returns a new connection to the service. // First, find the image $ image = $ compute-> Image (IMAGE_UBUNTU); // get a flavor object $ flavor = $ compute-> Flavor (FLAVOR_1GB ); this is the other two factory methods that return an "Image" object and a "Flavor" object respectively. // Create the server for ($ I = 0; $ I <2; $ I ++) {$ server = $ compute-> Server (); // get a blank server $ resp = $ server-> Create (array ('name' => sprintf ('server-% d', $ I ), 'image' => $ image, 'flavor' => $ flavor); // check for errors if ($ resp-> HttpStatus ()> 204) die ("Errorbuilding server. response is ". $ resp-> HttpBody (); // display the root password printf ("Server [% s] is building. root password is [% s] \ n ", $ se Rver-> Name (), $ server-> adminPass);} this actually creates a server. A new empty Server object is created from the "$ compute" service using the "Server ()" method. Finally, the "Server" object calls the "Create" method and must pass an attribute array as the parameter. 'Name', 'Image', and 'flavor' are required to create a new server.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service