jenkins-bot has submitted this change and it was merged.

Change subject: Show more informative instance status
......................................................................


Show more informative instance status

Nova's api will return a status and a task state, such as:

        RESIZE (resize_verify)

This change makes OpenStackManager show both. It also makes the
api action properly return the new instance state after the JS
module makes a reboot call.

Change-Id: I239045ed658968356e7450fd79bfe06333e55838
---
M api/ApiNovaInstance.php
M nova/OpenStackNovaInstance.php
M special/SpecialNovaInstance.php
3 files changed, 22 insertions(+), 3 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  Anomie: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/api/ApiNovaInstance.php b/api/ApiNovaInstance.php
index 8801ace..73fd52b 100644
--- a/api/ApiNovaInstance.php
+++ b/api/ApiNovaInstance.php
@@ -31,7 +31,10 @@
                        if ( ! $success ) {
                                $this->dieUsage( 'Failed to reboot instance.', 
'openstackmanager-rebootinstancefailed' );
                        }
-                       $this->getResult()->addValue( null, 
$this->getModuleName(), array ( 'instancestate' => 'rebooting' ) );
+                       $instance = $this->userNova->getInstance( 
$this->params['instanceid'] );
+                       if ( $instance ) {
+                               $this->getResult()->addValue( null, 
$this->getModuleName(), array ( 'instancestate' => 
$instance->getInstanceState() ) );
+                       }
                        break;
                case 'consoleoutput':
                        $output = $this->userNova->getConsoleOutput( 
$this->params['instanceid'] );
diff --git a/nova/OpenStackNovaInstance.php b/nova/OpenStackNovaInstance.php
index c311924..4b42b77 100644
--- a/nova/OpenStackNovaInstance.php
+++ b/nova/OpenStackNovaInstance.php
@@ -136,7 +136,16 @@
         * @return string
         */
        function getInstanceState() {
-               return OpenStackNovaController::_get_property( $this->instance, 
'OS-EXT-STS:vm_state' );
+               return OpenStackNovaController::_get_property( $this->instance, 
'status' );
+       }
+
+       /**
+        * Return the task state in which this instance currently exists
+        *
+        * @return string
+        */
+       function getInstanceTaskState() {
+               return OpenStackNovaController::_get_property( $this->instance, 
'OS-EXT-STS:task_state' );
        }
 
        /**
diff --git a/special/SpecialNovaInstance.php b/special/SpecialNovaInstance.php
index 1fa11dd..5e1c0ec 100644
--- a/special/SpecialNovaInstance.php
+++ b/special/SpecialNovaInstance.php
@@ -528,7 +528,14 @@
                        $instanceRow = array();
                        $this->pushResourceColumn( $instanceRow, 
$instance->getInstanceName(), array( 'class' => 'novainstancename' ) );
                        $this->pushRawResourceColumn( $instanceRow, 
$this->createResourceLink( $instance->getInstanceId() ), array( 'class' => 
'novainstanceid' ) );
-                       $this->pushResourceColumn( $instanceRow, 
$instance->getInstanceState(), array( 'class' => 'novainstancestate' ) );
+                       $state = $instance->getInstanceState();
+                       $taskState = $instance->getInstanceTaskState();
+                       if ( $taskState ) {
+                               $stateDisplay = "$state ($taskState)";
+                       } else {
+                               $stateDisplay = $state;
+                       }
+                       $this->pushResourceColumn( $instanceRow, $stateDisplay, 
array( 'class' => 'novainstancestate' ) );
                        $this->pushRawResourceColumn( $instanceRow, 
$this->createResourceList( $instance->getInstancePrivateIPs() ) );
                        $this->pushRawResourceColumn( $instanceRow, 
$this->createResourceList( $instance->getInstancePublicIPs() ) );
                        $this->pushRawResourceColumn( $instanceRow, 
$this->createResourceList( $instance->getSecurityGroups() ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I239045ed658968356e7450fd79bfe06333e55838
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Ryan Lane <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to