Index: trunk/extensions/OpenStackManager/SpecialCreateInstance.php |
— | — | @@ -97,13 +97,11 @@ |
98 | 98 | function tryCreateSubmit( $formData, $entryPoint = 'internal' ) { |
99 | 99 | global $wgOut; |
100 | 100 | |
101 | | - $instanceId = $this->adminNova->createInstance( $formData['imageType'], $formData['keypair'], |
| 101 | + $instance = $this->adminNova->createInstance( $formData['imageType'], $formData['keypair'], |
102 | 102 | $formData['instanceType'], $formData['availabilityZone'] ); |
103 | 103 | |
104 | | - print_r($instanceId); |
| 104 | + $wgOut->addHTML('<p>Created instance ' . $instance->getInstanceID() . ' with image ' . $instance->getImageId() . '</p>'); |
105 | 105 | |
106 | | - $wgOut->addHTML('<p>Created instance ' . $instanceId . '</p>'); |
107 | | - |
108 | 106 | return true; |
109 | 107 | } |
110 | 108 | } |
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php |
— | — | @@ -24,9 +24,10 @@ |
25 | 25 | if ( isset( $this->instances[$instanceId] ) && !$reload ) { |
26 | 26 | $instance = $this->instances[$instanceId]; |
27 | 27 | } else { |
28 | | - $instance = $this->novaConnection->describe_instances( $instanceId ); |
29 | | - $instance = $instance->body->reservationSet->item; |
30 | | - $this->instances["$instance->instancesSet->item->instanceId"] = $instance; |
| 28 | + $response = $this->novaConnection->describe_instances( $instanceId ); |
| 29 | + $instance = new OpenStackNovaInstance($response->body->reservationSet->item); |
| 30 | + $instanceId = $instance->getInstanceId(); |
| 31 | + $this->instances["$instanceId"] = $instance; |
31 | 32 | } |
32 | 33 | return $instance; |
33 | 34 | } |
— | — | @@ -34,10 +35,12 @@ |
35 | 36 | function getInstances( $reload = false ) { |
36 | 37 | if ( count( $this->instances ) == 0 || $reload ) { |
37 | 38 | $this->instances = array(); |
38 | | - $instances = $this->novaConnection->describe_instances(); |
| 39 | + $response = $this->novaConnection->describe_instances(); |
39 | 40 | $instances = $instances->body->reservationSet->item; |
40 | 41 | foreach ( $instances as $instance ) { |
41 | | - $this->instances["$instance->instancesSet->item->instanceId"] = $instance; |
| 42 | + $instance = new OpenStackNovaInstance($instance); |
| 43 | + $instanceId = $instance->getInstanceId(); |
| 44 | + $this->instances["$instanceId"] = $instance; |
42 | 45 | } |
43 | 46 | } |
44 | 47 | return $this->instances; |
— | — | @@ -97,11 +100,11 @@ |
98 | 101 | 'Placement.AvailabilityZone' => $availabilityZone, |
99 | 102 | )); |
100 | 103 | |
101 | | - $instance = $instance->body->reservationSet->item; |
102 | | - $instanceId = $instance->instancesSet->item->instanceId; |
| 104 | + $instance = new OpenStackNovaInstance($response->body->reservationSet->item); |
| 105 | + $instanceId = $instance->getInstanceId(); |
103 | 106 | $this->instances["$instanceId"] = $instance; |
104 | 107 | |
105 | | - return $instanceId; |
| 108 | + return $instance; |
106 | 109 | } |
107 | 110 | |
108 | 111 | } |
Index: trunk/extensions/OpenStackManager/OpenStackNovaInstance.php |
— | — | @@ -0,0 +1,40 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# TODO: Make this an abstract class, and make the EC2 API a subclass |
| 5 | +class OpenStackNovaInstance { |
| 6 | + |
| 7 | + var $instance; |
| 8 | + |
| 9 | + function __construct( $apiInstanceResponse ) { |
| 10 | + $this->instance = $apiInstanceResponse; |
| 11 | + } |
| 12 | + |
| 13 | + function getReservationId() { |
| 14 | + return $this->instance->reservationId; |
| 15 | + } |
| 16 | + |
| 17 | + function getInstanceId() { |
| 18 | + return $this->instance->instancesSet->item->instanceId; |
| 19 | + } |
| 20 | + |
| 21 | + function getInstanceState() { |
| 22 | + return $this->instance->instancesSet->item->instanceState->name; |
| 23 | + } |
| 24 | + |
| 25 | + function getInstanceType() { |
| 26 | + return $this->instance->instancesSet->item->instanceType; |
| 27 | + } |
| 28 | + |
| 29 | + function getImageId() { |
| 30 | + return $this->instance->instancesSet->item->imageId; |
| 31 | + } |
| 32 | + |
| 33 | + function getKeyName() { |
| 34 | + return $this->instance->instancesSet->item->keyName; |
| 35 | + } |
| 36 | + |
| 37 | + function getOwner() { |
| 38 | + return $this->instance->ownerId; |
| 39 | + } |
| 40 | + |
| 41 | +} |