Ryan Lane has uploaded a new change for review. https://gerrit.wikimedia.org/r/65269
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 modules/ext.openstack.Instance.js M nova/OpenStackNovaInstance.php 3 files changed, 67 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager refs/changes/69/65269/1 diff --git a/api/ApiNovaInstance.php b/api/ApiNovaInstance.php index 1870977..d6cc475 100644 --- a/api/ApiNovaInstance.php +++ b/api/ApiNovaInstance.php @@ -31,7 +31,10 @@ if ( ! $success ) { $this->dieUsageMsg( array( 'openstackmanager-rebootinstancefailed', $this->params['instanceid'] ) ); } - $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/modules/ext.openstack.Instance.js b/modules/ext.openstack.Instance.js index d598ba1..22a0071 100644 --- a/modules/ext.openstack.Instance.js +++ b/modules/ext.openstack.Instance.js @@ -20,6 +20,62 @@ reboot : { success : 'openstackmanager-rebootedinstance', failure : 'openstackmanager-rebootinstancefailed' + }, + consoleoutput : { + failure : 'openstackmanager-getconsoleoutputfailed' + } + }; + + Instance.prototype.postactions = { + reboot : { + success : function ( data, e ) { + var $state = $( e.target ).closest( 'tr' ).find( '.novainstancestate' ); + if ( data.novainstance.instancestate !== undefined ) { + $state.text( data.novainstance.instancestate ); + } + } + }, + consoleoutput : { + success : function ( data, e ) { + var $instancename = $( e.target ).closest( 'tr' ).find( '.novainstancename' ).text(), + $instanceid = $( e.target ).closest( 'tr' ).find( '.novainstanceid' ).text(), + $consoleoutput = $( '<pre>' ), + ofloc, + atloc, + myloc; + if ( $instanceid in consoledialogs ) { + return; + } + consoledialogs[ $instanceid ] = $consoleoutput; + $consoleoutput.attr( 'title', mw.msg( 'openstackmanager-consoleoutput', $instancename, $instanceid ) ); + $consoleoutput.addClass( 'osm-consoleoutput' ); + $consoleoutput.text( data.novainstance.consoleoutput ); + if ( $( '.osm-consoleoutput' ).length ) { + // position this dialog next to the last + ofloc = $( '.osm-consoleoutput' ).filter( ':last' ); + atloc = 'right top'; + myloc = 'left top'; + } else { + // this is the first dialog, position it left bottom + ofloc = window; + atloc = 'left bottom'; + myloc = 'left bottom'; + } + $consoleoutput.dialog({ + // remove the element, or it'll screw up positioning + close: function () { + $(this).dialog( 'destroy' ).remove(); + delete consoledialogs[ $instanceid ]; + }, + modal: false, + draggable: true, + resizable: true, + height: 500, + width: 400, + position: { my: myloc, at: atloc, of: ofloc }, + autoOpen: false + }).parent().css({ position: 'fixed' }).end().dialog( 'open' ); + } } }; diff --git a/nova/OpenStackNovaInstance.php b/nova/OpenStackNovaInstance.php index 2a6e6e8..728b0c3 100644 --- a/nova/OpenStackNovaInstance.php +++ b/nova/OpenStackNovaInstance.php @@ -136,7 +136,13 @@ * @return string */ function getInstanceState() { - return OpenStackNovaController::_get_property( $this->instance, 'OS-EXT-STS:vm_state' ); + $status = OpenStackNovaController::_get_property( $this->instance, 'status' ); + $taskState = OpenStackNovaController::_get_property( $this->instance, 'OS-EXT-STS:task_state' ); + if ( $taskState ) { + return "$status ($taskState)"; + } else { + return "$status"; + } } /** -- To view, visit https://gerrit.wikimedia.org/r/65269 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I239045ed658968356e7450fd79bfe06333e55838 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OpenStackManager Gerrit-Branch: master Gerrit-Owner: Ryan Lane <rl...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits