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

  • Resource
  • Service
  • Stack
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: /**
  3:  * Defines an OpenStack Heat Stack
  4:  *
  5:  * @copyright 2012-2013 Rackspace Hosting, Inc.
  6:  * See COPYING for licensing information
  7:  *
  8:  * @package phpOpenCloud
  9:  * @version 1.0
 10:  * @author Glen Campbell <glen.campbell@rackspace.com>
 11:  * @author Stephen Sugden <openstack@stephensugden.com>
 12:  * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
 13:  */
 14: 
 15: namespace OpenCloud\Orchestration;
 16: 
 17: use OpenCloud\AbstractClass\PersistentObject;
 18: use OpenCloud\Exceptions\CreateError;
 19: 
 20: /**
 21:  * The Stack class requires a CloudFormation template and may contain additional
 22:  * parameters for that template.
 23:  *
 24:  * A Stack is always associated with an (Orchestration) Service.
 25:  * 
 26:  * @codeCoverageIgnore
 27:  */
 28: class Stack extends PersistentObject 
 29: {
 30:     /**
 31:      * Identifier of stack.
 32:      * 
 33:      * @var string 
 34:      */
 35:     protected $id;
 36:     
 37:     /**
 38:      * The name associated with the stack. Must be unique within your account, 
 39:      * contain only alphanumeric characters (case sensitive) and start with an 
 40:      * alpha character. Maximum length of the name is 255 characters.
 41:      * 
 42:      * @var string 
 43:      */
 44:     protected $stack_name;
 45:     
 46:     /**
 47:      * A list of Parameter structures that specify input parameters for the stack.
 48:      * 
 49:      * @var mixed 
 50:      */
 51:     protected $parameters;
 52:     
 53:     /**
 54:      * Structure containing the template body.
 55:      * 
 56:      * @var string
 57:      */
 58:     protected $template;
 59:     
 60:     /**
 61:      * Set to true to disable rollback of the stack if stack creation failed.
 62:      * 
 63:      * @var bool 
 64:      */
 65:     protected $disable_rollback;
 66:     
 67:     /**
 68:      * Description of stack.
 69:      * 
 70:      * @var string 
 71:      */
 72:     protected $description;
 73:     
 74:     /**
 75:      * @var type 
 76:      */
 77:     protected $stack_status_reason;
 78:     
 79:     /**
 80:      * @var type 
 81:      */
 82:     protected $outputs;
 83:     
 84:     /**
 85:      * @var type 
 86:      */
 87:     protected $creation_time;
 88:     
 89:     /**
 90:      * Array of stack lists.
 91:      * 
 92:      * @var array 
 93:      */
 94:     protected $links;
 95:     
 96:     /**
 97:      * The list of capabilities that you want to allow in the stack.
 98:      * 
 99:      * @var mixed 
100:      */
101:     protected $capabilities;
102:     
103:     /**
104:      * The Simple Notification Service topic ARNs to publish stack related events.
105:      * 
106:      * @var mixed 
107:      */
108:     protected $notification_topics;
109:     
110:     /**
111:      * The amount of time that can pass before the stack status becomes 
112:      * CREATE_FAILED; if DisableRollback is not set or is set to false, the 
113:      * stack will be rolled back.
114:      * 
115:      * @var string 
116:      */
117:     protected $timeout_mins;
118:     
119:     /**
120:      * @var type
121:      */
122:     protected $stack_status;
123:     
124:     /**
125:      * @var type
126:      */
127:     protected $updated_time;
128:     
129:     /**
130:      * @var type
131:      */
132:     protected $template_description;
133:     
134:     protected static $json_name = "stack";
135:     protected static $url_resource = "stacks";
136:     protected $createKeys = array(
137:         'template', 
138:         'stack_name'
139:     );
140: 
141:     /**
142:      * {@inheritDoc}
143:      */
144:     protected function createJson() 
145:     {
146:         $pk = $this->primaryKeyField();
147:         
148:         if (!empty($this->{$pk})) {
149:             throw new CreateError(sprintf(
150:                 'Stack is already created and has ID of %s',
151:                 $this->$pk
152:             ));
153:         }
154: 
155:         $object = (object) array('disable_rollback' => false, 'timeout_mins' => 60);
156: 
157:         foreach ($this->createKeys as $property) {
158:             if (empty($this->$property)) {
159:                 throw new CreateError(sprintf(
160:                     'Cannot create Stack with null %s', 
161:                     $property
162:                 ));
163:             } else {
164:                 $object->$property = $this->$property;
165:             }
166:         }
167:         
168:         if (null !== $this->parameters) {
169:             $object->parameters = $this->parameters;
170:         }
171:         
172:         return $object;
173:     }
174: 
175:     public function name() 
176:     {
177:         return $this->stack_name;
178:     }
179: 
180:     public function status() 
181:     {
182:         return $this->stack_status;
183:     }
184: 
185:     public function resource($id = null) 
186:     {
187:         $resource = new Resource($this->getService());
188:         $resource->setParent($this);
189:         $resource->populate($id);
190:         return $resource;
191:     }
192: 
193:     public function resources() 
194:     {
195:         return $this->getService()->collection(
196:             'OpenCloud\Orchestration\Resource', 
197:             $this->url('resources'), 
198:             $this
199:         );
200:     }
201: }
202: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0