Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php |
— | — | @@ -123,8 +123,22 @@ |
124 | 124 | # where the name points to itself as a value |
125 | 125 | $images = $this->adminNova->getImages(); |
126 | 126 | $image_keys = array(); |
127 | | - foreach ( array_keys( $images ) as $image_key ) { |
128 | | - $image_keys["$image_key"] = $image_key; |
| 127 | + foreach ( $images as $image ) { |
| 128 | + if ( ! $image->imageIsPublic() ) { |
| 129 | + continue; |
| 130 | + } |
| 131 | + if ( $image->getImageState() != "available" ) { |
| 132 | + continue; |
| 133 | + } |
| 134 | + if ( $image->getImageType() != "machine" ) { |
| 135 | + continue; |
| 136 | + } |
| 137 | + $imageName = $image->getImageName(); |
| 138 | + if ( $imageName == '' ) { |
| 139 | + continue; |
| 140 | + } |
| 141 | + $imageLabel = $imageName . ' (' . $image->getImageArchitecture() . ')'; |
| 142 | + $image_keys["$imageLabel"] = $image->getImageId(); |
129 | 143 | } |
130 | 144 | $instanceInfo['imageType'] = array( |
131 | 145 | 'type' => 'select', |
Index: trunk/extensions/OpenStackManager/OpenStackNovaImage.php |
— | — | @@ -0,0 +1,69 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# TODO: Make this an abstract class, and make the EC2 API a subclass |
| 5 | +class OpenStackNovaImage { |
| 6 | + |
| 7 | + var $image; |
| 8 | + |
| 9 | + /** |
| 10 | + * @param $apiInstanceResponse |
| 11 | + */ |
| 12 | + function __construct( $apiInstanceResponse ) { |
| 13 | + $this->image = $apiInstanceResponse; |
| 14 | + } |
| 15 | + |
| 16 | + /** |
| 17 | + * Return the name of this image |
| 18 | + * |
| 19 | + * @return string |
| 20 | + */ |
| 21 | + function getImageName() { |
| 22 | + return (string)$this->image->displayName; |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Return the ID of this image |
| 27 | + * |
| 28 | + * @return string |
| 29 | + */ |
| 30 | + function getImageId() { |
| 31 | + return (string)$this->image->id; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Return the availability state of this image |
| 36 | + * |
| 37 | + * @return string |
| 38 | + */ |
| 39 | + function getImageState() { |
| 40 | + return (string)$this->image->imageState; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Return the image type |
| 45 | + * |
| 46 | + * @return string |
| 47 | + */ |
| 48 | + function getImageType() { |
| 49 | + return (string)$this->image->imageType; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Return the image architecture |
| 54 | + * |
| 55 | + * @return string |
| 56 | + */ |
| 57 | + function getImageArchitecture() { |
| 58 | + return (string)$this->image->architecture; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Return whether or not this image is public |
| 63 | + * |
| 64 | + * @return bool |
| 65 | + */ |
| 66 | + function imageIsPublic() { |
| 67 | + return (bool)$this->image->isPublic; |
| 68 | + } |
| 69 | + |
| 70 | +} |
Property changes on: trunk/extensions/OpenStackManager/OpenStackNovaImage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 71 | + native |
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php |
— | — | @@ -107,9 +107,9 @@ |
108 | 108 | $images = $this->novaConnection->describe_images(); |
109 | 109 | $images = $images->body->imagesSet->item; |
110 | 110 | foreach ( $images as $image ) { |
111 | | - if ( $image->imageType == 'machine' ) { |
112 | | - $this->images["$image->imageId"] = $image; |
113 | | - } |
| 111 | + $image = new OpenStackNovaImage( $image ); |
| 112 | + $imageId = $image->getImageId(); |
| 113 | + $this->images["$imageId"] = $image; |
114 | 114 | } |
115 | 115 | return $this->images; |
116 | 116 | } |
Index: trunk/extensions/OpenStackManager/OpenStackManager.php |
— | — | @@ -80,6 +80,7 @@ |
81 | 81 | $wgExtensionAliasesFiles['OpenStackManager'] = $dir . 'OpenStackManager.alias.php'; |
82 | 82 | $wgAutoloadClasses['OpenStackNovaInstance'] = $dir . 'OpenStackNovaInstance.php'; |
83 | 83 | $wgAutoloadClasses['OpenStackNovaInstanceType'] = $dir . 'OpenStackNovaInstanceType.php'; |
| 84 | +$wgAutoloadClasses['OpenStackNovaImage'] = $dir . 'OpenStackNovaImage.php'; |
84 | 85 | $wgAutoloadClasses['OpenStackNovaKeypair'] = $dir . 'OpenStackNovaKeypair.php'; |
85 | 86 | $wgAutoloadClasses['OpenStackNovaController'] = $dir . 'OpenStackNovaController.php'; |
86 | 87 | $wgAutoloadClasses['OpenStackNovaUser'] = $dir . 'OpenStackNovaUser.php'; |