Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • OpenStack
  • Rackspace

Functions

  • __raxsdk_timezone_set
  • define_gettext
  • noslash
  • setDebug
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * The Rackspace cloud/connection class (which uses different authentication
  4:  * than the pure OpenStack class)
  5:  *
  6:  * @copyright 2012-2013 Rackspace Hosting, Inc.
  7:  * See COPYING for licensing information
  8:  *
  9:  * @package phpOpenCloud
 10:  * @version 1.0
 11:  * @author Glen Campbell <glen.campbell@rackspace.com>
 12:  */
 13: 
 14: namespace OpenCloud;
 15: 
 16: /**
 17:  * Rackspace extends the OpenStack class with support for Rackspace's
 18:  * API key and tenant requirements.
 19:  *
 20:  * The only difference between Rackspace and OpenStack is that the
 21:  * Rackspace class generates credentials using the username
 22:  * and API key, as required by the Rackspace authentication
 23:  * service.
 24:  *
 25:  * Example:
 26:  * <code>
 27:  * $username = 'FRED';
 28:  * $apiKey = '0900af093093788912388fc09dde090ffee09';
 29:  * $conn = new Rackspace(
 30:  *      'https://identity.api.rackspacecloud.com/v2.0/',
 31:  *      array(
 32:  *          'username' => $username,
 33:  *          'apiKey' => $apiKey
 34:  *      ));
 35:  * </code>
 36:  */
 37: class Rackspace extends OpenStack
 38: {
 39: 
 40:     //this is the JSON string for our new credentials
 41: const APIKEYTEMPLATE = <<<ENDCRED
 42: { "auth": { "RAX-KSKEY:apiKeyCredentials": { "username": "%s",
 43:           "apiKey": "%s"
 44:         }
 45:     }
 46: }
 47: ENDCRED;
 48: 
 49:     /**
 50:      * Generates Rackspace API key credentials
 51:      *
 52:      * @return string
 53:      */
 54:     public function Credentials()
 55:     {
 56:         $sec = $this->Secret();
 57:         if (isset($sec['username'])
 58:             && isset($sec['apiKey'])
 59:         ) {
 60:             return sprintf(
 61:                 self::APIKEYTEMPLATE,
 62:                 $sec['username'],
 63:                 $sec['apiKey']
 64:            );
 65:         } else {
 66:             return parent::Credentials();
 67:         }
 68:     }
 69: 
 70:     /**
 71:      * Creates a new DbService (Database as a Service) object
 72:      *
 73:      * This is a factory method that is Rackspace-only (NOT part of OpenStack).
 74:      *
 75:      * @param string $name the name of the service (e.g., 'Cloud Databases')
 76:      * @param string $region the region (e.g., 'DFW')
 77:      * @param string $urltype the type of URL (e.g., 'publicURL');
 78:      */
 79:     public function DbService($name = null, $region = null, $urltype = null)
 80:     {
 81:         return $this->Service('Database', $name, $region, $urltype);
 82:     }
 83: 
 84:     /**
 85:      * Creates a new LoadBalancerService object
 86:      *
 87:      * This is a factory method that is Rackspace-only (NOT part of OpenStack).
 88:      *
 89:      * @param string $name the name of the service
 90:      *      (e.g., 'Cloud Load Balancers')
 91:      * @param string $region the region (e.g., 'DFW')
 92:      * @param string $urltype the type of URL (e.g., 'publicURL');
 93:      */
 94:     public function LoadBalancerService($name = null, $region = null, $urltype = null)
 95:     {
 96:         return $this->Service('LoadBalancer', $name, $region, $urltype);
 97:     }
 98: 
 99:     /**
100:      * creates a new DNS service object
101:      *
102:      * This is a factory method that is currently Rackspace-only
103:      * (not available via the OpenStack class)
104:      */
105:     public function DNS($name = null, $region = null, $urltype = null)
106:     {
107:         return $this->Service('DNS', $name, $region, $urltype);
108:     }
109: 
110:     /**
111:      * creates a new CloudMonitoring service object
112:      *
113:      * This is a factory method that is currently Rackspace-only
114:      * (not available via the OpenStack class)
115:      */
116:     public function CloudMonitoring($name=null, $region=null, $urltype=null)
117:     {
118:         return $this->Service('CloudMonitoring', $name, $region, $urltype);
119:     }
120: 
121:     /**
122:      * creates a new Autoscale service object
123:      *
124:      * This is a factory method that is currently Rackspace-only
125:      * (not available via the OpenStack class)
126:      */
127:     public function Autoscale($name=null, $region=null, $urltype=null)
128:     {
129:         return $this->Service('Autoscale', $name, $region, $urltype);
130:     }
131: 
132: }
133: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0