Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php |
— | — | @@ -53,6 +53,12 @@ |
54 | 54 | return true; |
55 | 55 | } |
56 | 56 | $this->configureInstance(); |
| 57 | + } else if ( $action == "consoleoutput" ) { |
| 58 | + if ( ! $this->userLDAP->inProject( $project ) ) { |
| 59 | + $this->notInProject(); |
| 60 | + return true; |
| 61 | + } |
| 62 | + $this->getConsoleOutput(); |
57 | 63 | } else { |
58 | 64 | $this->listInstances(); |
59 | 65 | } |
— | — | @@ -333,6 +339,29 @@ |
334 | 340 | } |
335 | 341 | |
336 | 342 | /** |
| 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 | + /** |
337 | 366 | * @return void |
338 | 367 | */ |
339 | 368 | function listInstances() { |
— | — | @@ -388,25 +417,33 @@ |
389 | 418 | $instanceOut .= Html::element( 'td', array(), $instance->getImageId() ); |
390 | 419 | $instanceOut .= Html::element( 'td', array(), $instance->getLaunchTime() ); |
391 | 420 | $msg = wfMsg( 'openstackmanager-delete' ); |
392 | | - $actions = $sk->link( $this->getTitle(), $msg, array(), |
| 421 | + $link = $sk->link( $this->getTitle(), $msg, array(), |
393 | 422 | array( 'action' => 'delete', |
394 | 423 | 'project' => $project, |
395 | 424 | 'instanceid' => $instance->getInstanceId() ), |
396 | 425 | array() ); |
397 | | - $actions .= ', '; |
| 426 | + $actions = Html::rawElement( 'li', array(), $link ); |
398 | 427 | #$msg = wfMsg( 'openstackmanager-rename' ); |
399 | 428 | #$actions .= $sk->link( $this->getTitle(), $msg, array(), |
400 | 429 | # array( 'action' => 'rename', |
401 | 430 | # 'project' => $project, |
402 | 431 | # 'instanceid' => $instance->getInstanceId() ), |
403 | 432 | # array() ); |
404 | | - #$actions .= ', '; |
405 | 433 | $msg = wfMsg( 'openstackmanager-configure' ); |
406 | | - $actions .= $sk->link( $this->getTitle(), $msg, array(), |
| 434 | + $link = $sk->link( $this->getTitle(), $msg, array(), |
407 | 435 | array( 'action' => 'configure', |
408 | 436 | 'project' => $project, |
409 | 437 | 'instanceid' => $instance->getInstanceId() ), |
410 | 438 | 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 ); |
411 | 448 | $instanceOut .= Html::rawElement( 'td', array(), $actions ); |
412 | 449 | $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut ); |
413 | 450 | } |
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php |
— | — | @@ -85,10 +85,8 @@ |
86 | 86 | 'openstackmanager-imageid' => 'Image ID', |
87 | 87 | 'openstackmanager-imagetype' => 'Image type', |
88 | 88 | 'openstackmanager-launchtime' => 'Launch time', |
89 | | - |
90 | 89 | 'openstackmanager-createinstance' => 'Create a new instance', |
91 | 90 | 'openstackmanager-invaliddomain' => 'Requested domain is invalid.', |
92 | | - |
93 | 91 | 'openstackmanager-createdinstance' => 'Created instance $1 with image $2 and hostname $3.', |
94 | 92 | 'openstackmanager-createfailedldap' => 'Failed to create instance as the host could not be added to LDAP.', |
95 | 93 | 'openstackmanager-createinstancefailed' => 'Failed to create instance.', |
— | — | @@ -98,6 +96,8 @@ |
99 | 97 | 'openstackmanager-modifiedinstance' => 'Successfully modified instance.', |
100 | 98 | 'openstackmanager-modifyinstancefailed' => 'Failed to modify instance.', |
101 | 99 | 'openstackmanager-deleteinstancefailed' => 'Failed to delete instance.', |
| 100 | + 'openstackmanager-consoleoutput' => 'Console Output', |
| 101 | + 'openstackmanager-getconsoleoutput' => 'get console output', |
102 | 102 | |
103 | 103 | 'openstackmanager-novapublickey' => 'Public SSH key', |
104 | 104 | 'openstackmanager-novakey-key' => 'Public SSH key', |
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php |
— | — | @@ -163,6 +163,16 @@ |
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
| 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 | + /** |
167 | 177 | * @param $instanceName |
168 | 178 | * @param $image |
169 | 179 | * @param $key |