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 Stephen Sugden <openstack@stephensugden.com>
11:  */
12: 
13: namespace OpenCloud\Orchestration;
14: 
15: use OpenCloud\AbstractClass\PersistentObject;
16: 
17: /**
18:  * @codeCoverageIgnore
19:  */
20: class Resource extends PersistentObject 
21: {
22:     
23:     protected $links;
24:     protected $logical_resource_id;
25:     protected $physical_resource_id;
26:     protected $resource_status;
27:     protected $resource_status_reason;
28:     protected $resource_type;
29:     protected $updated_time;
30:     
31:     protected static $url_resource = 'resources';
32:     protected static $json_name = 'resource';
33: 
34:     public function create($info = null) 
35:     {
36:         $this->noCreate();
37:     }
38: 
39:     public function id() 
40:     {
41:         return $this->physical_resource_id;
42:     }
43: 
44:     protected function primaryKeyField() 
45:     {
46:         return 'physical_resource_id';
47:     }
48: 
49:     public function name() 
50:     {
51:         return $this->logical_resource_id;
52:     }
53: 
54:     public function type() 
55:     {
56:         return $this->resource_type;
57:     }
58: 
59:     public function status() 
60:     {
61:         return $this->resource_status;
62:     }
63: 
64:     public function get() 
65:     {
66:         $service = $this->parent()->service();
67:  
68:         switch ($this->resource_type) {
69:             case 'AWS::EC2::Instance':
70:                 $objSvc = 'Compute';
71:                 $method = 'Server';
72:                 $name = 'nova';
73:                 break;
74:             default:
75:                 throw new Exception(sprintf(
76:                     'Unknown resource type: %s', 
77:                     $this->resource_type
78:                 ));
79:         }
80:         
81:         return $service->connection()->$objSvc($name, $service->region())->$method($this->id());
82:     }
83: }
84: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0