r79269 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79268‎ | r79269 | r79270 >
Date:17:26, 30 December 2010
Author:laner
Status:deferred
Tags:
Comment:
* Fixing register_globals issue
* Adding initial support for users to specify their shell account username on wiki account creation
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaHost.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaUser.php (modified) (history)
  • /trunk/extensions/OpenStackManager/SpecialNovaInstance.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/SpecialNovaInstance.php
@@ -147,27 +147,29 @@
148148 'default' => $wgRequest->getText( 'project' ),
149149 );
150150
151 - if ( isset( $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
152 - $classes = array();
153 - foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
154 - $classes["$class"] = $class;
155 - }
156 - $instanceInfo['puppetclasses'] = array(
157 - 'type' => 'multiselect',
158 - 'section' => 'instance/puppetinfo',
159 - 'options' => $classes,
160 - 'label-message' => 'puppetclasses',
161 - );
162 - }
163 -
164 - if ( isset( $wgOpenStackManagerPuppetOptions['availablevariables'] ) ) {
165 - foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
166 - $instanceInfo["$variable"] = array(
167 - 'type' => 'text',
 151+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
 152+ if ( $wgOpenStackManagerPuppetOptions['availableclasses'] ) {
 153+ $classes = array();
 154+ foreach ( $wgOpenStackManagerPuppetOptions['availableclasses'] as $class ) {
 155+ $classes["$class"] = $class;
 156+ }
 157+ $instanceInfo['puppetclasses'] = array(
 158+ 'type' => 'multiselect',
168159 'section' => 'instance/puppetinfo',
169 - 'label' => $variable,
 160+ 'options' => $classes,
 161+ 'label-message' => 'puppetclasses',
170162 );
171163 }
 164+
 165+ if ( $wgOpenStackManagerPuppetOptions['availablevariables'] ) {
 166+ foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
 167+ $instanceInfo["$variable"] = array(
 168+ 'type' => 'text',
 169+ 'section' => 'instance/puppetinfo',
 170+ 'label' => $variable,
 171+ );
 172+ }
 173+ }
172174 }
173175
174176 $instanceInfo['action'] = array(
@@ -298,14 +300,12 @@
299301 $instance = $this->userNova->createInstance( $formData['instancename'], $formData['imageType'], '', $formData['instanceType'], $formData['availabilityZone'] );
300302 if ( $instance ) {
301303 $puppetinfo = array();
302 - if ( isset( $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
 304+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
303305 foreach ( $formData['puppetclasses'] as $class ) {
304306 if ( in_array( $class, $wgOpenStackManagerPuppetOptions['availableclasses'] ) ) {
305307 $puppetinfo['classes'][] = $class;
306308 }
307309 }
308 - }
309 - if ( isset( $wgOpenStackManagerPuppetOptions['availablevariables'] ) ) {
310310 foreach ( $wgOpenStackManagerPuppetOptions['availablevariables'] as $variable ) {
311311 if ( isset ( $formData["$variable"] ) ) {
312312 $puppetinfo['variables']["$variable"] = $formData["$variable"];
Index: trunk/extensions/OpenStackManager/OpenStackNovaHost.php
@@ -255,17 +255,13 @@
256256 $hostEntry['arecord'] = $ip;
257257 $hostEntry['associateddomain'][] = $hostname . '.' . $domainname;
258258 $hostEntry['cnamerecord'][] = $instanceid . '.' . $domainname;
259 - if ( $wgOpenStackManagerPuppetOptions ) {
 259+ if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
260260 $hostEntry['objectclass'][] = 'puppetclient';
261 - if ( isset( $wgOpenStackManagerPuppetOptions['defaultclasses'] ) ) {
262 - foreach ( $wgOpenStackManagerPuppetOptions['defaultclasses'] as $class ) {
263 - $hostEntry['puppetclass'][] = $class;
264 - }
 261+ foreach ( $wgOpenStackManagerPuppetOptions['defaultclasses'] as $class ) {
 262+ $hostEntry['puppetclass'][] = $class;
265263 }
266 - if ( isset( $wgOpenStackManagerPuppetOptions['defaultvariables'] ) ) {
267 - foreach ( $wgOpenStackManagerPuppetOptions['defaultvariables'] as $variable => $value ) {
268 - $hostEntry['puppetvar'][] = $variable . ' = ' . $value;
269 - }
 264+ foreach ( $wgOpenStackManagerPuppetOptions['defaultvariables'] as $variable => $value ) {
 265+ $hostEntry['puppetvar'][] = $variable . ' = ' . $value;
270266 }
271267 if ( $puppetinfo ) {
272268 foreach( $puppetinfo['classes'] as $class ) {
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php
@@ -280,12 +280,12 @@
281281 $values['accesskey'] = OpenStackNovaUser::uuid4();
282282 $values['secretkey'] = OpenStackNovaUser::uuid4();
283283 $values['isadmin'] = 'FALSE';
284 - $uid = OpenStackNovaUser::getNextIdNumber( $auth, 'uidnumber' );
285 - if ( ! $uid ) {
 284+ $uidnumber = OpenStackNovaUser::getNextIdNumber( $auth, 'uidnumber' );
 285+ if ( ! $uidnumber ) {
286286 $result = false;
287287 return false;
288288 }
289 - $values['uidnumber'] = $uid;
 289+ $values['uidnumber'] = $uidnumber;
290290 $values['gidnumber'] = $wgOpenStackManagerLDAPDefaultGid;
291291 $values['homedirectory'] = '/home/' . $username;
292292
@@ -295,4 +295,11 @@
296296 return true;
297297 }
298298
 299+ static function LDAPModifyUITemplate( &$template ) {
 300+ $input = array( 'msg' => 'shellaccountname', 'type' => 'text', 'name' => 'shellaccountname', 'value' => '', 'helptext' => 'shellaccountnamehelp' );
 301+ $template->set( 'extraInput', array( $input ) );
 302+
 303+ return true;
 304+ }
 305+
299306 }
Index: trunk/extensions/OpenStackManager/OpenStackManager.php
@@ -35,6 +35,22 @@
3636 $wgOpenStackManagerNovaPort = 8773;
3737 $wgOpenStackManagerNovaResourcePrefix = '/services/Cloud/';
3838 $wgOpenStackManagerNovaAdminKeys = array( 'accessKey' => '', 'secretKey' => '' );
 39+$wgOpenStackManagerNovaKeypairStorage = 'ldap';
 40+$wgOpenStackManagerLDAPDomain = '';
 41+$wgOpenStackManagerLDAPUser = '';
 42+$wgOpenStackManagerLDAPUserPassword = '';
 43+$wgOpenStackManagerLDAPProjectBaseDN = '';
 44+$wgOpenStackManagerLDAPInstanceBaseDN = '';
 45+$wgOpenStackManagerLDAPDefaultGid = '500';
 46+$wgOpenStackManagerDNSServers = array( 'primary' => 'localhost', 'secondary' => 'localhost' );
 47+$wgOpenStackManagerDNSSOA = array( 'hostmaster' => 'hostmaster@localhost.localdomain', 'refresh' => '1800', 'retry' => '3600', 'expiry' => '86400', 'minimum' => '7200' );
 48+$wgOpenStackManagerPuppetOptions = array(
 49+ 'enabled' => false,
 50+ 'defaultclasses' => array(),
 51+ 'defaultvariables' => array(),
 52+ 'availableclasses' => array(),
 53+ 'availablevariables' => array(),
 54+ );
3955
4056 $dir = dirname(__FILE__) . '/';
4157
@@ -62,5 +78,6 @@
6379 $wgSpecialPageGroups['NovaDomain'] = 'other';
6480
6581 $wgHooks['LDAPSetCreationValues'][] = 'OpenStackNovaUser::LDAPSetCreationValues';
 82+$wgHooks['LDAPModifyUITemplate'][] = 'OpenStackNovaUser::LDAPModifyUITemplate';
6683
6784 require_once( "$IP/extensions/OpenStackManager/OpenStackNovaProject.php" );

Status & tagging log