r80042 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80041‎ | r80042 | r80043 >
Date:21:15, 11 January 2011
Author:reedy
Status:deferred
Tags:
Comment:
Move SpecialNova*.php to specials/

Update paths aswell
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.php (modified) (history)
  • /trunk/extensions/OpenStackManager/SpecialNova.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaAddress.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaDomain.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaInstance.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaKey.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaProject.php (deleted) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNova.php (added) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaAddress.php (added) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaDomain.php (added) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (added) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaKey.php (added) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaProject.php (added) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/SpecialNovaInstance.php
@@ -1,495 +0,0 @@
2 -<?php
3 -class SpecialNovaInstance extends SpecialNova {
4 -
5 - var $adminNova, $userNova;
6 - var $userLDAP;
7 -
8 - function __construct() {
9 - parent::__construct( 'NovaInstance' );
10 - }
11 -
12 - function execute( $par ) {
13 - global $wgRequest, $wgUser;
14 - global $wgOpenStackManagerNovaAdminKeys;
15 -
16 - if ( ! $wgUser->isLoggedIn() ) {
17 - $this->notLoggedIn();
18 - return true;
19 - }
20 - $user = new OpenStackNovaUser();
21 - if ( ! $user->exists() ) {
22 - $this->noCredentials();
23 - return true;
24 - }
25 - $this->userLDAP = new OpenStackNovaUser();
26 - $project = $wgRequest->getVal( 'project' );
27 - $userCredentials = $user->getCredentials( $project );
28 - $this->userNova = new OpenStackNovaController( $userCredentials );
29 - $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
30 - $this->adminNova = new OpenStackNovaController( $adminCredentials );
31 -
32 - $action = $wgRequest->getVal( 'action' );
33 -
34 - if ( $action == "create" ) {
35 - if ( ! $user->inProject( $project ) ) {
36 - $this->notInProject();
37 - return true;
38 - }
39 - $this->createInstance();
40 - } else if ( $action == "delete" ) {
41 - if ( ! $user->inProject( $project ) ) {
42 - $this->notInProject();
43 - return true;
44 - }
45 - $this->deleteInstance();
46 - } else if ( $action == "rename" ) {
47 - if ( ! $user->inProject( $project ) ) {
48 - $this->notInProject();
49 - return true;
50 - }
51 - $this->renameInstance();
52 - } else if ( $action == "configure" ) {
53 - if ( ! $user->inProject( $project ) ) {
54 - $this->notInProject();
55 - return true;
56 - }
57 - $this->configureInstance();
58 - } else {
59 - $this->listInstances();
60 - }
61 - }
62 -
63 - function createInstance() {
64 - global $wgRequest, $wgOut;
65 - global $wgOpenStackManagerPuppetOptions;
66 -
67 - $this->setHeaders();
68 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-createinstance' ) );
69 -
70 - $instanceInfo = Array();
71 - $instanceInfo['instancename'] = array(
72 - 'type' => 'text',
73 - 'label-message' => 'openstackmanager-instancename',
74 - 'validation-callback' => array( $this, 'validateInstanceName' ),
75 - 'default' => '',
76 - 'section' => 'instance/info',
77 - );
78 -
79 - $instanceTypes = $this->adminNova->getInstanceTypes();
80 - $instanceType_keys = Array();
81 - foreach ( $instanceTypes as $instanceType ) {
82 - $instanceType_keys["$instanceType"] = $instanceType;
83 - }
84 - $instanceInfo['instanceType'] = array(
85 - 'type' => 'select',
86 - 'label-message' => 'openstackmanager-instancetype',
87 - 'section' => 'instance/info',
88 - 'options' => $instanceType_keys,
89 - );
90 -
91 - # Availability zone names can't be translated. Get the keys, and make an array
92 - # where the name points to itself as a value
93 - $availabilityZones = $this->adminNova->getAvailabilityZones();
94 - $availabilityZone_keys = Array();
95 - foreach ( array_keys( $availabilityZones ) as $availabilityZone_key ) {
96 - $availabilityZone_keys["$availabilityZone_key"] = $availabilityZone_key;
97 - }
98 - $instanceInfo['availabilityZone'] = array(
99 - 'type' => 'select',
100 - 'section' => 'instance/info',
101 - 'options' => $availabilityZone_keys,
102 - 'label-message' => 'openstackmanager-availabilityzone',
103 - );
104 -
105 - # Image names can't be translated. Get the image, and make an array
106 - # where the name points to itself as a value
107 - $images = $this->adminNova->getImages();
108 - $image_keys = Array();
109 - foreach ( array_keys( $images ) as $image_key ) {
110 - $image_keys["$image_key"] = $image_key;
111 - }
112 - $instanceInfo['imageType'] = array(
113 - 'type' => 'select',
114 - 'section' => 'instance/info',
115 - 'options' => $image_keys,
116 - 'label-message' => 'openstackmanager-imagetype',
117 - );
118 -
119 - # Keypair names can't be translated. Get the keys, and make an array
120 - # where the name points to itself as a value
121 - # TODO: get keypairs as the user, not the admin
122 - # $keypairs = $this->userNova->getKeypairs();
123 - # $keypair_keys = Array();
124 - # foreach ( array_keys( $keypairs ) as $keypair_key ) {
125 - # $keypair_keys["$keypair_key"] = $keypair_key;
126 - # }
127 - # $instanceInfo['keypair'] = array(
128 - # 'type' => 'select',
129 - # 'section' => 'instance/info',
130 - # 'options' => $keypair_keys,
131 - # 'label-message' => 'keypair',
132 - # );
133 -
134 - $domains = OpenStackNovaDomain::getAllDomains( true );
135 - $domain_keys = array();
136 - foreach ( $domains as $domain ) {
137 - $domainname = $domain->getDomainName();
138 - $domain_keys["$domainname"] = $domainname;
139 - }
140 - $instanceInfo['domain'] = array(
141 - 'type' => 'select',
142 - 'section' => 'instance/info',
143 - 'options' => $domain_keys,
144 - 'label-message' => 'openstackmanager-dnsdomain',
145 - );
146 -
147 - $instanceInfo['project'] = array(
148 - 'type' => 'hidden',
149 - 'default' => $wgRequest->getText( 'project' ),
150 - );
151 -
152 - if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
153 - if ( $wgOpenStackManagerPuppetOptions['availableclasses'] ) {
154 - $classes = array();
155 - foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
156 - $classes["$class"] = $class;
157 - }
158 - $instanceInfo['puppetclasses'] = array(
159 - 'type' => 'multiselect',
160 - 'section' => 'instance/puppetinfo',
161 - 'options' => $classes,
162 - 'label-message' => 'openstackmanager-puppetclasses',
163 - );
164 - }
165 -
166 - if ( $wgOpenStackManagerPuppetOptions['availablevariables'] ) {
167 - foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
168 - $instanceInfo["$variable"] = array(
169 - 'type' => 'text',
170 - 'section' => 'instance/puppetinfo',
171 - 'label' => $variable,
172 - );
173 - }
174 - }
175 - }
176 -
177 - $instanceInfo['action'] = array(
178 - 'type' => 'hidden',
179 - 'default' => 'create',
180 - );
181 -
182 - $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
183 - $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
184 - $instanceForm->setSubmitID( 'openstackmanager-novainstance-createinstancesubmit' );
185 - $instanceForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
186 - $instanceForm->show();
187 -
188 - }
189 -
190 - function configureInstance() {
191 - global $wgRequest, $wgOut;
192 - global $wgOpenStackManagerPuppetOptions;
193 -
194 - $this->setHeaders();
195 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-configureinstance' ) );
196 -
197 - $instanceid = $wgRequest->getText( 'instanceid' );
198 -
199 - $instanceInfo = Array();
200 - $instanceInfo['instanceid'] = array(
201 - 'type' => 'hidden',
202 - 'default' => $instanceid,
203 - );
204 - $instanceInfo['project'] = array(
205 - 'type' => 'hidden',
206 - 'default' => $wgRequest->getText( 'project' ),
207 - );
208 -
209 - if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
210 - $host = OpenStackNovaHost::getHostByInstanceId( $instanceid );
211 - if ( ! $host ) {
212 - $wgOut->addHTML( Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) ) );
213 - return false;
214 - }
215 - $puppetinfo = $host->getPuppetConfiguration();
216 -
217 - if ( $wgOpenStackManagerPuppetOptions['availableclasses'] ) {
218 - $classes = array();
219 - $defaults = array();
220 - foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
221 - $classes["$class"] = $class;
222 - if ( in_array( $class, $puppetinfo['puppetclass'] ) ) {
223 - $defaults["$class"] = $class;
224 - }
225 - }
226 - $instanceInfo['puppetclasses'] = array(
227 - 'type' => 'multiselect',
228 - 'section' => 'instance/puppetinfo',
229 - 'options' => $classes,
230 - 'default' => $defaults,
231 - 'label-message' => 'openstackmanager-puppetclasses',
232 - );
233 - }
234 -
235 - if ( $wgOpenStackManagerPuppetOptions['availablevariables'] ) {
236 - foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
237 - $default = '';
238 - if ( array_key_exists( $variable, $puppetinfo['puppetvar'] ) ) {
239 - $default = $puppetinfo['puppetvar']["$variable"];
240 - }
241 - $instanceInfo["$variable"] = array(
242 - 'type' => 'text',
243 - 'section' => 'instance/puppetinfo',
244 - 'label' => $variable,
245 - 'default' => $default,
246 - );
247 - }
248 - }
249 - }
250 -
251 - $instanceInfo['action'] = array(
252 - 'type' => 'hidden',
253 - 'default' => 'configure',
254 - );
255 -
256 - $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
257 - $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
258 - $instanceForm->setSubmitID( 'novainstance-form-configureinstancesubmit' );
259 - $instanceForm->setSubmitCallback( array( $this, 'tryConfigureSubmit' ) );
260 - $instanceForm->show();
261 -
262 - return true;
263 - }
264 -
265 - function deleteInstance() {
266 - global $wgOut, $wgRequest;
267 -
268 - $this->setHeaders();
269 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletedomain' ) );
270 -
271 - $instanceid = $wgRequest->getText( 'instanceid' );
272 - $project = $wgRequest->getText( 'project' );
273 - if ( ! $wgRequest->wasPosted() ) {
274 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deleteinstancequestion', array(), $instanceid ) );
275 - $wgOut->addHTML( $out );
276 - }
277 - $instanceInfo = Array();
278 - $instanceInfo['instanceid'] = array(
279 - 'type' => 'hidden',
280 - 'default' => $instanceid,
281 - );
282 - $instanceInfo['project'] = array(
283 - 'type' => 'hidden',
284 - 'default' => $project,
285 - );
286 - $instanceInfo['action'] = array(
287 - 'type' => 'hidden',
288 - 'default' => 'delete',
289 - );
290 - $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
291 - $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
292 - $instanceForm->setSubmitID( 'novainstance-form-deleteinstancesubmit' );
293 - $instanceForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
294 - $instanceForm->setSubmitText( 'confirm' );
295 - $instanceForm->show();
296 -
297 - return true;
298 - }
299 -
300 - function modifyInstance() {
301 - return true;
302 - }
303 -
304 - function listInstances() {
305 - global $wgOut, $wgUser;
306 -
307 - $this->setHeaders();
308 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-instancelist' ) );
309 -
310 - $userProjects = $this->userLDAP->getProjects();
311 - $sk = $wgUser->getSkin();
312 - $out = '';
313 - $instances = $this->adminNova->getInstances();
314 - $header = Html::element( 'th', array(), wfMsg( 'openstackmanager-instancename' ) );
315 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceid' ) );
316 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancestate' ) );
317 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancetype' ) );
318 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceip' ) );
319 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-imageid' ) );
320 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
321 - $projectArr = array();
322 - foreach ( $instances as $instance ) {
323 - $project = $instance->getOwner();
324 - if ( ! in_array( $project, $userProjects ) ) {
325 - continue;
326 - }
327 - $instanceName = (string)$instance->getInstanceName();
328 - $title = Title::newFromText( $instanceName, NS_VM );
329 - $instanceNameLink = $sk->link( $title, $instanceName, array(), array(), array() );
330 - $instanceOut = Html::rawElement( 'td', array(), $instanceNameLink );
331 - $instanceOut .= Html::element( 'td', array(), $instance->getInstanceId() );
332 - $instanceOut .= Html::element( 'td', array(), $instance->getInstanceState() );
333 - $instanceOut .= Html::element( 'td', array(), $instance->getInstanceType() );
334 - $instanceOut .= Html::element( 'td', array(), $instance->getInstancePrivateIP() );
335 - $instanceOut .= Html::element( 'td', array(), $instance->getImageId() );
336 - $msg = wfMsg( 'openstackmanager-delete' );
337 - $actions = $sk->link( $this->getTitle(), $msg, array(),
338 - array( 'action' => 'delete',
339 - 'project' => $project,
340 - 'instanceid' => $instance->getInstanceId() ),
341 - array() );
342 - $actions .= ', ';
343 - $msg = wfMsg( 'openstackmanager-rename' );
344 - $actions .= $sk->link( $this->getTitle(), $msg, array(),
345 - array( 'action' => 'rename',
346 - 'project' => $project,
347 - 'instanceid' => $instance->getInstanceId() ),
348 - array() );
349 - $actions .= ', ';
350 - $msg = wfMsg( 'openstackmanager-configure' );
351 - $actions .= $sk->link( $this->getTitle(), $msg, array(),
352 - array( 'action' => 'configure',
353 - 'project' => $project,
354 - 'instanceid' => $instance->getInstanceId() ),
355 - array() );
356 - $instanceOut .= Html::rawElement( 'td', array(), $actions );
357 - $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut );
358 - }
359 - foreach ( $userProjects as $project ) {
360 - $out .= Html::element( 'h2', array(), $project );
361 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createinstance' ), array(),
362 - array( 'action' => 'create', 'project' => $project ), array() );
363 - if ( isset( $projectArr["$project"] ) ) {
364 - $projectOut = $header;
365 - $projectOut .= $projectArr["$project"];
366 - $out .= Html::rawElement( 'table',
367 - array( 'id' => 'novainstancelist', 'class' => 'wikitable' ), $projectOut );
368 - }
369 - }
370 -
371 - $wgOut->addHTML( $out );
372 - }
373 -
374 - function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
375 - global $wgOut, $wgUser;
376 - global $wgOpenStackManagerPuppetOptions;
377 -
378 - $sk = $wgUser->getSkin();
379 - $domain = OpenStackNovaDomain::getDomainByName( $formData['domain'] );
380 - if ( ! $domain ) {
381 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invaliddomain' ) );
382 - return false;
383 - }
384 - $instance = $this->userNova->createInstance( $formData['instancename'], $formData['imageType'], '', $formData['instanceType'], $formData['availabilityZone'] );
385 - if ( $instance ) {
386 - $puppetinfo = array();
387 - if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
388 - foreach ( $formData['puppetclasses'] as $class ) {
389 - if ( in_array( $class, $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
390 - $puppetinfo['classes'][] = $class;
391 - }
392 - }
393 - foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
394 - if ( isset ( $formData["$variable"] ) ) {
395 - $puppetinfo['variables']["$variable"] = $formData["$variable"];
396 - }
397 - }
398 - }
399 - $host = OpenStackNovaHost::addHost( $instance, $domain, $puppetinfo );
400 -
401 - if ( $host ) {
402 - $title = Title::newFromText( $wgOut->getPageTitle() );
403 - $job = new OpenStackNovaHostJob( $title, array( 'instanceid' => (string)$instance->getInstanceId() ) );
404 - $job->insert();
405 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-createdinstance', array(),
406 - $instance->getInstanceID(), $instance->getImageId(),
407 - $host->getFullyQualifiedHostName() ) );
408 - } else {
409 - $this->userNova->terminateInstance( $instance->getInstanceId() );
410 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createfailedldap' ) );
411 - }
412 - # TODO: also add puppet
413 - } else {
414 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createinstancefailed' ) );
415 - }
416 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
417 -
418 - $wgOut->addHTML( $out );
419 - return true;
420 - }
421 -
422 - function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
423 - global $wgOut, $wgUser;
424 -
425 - $sk = $wgUser->getSkin();
426 - $instance = $this->adminNova->getInstance( $formData['instanceid'] );
427 - if ( ! $instance ) {
428 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) );
429 - return true;
430 - }
431 - $instancename = $instance->getInstanceName();
432 - $instanceid = $instance->getInstanceId();
433 - $success = $this->userNova->terminateInstance( $instanceid );
434 - if ( $success ) {
435 - $success = OpenStackNovaHost::deleteHostByInstanceId( $instanceid );
436 - if ( $success ) {
437 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedinstance', array(), $instanceid ) );
438 - } else {
439 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedinstance-faileddns', array(), $instancename, $instanceid ) );
440 - }
441 - } else {
442 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteinstancefailed' ) );
443 - }
444 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
445 -
446 - $wgOut->addHTML( $out );
447 - return true;
448 - }
449 -
450 - function tryConfigureSubmit( $formData, $entryPoint = 'internal' ) {
451 - global $wgOut, $wgUser;
452 - global $wgOpenStackManagerPuppetOptions;
453 -
454 - $sk = $wgUser->getSkin();
455 - $host = OpenStackNovaHost::getHostByInstanceId( $formData['instanceid'] );
456 - if ( $host ) {
457 - $puppetinfo = array();
458 - if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
459 - foreach ( $formData['puppetclasses'] as $class ) {
460 - if ( in_array( $class, $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
461 - $puppetinfo['classes'][] = $class;
462 - }
463 - }
464 - foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
465 - if ( isset ( $formData["$variable"] ) ) {
466 - $puppetinfo['variables']["$variable"] = $formData["$variable"];
467 - }
468 - }
469 - }
470 - $success = $host->modifyPuppetConfiguration( $puppetinfo );
471 - if ( $success ) {
472 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-modifiedinstance' ) );
473 - } else {
474 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-modifyinstancefailed' ) );
475 - }
476 - } else {
477 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) );
478 - }
479 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
480 -
481 - $wgOut->addHTML( $out );
482 - return true;
483 - }
484 -
485 - function validateInstanceName( $instancename, $alldata ) {
486 - if ( ! preg_match( "/^[a-z][a-z0-9\-]*$/", $instancename ) ) {
487 - return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'openstackmanager-badinstancename' ) );
488 - } else {
489 - return true;
490 - }
491 - }
492 -
493 -}
494 -
495 -class SpecialNovaInstanceForm extends HTMLForm {
496 -}
Index: trunk/extensions/OpenStackManager/SpecialNovaProject.php
@@ -1,303 +0,0 @@
2 -<?php
3 -class SpecialNovaProject extends SpecialNova {
4 -
5 - var $userNova, $adminNova;
6 -
7 - function __construct() {
8 - parent::__construct( 'NovaProject' );
9 -
10 - global $wgOpenStackManagerNovaAdminKeys;
11 -
12 - $this->userLDAP = new OpenStackNovaUser();
13 - $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
14 - $this->adminNova = new OpenStackNovaController( $adminCredentials );
15 - }
16 -
17 - public function isRestricted() {
18 - return true;
19 - }
20 -
21 -# public function userCanExecute( $user ) {
22 -# global $wgRequest;
23 -#
24 -# #$project = $wgRequest->getVal('project');
25 -# #if ( $project && ! $this->userLDAP->inProject( $project ) ) {
26 -# # return false;
27 -# #}
28 -# return true;
29 -# }
30 -
31 - function execute( $par ) {
32 - global $wgRequest, $wgUser;
33 -
34 - # if ( ! $wgUser->isAllowed( 'manageproject' ) ) {
35 - # return false;
36 - # }
37 - if ( ! $wgUser->isLoggedIn() ) {
38 - $this->notLoggedIn();
39 - return false;
40 - }
41 -
42 - $action = $wgRequest->getVal( 'action' );
43 - if ( $action == "create" ) {
44 - $this->createProject();
45 - } else if ( $action == "delete" ) {
46 - $this->deleteProject();
47 - } else if ( $action == "addmember" ) {
48 - $this->addMember();
49 - } else if ( $action == "deletemember" ) {
50 - $this->deleteMember();
51 - } else {
52 - $this->listProjects();
53 - }
54 - }
55 -
56 - function createProject() {
57 - global $wgRequest, $wgOut;
58 -
59 - $this->setHeaders();
60 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-createproject' ) );
61 -
62 - $projectInfo = Array();
63 - $projectInfo['projectname'] = array(
64 - 'type' => 'text',
65 - 'label-message' => 'openstackmanager-projectname',
66 - 'default' => '',
67 - 'section' => 'project/info',
68 - );
69 -
70 - $projectInfo['action'] = array(
71 - 'type' => 'hidden',
72 - 'default' => 'create',
73 - );
74 -
75 - $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
76 - $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
77 - $projectForm->setSubmitID( 'novaproject-form-createprojectsubmit' );
78 - $projectForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
79 - $projectForm->show();
80 -
81 - return true;
82 - }
83 -
84 - function addMember() {
85 - global $wgRequest, $wgOut;
86 -
87 - $this->setHeaders();
88 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-addmember' ) );
89 -
90 - $project = $wgRequest->getText( 'projectname' );
91 - $projectInfo = Array();
92 - $projectInfo['member'] = array(
93 - 'type' => 'text',
94 - 'label-message' => 'openstackmanager-member',
95 - 'default' => '',
96 - 'section' => 'project/info',
97 - );
98 - $projectInfo['action'] = array(
99 - 'type' => 'hidden',
100 - 'default' => 'addmember',
101 - );
102 - $projectInfo['projectname'] = array(
103 - 'type' => 'hidden',
104 - 'default' => $project,
105 - );
106 -
107 - $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
108 - $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
109 - $projectForm->setSubmitID( 'novaproject-form-addmembersubmit' );
110 - $projectForm->setSubmitCallback( array( $this, 'tryAddMemberSubmit' ) );
111 - $projectForm->show();
112 -
113 - return true;
114 - }
115 -
116 - function deleteMember() {
117 - global $wgRequest, $wgOut;
118 -
119 - $this->setHeaders();
120 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-removemember' ) );
121 -
122 - $member = $wgRequest->getText( 'member' );
123 - $project = $wgRequest->getText( 'projectname' );
124 - if ( ! $wgRequest->wasPosted() ) {
125 - $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removememberconfirm', array(), $member, $project ) );
126 - $wgOut->addHTML( $out );
127 - }
128 - $projectInfo = Array();
129 - $projectInfo['member'] = array(
130 - 'type' => 'hidden',
131 - 'default' => $member,
132 - );
133 - $projectInfo['action'] = array(
134 - 'type' => 'hidden',
135 - 'default' => 'deletemember',
136 - );
137 - $projectInfo['projectname'] = array(
138 - 'type' => 'hidden',
139 - 'default' => $project,
140 - );
141 -
142 - $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
143 - $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
144 - $projectForm->setSubmitID( 'novaproject-form-deletemembersubmit' );
145 - $projectForm->setSubmitCallback( array( $this, 'tryDeleteMemberSubmit' ) );
146 - $projectForm->show();
147 -
148 - return true;
149 - }
150 -
151 - function deleteProject() {
152 - global $wgOut, $wgRequest;
153 -
154 - $this->setHeaders();
155 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-deleteproject' ) );
156 -
157 - $project = $wgRequest->getText( 'projectname' );
158 - if ( ! $wgRequest->wasPosted() ) {
159 - $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removeprojectconfirm', array(), $project ) );
160 - $wgOut->addHTML( $out );
161 - }
162 - $projectInfo = Array();
163 - $projectInfo['projectname'] = array(
164 - 'type' => 'hidden',
165 - 'default' => $project,
166 - );
167 - $projectInfo['action'] = array(
168 - 'type' => 'hidden',
169 - 'default' => 'delete',
170 - );
171 - $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
172 - $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
173 - $projectForm->setSubmitID( 'novaproject-form-deleteprojectsubmit' );
174 - $projectForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
175 - $projectForm->setSubmitText( 'confirm' );
176 - $projectForm->show();
177 -
178 - return true;
179 - }
180 -
181 - function listProjects() {
182 - global $wgOut, $wgUser;
183 -
184 - $this->setHeaders();
185 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-projectlist' ) );
186 -
187 - $out = '';
188 - $sk = $wgUser->getSkin();
189 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createproject' ), array(), array( 'action' => 'create' ), array() );
190 - $projectsOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-projectname' ) );
191 - $projectsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-members' ) );
192 - $projectsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
193 - $projects = OpenStackNovaProject::getAllProjects();
194 - if ( ! $projects ) {
195 - $projectsOut = '';
196 - }
197 - foreach ( $projects as $project ) {
198 - $projectName = $project->getProjectName();
199 - $projectOut = Html::element( 'td', array(), $projectName );
200 - $projectMembers = $project->getMembers();
201 - $memberOut = '';
202 - foreach ( $projectMembers as $projectMember ) {
203 - $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-removemember' ), array(),
204 - array( 'action' => 'deletemember', 'projectname' => $projectName, 'member' => $projectMember ), array() );
205 - $projectMemberOut = htmlentities( $projectMember ) . ' (' . $link . ')';
206 - $memberOut .= Html::rawElement( 'li', array(), $projectMemberOut );
207 - }
208 - if ( $memberOut ) {
209 - $memberOut .= '<br />';
210 - $memberOut = Html::rawElement( 'ul', array(), $memberOut );
211 - }
212 - $memberOut .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-addmember' ), array(),
213 - array( 'action' => 'addmember', 'projectname' => $projectName ), array() );
214 - $projectOut .= Html::rawElement( 'td', array(), $memberOut );
215 - $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-deleteproject' ), array(),
216 - array( 'action' => 'delete', 'projectname' => $projectName ), array() );
217 - $projectOut .= Html::rawElement( 'td', array(), $link );
218 - $projectsOut .= Html::rawElement( 'tr', array(), $projectOut );
219 - }
220 - if ( $projectsOut ) {
221 - $out .= Html::rawElement( 'table', array( 'class' => 'wikitable' ), $projectsOut );
222 - }
223 -
224 - $wgOut->addHTML( $out );
225 - }
226 -
227 - function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
228 - global $wgOut, $wgUser;
229 -
230 - $success = OpenStackNovaProject::createProject( $formData['projectname'] );
231 - if ( ! $success ) {
232 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createprojectfailed' ) );
233 - $wgOut->addHTML( $out );
234 - return false;
235 - }
236 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createdproject' ) );
237 - $out .= '<br />';
238 - $sk = $wgUser->getSkin();
239 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
240 - $wgOut->addHTML( $out );
241 -
242 - return true;
243 - }
244 -
245 - function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
246 - global $wgOut, $wgUser;
247 -
248 - $success = OpenStackNovaProject::deleteProject( $formData['projectname'] );
249 - if ( $success ) {
250 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedproject' ) );
251 - } else {
252 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteprojectfailed' ) );
253 - }
254 - $out .= '<br />';
255 - $sk = $wgUser->getSkin();
256 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
257 - $wgOut->addHTML( $out );
258 -
259 - return true;
260 - }
261 -
262 - function tryAddMemberSubmit( $formData, $entryPoint = 'internal' ) {
263 - global $wgOut, $wgUser;
264 -
265 - $project = new OpenStackNovaProject( $formData['projectname'] );
266 - $success = $project->addMember( $formData['member'] );
267 - if ( $success ) {
268 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-addedto', array(), $formData['member'],
269 - $formData['projectname'] ) );
270 - } else {
271 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoadd', array(), $formData['member'],
272 - $formData['projectname'] ) );
273 - }
274 - $out .= '<br />';
275 - $sk = $wgUser->getSkin();
276 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
277 - $wgOut->addHTML( $out );
278 -
279 - return true;
280 - }
281 -
282 - function tryDeleteMemberSubmit( $formData, $entryPoint = 'internal' ) {
283 - global $wgOut, $wgUser;
284 -
285 - $project = new OpenStackNovaProject( $formData['projectname'] );
286 - $success = $project->deleteMember( $formData['member'] );
287 - if ( $success ) {
288 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removedfrom', array(), $formData['member'],
289 - $formData['projectname'] ) );
290 - } else {
291 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoremove', array(), $formData['member'],
292 - $formData['projectname'] ) );
293 - }
294 - $out .= '<br />';
295 - $sk = $wgUser->getSkin();
296 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
297 - $wgOut->addHTML( $out );
298 -
299 - return true;
300 - }
301 -}
302 -
303 -class SpecialNovaProjectForm extends HTMLForm {
304 -}
Index: trunk/extensions/OpenStackManager/SpecialNovaDomain.php
@@ -1,182 +0,0 @@
2 -<?php
3 -class SpecialNovaDomain extends SpecialNova {
4 -
5 - var $userNova, $adminNova;
6 -
7 - function __construct() {
8 - parent::__construct( 'NovaDomain' );
9 -
10 - global $wgOpenStackManagerNovaAdminKeys;
11 -
12 - $this->userLDAP = new OpenStackNovaUser();
13 - $this->adminNova = new OpenStackNovaController( $wgOpenStackManagerNovaAdminKeys );
14 - }
15 -
16 - public function isRestricted() {
17 - return true;
18 - }
19 -
20 - function execute( $par ) {
21 - global $wgRequest, $wgUser;
22 -
23 - # if ( ! $wgUser->isAllowed( 'manageproject' ) ) {
24 - # return false;
25 - # }
26 - if ( ! $wgUser->isLoggedIn() ) {
27 - $this->notLoggedIn();
28 - return false;
29 - }
30 -
31 - $action = $wgRequest->getVal( 'action' );
32 - if ( $action == "create" ) {
33 - $this->createDomain();
34 - } else if ( $action == "delete" ) {
35 - $this->deleteDomain();
36 - } else {
37 - $this->listDomains();
38 - }
39 - }
40 -
41 - function createDomain() {
42 - global $wgRequest, $wgOut;
43 - global $wgOpenStackManagerDNSOptions;
44 -
45 - $this->setHeaders();
46 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-createdomain' ) );
47 -
48 - $domainInfo = Array();
49 - $domainInfo['domainname'] = array(
50 - 'type' => 'text',
51 - 'label-message' => 'openstackmanager-domainname',
52 - 'default' => '',
53 - 'section' => 'domain/info',
54 - );
55 - $domainInfo['fqdn'] = array(
56 - 'type' => 'text',
57 - 'label-message' => 'openstackmanager-fqdn',
58 - 'default' => '',
59 - 'section' => 'domain/info',
60 - );
61 - $domainInfo['location'] = array(
62 - 'type' => 'text',
63 - 'label-message' => 'openstackmanager-location',
64 - 'default' => '',
65 - 'section' => 'domain/info',
66 - );
67 - $domainInfo['action'] = array(
68 - 'type' => 'hidden',
69 - 'default' => 'create',
70 - );
71 -
72 - $domainForm = new SpecialNovaDomainForm( $domainInfo, 'openstackmanager-novadomain' );
73 - $domainForm->setTitle( SpecialPage::getTitleFor( 'NovaDomain' ) );
74 - $domainForm->setSubmitID( 'novadomain-form-createdomainsubmit' );
75 - $domainForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
76 - $domainForm->show();
77 -
78 - return true;
79 - }
80 -
81 - function deleteDomain() {
82 - global $wgOut, $wgRequest;
83 -
84 - $this->setHeaders();
85 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletedomain' ) );
86 -
87 - $domainname = $wgRequest->getText( 'domainname' );
88 - if ( ! $wgRequest->wasPosted() ) {
89 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedomain-confirm', array(), $domainname ) );
90 - $wgOut->addHTML( $out );
91 - }
92 - $domainInfo = Array();
93 - $domainInfo['domainname'] = array(
94 - 'type' => 'hidden',
95 - 'default' => $domainname,
96 - );
97 - $domainInfo['action'] = array(
98 - 'type' => 'hidden',
99 - 'default' => 'delete',
100 - );
101 - $domainForm = new SpecialNovaDomainForm( $domainInfo, 'openstackmanager-novadomain' );
102 - $domainForm->setTitle( SpecialPage::getTitleFor( 'NovaDomain' ) );
103 - $domainForm->setSubmitID( 'novadomain-form-deletedomainsubmit' );
104 - $domainForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
105 - $domainForm->setSubmitText( 'confirm' );
106 - $domainForm->show();
107 -
108 - return true;
109 - }
110 -
111 - function listDomains() {
112 - global $wgOut, $wgUser;
113 -
114 - $this->setHeaders();
115 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-domainlist' ) );
116 -
117 - $out = '';
118 - $sk = $wgUser->getSkin();
119 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createdomain' ), array(), array( 'action' => 'create' ), array() );
120 - $domainsOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-domainname' ) );
121 - $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-fqdn' ) );
122 - $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-location' ) );
123 - $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
124 - $domains = OpenStackNovaDomain::getAllDomains();
125 - foreach ( $domains as $domain ) {
126 - $domainName = $domain->getDomainName();
127 - $fqdn = $domain->getFullyQualifiedDomainName();
128 - $location = $domain->getLocation();
129 - $domainOut = Html::element( 'td', array(), $domainName );
130 - $domainOut .= Html::element( 'td', array(), $fqdn );
131 - $domainOut .= Html::element( 'td', array(), $location );
132 - $msg = wfMsg( 'openstackmanager-delete' );
133 - $link = $sk->link( $this->getTitle(), $msg, array(),
134 - array( 'action' => 'delete', 'domainname' => $domainName ), array() );
135 - $domainOut .= Html::rawElement( 'td', array(), $link );
136 - $domainsOut .= Html::rawElement( 'tr', array(), $domainOut );
137 - }
138 - if ( $domains ) {
139 - $out .= Html::rawElement( 'table', array( 'class' => 'wikitable' ), $domainsOut );
140 - }
141 -
142 - $wgOut->addHTML( $out );
143 - }
144 -
145 - function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
146 - global $wgOut, $wgUser;
147 -
148 - $success = OpenStackNovaDomain::createDomain( $formData['domainname'], $formData['fqdn'], $formData['location'] );
149 - if ( ! $success ) {
150 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createdomainfailed' ) );
151 - $wgOut->addHTML( $out );
152 - return false;
153 - }
154 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createddomain' ) );
155 - $out .= '<br />';
156 - $sk = $wgUser->getSkin();
157 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backdomainlist' ), array(), array(), array() );
158 - $wgOut->addHTML( $out );
159 -
160 - return true;
161 - }
162 -
163 - function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
164 - global $wgOut, $wgUser;
165 -
166 - $success = OpenStackNovaDomain::deleteDomain( $formData['domainname'] );
167 - if ( $success ) {
168 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteddomain' ) );
169 - } else {
170 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-failedeletedomain' ) );
171 - }
172 - $out .= '<br />';
173 - $sk = $wgUser->getSkin();
174 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backdomainlist' ), array(), array(), array() );
175 - $wgOut->addHTML( $out );
176 -
177 - return true;
178 - }
179 -
180 -}
181 -
182 -class SpecialNovaDomainForm extends HTMLForm {
183 -}
Index: trunk/extensions/OpenStackManager/SpecialNova.php
@@ -1,27 +0,0 @@
2 -<?php
3 -
4 -abstract class SpecialNova extends SpecialPage {
5 - function notLoggedIn() {
6 - global $wgOut;
7 -
8 - $this->setHeaders();
9 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-notloggedin' ) );
10 - $wgOut->addHTML( wfMsg( 'openstackmanager-mustbeloggedin' ) );
11 - }
12 -
13 - function noCredentials() {
14 - global $wgOut;
15 -
16 - $this->setHeaders();
17 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-nonovacred' ) );
18 - $wgOut->addHTML( wfMsg( 'openstackmanager-nonovacred-admincreate' ) );
19 - }
20 -
21 - function notInProject() {
22 - global $wgOut;
23 -
24 - $this->setHeaders();
25 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-noaccount' ) );
26 - $wgOut->addHTML( wfMsg( 'openstackmanager-noaccount2' ) );
27 - }
28 -}
Index: trunk/extensions/OpenStackManager/SpecialNovaAddress.php
@@ -1,333 +0,0 @@
2 -<?php
3 -class SpecialNovaAddress extends SpecialNova {
4 -
5 - var $adminNova;
6 - var $userNova;
7 - var $userLDAP;
8 -
9 - function __construct() {
10 - parent::__construct( 'NovaAddress' );
11 - }
12 -
13 - function execute( $par ) {
14 - global $wgRequest, $wgUser;
15 - global $wgOpenStackManagerNovaAdminKeys;
16 -
17 - if ( ! $wgUser->isLoggedIn() ) {
18 - $this->notLoggedIn();
19 - return false;
20 - }
21 - $this->userLDAP = new OpenStackNovaUser();
22 - if ( ! $this->userLDAP->exists() ) {
23 - $this->noCredentials();
24 - return true;
25 - }
26 - $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
27 - $this->adminNova = new OpenStackNovaController( $adminCredentials );
28 -
29 - $action = $wgRequest->getVal( 'action' );
30 - if ( $action == "allocate" ) {
31 - $this->allocateAddress();
32 - } else if ( $action == "release" ) {
33 - $this->releaseAddress();
34 - } else if ( $action == "associate" ) {
35 - $this->associateAddress();
36 - } else if ( $action == "disassociate" ) {
37 - $this->disassociateAddress();
38 - } else {
39 - $this->listAddresses();
40 - }
41 - }
42 -
43 - function allocateAddress() {
44 - global $wgRequest, $wgOut;
45 -
46 - $this->setHeaders();
47 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-allocateaddress' ) );
48 -
49 - $project = $wgRequest->getText( 'project' );
50 - $userCredentials = $this->userLDAP->getCredentials( $project );
51 - $this->userNova = new OpenStackNovaController( $userCredentials );
52 - if ( ! $wgRequest->wasPosted() ) {
53 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-allocateaddress-confirm', array(), $project ) );
54 - $wgOut->addHTML( $out );
55 - }
56 - $addressInfo = Array();
57 - $addressInfo['project'] = array(
58 - 'type' => 'hidden',
59 - 'default' => $project,
60 - );
61 - $addressInfo['action'] = array(
62 - 'type' => 'hidden',
63 - 'default' => 'allocate',
64 - );
65 -
66 - $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
67 - $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
68 - $addressForm->setSubmitID( 'novaaddress-form-allocateaddresssubmit' );
69 - $addressForm->setSubmitCallback( array( $this, 'tryAllocateSubmit' ) );
70 - $addressForm->show();
71 -
72 - return true;
73 - }
74 -
75 - function releaseAddress() {
76 - global $wgOut, $wgRequest;
77 -
78 - $this->setHeaders();
79 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-releaseaddress' ) );
80 -
81 - $project = $wgRequest->getText( 'project' );
82 - $userCredentials = $this->userLDAP->getCredentials( $project );
83 - $this->userNova = new OpenStackNovaController( $userCredentials );
84 - $ip = $wgRequest->getText( 'ip' );
85 - if ( ! $wgRequest->wasPosted() ) {
86 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releaseaddress-confirm', array(), $ip ) );
87 - $wgOut->addHTML( $out );
88 - }
89 - $addressInfo = Array();
90 - $addressInfo['project'] = array(
91 - 'type' => 'hidden',
92 - 'default' => $project,
93 - );
94 - $addressInfo['ip'] = array(
95 - 'type' => 'hidden',
96 - 'default' => $ip,
97 - );
98 - $addressInfo['action'] = array(
99 - 'type' => 'hidden',
100 - 'default' => 'release',
101 - );
102 - $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
103 - $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
104 - $addressForm->setSubmitID( 'novaaddress-form-releaseaddresssubmit' );
105 - $addressForm->setSubmitCallback( array( $this, 'tryReleaseSubmit' ) );
106 - $addressForm->setSubmitText( 'confirm' );
107 - $addressForm->show();
108 -
109 - return true;
110 - }
111 -
112 - function associateAddress() {
113 - global $wgOut, $wgRequest;
114 -
115 - $this->setHeaders();
116 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-associateaddress' ) );
117 -
118 - $ip = $wgRequest->getText( 'ip' );
119 - $project = $wgRequest->getText( 'project' );
120 - $userCredentials = $this->userLDAP->getCredentials( $project );
121 - $this->userNova = new OpenStackNovaController( $userCredentials );
122 - $instances = $this->userNova->getInstances();
123 - $instance_keys = array();
124 - foreach ( $instances as $instance ) {
125 - if ( $instance->getOwner() == $project ) {
126 - $instancename = $instance->getInstanceName();
127 - $instanceid = $instance->getInstanceId();
128 - $instance_keys["$instancename"] = $instanceid;
129 - }
130 - }
131 - $addressInfo = array();
132 - $addressInfo['project'] = array(
133 - 'type' => 'hidden',
134 - 'default' => $project,
135 - );
136 - $addressInfo['ip'] = array(
137 - 'type' => 'hidden',
138 - 'default' => $ip,
139 - );
140 - $addressInfo['instanceid'] = array(
141 - 'type' => 'select',
142 - 'label-message' => 'openstackmanager-instancename',
143 - 'options' => $instance_keys,
144 - );
145 - $addressInfo['action'] = array(
146 - 'type' => 'hidden',
147 - 'default' => 'associate',
148 - );
149 - $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
150 - $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
151 - $addressForm->setSubmitID( 'novaaddress-form-releaseaddresssubmit' );
152 - $addressForm->setSubmitCallback( array( $this, 'tryAssociateSubmit' ) );
153 - $addressForm->show();
154 -
155 - }
156 -
157 - function disassociateAddress() {
158 - global $wgOut, $wgRequest;
159 -
160 - $this->setHeaders();
161 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-disassociateaddress' ) );
162 -
163 - $project = $wgRequest->getText( 'project' );
164 - $userCredentials = $this->userLDAP->getCredentials( $project );
165 - $this->userNova = new OpenStackNovaController( $userCredentials );
166 - $ip = $wgRequest->getText( 'ip' );
167 - if ( ! $wgRequest->wasPosted() ) {
168 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociateaddress-confirm', array(), $ip ) );
169 - $wgOut->addHTML( $out );
170 - }
171 - $addressInfo = Array();
172 - $addressInfo['project'] = array(
173 - 'type' => 'hidden',
174 - 'default' => $project,
175 - );
176 - $addressInfo['ip'] = array(
177 - 'type' => 'hidden',
178 - 'default' => $ip,
179 - );
180 - $addressInfo['action'] = array(
181 - 'type' => 'hidden',
182 - 'default' => 'disassociate',
183 - );
184 - $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
185 - $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
186 - $addressForm->setSubmitID( 'novaaddress-form-disassociateaddresssubmit' );
187 - $addressForm->setSubmitCallback( array( $this, 'tryDisassociateSubmit' ) );
188 - $addressForm->setSubmitText( 'confirm' );
189 - $addressForm->show();
190 -
191 - }
192 -
193 - function listAddresses() {
194 - global $wgOut, $wgUser;
195 -
196 - $this->setHeaders();
197 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-addresslist' ) );
198 -
199 - $userProjects = $this->userLDAP->getProjects();
200 - $out = '';
201 - $sk = $wgUser->getSkin();
202 - $header = Html::element( 'th', array(), wfMsg( 'openstackmanager-address' ) );
203 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceid' ) );
204 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancename' ) );
205 - $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
206 - $addresses = $this->adminNova->getAddresses();
207 - $projectArr = array();
208 - foreach ( $addresses as $address ) {
209 - $ip = $address->getPublicIP();
210 - $instanceid = $address->getInstanceId();
211 - $project = $address->getProject();
212 - $addressOut = Html::element( 'td', array(), $ip );
213 - if ( $instanceid ) {
214 - $addressOut .= Html::element( 'td', array(), $instanceid );
215 - $instance = $this->adminNova->getInstance( $instanceid );
216 - $instancename = $instance->getInstanceName();
217 - $addressOut .= Html::element( 'td', array(), $instancename );
218 - } else {
219 - $addressOut .= Html::element( 'td', array(), '' );
220 - $addressOut .= Html::element( 'td', array(), '' );
221 - }
222 - if ( $instanceid ) {
223 - $msg = wfMsg( 'openstackmanager-reassociateaddress' );
224 - } else {
225 - $msg = wfMsg( 'openstackmanager-releaseaddress' );
226 - $link = $sk->link( $this->getTitle(), $msg, array(),
227 - array( 'action' => 'release', 'ip' => $ip, 'project' => $project ), array() );
228 - $actions = Html::rawElement( 'li', array(), $link );
229 - $msg = wfMsg( 'openstackmanager-associateaddress' );
230 - }
231 - $link = $sk->link( $this->getTitle(), $msg, array(),
232 - array( 'action' => 'associate', 'ip' => $ip, 'project' => $project ), array() );
233 - $actions .= Html::rawElement( 'li', array(), $link );
234 - if ( $instanceid ) {
235 - $msg = wfMsg( 'openstackmanager-disassociateaddress' );
236 - $link = $sk->link( $this->getTitle(), $msg, array(),
237 - array( 'action' => 'disassociate', 'ip' => $ip, 'project' => $project ), array() );
238 - $actions .= Html::rawElement( 'li', array(), $link );
239 - }
240 - $actions = Html::rawElement( 'ul', array(), $actions );
241 - $addressOut .= Html::rawElement( 'td', array(), $actions );
242 - $projectArr["$project"] = Html::rawElement( 'tr', array(), $addressOut );
243 - }
244 - foreach ( $userProjects as $project ) {
245 - $out .= Html::element( 'h2', array(), $project );
246 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-allocateaddress' ), array(), array( 'action' => 'allocate', 'project' => $project ), array() );
247 - if ( isset( $projectArr["$project"] ) ) {
248 - $projectOut = $header;
249 - $projectOut .= $projectArr["$project"];
250 - $out .= Html::rawElement( 'table',
251 - array( 'id' => 'novainstancelist', 'class' => 'wikitable' ), $projectOut );
252 - }
253 - }
254 - $wgOut->addHTML( $out );
255 - }
256 -
257 - function tryAllocateSubmit( $formData, $entryPoint = 'internal' ) {
258 - global $wgOut, $wgUser;
259 -
260 - $address = $this->userNova->allocateAddress();
261 - if ( ! $address ) {
262 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-allocateaddressfailed' ) );
263 - $wgOut->addHTML( $out );
264 - return false;
265 - }
266 - $ip = $address->getPublicIP();
267 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-allocatedaddress' , array(), $ip ) );
268 - $out .= '<br />';
269 - $sk = $wgUser->getSkin();
270 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
271 - $wgOut->addHTML( $out );
272 -
273 - return true;
274 - }
275 -
276 - function tryReleaseSubmit( $formData, $entryPoint = 'internal' ) {
277 - global $wgOut, $wgUser;
278 -
279 - $ip = $formData['ip'];
280 - $success = $this->userNova->releaseAddress( $ip );
281 - if ( $success ) {
282 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releasedaddress', array(), $ip ) );
283 - } else {
284 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releaseaddressfailed', array(), $ip ) );
285 - }
286 - $out .= '<br />';
287 - $sk = $wgUser->getSkin();
288 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
289 - $wgOut->addHTML( $out );
290 -
291 - return true;
292 - }
293 -
294 - function tryAssociateSubmit( $formData, $entryPoint = 'internal' ) {
295 - global $wgOut, $wgUser;
296 -
297 - $instanceid = $formData['instanceid'];
298 - $ip = $formData['ip'];
299 - $address = $this->userNova->associateAddress( $instanceid, $ip );
300 - if ( $address ) {
301 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-associatedaddress', array(), $ip, $instanceid ) );
302 - } else {
303 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-associateaddressfailed', array(), $ip, $instanceid ) );
304 - }
305 - $out .= '<br />';
306 - $sk = $wgUser->getSkin();
307 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
308 - $wgOut->addHTML( $out );
309 -
310 - return true;
311 - }
312 -
313 - function tryDisassociateSubmit( $formData, $entryPoint = 'internal' ) {
314 - global $wgOut, $wgUser;
315 -
316 - $ip = $formData['ip'];
317 - $address = $this->userNova->disassociateAddress( $ip );
318 - if ( $address ) {
319 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociatedaddress', array(), $ip ) );
320 - } else {
321 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociateaddressfailed', array(), $ip ) );
322 - }
323 - $out .= '<br />';
324 - $sk = $wgUser->getSkin();
325 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
326 - $wgOut->addHTML( $out );
327 -
328 - return true;
329 - }
330 -
331 -}
332 -
333 -class SpecialNovaAddressForm extends HTMLForm {
334 -}
Index: trunk/extensions/OpenStackManager/SpecialNovaKey.php
@@ -1,241 +0,0 @@
2 -<?php
3 -class SpecialNovaKey extends SpecialNova {
4 -
5 - var $userNova, $userLDAP;
6 -
7 - function __construct() {
8 - parent::__construct( 'NovaKey' );
9 - }
10 -
11 - public function isRestricted() {
12 - return true;
13 - }
14 -
15 - function execute( $par ) {
16 - global $wgRequest, $wgUser;
17 -
18 - if ( ! $wgUser->isLoggedIn() ) {
19 - $this->notLoggedIn();
20 - return true;
21 - }
22 - $this->userLDAP = new OpenStackNovaUser();
23 - if ( ! $this->userLDAP->exists() ) {
24 - $this->noCredentials();
25 - return true;
26 - }
27 -
28 - $action = $wgRequest->getVal( 'action' );
29 - if ( $action == "import" ) {
30 - $this->importKey();
31 - } else if ( $action == "delete" ) {
32 - $this->deleteKey();
33 - } else {
34 - $this->listKeys();
35 - }
36 - }
37 -
38 - function importKey() {
39 - global $wgRequest, $wgOut;
40 - global $wgOpenStackManagerNovaKeypairStorage;
41 -
42 - if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
43 - $project = $wgRequest->getVal( 'project' );
44 - if ( $project && ! $this->userLDAP->inProject( $project ) ) {
45 - $this->notInProject();
46 - return true;
47 - }
48 - $userCredentials = $this->userLDAP->getCredentials( $project );
49 - $this->userNova = new OpenStackNovaController( $userCredentials );
50 - }
51 -
52 - $this->setHeaders();
53 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-importkey' ) );
54 -
55 - $keyInfo = Array();
56 -
57 - if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
58 - $keyInfo['keyname'] = array(
59 - 'type' => 'text',
60 - 'label-message' => 'openstackmanager-keyname',
61 - 'default' => '',
62 - 'section' => 'key/info',
63 - );
64 - }
65 -
66 - $keyInfo['key'] = array(
67 - 'type' => 'textarea',
68 - 'section' => 'key/info',
69 - 'default' => '',
70 - 'label-message' => 'openstackmanager-key',
71 - );
72 -
73 - $keyInfo['action'] = array(
74 - 'type' => 'hidden',
75 - 'default' => 'import',
76 - );
77 -
78 - $keyInfo['project'] = array(
79 - 'type' => 'hidden',
80 - 'default' => htmlentities( $project ),
81 - );
82 -
83 - $keyForm = new SpecialNovaKeyForm( $keyInfo, 'openstackmanager-novakey' );
84 - $keyForm->setTitle( SpecialPage::getTitleFor( 'NovaKey' ) );
85 - $keyForm->setSubmitID( 'novakey-form-createkeysubmit' );
86 - $keyForm->setSubmitCallback( array( $this, 'tryImportSubmit' ) );
87 - $keyForm->show();
88 -
89 - }
90 -
91 - function deleteKey() {
92 - global $wgOut, $wgRequest;
93 - global $wgOpenStackManagerNovaKeypairStorage;
94 -
95 - $this->setHeaders();
96 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletekey' ) );
97 -
98 - $keyInfo = Array();
99 -
100 - if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
101 - $keyname = $wgRequest->getVal( 'keyname' );
102 - $project = $wgRequest->getVal( 'project' );
103 - if ( $project && ! $this->userLDAP->inProject( $project ) ) {
104 - $this->notInProject();
105 - return true;
106 - }
107 - $keyInfo['keyname'] = array(
108 - 'type' => 'hidden',
109 - 'default' => $project,
110 - );
111 - $keyInfo['project'] = array(
112 - 'type' => 'hidden',
113 - 'default' => $keyname,
114 - );
115 - } else if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
116 - $hash = $wgRequest->getVal( 'hash' );
117 - $keypairs = $this->userLDAP->getKeypairs();
118 - if ( ! $wgRequest->wasPosted() ) {
119 - $out = Html::element( 'pre', array(), $keypairs[$hash] );
120 - $out .= Html::element( 'p', array(), wfMsg( 'openstackmanager-deletekeyconfirm' ) );
121 - $wgOut->addHTML( $out );
122 - }
123 - $keyInfo['hash'] = array(
124 - 'type' => 'hidden',
125 - 'default' => $hash,
126 - );
127 - }
128 - $keyInfo['key'] = array(
129 - 'type' => 'hidden',
130 - 'default' => $keypairs[$hash],
131 - );
132 - $keyInfo['action'] = array(
133 - 'type' => 'hidden',
134 - 'default' => 'delete',
135 - );
136 - $keyForm = new SpecialNovaKeyForm( $keyInfo, 'openstackmanager-novakey' );
137 - $keyForm->setTitle( SpecialPage::getTitleFor( 'NovaKey' ) );
138 - $keyForm->setSubmitID( 'novakey-form-deletekeysubmit' );
139 - $keyForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
140 - $keyForm->setSubmitText( 'confirm' );
141 - $keyForm->show();
142 - return true;
143 - }
144 -
145 - function listKeys() {
146 - global $wgOut, $wgUser;
147 - global $wgOpenStackManagerNovaKeypairStorage;
148 -
149 - $this->setHeaders();
150 - $wgOut->setPagetitle( wfMsg( 'openstackmanager-keylist' ) );
151 -
152 - $out = '';
153 - $sk = $wgUser->getSkin();
154 - if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
155 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-importkey' ), array(), array( 'action' => 'import' ), array() );
156 - $projects = $this->userLDAP->getProjects();
157 - foreach ( $projects as $project ) {
158 - $userCredentials = $this->userLDAP->getCredentials( $project );
159 - $this->userNova = new OpenStackNovaController( $userCredentials );
160 - $keypairs = $this->userNova->getKeypairs();
161 - if ( ! $keypairs ) {
162 - continue;
163 - }
164 - $out .= Html::element( 'h2', array(), $project );
165 - $projectOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-name' ) );
166 - $projectOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-fingerprint' ) );
167 - foreach ( $keypairs as $keypair ) {
168 - $keyOut = Html::element( 'td', array(), $keypair->getKeyName() );
169 - $keyOut .= Html::element( 'td', array(), $keypair->getKeyFingerprint() );
170 - $projectOut .= Html::rawElement( 'tr', array(), $keyOut );
171 - }
172 - $out .= Html::rawElement( 'table', array( 'id' => 'novakeylist', 'class' => 'wikitable' ), $projectOut );
173 - }
174 - } else if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
175 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-importkey' ), array(), array( 'action' => 'import' ), array() );
176 - $keypairs = $this->userLDAP->getKeypairs();
177 - $keysOut = '';
178 - foreach ( $keypairs as $hash => $key ) {
179 - $keyOut = Html::element( 'td', array(), $key );
180 - $msg = wfMsg( 'openstackmanager-delete' );
181 - $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'delete', 'hash' => $hash ), array() );
182 - $keyOut .= Html::rawElement( 'td', array(), $link );
183 - $keysOut .= Html::rawElement( 'tr', array(), $keyOut );
184 - }
185 - $out .= Html::rawElement( 'table', array(), $keysOut );
186 - } else {
187 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invalidkeypair' ) );
188 - }
189 -
190 - $wgOut->addHTML( $out );
191 - }
192 -
193 - function tryImportSubmit( $formData, $entryPoint = 'internal' ) {
194 - global $wgOut, $wgUser;
195 - global $wgOpenStackManagerNovaKeypairStorage;
196 -
197 - if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
198 - $success = $this->userLDAP->importKeypair( $formData['key'] );
199 - if ( ! $success ) {
200 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-keypairimportfailed' ) );
201 - $wgOut->addHTML( $out );
202 - return false;
203 - }
204 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-keypairimported' ) );
205 - } else if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
206 - # wgOpenStackManagerNovaKeypairStorage == 'nova'
207 - # OpenStack's EC2 API doesn't yet support importing keys, use
208 - # of this option isn't currently recommended
209 - $keypair = $this->userNova->importKeypair( $formData['keyname'], $formData['key'] );
210 -
211 - $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-keypairimportedfingerprint', array(),
212 - $keypair->getKeyName(), $keypair->getKeyFingerprint() ) );
213 - } else {
214 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invalidkeypair' ) );
215 - }
216 - $out .= '<br />';
217 - $sk = $wgUser->getSkin();
218 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backkeylist' ), array(), array(), array() );
219 - $wgOut->addHTML( $out );
220 - return true;
221 - }
222 -
223 - function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
224 - global $wgOut, $wgUser;
225 - global $wgOpenStackManagerNovaKeypairStorage;
226 -
227 - $success = $this->userLDAP->deleteKeypair( $formData['key'] );
228 - if ( $success ) {
229 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedkey' ) );
230 - } else {
231 - $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedkeyfailed' ) );
232 - }
233 - $out .= '<br />';
234 - $sk = $wgUser->getSkin();
235 - $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backkeylist' ), array(), array(), array() );
236 - $wgOut->addHTML( $out );
237 - return true;
238 - }
239 -}
240 -
241 -class SpecialNovaKeyForm extends HTMLForm {
242 -}
Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -0,0 +1,495 @@
 2+<?php
 3+class SpecialNovaInstance extends SpecialNova {
 4+
 5+ var $adminNova, $userNova;
 6+ var $userLDAP;
 7+
 8+ function __construct() {
 9+ parent::__construct( 'NovaInstance' );
 10+ }
 11+
 12+ function execute( $par ) {
 13+ global $wgRequest, $wgUser;
 14+ global $wgOpenStackManagerNovaAdminKeys;
 15+
 16+ if ( ! $wgUser->isLoggedIn() ) {
 17+ $this->notLoggedIn();
 18+ return true;
 19+ }
 20+ $user = new OpenStackNovaUser();
 21+ if ( ! $user->exists() ) {
 22+ $this->noCredentials();
 23+ return true;
 24+ }
 25+ $this->userLDAP = new OpenStackNovaUser();
 26+ $project = $wgRequest->getVal( 'project' );
 27+ $userCredentials = $user->getCredentials( $project );
 28+ $this->userNova = new OpenStackNovaController( $userCredentials );
 29+ $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
 30+ $this->adminNova = new OpenStackNovaController( $adminCredentials );
 31+
 32+ $action = $wgRequest->getVal( 'action' );
 33+
 34+ if ( $action == "create" ) {
 35+ if ( ! $user->inProject( $project ) ) {
 36+ $this->notInProject();
 37+ return true;
 38+ }
 39+ $this->createInstance();
 40+ } else if ( $action == "delete" ) {
 41+ if ( ! $user->inProject( $project ) ) {
 42+ $this->notInProject();
 43+ return true;
 44+ }
 45+ $this->deleteInstance();
 46+ } else if ( $action == "rename" ) {
 47+ if ( ! $user->inProject( $project ) ) {
 48+ $this->notInProject();
 49+ return true;
 50+ }
 51+ $this->renameInstance();
 52+ } else if ( $action == "configure" ) {
 53+ if ( ! $user->inProject( $project ) ) {
 54+ $this->notInProject();
 55+ return true;
 56+ }
 57+ $this->configureInstance();
 58+ } else {
 59+ $this->listInstances();
 60+ }
 61+ }
 62+
 63+ function createInstance() {
 64+ global $wgRequest, $wgOut;
 65+ global $wgOpenStackManagerPuppetOptions;
 66+
 67+ $this->setHeaders();
 68+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-createinstance' ) );
 69+
 70+ $instanceInfo = Array();
 71+ $instanceInfo['instancename'] = array(
 72+ 'type' => 'text',
 73+ 'label-message' => 'openstackmanager-instancename',
 74+ 'validation-callback' => array( $this, 'validateInstanceName' ),
 75+ 'default' => '',
 76+ 'section' => 'instance/info',
 77+ );
 78+
 79+ $instanceTypes = $this->adminNova->getInstanceTypes();
 80+ $instanceType_keys = Array();
 81+ foreach ( $instanceTypes as $instanceType ) {
 82+ $instanceType_keys["$instanceType"] = $instanceType;
 83+ }
 84+ $instanceInfo['instanceType'] = array(
 85+ 'type' => 'select',
 86+ 'label-message' => 'openstackmanager-instancetype',
 87+ 'section' => 'instance/info',
 88+ 'options' => $instanceType_keys,
 89+ );
 90+
 91+ # Availability zone names can't be translated. Get the keys, and make an array
 92+ # where the name points to itself as a value
 93+ $availabilityZones = $this->adminNova->getAvailabilityZones();
 94+ $availabilityZone_keys = Array();
 95+ foreach ( array_keys( $availabilityZones ) as $availabilityZone_key ) {
 96+ $availabilityZone_keys["$availabilityZone_key"] = $availabilityZone_key;
 97+ }
 98+ $instanceInfo['availabilityZone'] = array(
 99+ 'type' => 'select',
 100+ 'section' => 'instance/info',
 101+ 'options' => $availabilityZone_keys,
 102+ 'label-message' => 'openstackmanager-availabilityzone',
 103+ );
 104+
 105+ # Image names can't be translated. Get the image, and make an array
 106+ # where the name points to itself as a value
 107+ $images = $this->adminNova->getImages();
 108+ $image_keys = Array();
 109+ foreach ( array_keys( $images ) as $image_key ) {
 110+ $image_keys["$image_key"] = $image_key;
 111+ }
 112+ $instanceInfo['imageType'] = array(
 113+ 'type' => 'select',
 114+ 'section' => 'instance/info',
 115+ 'options' => $image_keys,
 116+ 'label-message' => 'openstackmanager-imagetype',
 117+ );
 118+
 119+ # Keypair names can't be translated. Get the keys, and make an array
 120+ # where the name points to itself as a value
 121+ # TODO: get keypairs as the user, not the admin
 122+ # $keypairs = $this->userNova->getKeypairs();
 123+ # $keypair_keys = Array();
 124+ # foreach ( array_keys( $keypairs ) as $keypair_key ) {
 125+ # $keypair_keys["$keypair_key"] = $keypair_key;
 126+ # }
 127+ # $instanceInfo['keypair'] = array(
 128+ # 'type' => 'select',
 129+ # 'section' => 'instance/info',
 130+ # 'options' => $keypair_keys,
 131+ # 'label-message' => 'keypair',
 132+ # );
 133+
 134+ $domains = OpenStackNovaDomain::getAllDomains( true );
 135+ $domain_keys = array();
 136+ foreach ( $domains as $domain ) {
 137+ $domainname = $domain->getDomainName();
 138+ $domain_keys["$domainname"] = $domainname;
 139+ }
 140+ $instanceInfo['domain'] = array(
 141+ 'type' => 'select',
 142+ 'section' => 'instance/info',
 143+ 'options' => $domain_keys,
 144+ 'label-message' => 'openstackmanager-dnsdomain',
 145+ );
 146+
 147+ $instanceInfo['project'] = array(
 148+ 'type' => 'hidden',
 149+ 'default' => $wgRequest->getText( 'project' ),
 150+ );
 151+
 152+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
 153+ if ( $wgOpenStackManagerPuppetOptions['availableclasses'] ) {
 154+ $classes = array();
 155+ foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
 156+ $classes["$class"] = $class;
 157+ }
 158+ $instanceInfo['puppetclasses'] = array(
 159+ 'type' => 'multiselect',
 160+ 'section' => 'instance/puppetinfo',
 161+ 'options' => $classes,
 162+ 'label-message' => 'openstackmanager-puppetclasses',
 163+ );
 164+ }
 165+
 166+ if ( $wgOpenStackManagerPuppetOptions['availablevariables'] ) {
 167+ foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
 168+ $instanceInfo["$variable"] = array(
 169+ 'type' => 'text',
 170+ 'section' => 'instance/puppetinfo',
 171+ 'label' => $variable,
 172+ );
 173+ }
 174+ }
 175+ }
 176+
 177+ $instanceInfo['action'] = array(
 178+ 'type' => 'hidden',
 179+ 'default' => 'create',
 180+ );
 181+
 182+ $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
 183+ $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
 184+ $instanceForm->setSubmitID( 'openstackmanager-novainstance-createinstancesubmit' );
 185+ $instanceForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
 186+ $instanceForm->show();
 187+
 188+ }
 189+
 190+ function configureInstance() {
 191+ global $wgRequest, $wgOut;
 192+ global $wgOpenStackManagerPuppetOptions;
 193+
 194+ $this->setHeaders();
 195+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-configureinstance' ) );
 196+
 197+ $instanceid = $wgRequest->getText( 'instanceid' );
 198+
 199+ $instanceInfo = Array();
 200+ $instanceInfo['instanceid'] = array(
 201+ 'type' => 'hidden',
 202+ 'default' => $instanceid,
 203+ );
 204+ $instanceInfo['project'] = array(
 205+ 'type' => 'hidden',
 206+ 'default' => $wgRequest->getText( 'project' ),
 207+ );
 208+
 209+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
 210+ $host = OpenStackNovaHost::getHostByInstanceId( $instanceid );
 211+ if ( ! $host ) {
 212+ $wgOut->addHTML( Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) ) );
 213+ return false;
 214+ }
 215+ $puppetinfo = $host->getPuppetConfiguration();
 216+
 217+ if ( $wgOpenStackManagerPuppetOptions['availableclasses'] ) {
 218+ $classes = array();
 219+ $defaults = array();
 220+ foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
 221+ $classes["$class"] = $class;
 222+ if ( in_array( $class, $puppetinfo['puppetclass'] ) ) {
 223+ $defaults["$class"] = $class;
 224+ }
 225+ }
 226+ $instanceInfo['puppetclasses'] = array(
 227+ 'type' => 'multiselect',
 228+ 'section' => 'instance/puppetinfo',
 229+ 'options' => $classes,
 230+ 'default' => $defaults,
 231+ 'label-message' => 'openstackmanager-puppetclasses',
 232+ );
 233+ }
 234+
 235+ if ( $wgOpenStackManagerPuppetOptions['availablevariables'] ) {
 236+ foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
 237+ $default = '';
 238+ if ( array_key_exists( $variable, $puppetinfo['puppetvar'] ) ) {
 239+ $default = $puppetinfo['puppetvar']["$variable"];
 240+ }
 241+ $instanceInfo["$variable"] = array(
 242+ 'type' => 'text',
 243+ 'section' => 'instance/puppetinfo',
 244+ 'label' => $variable,
 245+ 'default' => $default,
 246+ );
 247+ }
 248+ }
 249+ }
 250+
 251+ $instanceInfo['action'] = array(
 252+ 'type' => 'hidden',
 253+ 'default' => 'configure',
 254+ );
 255+
 256+ $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
 257+ $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
 258+ $instanceForm->setSubmitID( 'novainstance-form-configureinstancesubmit' );
 259+ $instanceForm->setSubmitCallback( array( $this, 'tryConfigureSubmit' ) );
 260+ $instanceForm->show();
 261+
 262+ return true;
 263+ }
 264+
 265+ function deleteInstance() {
 266+ global $wgOut, $wgRequest;
 267+
 268+ $this->setHeaders();
 269+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletedomain' ) );
 270+
 271+ $instanceid = $wgRequest->getText( 'instanceid' );
 272+ $project = $wgRequest->getText( 'project' );
 273+ if ( ! $wgRequest->wasPosted() ) {
 274+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deleteinstancequestion', array(), $instanceid ) );
 275+ $wgOut->addHTML( $out );
 276+ }
 277+ $instanceInfo = Array();
 278+ $instanceInfo['instanceid'] = array(
 279+ 'type' => 'hidden',
 280+ 'default' => $instanceid,
 281+ );
 282+ $instanceInfo['project'] = array(
 283+ 'type' => 'hidden',
 284+ 'default' => $project,
 285+ );
 286+ $instanceInfo['action'] = array(
 287+ 'type' => 'hidden',
 288+ 'default' => 'delete',
 289+ );
 290+ $instanceForm = new SpecialNovaInstanceForm( $instanceInfo, 'openstackmanager-novainstance' );
 291+ $instanceForm->setTitle( SpecialPage::getTitleFor( 'NovaInstance' ) );
 292+ $instanceForm->setSubmitID( 'novainstance-form-deleteinstancesubmit' );
 293+ $instanceForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
 294+ $instanceForm->setSubmitText( 'confirm' );
 295+ $instanceForm->show();
 296+
 297+ return true;
 298+ }
 299+
 300+ function modifyInstance() {
 301+ return true;
 302+ }
 303+
 304+ function listInstances() {
 305+ global $wgOut, $wgUser;
 306+
 307+ $this->setHeaders();
 308+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-instancelist' ) );
 309+
 310+ $userProjects = $this->userLDAP->getProjects();
 311+ $sk = $wgUser->getSkin();
 312+ $out = '';
 313+ $instances = $this->adminNova->getInstances();
 314+ $header = Html::element( 'th', array(), wfMsg( 'openstackmanager-instancename' ) );
 315+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceid' ) );
 316+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancestate' ) );
 317+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancetype' ) );
 318+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceip' ) );
 319+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-imageid' ) );
 320+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
 321+ $projectArr = array();
 322+ foreach ( $instances as $instance ) {
 323+ $project = $instance->getOwner();
 324+ if ( ! in_array( $project, $userProjects ) ) {
 325+ continue;
 326+ }
 327+ $instanceName = (string)$instance->getInstanceName();
 328+ $title = Title::newFromText( $instanceName, NS_VM );
 329+ $instanceNameLink = $sk->link( $title, $instanceName, array(), array(), array() );
 330+ $instanceOut = Html::rawElement( 'td', array(), $instanceNameLink );
 331+ $instanceOut .= Html::element( 'td', array(), $instance->getInstanceId() );
 332+ $instanceOut .= Html::element( 'td', array(), $instance->getInstanceState() );
 333+ $instanceOut .= Html::element( 'td', array(), $instance->getInstanceType() );
 334+ $instanceOut .= Html::element( 'td', array(), $instance->getInstancePrivateIP() );
 335+ $instanceOut .= Html::element( 'td', array(), $instance->getImageId() );
 336+ $msg = wfMsg( 'openstackmanager-delete' );
 337+ $actions = $sk->link( $this->getTitle(), $msg, array(),
 338+ array( 'action' => 'delete',
 339+ 'project' => $project,
 340+ 'instanceid' => $instance->getInstanceId() ),
 341+ array() );
 342+ $actions .= ', ';
 343+ $msg = wfMsg( 'openstackmanager-rename' );
 344+ $actions .= $sk->link( $this->getTitle(), $msg, array(),
 345+ array( 'action' => 'rename',
 346+ 'project' => $project,
 347+ 'instanceid' => $instance->getInstanceId() ),
 348+ array() );
 349+ $actions .= ', ';
 350+ $msg = wfMsg( 'openstackmanager-configure' );
 351+ $actions .= $sk->link( $this->getTitle(), $msg, array(),
 352+ array( 'action' => 'configure',
 353+ 'project' => $project,
 354+ 'instanceid' => $instance->getInstanceId() ),
 355+ array() );
 356+ $instanceOut .= Html::rawElement( 'td', array(), $actions );
 357+ $projectArr["$project"] .= Html::rawElement( 'tr', array(), $instanceOut );
 358+ }
 359+ foreach ( $userProjects as $project ) {
 360+ $out .= Html::element( 'h2', array(), $project );
 361+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createinstance' ), array(),
 362+ array( 'action' => 'create', 'project' => $project ), array() );
 363+ if ( isset( $projectArr["$project"] ) ) {
 364+ $projectOut = $header;
 365+ $projectOut .= $projectArr["$project"];
 366+ $out .= Html::rawElement( 'table',
 367+ array( 'id' => 'novainstancelist', 'class' => 'wikitable' ), $projectOut );
 368+ }
 369+ }
 370+
 371+ $wgOut->addHTML( $out );
 372+ }
 373+
 374+ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
 375+ global $wgOut, $wgUser;
 376+ global $wgOpenStackManagerPuppetOptions;
 377+
 378+ $sk = $wgUser->getSkin();
 379+ $domain = OpenStackNovaDomain::getDomainByName( $formData['domain'] );
 380+ if ( ! $domain ) {
 381+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invaliddomain' ) );
 382+ return false;
 383+ }
 384+ $instance = $this->userNova->createInstance( $formData['instancename'], $formData['imageType'], '', $formData['instanceType'], $formData['availabilityZone'] );
 385+ if ( $instance ) {
 386+ $puppetinfo = array();
 387+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
 388+ foreach ( $formData['puppetclasses'] as $class ) {
 389+ if ( in_array( $class, $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
 390+ $puppetinfo['classes'][] = $class;
 391+ }
 392+ }
 393+ foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
 394+ if ( isset ( $formData["$variable"] ) ) {
 395+ $puppetinfo['variables']["$variable"] = $formData["$variable"];
 396+ }
 397+ }
 398+ }
 399+ $host = OpenStackNovaHost::addHost( $instance, $domain, $puppetinfo );
 400+
 401+ if ( $host ) {
 402+ $title = Title::newFromText( $wgOut->getPageTitle() );
 403+ $job = new OpenStackNovaHostJob( $title, array( 'instanceid' => (string)$instance->getInstanceId() ) );
 404+ $job->insert();
 405+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-createdinstance', array(),
 406+ $instance->getInstanceID(), $instance->getImageId(),
 407+ $host->getFullyQualifiedHostName() ) );
 408+ } else {
 409+ $this->userNova->terminateInstance( $instance->getInstanceId() );
 410+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createfailedldap' ) );
 411+ }
 412+ # TODO: also add puppet
 413+ } else {
 414+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createinstancefailed' ) );
 415+ }
 416+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
 417+
 418+ $wgOut->addHTML( $out );
 419+ return true;
 420+ }
 421+
 422+ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
 423+ global $wgOut, $wgUser;
 424+
 425+ $sk = $wgUser->getSkin();
 426+ $instance = $this->adminNova->getInstance( $formData['instanceid'] );
 427+ if ( ! $instance ) {
 428+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) );
 429+ return true;
 430+ }
 431+ $instancename = $instance->getInstanceName();
 432+ $instanceid = $instance->getInstanceId();
 433+ $success = $this->userNova->terminateInstance( $instanceid );
 434+ if ( $success ) {
 435+ $success = OpenStackNovaHost::deleteHostByInstanceId( $instanceid );
 436+ if ( $success ) {
 437+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedinstance', array(), $instanceid ) );
 438+ } else {
 439+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedinstance-faileddns', array(), $instancename, $instanceid ) );
 440+ }
 441+ } else {
 442+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteinstancefailed' ) );
 443+ }
 444+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
 445+
 446+ $wgOut->addHTML( $out );
 447+ return true;
 448+ }
 449+
 450+ function tryConfigureSubmit( $formData, $entryPoint = 'internal' ) {
 451+ global $wgOut, $wgUser;
 452+ global $wgOpenStackManagerPuppetOptions;
 453+
 454+ $sk = $wgUser->getSkin();
 455+ $host = OpenStackNovaHost::getHostByInstanceId( $formData['instanceid'] );
 456+ if ( $host ) {
 457+ $puppetinfo = array();
 458+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
 459+ foreach ( $formData['puppetclasses'] as $class ) {
 460+ if ( in_array( $class, $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
 461+ $puppetinfo['classes'][] = $class;
 462+ }
 463+ }
 464+ foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
 465+ if ( isset ( $formData["$variable"] ) ) {
 466+ $puppetinfo['variables']["$variable"] = $formData["$variable"];
 467+ }
 468+ }
 469+ }
 470+ $success = $host->modifyPuppetConfiguration( $puppetinfo );
 471+ if ( $success ) {
 472+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-modifiedinstance' ) );
 473+ } else {
 474+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-modifyinstancefailed' ) );
 475+ }
 476+ } else {
 477+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-nonexistanthost' ) );
 478+ }
 479+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backinstancelist' ), array(), array(), array() );
 480+
 481+ $wgOut->addHTML( $out );
 482+ return true;
 483+ }
 484+
 485+ function validateInstanceName( $instancename, $alldata ) {
 486+ if ( ! preg_match( "/^[a-z][a-z0-9\-]*$/", $instancename ) ) {
 487+ return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'openstackmanager-badinstancename' ) );
 488+ } else {
 489+ return true;
 490+ }
 491+ }
 492+
 493+}
 494+
 495+class SpecialNovaInstanceForm extends HTMLForm {
 496+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
___________________________________________________________________
Added: svn:eol-style
1497 + native
Index: trunk/extensions/OpenStackManager/special/SpecialNovaAddress.php
@@ -0,0 +1,333 @@
 2+<?php
 3+class SpecialNovaAddress extends SpecialNova {
 4+
 5+ var $adminNova;
 6+ var $userNova;
 7+ var $userLDAP;
 8+
 9+ function __construct() {
 10+ parent::__construct( 'NovaAddress' );
 11+ }
 12+
 13+ function execute( $par ) {
 14+ global $wgRequest, $wgUser;
 15+ global $wgOpenStackManagerNovaAdminKeys;
 16+
 17+ if ( ! $wgUser->isLoggedIn() ) {
 18+ $this->notLoggedIn();
 19+ return false;
 20+ }
 21+ $this->userLDAP = new OpenStackNovaUser();
 22+ if ( ! $this->userLDAP->exists() ) {
 23+ $this->noCredentials();
 24+ return true;
 25+ }
 26+ $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
 27+ $this->adminNova = new OpenStackNovaController( $adminCredentials );
 28+
 29+ $action = $wgRequest->getVal( 'action' );
 30+ if ( $action == "allocate" ) {
 31+ $this->allocateAddress();
 32+ } else if ( $action == "release" ) {
 33+ $this->releaseAddress();
 34+ } else if ( $action == "associate" ) {
 35+ $this->associateAddress();
 36+ } else if ( $action == "disassociate" ) {
 37+ $this->disassociateAddress();
 38+ } else {
 39+ $this->listAddresses();
 40+ }
 41+ }
 42+
 43+ function allocateAddress() {
 44+ global $wgRequest, $wgOut;
 45+
 46+ $this->setHeaders();
 47+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-allocateaddress' ) );
 48+
 49+ $project = $wgRequest->getText( 'project' );
 50+ $userCredentials = $this->userLDAP->getCredentials( $project );
 51+ $this->userNova = new OpenStackNovaController( $userCredentials );
 52+ if ( ! $wgRequest->wasPosted() ) {
 53+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-allocateaddress-confirm', array(), $project ) );
 54+ $wgOut->addHTML( $out );
 55+ }
 56+ $addressInfo = Array();
 57+ $addressInfo['project'] = array(
 58+ 'type' => 'hidden',
 59+ 'default' => $project,
 60+ );
 61+ $addressInfo['action'] = array(
 62+ 'type' => 'hidden',
 63+ 'default' => 'allocate',
 64+ );
 65+
 66+ $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
 67+ $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
 68+ $addressForm->setSubmitID( 'novaaddress-form-allocateaddresssubmit' );
 69+ $addressForm->setSubmitCallback( array( $this, 'tryAllocateSubmit' ) );
 70+ $addressForm->show();
 71+
 72+ return true;
 73+ }
 74+
 75+ function releaseAddress() {
 76+ global $wgOut, $wgRequest;
 77+
 78+ $this->setHeaders();
 79+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-releaseaddress' ) );
 80+
 81+ $project = $wgRequest->getText( 'project' );
 82+ $userCredentials = $this->userLDAP->getCredentials( $project );
 83+ $this->userNova = new OpenStackNovaController( $userCredentials );
 84+ $ip = $wgRequest->getText( 'ip' );
 85+ if ( ! $wgRequest->wasPosted() ) {
 86+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releaseaddress-confirm', array(), $ip ) );
 87+ $wgOut->addHTML( $out );
 88+ }
 89+ $addressInfo = Array();
 90+ $addressInfo['project'] = array(
 91+ 'type' => 'hidden',
 92+ 'default' => $project,
 93+ );
 94+ $addressInfo['ip'] = array(
 95+ 'type' => 'hidden',
 96+ 'default' => $ip,
 97+ );
 98+ $addressInfo['action'] = array(
 99+ 'type' => 'hidden',
 100+ 'default' => 'release',
 101+ );
 102+ $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
 103+ $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
 104+ $addressForm->setSubmitID( 'novaaddress-form-releaseaddresssubmit' );
 105+ $addressForm->setSubmitCallback( array( $this, 'tryReleaseSubmit' ) );
 106+ $addressForm->setSubmitText( 'confirm' );
 107+ $addressForm->show();
 108+
 109+ return true;
 110+ }
 111+
 112+ function associateAddress() {
 113+ global $wgOut, $wgRequest;
 114+
 115+ $this->setHeaders();
 116+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-associateaddress' ) );
 117+
 118+ $ip = $wgRequest->getText( 'ip' );
 119+ $project = $wgRequest->getText( 'project' );
 120+ $userCredentials = $this->userLDAP->getCredentials( $project );
 121+ $this->userNova = new OpenStackNovaController( $userCredentials );
 122+ $instances = $this->userNova->getInstances();
 123+ $instance_keys = array();
 124+ foreach ( $instances as $instance ) {
 125+ if ( $instance->getOwner() == $project ) {
 126+ $instancename = $instance->getInstanceName();
 127+ $instanceid = $instance->getInstanceId();
 128+ $instance_keys["$instancename"] = $instanceid;
 129+ }
 130+ }
 131+ $addressInfo = array();
 132+ $addressInfo['project'] = array(
 133+ 'type' => 'hidden',
 134+ 'default' => $project,
 135+ );
 136+ $addressInfo['ip'] = array(
 137+ 'type' => 'hidden',
 138+ 'default' => $ip,
 139+ );
 140+ $addressInfo['instanceid'] = array(
 141+ 'type' => 'select',
 142+ 'label-message' => 'openstackmanager-instancename',
 143+ 'options' => $instance_keys,
 144+ );
 145+ $addressInfo['action'] = array(
 146+ 'type' => 'hidden',
 147+ 'default' => 'associate',
 148+ );
 149+ $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
 150+ $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
 151+ $addressForm->setSubmitID( 'novaaddress-form-releaseaddresssubmit' );
 152+ $addressForm->setSubmitCallback( array( $this, 'tryAssociateSubmit' ) );
 153+ $addressForm->show();
 154+
 155+ }
 156+
 157+ function disassociateAddress() {
 158+ global $wgOut, $wgRequest;
 159+
 160+ $this->setHeaders();
 161+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-disassociateaddress' ) );
 162+
 163+ $project = $wgRequest->getText( 'project' );
 164+ $userCredentials = $this->userLDAP->getCredentials( $project );
 165+ $this->userNova = new OpenStackNovaController( $userCredentials );
 166+ $ip = $wgRequest->getText( 'ip' );
 167+ if ( ! $wgRequest->wasPosted() ) {
 168+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociateaddress-confirm', array(), $ip ) );
 169+ $wgOut->addHTML( $out );
 170+ }
 171+ $addressInfo = Array();
 172+ $addressInfo['project'] = array(
 173+ 'type' => 'hidden',
 174+ 'default' => $project,
 175+ );
 176+ $addressInfo['ip'] = array(
 177+ 'type' => 'hidden',
 178+ 'default' => $ip,
 179+ );
 180+ $addressInfo['action'] = array(
 181+ 'type' => 'hidden',
 182+ 'default' => 'disassociate',
 183+ );
 184+ $addressForm = new SpecialNovaAddressForm( $addressInfo, 'openstackmanager-novaaddress' );
 185+ $addressForm->setTitle( SpecialPage::getTitleFor( 'NovaAddress' ) );
 186+ $addressForm->setSubmitID( 'novaaddress-form-disassociateaddresssubmit' );
 187+ $addressForm->setSubmitCallback( array( $this, 'tryDisassociateSubmit' ) );
 188+ $addressForm->setSubmitText( 'confirm' );
 189+ $addressForm->show();
 190+
 191+ }
 192+
 193+ function listAddresses() {
 194+ global $wgOut, $wgUser;
 195+
 196+ $this->setHeaders();
 197+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-addresslist' ) );
 198+
 199+ $userProjects = $this->userLDAP->getProjects();
 200+ $out = '';
 201+ $sk = $wgUser->getSkin();
 202+ $header = Html::element( 'th', array(), wfMsg( 'openstackmanager-address' ) );
 203+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instanceid' ) );
 204+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-instancename' ) );
 205+ $header .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
 206+ $addresses = $this->adminNova->getAddresses();
 207+ $projectArr = array();
 208+ foreach ( $addresses as $address ) {
 209+ $ip = $address->getPublicIP();
 210+ $instanceid = $address->getInstanceId();
 211+ $project = $address->getProject();
 212+ $addressOut = Html::element( 'td', array(), $ip );
 213+ if ( $instanceid ) {
 214+ $addressOut .= Html::element( 'td', array(), $instanceid );
 215+ $instance = $this->adminNova->getInstance( $instanceid );
 216+ $instancename = $instance->getInstanceName();
 217+ $addressOut .= Html::element( 'td', array(), $instancename );
 218+ } else {
 219+ $addressOut .= Html::element( 'td', array(), '' );
 220+ $addressOut .= Html::element( 'td', array(), '' );
 221+ }
 222+ if ( $instanceid ) {
 223+ $msg = wfMsg( 'openstackmanager-reassociateaddress' );
 224+ } else {
 225+ $msg = wfMsg( 'openstackmanager-releaseaddress' );
 226+ $link = $sk->link( $this->getTitle(), $msg, array(),
 227+ array( 'action' => 'release', 'ip' => $ip, 'project' => $project ), array() );
 228+ $actions = Html::rawElement( 'li', array(), $link );
 229+ $msg = wfMsg( 'openstackmanager-associateaddress' );
 230+ }
 231+ $link = $sk->link( $this->getTitle(), $msg, array(),
 232+ array( 'action' => 'associate', 'ip' => $ip, 'project' => $project ), array() );
 233+ $actions .= Html::rawElement( 'li', array(), $link );
 234+ if ( $instanceid ) {
 235+ $msg = wfMsg( 'openstackmanager-disassociateaddress' );
 236+ $link = $sk->link( $this->getTitle(), $msg, array(),
 237+ array( 'action' => 'disassociate', 'ip' => $ip, 'project' => $project ), array() );
 238+ $actions .= Html::rawElement( 'li', array(), $link );
 239+ }
 240+ $actions = Html::rawElement( 'ul', array(), $actions );
 241+ $addressOut .= Html::rawElement( 'td', array(), $actions );
 242+ $projectArr["$project"] = Html::rawElement( 'tr', array(), $addressOut );
 243+ }
 244+ foreach ( $userProjects as $project ) {
 245+ $out .= Html::element( 'h2', array(), $project );
 246+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-allocateaddress' ), array(), array( 'action' => 'allocate', 'project' => $project ), array() );
 247+ if ( isset( $projectArr["$project"] ) ) {
 248+ $projectOut = $header;
 249+ $projectOut .= $projectArr["$project"];
 250+ $out .= Html::rawElement( 'table',
 251+ array( 'id' => 'novainstancelist', 'class' => 'wikitable' ), $projectOut );
 252+ }
 253+ }
 254+ $wgOut->addHTML( $out );
 255+ }
 256+
 257+ function tryAllocateSubmit( $formData, $entryPoint = 'internal' ) {
 258+ global $wgOut, $wgUser;
 259+
 260+ $address = $this->userNova->allocateAddress();
 261+ if ( ! $address ) {
 262+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-allocateaddressfailed' ) );
 263+ $wgOut->addHTML( $out );
 264+ return false;
 265+ }
 266+ $ip = $address->getPublicIP();
 267+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-allocatedaddress' , array(), $ip ) );
 268+ $out .= '<br />';
 269+ $sk = $wgUser->getSkin();
 270+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
 271+ $wgOut->addHTML( $out );
 272+
 273+ return true;
 274+ }
 275+
 276+ function tryReleaseSubmit( $formData, $entryPoint = 'internal' ) {
 277+ global $wgOut, $wgUser;
 278+
 279+ $ip = $formData['ip'];
 280+ $success = $this->userNova->releaseAddress( $ip );
 281+ if ( $success ) {
 282+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releasedaddress', array(), $ip ) );
 283+ } else {
 284+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-releaseaddressfailed', array(), $ip ) );
 285+ }
 286+ $out .= '<br />';
 287+ $sk = $wgUser->getSkin();
 288+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
 289+ $wgOut->addHTML( $out );
 290+
 291+ return true;
 292+ }
 293+
 294+ function tryAssociateSubmit( $formData, $entryPoint = 'internal' ) {
 295+ global $wgOut, $wgUser;
 296+
 297+ $instanceid = $formData['instanceid'];
 298+ $ip = $formData['ip'];
 299+ $address = $this->userNova->associateAddress( $instanceid, $ip );
 300+ if ( $address ) {
 301+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-associatedaddress', array(), $ip, $instanceid ) );
 302+ } else {
 303+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-associateaddressfailed', array(), $ip, $instanceid ) );
 304+ }
 305+ $out .= '<br />';
 306+ $sk = $wgUser->getSkin();
 307+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
 308+ $wgOut->addHTML( $out );
 309+
 310+ return true;
 311+ }
 312+
 313+ function tryDisassociateSubmit( $formData, $entryPoint = 'internal' ) {
 314+ global $wgOut, $wgUser;
 315+
 316+ $ip = $formData['ip'];
 317+ $address = $this->userNova->disassociateAddress( $ip );
 318+ if ( $address ) {
 319+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociatedaddress', array(), $ip ) );
 320+ } else {
 321+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-disassociateaddressfailed', array(), $ip ) );
 322+ }
 323+ $out .= '<br />';
 324+ $sk = $wgUser->getSkin();
 325+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backaddresslist' ), array(), array(), array() );
 326+ $wgOut->addHTML( $out );
 327+
 328+ return true;
 329+ }
 330+
 331+}
 332+
 333+class SpecialNovaAddressForm extends HTMLForm {
 334+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaAddress.php
___________________________________________________________________
Added: svn:eol-style
1335 + native
Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
@@ -0,0 +1,303 @@
 2+<?php
 3+class SpecialNovaProject extends SpecialNova {
 4+
 5+ var $userNova, $adminNova;
 6+
 7+ function __construct() {
 8+ parent::__construct( 'NovaProject' );
 9+
 10+ global $wgOpenStackManagerNovaAdminKeys;
 11+
 12+ $this->userLDAP = new OpenStackNovaUser();
 13+ $adminCredentials = $wgOpenStackManagerNovaAdminKeys;
 14+ $this->adminNova = new OpenStackNovaController( $adminCredentials );
 15+ }
 16+
 17+ public function isRestricted() {
 18+ return true;
 19+ }
 20+
 21+# public function userCanExecute( $user ) {
 22+# global $wgRequest;
 23+#
 24+# #$project = $wgRequest->getVal('project');
 25+# #if ( $project && ! $this->userLDAP->inProject( $project ) ) {
 26+# # return false;
 27+# #}
 28+# return true;
 29+# }
 30+
 31+ function execute( $par ) {
 32+ global $wgRequest, $wgUser;
 33+
 34+ # if ( ! $wgUser->isAllowed( 'manageproject' ) ) {
 35+ # return false;
 36+ # }
 37+ if ( ! $wgUser->isLoggedIn() ) {
 38+ $this->notLoggedIn();
 39+ return false;
 40+ }
 41+
 42+ $action = $wgRequest->getVal( 'action' );
 43+ if ( $action == "create" ) {
 44+ $this->createProject();
 45+ } else if ( $action == "delete" ) {
 46+ $this->deleteProject();
 47+ } else if ( $action == "addmember" ) {
 48+ $this->addMember();
 49+ } else if ( $action == "deletemember" ) {
 50+ $this->deleteMember();
 51+ } else {
 52+ $this->listProjects();
 53+ }
 54+ }
 55+
 56+ function createProject() {
 57+ global $wgRequest, $wgOut;
 58+
 59+ $this->setHeaders();
 60+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-createproject' ) );
 61+
 62+ $projectInfo = Array();
 63+ $projectInfo['projectname'] = array(
 64+ 'type' => 'text',
 65+ 'label-message' => 'openstackmanager-projectname',
 66+ 'default' => '',
 67+ 'section' => 'project/info',
 68+ );
 69+
 70+ $projectInfo['action'] = array(
 71+ 'type' => 'hidden',
 72+ 'default' => 'create',
 73+ );
 74+
 75+ $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
 76+ $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
 77+ $projectForm->setSubmitID( 'novaproject-form-createprojectsubmit' );
 78+ $projectForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
 79+ $projectForm->show();
 80+
 81+ return true;
 82+ }
 83+
 84+ function addMember() {
 85+ global $wgRequest, $wgOut;
 86+
 87+ $this->setHeaders();
 88+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-addmember' ) );
 89+
 90+ $project = $wgRequest->getText( 'projectname' );
 91+ $projectInfo = Array();
 92+ $projectInfo['member'] = array(
 93+ 'type' => 'text',
 94+ 'label-message' => 'openstackmanager-member',
 95+ 'default' => '',
 96+ 'section' => 'project/info',
 97+ );
 98+ $projectInfo['action'] = array(
 99+ 'type' => 'hidden',
 100+ 'default' => 'addmember',
 101+ );
 102+ $projectInfo['projectname'] = array(
 103+ 'type' => 'hidden',
 104+ 'default' => $project,
 105+ );
 106+
 107+ $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
 108+ $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
 109+ $projectForm->setSubmitID( 'novaproject-form-addmembersubmit' );
 110+ $projectForm->setSubmitCallback( array( $this, 'tryAddMemberSubmit' ) );
 111+ $projectForm->show();
 112+
 113+ return true;
 114+ }
 115+
 116+ function deleteMember() {
 117+ global $wgRequest, $wgOut;
 118+
 119+ $this->setHeaders();
 120+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-removemember' ) );
 121+
 122+ $member = $wgRequest->getText( 'member' );
 123+ $project = $wgRequest->getText( 'projectname' );
 124+ if ( ! $wgRequest->wasPosted() ) {
 125+ $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removememberconfirm', array(), $member, $project ) );
 126+ $wgOut->addHTML( $out );
 127+ }
 128+ $projectInfo = Array();
 129+ $projectInfo['member'] = array(
 130+ 'type' => 'hidden',
 131+ 'default' => $member,
 132+ );
 133+ $projectInfo['action'] = array(
 134+ 'type' => 'hidden',
 135+ 'default' => 'deletemember',
 136+ );
 137+ $projectInfo['projectname'] = array(
 138+ 'type' => 'hidden',
 139+ 'default' => $project,
 140+ );
 141+
 142+ $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
 143+ $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
 144+ $projectForm->setSubmitID( 'novaproject-form-deletemembersubmit' );
 145+ $projectForm->setSubmitCallback( array( $this, 'tryDeleteMemberSubmit' ) );
 146+ $projectForm->show();
 147+
 148+ return true;
 149+ }
 150+
 151+ function deleteProject() {
 152+ global $wgOut, $wgRequest;
 153+
 154+ $this->setHeaders();
 155+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-deleteproject' ) );
 156+
 157+ $project = $wgRequest->getText( 'projectname' );
 158+ if ( ! $wgRequest->wasPosted() ) {
 159+ $out .= Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removeprojectconfirm', array(), $project ) );
 160+ $wgOut->addHTML( $out );
 161+ }
 162+ $projectInfo = Array();
 163+ $projectInfo['projectname'] = array(
 164+ 'type' => 'hidden',
 165+ 'default' => $project,
 166+ );
 167+ $projectInfo['action'] = array(
 168+ 'type' => 'hidden',
 169+ 'default' => 'delete',
 170+ );
 171+ $projectForm = new SpecialNovaProjectForm( $projectInfo, 'openstackmanager-novaproject' );
 172+ $projectForm->setTitle( SpecialPage::getTitleFor( 'NovaProject' ) );
 173+ $projectForm->setSubmitID( 'novaproject-form-deleteprojectsubmit' );
 174+ $projectForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
 175+ $projectForm->setSubmitText( 'confirm' );
 176+ $projectForm->show();
 177+
 178+ return true;
 179+ }
 180+
 181+ function listProjects() {
 182+ global $wgOut, $wgUser;
 183+
 184+ $this->setHeaders();
 185+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-projectlist' ) );
 186+
 187+ $out = '';
 188+ $sk = $wgUser->getSkin();
 189+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createproject' ), array(), array( 'action' => 'create' ), array() );
 190+ $projectsOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-projectname' ) );
 191+ $projectsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-members' ) );
 192+ $projectsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
 193+ $projects = OpenStackNovaProject::getAllProjects();
 194+ if ( ! $projects ) {
 195+ $projectsOut = '';
 196+ }
 197+ foreach ( $projects as $project ) {
 198+ $projectName = $project->getProjectName();
 199+ $projectOut = Html::element( 'td', array(), $projectName );
 200+ $projectMembers = $project->getMembers();
 201+ $memberOut = '';
 202+ foreach ( $projectMembers as $projectMember ) {
 203+ $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-removemember' ), array(),
 204+ array( 'action' => 'deletemember', 'projectname' => $projectName, 'member' => $projectMember ), array() );
 205+ $projectMemberOut = htmlentities( $projectMember ) . ' (' . $link . ')';
 206+ $memberOut .= Html::rawElement( 'li', array(), $projectMemberOut );
 207+ }
 208+ if ( $memberOut ) {
 209+ $memberOut .= '<br />';
 210+ $memberOut = Html::rawElement( 'ul', array(), $memberOut );
 211+ }
 212+ $memberOut .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-addmember' ), array(),
 213+ array( 'action' => 'addmember', 'projectname' => $projectName ), array() );
 214+ $projectOut .= Html::rawElement( 'td', array(), $memberOut );
 215+ $link = $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-deleteproject' ), array(),
 216+ array( 'action' => 'delete', 'projectname' => $projectName ), array() );
 217+ $projectOut .= Html::rawElement( 'td', array(), $link );
 218+ $projectsOut .= Html::rawElement( 'tr', array(), $projectOut );
 219+ }
 220+ if ( $projectsOut ) {
 221+ $out .= Html::rawElement( 'table', array( 'class' => 'wikitable' ), $projectsOut );
 222+ }
 223+
 224+ $wgOut->addHTML( $out );
 225+ }
 226+
 227+ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
 228+ global $wgOut, $wgUser;
 229+
 230+ $success = OpenStackNovaProject::createProject( $formData['projectname'] );
 231+ if ( ! $success ) {
 232+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createprojectfailed' ) );
 233+ $wgOut->addHTML( $out );
 234+ return false;
 235+ }
 236+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createdproject' ) );
 237+ $out .= '<br />';
 238+ $sk = $wgUser->getSkin();
 239+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
 240+ $wgOut->addHTML( $out );
 241+
 242+ return true;
 243+ }
 244+
 245+ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
 246+ global $wgOut, $wgUser;
 247+
 248+ $success = OpenStackNovaProject::deleteProject( $formData['projectname'] );
 249+ if ( $success ) {
 250+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedproject' ) );
 251+ } else {
 252+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteprojectfailed' ) );
 253+ }
 254+ $out .= '<br />';
 255+ $sk = $wgUser->getSkin();
 256+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
 257+ $wgOut->addHTML( $out );
 258+
 259+ return true;
 260+ }
 261+
 262+ function tryAddMemberSubmit( $formData, $entryPoint = 'internal' ) {
 263+ global $wgOut, $wgUser;
 264+
 265+ $project = new OpenStackNovaProject( $formData['projectname'] );
 266+ $success = $project->addMember( $formData['member'] );
 267+ if ( $success ) {
 268+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-addedto', array(), $formData['member'],
 269+ $formData['projectname'] ) );
 270+ } else {
 271+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoadd', array(), $formData['member'],
 272+ $formData['projectname'] ) );
 273+ }
 274+ $out .= '<br />';
 275+ $sk = $wgUser->getSkin();
 276+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
 277+ $wgOut->addHTML( $out );
 278+
 279+ return true;
 280+ }
 281+
 282+ function tryDeleteMemberSubmit( $formData, $entryPoint = 'internal' ) {
 283+ global $wgOut, $wgUser;
 284+
 285+ $project = new OpenStackNovaProject( $formData['projectname'] );
 286+ $success = $project->deleteMember( $formData['member'] );
 287+ if ( $success ) {
 288+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-removedfrom', array(), $formData['member'],
 289+ $formData['projectname'] ) );
 290+ } else {
 291+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-failedtoremove', array(), $formData['member'],
 292+ $formData['projectname'] ) );
 293+ }
 294+ $out .= '<br />';
 295+ $sk = $wgUser->getSkin();
 296+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backprojectlist' ), array(), array(), array() );
 297+ $wgOut->addHTML( $out );
 298+
 299+ return true;
 300+ }
 301+}
 302+
 303+class SpecialNovaProjectForm extends HTMLForm {
 304+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php
___________________________________________________________________
Added: svn:eol-style
1305 + native
Index: trunk/extensions/OpenStackManager/special/SpecialNovaDomain.php
@@ -0,0 +1,182 @@
 2+<?php
 3+class SpecialNovaDomain extends SpecialNova {
 4+
 5+ var $userNova, $adminNova;
 6+
 7+ function __construct() {
 8+ parent::__construct( 'NovaDomain' );
 9+
 10+ global $wgOpenStackManagerNovaAdminKeys;
 11+
 12+ $this->userLDAP = new OpenStackNovaUser();
 13+ $this->adminNova = new OpenStackNovaController( $wgOpenStackManagerNovaAdminKeys );
 14+ }
 15+
 16+ public function isRestricted() {
 17+ return true;
 18+ }
 19+
 20+ function execute( $par ) {
 21+ global $wgRequest, $wgUser;
 22+
 23+ # if ( ! $wgUser->isAllowed( 'manageproject' ) ) {
 24+ # return false;
 25+ # }
 26+ if ( ! $wgUser->isLoggedIn() ) {
 27+ $this->notLoggedIn();
 28+ return false;
 29+ }
 30+
 31+ $action = $wgRequest->getVal( 'action' );
 32+ if ( $action == "create" ) {
 33+ $this->createDomain();
 34+ } else if ( $action == "delete" ) {
 35+ $this->deleteDomain();
 36+ } else {
 37+ $this->listDomains();
 38+ }
 39+ }
 40+
 41+ function createDomain() {
 42+ global $wgRequest, $wgOut;
 43+ global $wgOpenStackManagerDNSOptions;
 44+
 45+ $this->setHeaders();
 46+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-createdomain' ) );
 47+
 48+ $domainInfo = Array();
 49+ $domainInfo['domainname'] = array(
 50+ 'type' => 'text',
 51+ 'label-message' => 'openstackmanager-domainname',
 52+ 'default' => '',
 53+ 'section' => 'domain/info',
 54+ );
 55+ $domainInfo['fqdn'] = array(
 56+ 'type' => 'text',
 57+ 'label-message' => 'openstackmanager-fqdn',
 58+ 'default' => '',
 59+ 'section' => 'domain/info',
 60+ );
 61+ $domainInfo['location'] = array(
 62+ 'type' => 'text',
 63+ 'label-message' => 'openstackmanager-location',
 64+ 'default' => '',
 65+ 'section' => 'domain/info',
 66+ );
 67+ $domainInfo['action'] = array(
 68+ 'type' => 'hidden',
 69+ 'default' => 'create',
 70+ );
 71+
 72+ $domainForm = new SpecialNovaDomainForm( $domainInfo, 'openstackmanager-novadomain' );
 73+ $domainForm->setTitle( SpecialPage::getTitleFor( 'NovaDomain' ) );
 74+ $domainForm->setSubmitID( 'novadomain-form-createdomainsubmit' );
 75+ $domainForm->setSubmitCallback( array( $this, 'tryCreateSubmit' ) );
 76+ $domainForm->show();
 77+
 78+ return true;
 79+ }
 80+
 81+ function deleteDomain() {
 82+ global $wgOut, $wgRequest;
 83+
 84+ $this->setHeaders();
 85+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletedomain' ) );
 86+
 87+ $domainname = $wgRequest->getText( 'domainname' );
 88+ if ( ! $wgRequest->wasPosted() ) {
 89+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-deletedomain-confirm', array(), $domainname ) );
 90+ $wgOut->addHTML( $out );
 91+ }
 92+ $domainInfo = Array();
 93+ $domainInfo['domainname'] = array(
 94+ 'type' => 'hidden',
 95+ 'default' => $domainname,
 96+ );
 97+ $domainInfo['action'] = array(
 98+ 'type' => 'hidden',
 99+ 'default' => 'delete',
 100+ );
 101+ $domainForm = new SpecialNovaDomainForm( $domainInfo, 'openstackmanager-novadomain' );
 102+ $domainForm->setTitle( SpecialPage::getTitleFor( 'NovaDomain' ) );
 103+ $domainForm->setSubmitID( 'novadomain-form-deletedomainsubmit' );
 104+ $domainForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
 105+ $domainForm->setSubmitText( 'confirm' );
 106+ $domainForm->show();
 107+
 108+ return true;
 109+ }
 110+
 111+ function listDomains() {
 112+ global $wgOut, $wgUser;
 113+
 114+ $this->setHeaders();
 115+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-domainlist' ) );
 116+
 117+ $out = '';
 118+ $sk = $wgUser->getSkin();
 119+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-createdomain' ), array(), array( 'action' => 'create' ), array() );
 120+ $domainsOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-domainname' ) );
 121+ $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-fqdn' ) );
 122+ $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-location' ) );
 123+ $domainsOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-actions' ) );
 124+ $domains = OpenStackNovaDomain::getAllDomains();
 125+ foreach ( $domains as $domain ) {
 126+ $domainName = $domain->getDomainName();
 127+ $fqdn = $domain->getFullyQualifiedDomainName();
 128+ $location = $domain->getLocation();
 129+ $domainOut = Html::element( 'td', array(), $domainName );
 130+ $domainOut .= Html::element( 'td', array(), $fqdn );
 131+ $domainOut .= Html::element( 'td', array(), $location );
 132+ $msg = wfMsg( 'openstackmanager-delete' );
 133+ $link = $sk->link( $this->getTitle(), $msg, array(),
 134+ array( 'action' => 'delete', 'domainname' => $domainName ), array() );
 135+ $domainOut .= Html::rawElement( 'td', array(), $link );
 136+ $domainsOut .= Html::rawElement( 'tr', array(), $domainOut );
 137+ }
 138+ if ( $domains ) {
 139+ $out .= Html::rawElement( 'table', array( 'class' => 'wikitable' ), $domainsOut );
 140+ }
 141+
 142+ $wgOut->addHTML( $out );
 143+ }
 144+
 145+ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) {
 146+ global $wgOut, $wgUser;
 147+
 148+ $success = OpenStackNovaDomain::createDomain( $formData['domainname'], $formData['fqdn'], $formData['location'] );
 149+ if ( ! $success ) {
 150+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createdomainfailed' ) );
 151+ $wgOut->addHTML( $out );
 152+ return false;
 153+ }
 154+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-createddomain' ) );
 155+ $out .= '<br />';
 156+ $sk = $wgUser->getSkin();
 157+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backdomainlist' ), array(), array(), array() );
 158+ $wgOut->addHTML( $out );
 159+
 160+ return true;
 161+ }
 162+
 163+ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
 164+ global $wgOut, $wgUser;
 165+
 166+ $success = OpenStackNovaDomain::deleteDomain( $formData['domainname'] );
 167+ if ( $success ) {
 168+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deleteddomain' ) );
 169+ } else {
 170+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-failedeletedomain' ) );
 171+ }
 172+ $out .= '<br />';
 173+ $sk = $wgUser->getSkin();
 174+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backdomainlist' ), array(), array(), array() );
 175+ $wgOut->addHTML( $out );
 176+
 177+ return true;
 178+ }
 179+
 180+}
 181+
 182+class SpecialNovaDomainForm extends HTMLForm {
 183+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaDomain.php
___________________________________________________________________
Added: svn:eol-style
1184 + native
Index: trunk/extensions/OpenStackManager/special/SpecialNovaKey.php
@@ -0,0 +1,241 @@
 2+<?php
 3+class SpecialNovaKey extends SpecialNova {
 4+
 5+ var $userNova, $userLDAP;
 6+
 7+ function __construct() {
 8+ parent::__construct( 'NovaKey' );
 9+ }
 10+
 11+ public function isRestricted() {
 12+ return true;
 13+ }
 14+
 15+ function execute( $par ) {
 16+ global $wgRequest, $wgUser;
 17+
 18+ if ( ! $wgUser->isLoggedIn() ) {
 19+ $this->notLoggedIn();
 20+ return true;
 21+ }
 22+ $this->userLDAP = new OpenStackNovaUser();
 23+ if ( ! $this->userLDAP->exists() ) {
 24+ $this->noCredentials();
 25+ return true;
 26+ }
 27+
 28+ $action = $wgRequest->getVal( 'action' );
 29+ if ( $action == "import" ) {
 30+ $this->importKey();
 31+ } else if ( $action == "delete" ) {
 32+ $this->deleteKey();
 33+ } else {
 34+ $this->listKeys();
 35+ }
 36+ }
 37+
 38+ function importKey() {
 39+ global $wgRequest, $wgOut;
 40+ global $wgOpenStackManagerNovaKeypairStorage;
 41+
 42+ if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
 43+ $project = $wgRequest->getVal( 'project' );
 44+ if ( $project && ! $this->userLDAP->inProject( $project ) ) {
 45+ $this->notInProject();
 46+ return true;
 47+ }
 48+ $userCredentials = $this->userLDAP->getCredentials( $project );
 49+ $this->userNova = new OpenStackNovaController( $userCredentials );
 50+ }
 51+
 52+ $this->setHeaders();
 53+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-importkey' ) );
 54+
 55+ $keyInfo = Array();
 56+
 57+ if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
 58+ $keyInfo['keyname'] = array(
 59+ 'type' => 'text',
 60+ 'label-message' => 'openstackmanager-keyname',
 61+ 'default' => '',
 62+ 'section' => 'key/info',
 63+ );
 64+ }
 65+
 66+ $keyInfo['key'] = array(
 67+ 'type' => 'textarea',
 68+ 'section' => 'key/info',
 69+ 'default' => '',
 70+ 'label-message' => 'openstackmanager-key',
 71+ );
 72+
 73+ $keyInfo['action'] = array(
 74+ 'type' => 'hidden',
 75+ 'default' => 'import',
 76+ );
 77+
 78+ $keyInfo['project'] = array(
 79+ 'type' => 'hidden',
 80+ 'default' => htmlentities( $project ),
 81+ );
 82+
 83+ $keyForm = new SpecialNovaKeyForm( $keyInfo, 'openstackmanager-novakey' );
 84+ $keyForm->setTitle( SpecialPage::getTitleFor( 'NovaKey' ) );
 85+ $keyForm->setSubmitID( 'novakey-form-createkeysubmit' );
 86+ $keyForm->setSubmitCallback( array( $this, 'tryImportSubmit' ) );
 87+ $keyForm->show();
 88+
 89+ }
 90+
 91+ function deleteKey() {
 92+ global $wgOut, $wgRequest;
 93+ global $wgOpenStackManagerNovaKeypairStorage;
 94+
 95+ $this->setHeaders();
 96+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-deletekey' ) );
 97+
 98+ $keyInfo = Array();
 99+
 100+ if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
 101+ $keyname = $wgRequest->getVal( 'keyname' );
 102+ $project = $wgRequest->getVal( 'project' );
 103+ if ( $project && ! $this->userLDAP->inProject( $project ) ) {
 104+ $this->notInProject();
 105+ return true;
 106+ }
 107+ $keyInfo['keyname'] = array(
 108+ 'type' => 'hidden',
 109+ 'default' => $project,
 110+ );
 111+ $keyInfo['project'] = array(
 112+ 'type' => 'hidden',
 113+ 'default' => $keyname,
 114+ );
 115+ } else if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
 116+ $hash = $wgRequest->getVal( 'hash' );
 117+ $keypairs = $this->userLDAP->getKeypairs();
 118+ if ( ! $wgRequest->wasPosted() ) {
 119+ $out = Html::element( 'pre', array(), $keypairs[$hash] );
 120+ $out .= Html::element( 'p', array(), wfMsg( 'openstackmanager-deletekeyconfirm' ) );
 121+ $wgOut->addHTML( $out );
 122+ }
 123+ $keyInfo['hash'] = array(
 124+ 'type' => 'hidden',
 125+ 'default' => $hash,
 126+ );
 127+ }
 128+ $keyInfo['key'] = array(
 129+ 'type' => 'hidden',
 130+ 'default' => $keypairs[$hash],
 131+ );
 132+ $keyInfo['action'] = array(
 133+ 'type' => 'hidden',
 134+ 'default' => 'delete',
 135+ );
 136+ $keyForm = new SpecialNovaKeyForm( $keyInfo, 'openstackmanager-novakey' );
 137+ $keyForm->setTitle( SpecialPage::getTitleFor( 'NovaKey' ) );
 138+ $keyForm->setSubmitID( 'novakey-form-deletekeysubmit' );
 139+ $keyForm->setSubmitCallback( array( $this, 'tryDeleteSubmit' ) );
 140+ $keyForm->setSubmitText( 'confirm' );
 141+ $keyForm->show();
 142+ return true;
 143+ }
 144+
 145+ function listKeys() {
 146+ global $wgOut, $wgUser;
 147+ global $wgOpenStackManagerNovaKeypairStorage;
 148+
 149+ $this->setHeaders();
 150+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-keylist' ) );
 151+
 152+ $out = '';
 153+ $sk = $wgUser->getSkin();
 154+ if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
 155+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-importkey' ), array(), array( 'action' => 'import' ), array() );
 156+ $projects = $this->userLDAP->getProjects();
 157+ foreach ( $projects as $project ) {
 158+ $userCredentials = $this->userLDAP->getCredentials( $project );
 159+ $this->userNova = new OpenStackNovaController( $userCredentials );
 160+ $keypairs = $this->userNova->getKeypairs();
 161+ if ( ! $keypairs ) {
 162+ continue;
 163+ }
 164+ $out .= Html::element( 'h2', array(), $project );
 165+ $projectOut = Html::element( 'th', array(), wfMsg( 'openstackmanager-name' ) );
 166+ $projectOut .= Html::element( 'th', array(), wfMsg( 'openstackmanager-fingerprint' ) );
 167+ foreach ( $keypairs as $keypair ) {
 168+ $keyOut = Html::element( 'td', array(), $keypair->getKeyName() );
 169+ $keyOut .= Html::element( 'td', array(), $keypair->getKeyFingerprint() );
 170+ $projectOut .= Html::rawElement( 'tr', array(), $keyOut );
 171+ }
 172+ $out .= Html::rawElement( 'table', array( 'id' => 'novakeylist', 'class' => 'wikitable' ), $projectOut );
 173+ }
 174+ } else if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
 175+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-importkey' ), array(), array( 'action' => 'import' ), array() );
 176+ $keypairs = $this->userLDAP->getKeypairs();
 177+ $keysOut = '';
 178+ foreach ( $keypairs as $hash => $key ) {
 179+ $keyOut = Html::element( 'td', array(), $key );
 180+ $msg = wfMsg( 'openstackmanager-delete' );
 181+ $link = $sk->link( $this->getTitle(), $msg, array(), array( 'action' => 'delete', 'hash' => $hash ), array() );
 182+ $keyOut .= Html::rawElement( 'td', array(), $link );
 183+ $keysOut .= Html::rawElement( 'tr', array(), $keyOut );
 184+ }
 185+ $out .= Html::rawElement( 'table', array(), $keysOut );
 186+ } else {
 187+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invalidkeypair' ) );
 188+ }
 189+
 190+ $wgOut->addHTML( $out );
 191+ }
 192+
 193+ function tryImportSubmit( $formData, $entryPoint = 'internal' ) {
 194+ global $wgOut, $wgUser;
 195+ global $wgOpenStackManagerNovaKeypairStorage;
 196+
 197+ if ( $wgOpenStackManagerNovaKeypairStorage == 'ldap' ) {
 198+ $success = $this->userLDAP->importKeypair( $formData['key'] );
 199+ if ( ! $success ) {
 200+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-keypairimportfailed' ) );
 201+ $wgOut->addHTML( $out );
 202+ return false;
 203+ }
 204+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-keypairimported' ) );
 205+ } else if ( $wgOpenStackManagerNovaKeypairStorage == 'nova' ) {
 206+ # wgOpenStackManagerNovaKeypairStorage == 'nova'
 207+ # OpenStack's EC2 API doesn't yet support importing keys, use
 208+ # of this option isn't currently recommended
 209+ $keypair = $this->userNova->importKeypair( $formData['keyname'], $formData['key'] );
 210+
 211+ $out = Html::element( 'p', array(), wfMsgExt( 'openstackmanager-keypairimportedfingerprint', array(),
 212+ $keypair->getKeyName(), $keypair->getKeyFingerprint() ) );
 213+ } else {
 214+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invalidkeypair' ) );
 215+ }
 216+ $out .= '<br />';
 217+ $sk = $wgUser->getSkin();
 218+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backkeylist' ), array(), array(), array() );
 219+ $wgOut->addHTML( $out );
 220+ return true;
 221+ }
 222+
 223+ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) {
 224+ global $wgOut, $wgUser;
 225+ global $wgOpenStackManagerNovaKeypairStorage;
 226+
 227+ $success = $this->userLDAP->deleteKeypair( $formData['key'] );
 228+ if ( $success ) {
 229+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedkey' ) );
 230+ } else {
 231+ $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-deletedkeyfailed' ) );
 232+ }
 233+ $out .= '<br />';
 234+ $sk = $wgUser->getSkin();
 235+ $out .= $sk->link( $this->getTitle(), wfMsg( 'openstackmanager-backkeylist' ), array(), array(), array() );
 236+ $wgOut->addHTML( $out );
 237+ return true;
 238+ }
 239+}
 240+
 241+class SpecialNovaKeyForm extends HTMLForm {
 242+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNovaKey.php
___________________________________________________________________
Added: svn:eol-style
1243 + native
Index: trunk/extensions/OpenStackManager/special/SpecialNova.php
@@ -0,0 +1,27 @@
 2+<?php
 3+
 4+abstract class SpecialNova extends SpecialPage {
 5+ function notLoggedIn() {
 6+ global $wgOut;
 7+
 8+ $this->setHeaders();
 9+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-notloggedin' ) );
 10+ $wgOut->addHTML( wfMsg( 'openstackmanager-mustbeloggedin' ) );
 11+ }
 12+
 13+ function noCredentials() {
 14+ global $wgOut;
 15+
 16+ $this->setHeaders();
 17+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-nonovacred' ) );
 18+ $wgOut->addHTML( wfMsg( 'openstackmanager-nonovacred-admincreate' ) );
 19+ }
 20+
 21+ function notInProject() {
 22+ global $wgOut;
 23+
 24+ $this->setHeaders();
 25+ $wgOut->setPagetitle( wfMsg( 'openstackmanager-noaccount' ) );
 26+ $wgOut->addHTML( wfMsg( 'openstackmanager-noaccount2' ) );
 27+ }
 28+}
Property changes on: trunk/extensions/OpenStackManager/special/SpecialNova.php
___________________________________________________________________
Added: svn:eol-style
129 + native
Index: trunk/extensions/OpenStackManager/OpenStackManager.php
@@ -63,12 +63,12 @@
6464 $wgAutoloadClasses['OpenStackNovaDomain'] = $dir . 'OpenStackNovaDomain.php';
6565 $wgAutoloadClasses['OpenStackNovaHost'] = $dir . 'OpenStackNovaHost.php';
6666 $wgAutoloadClasses['OpenStackNovaAddress'] = $dir . 'OpenStackNovaAddress.php';
67 -$wgAutoloadClasses['SpecialNovaInstance'] = $dir . 'SpecialNovaInstance.php';
68 -$wgAutoloadClasses['SpecialNovaKey'] = $dir . 'SpecialNovaKey.php';
69 -$wgAutoloadClasses['SpecialNovaProject'] = $dir . 'SpecialNovaProject.php';
70 -$wgAutoloadClasses['SpecialNovaDomain'] = $dir . 'SpecialNovaDomain.php';
71 -$wgAutoloadClasses['SpecialNovaAddress'] = $dir . 'SpecialNovaAddress.php';
72 -$wgAutoloadClasses['SpecialNova'] = $dir . 'SpecialNova.php';
 67+$wgAutoloadClasses['SpecialNovaInstance'] = $dir . 'special/SpecialNovaInstance.php';
 68+$wgAutoloadClasses['SpecialNovaKey'] = $dir . 'special/SpecialNovaKey.php';
 69+$wgAutoloadClasses['SpecialNovaProject'] = $dir . 'special/SpecialNovaProject.php';
 70+$wgAutoloadClasses['SpecialNovaDomain'] = $dir . 'special/SpecialNovaDomain.php';
 71+$wgAutoloadClasses['SpecialNovaAddress'] = $dir . 'special/SpecialNovaAddress.php';
 72+$wgAutoloadClasses['SpecialNova'] = $dir . 'special/SpecialNova.php';
7373 $wgAutoloadClasses['OpenStackNovaHostJob'] = $dir . 'OpenStackNovaHostJob.php';
7474 $wgAutoloadClasses['AmazonEC2'] = $dir . 'aws-sdk/sdk.class.php';
7575 $wgSpecialPages['NovaInstance'] = 'SpecialNovaInstance';

Status & tagging log