r81658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81657‎ | r81658 | r81659 >
Date:23:42, 7 February 2011
Author:laner
Status:deferred
Tags:
Comment:
* Added support for getting console output from instances
* Changed actions td on instance list page to be a list
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.i18n.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaController.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -53,6 +53,12 @@
5454 return true;
5555 }
5656 $this->configureInstance();
 57+ } else if ( $action == "consoleoutput" ) {
 58+ if ( ! $this->userLDAP->inProject( $project ) ) {
 59+ $this->notInProject();
 60+ return true;
 61+ }
 62+ $this->getConsoleOutput();
5763 } else {
5864 $this->listInstances();
5965 }
@@ -333,6 +339,29 @@
334340 }
335341
336342 /**
 343+ * @return bool
 344+ */
 345+ function getConsoleOutput() {
 346+ global $wgOut, $wgRequest;
 347+ global $wgUser;
 348+
 349+ $this->setHeaders();
 350+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-consoleoutput' ) );
 351+
 352+ $project = $wgRequest->getText( 'project' );
 353+ if ( ! $this->userLDAP->inRole( 'sysadmin', $project ) ) {
 354+ $this->notInRole( 'sysadmin' );
 355+ return false;
 356+ }
 357+ $instanceid = $wgRequest->getText( 'instanceid' );
 358+ $consoleOutput = $this->userNova->getConsoleOutput( $instanceid );
 359+ $sk = $wgUser->getSkin();
 360+ $out = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
 361+ $out .= Html::element( 'pre', array(), $consoleOutput );
 362+ $wgOut->addHTML( $out );
 363+ }
 364+
 365+ /**
337366 * @return void
338367 */
339368 function listInstances() {
@@ -388,25 +417,33 @@
389418 $instanceOut .= Html::element( 'td', array(), $instance->getImageId() );
390419 $instanceOut .= Html::element( 'td', array(), $instance->getLaunchTime() );
391420 $msg = wfMsg( 'openstackmanager-delete' );
392 - $actions = $sk->link( $this->getTitle(), $msg, array(),
 421+ $link = $sk->link( $this->getTitle(), $msg, array(),
393422 array( 'action' => 'delete',
394423 'project' => $project,
395424 'instanceid' => $instance->getInstanceId() ),
396425 array() );
397 - $actions .= ', ';
 426+ $actions = Html::rawElement( 'li', array(), $link );
398427 #$msg = wfMsg( 'openstackmanager-rename' );
399428 #$actions .= $sk->link( $this->getTitle(), $msg, array(),
400429 # array( 'action' => 'rename',
401430 # 'project' => $project,
402431 # 'instanceid' => $instance->getInstanceId() ),
403432 # array() );
404 - #$actions .= ', ';
405433 $msg = wfMsg( 'openstackmanager-configure' );
406 - $actions .= $sk->link( $this->getTitle(), $msg, array(),
 434+ $link = $sk->link( $this->getTitle(), $msg, array(),
407435 array( 'action' => 'configure',
408436 'project' => $project,
409437 'instanceid' => $instance->getInstanceId() ),
410438 array() );
 439+ $actions .= Html::rawElement( 'li', array(), $link );
 440+ $msg = wfMsg( 'openstackmanager-getconsoleoutput' );
 441+ $link = $sk->link( $this->getTitle(), $msg, array(),
 442+ array( 'action' => 'consoleoutput',
 443+ 'project' => $project,
 444+ 'instanceid' => $instance->getInstanceId() ),
 445+ array() );
 446+ $actions .= Html::rawElement( 'li', array(), $link );
 447+ $actions = Html::rawElement( 'ul', array(), $actions );
411448 $instanceOut .= Html::rawElement( 'td', array(), $actions );
412449 $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut );
413450 }
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php
@@ -85,10 +85,8 @@
8686 'openstackmanager-imageid' => 'Image ID',
8787 'openstackmanager-imagetype' => 'Image type',
8888 'openstackmanager-launchtime' => 'Launch time',
89 -
9089 'openstackmanager-createinstance' => 'Create a new instance',
9190 'openstackmanager-invaliddomain' => 'Requested domain is invalid.',
92 -
9391 'openstackmanager-createdinstance' => 'Created instance $1 with image $2 and hostname $3.',
9492 'openstackmanager-createfailedldap' => 'Failed to create instance as the host could not be added to LDAP.',
9593 'openstackmanager-createinstancefailed' => 'Failed to create instance.',
@@ -98,6 +96,8 @@
9997 'openstackmanager-modifiedinstance' => 'Successfully modified instance.',
10098 'openstackmanager-modifyinstancefailed' => 'Failed to modify instance.',
10199 'openstackmanager-deleteinstancefailed' => 'Failed to delete instance.',
 100+ 'openstackmanager-consoleoutput' => 'Console Output',
 101+ 'openstackmanager-getconsoleoutput' => 'get console output',
102102
103103 'openstackmanager-novapublickey' => 'Public SSH key',
104104 'openstackmanager-novakey-key' => 'Public SSH key',
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php
@@ -163,6 +163,16 @@
164164 }
165165
166166 /**
 167+ * Get the console output of an instance
 168+ *
 169+ * @param $instanceid string
 170+ */
 171+ function getConsoleOutput( $instanceid ) {
 172+ $consoleOutput = $this->novaConnection->get_console_output( $instanceid, $opt );
 173+ return (string)$consoleOutput->body->output;
 174+ }
 175+
 176+ /**
167177 * @param $instanceName
168178 * @param $image
169179 * @param $key

Status & tagging log