Ryan Lane has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/102285


Change subject: Use image metadata for hidden and default images.
......................................................................

Use image metadata for hidden and default images.

Rather than keeping a list of images in the configuration, set
metadata items in glance for the images and filter/default based
on that.

Change-Id: I67162e5fb2de12512e350c29c8b72c77c0ec7df6
---
M OpenStackManager.php
M nova/OpenStackNovaImage.php
M special/SpecialNovaInstance.php
3 files changed, 12 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager 
refs/changes/85/102285/1

diff --git a/OpenStackManager.php b/OpenStackManager.php
index a7e174d..56479b3 100644
--- a/OpenStackManager.php
+++ b/OpenStackManager.php
@@ -108,10 +108,6 @@
        );
 // Default security rules to add to a project when created
 $wgOpenStackManagerDefaultSecurityGroupRules = array();
-// Image ID to default to in the instance creation interface
-$wgOpenStackManagerInstanceDefaultImage = "";
-// List of image IDs to not display on instance creation interface
-$wgOpenStackManagerInstanceBannedImages = array();
 // List of instance type names to not display on instance creation interface
 $wgOpenStackManagerInstanceBannedInstanceTypes = array();
 // Whether resource pages should be managed on instance/project 
creation/deletion
diff --git a/nova/OpenStackNovaImage.php b/nova/OpenStackNovaImage.php
index 75ed4ed..0caf480 100644
--- a/nova/OpenStackNovaImage.php
+++ b/nova/OpenStackNovaImage.php
@@ -45,4 +45,12 @@
                return $this->image->status;
        }
 
+       /**
+        * Return the value of the metadata key requested
+        *
+        * @return string
+        */
+       function getImageMetadata( $key ) {
+               return OpenStackNovaController::_get_property( 
$this->image->metadata, $key );
+       }
 }
diff --git a/special/SpecialNovaInstance.php b/special/SpecialNovaInstance.php
index 01500d2..fa33fe4 100644
--- a/special/SpecialNovaInstance.php
+++ b/special/SpecialNovaInstance.php
@@ -93,7 +93,6 @@
                global $wgOpenStackManagerPuppetOptions;
                global $wgOpenStackManagerInstanceBannedInstanceTypes;
                global $wgOpenStackManagerInstanceDefaultImage;
-               global $wgOpenStackManagerInstanceBannedImages;
 
                $this->setHeaders();
                $this->getOutput()->setPagetitle( $this->msg( 
'openstackmanager-createinstance' ) );
@@ -157,11 +156,13 @@
                        if ( $imageName === '' ) {
                                continue;
                        }
-                       if ( in_array( $image->getImageId(), 
$wgOpenStackManagerInstanceBannedImages ) ) {
+                       $isHidden = $image->getImageMetadata( 'hidden' );
+                       if ( $isHidden ) {
                                continue;
                        }
                        $imageLabel = $imageName;
-                       if ( $image->getImageId() === 
$wgOpenStackManagerInstanceDefaultImage ) {
+                       $isDefault = $image->getImageMetadata( 'default' );
+                       if ( $isDefault ) {
                                $default = $imageLabel;
                        }
                        $image_keys[$imageLabel] = $image->getImageId();

-- 
To view, visit https://gerrit.wikimedia.org/r/102285
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67162e5fb2de12512e350c29c8b72c77c0ec7df6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Ryan Lane <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to