Index: trunk/extensions/OpenStackManager/OpenStackNovaLdapConnection.php |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class OpenStackNovaLdapConnection { |
| 5 | + |
| 6 | + /** |
| 7 | + * Connect to LDAP as the open stack manager account using wgAuth |
| 8 | + * |
| 9 | + * @return void |
| 10 | + */ |
| 11 | + static function connect() { |
| 12 | + global $wgAuth; |
| 13 | + global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
| 14 | + global $wgOpenStackManagerLDAPDomain; |
| 15 | + |
| 16 | + // Only reconnect/rebind if we aren't alredy bound |
| 17 | + if ( $wgAuth->boundAs != $wgOpenStackManagerLDAPUser ) { |
| 18 | + $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
| 19 | + $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | +} |
Index: trunk/extensions/OpenStackManager/OpenStackNovaSudoer.php |
— | — | @@ -11,25 +11,11 @@ |
12 | 12 | */ |
13 | 13 | function __construct( $sudoername ) { |
14 | 14 | $this->sudoername = $sudoername; |
15 | | - $this->connect(); |
| 15 | + OpenStackNovaLdapConnection::connect(); |
16 | 16 | $this->fetchSudoerInfo(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | | - * Connect to LDAP as the open stack manager account using wgAuth |
21 | | - * |
22 | | - * @return void |
23 | | - */ |
24 | | - function connect() { |
25 | | - global $wgAuth; |
26 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
27 | | - global $wgOpenStackManagerLDAPDomain; |
28 | | - |
29 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
30 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
31 | | - } |
32 | | - |
33 | | - /** |
34 | 20 | * Fetch the sudoer policy from LDAP and initialize the object |
35 | 21 | * |
36 | 22 | * @return void |
— | — | @@ -140,9 +126,6 @@ |
141 | 127 | global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
142 | 128 | global $wgOpenStackManagerLDAPDomain; |
143 | 129 | |
144 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
145 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
146 | | - |
147 | 130 | $sudoer = array(); |
148 | 131 | foreach ( $users as $user ) { |
149 | 132 | $sudoer['sudouser'][] = $user; |
— | — | @@ -180,8 +163,7 @@ |
181 | 164 | global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
182 | 165 | global $wgOpenStackManagerLDAPSudoerBaseDN, $wgOpenStackManagerLDAPDomain; |
183 | 166 | |
184 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
185 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 167 | + OpenStackNovaLdapConnection::connect(); |
186 | 168 | |
187 | 169 | $sudoers = array(); |
188 | 170 | wfSuppressWarnings(); |
— | — | @@ -238,8 +220,7 @@ |
239 | 221 | global $wgOpenStackManagerLDAPSudoerBaseDN; |
240 | 222 | global $wgOpenStackManagerLDAPDomain; |
241 | 223 | |
242 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
243 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 224 | + OpenStackNovaLdapConnection::connect(); |
244 | 225 | |
245 | 226 | $sudoer = array(); |
246 | 227 | $sudoer['objectclass'][] = 'sudorole'; |
— | — | @@ -282,8 +263,7 @@ |
283 | 264 | global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
284 | 265 | global $wgOpenStackManagerLDAPDomain; |
285 | 266 | |
286 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
287 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 267 | + OpenStackNovaLdapConnection::connect(); |
288 | 268 | |
289 | 269 | $sudoer = new OpenStackNovaSudoer( $sudoername ); |
290 | 270 | if ( ! $sudoer ) { |
Index: trunk/extensions/OpenStackManager/OpenStackNovaRole.php |
— | — | @@ -20,25 +20,13 @@ |
21 | 21 | } else { |
22 | 22 | $this->global = true; |
23 | 23 | } |
24 | | - $this->connect(); |
| 24 | + OpenStackNovaLdapConnection::connect(); |
25 | 25 | $this->fetchRoleInfo(); |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return void |
30 | 30 | */ |
31 | | - function connect() { |
32 | | - global $wgAuth; |
33 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
34 | | - global $wgOpenStackManagerLDAPDomain; |
35 | | - |
36 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
37 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * @return void |
42 | | - */ |
43 | 31 | function fetchRoleInfo() { |
44 | 32 | global $wgAuth; |
45 | 33 | global $wgOpenStackManagerLDAPGlobalRoles; |
— | — | @@ -213,12 +201,9 @@ |
214 | 202 | */ |
215 | 203 | static function getAllGlobalRoles() { |
216 | 204 | global $wgAuth; |
217 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
218 | | - global $wgOpenStackManagerLDAPDomain; |
219 | 205 | global $wgOpenStackManagerLDAPGlobalRoles; |
220 | 206 | |
221 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
222 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 207 | + OpenStackNovaLdapConnection::connect(); |
223 | 208 | |
224 | 209 | $roles = array(); |
225 | 210 | foreach ( array_keys( $wgOpenStackManagerLDAPGlobalRoles ) as $rolename ) { |
— | — | @@ -237,11 +222,8 @@ |
238 | 223 | */ |
239 | 224 | static function createRole( $rolename, $project ) { |
240 | 225 | global $wgAuth; |
241 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
242 | | - global $wgOpenStackManagerLDAPDomain; |
243 | 226 | |
244 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
245 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 227 | + OpenStackNovaLdapConnection::connect(); |
246 | 228 | |
247 | 229 | $role = array(); |
248 | 230 | $role['objectclass'][] = 'groupofnames'; |
Index: trunk/extensions/OpenStackManager/OpenStackNovaProject.php |
— | — | @@ -14,25 +14,11 @@ |
15 | 15 | */ |
16 | 16 | function __construct( $projectname ) { |
17 | 17 | $this->projectname = $projectname; |
18 | | - $this->connect(); |
| 18 | + OpenStackNovaLdapConnection::connect(); |
19 | 19 | $this->fetchProjectInfo(); |
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | | - * Connect to LDAP as the open stack manager account using wgAuth |
24 | | - * |
25 | | - * @return void |
26 | | - */ |
27 | | - function connect() { |
28 | | - global $wgAuth; |
29 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
30 | | - global $wgOpenStackManagerLDAPDomain; |
31 | | - |
32 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
33 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
34 | | - } |
35 | | - |
36 | | - /** |
37 | 23 | * Fetch the project from LDAP and initialize the object |
38 | 24 | * @return void |
39 | 25 | */ |
— | — | @@ -207,12 +193,9 @@ |
208 | 194 | */ |
209 | 195 | static function getAllProjects() { |
210 | 196 | global $wgAuth; |
211 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
212 | 197 | global $wgOpenStackManagerLDAPProjectBaseDN; |
213 | | - global $wgOpenStackManagerLDAPDomain; |
214 | 198 | |
215 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
216 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 199 | + OpenStackNovaLdapConnection::connect(); |
217 | 200 | |
218 | 201 | $projects = array(); |
219 | 202 | wfSuppressWarnings(); |
— | — | @@ -245,12 +228,10 @@ |
246 | 229 | */ |
247 | 230 | static function createProject( $projectname ) { |
248 | 231 | global $wgAuth; |
249 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
| 232 | + global $wgOpenStackManagerLDAPUser; |
250 | 233 | global $wgOpenStackManagerLDAPProjectBaseDN; |
251 | | - global $wgOpenStackManagerLDAPDomain; |
252 | 234 | |
253 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
254 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 235 | + OpenStackNovaLdapConnection::connect(); |
255 | 236 | |
256 | 237 | $project = array(); |
257 | 238 | $project['objectclass'][] = 'groupofnames'; |
— | — | @@ -289,11 +270,8 @@ |
290 | 271 | */ |
291 | 272 | static function deleteProject( $projectname ) { |
292 | 273 | global $wgAuth; |
293 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
294 | | - global $wgOpenStackManagerLDAPDomain; |
295 | 274 | |
296 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
297 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 275 | + OpenStackNovaLdapConnection::connect(); |
298 | 276 | |
299 | 277 | $project = new OpenStackNovaProject( $projectname ); |
300 | 278 | if ( ! $project ) { |
— | — | @@ -338,12 +316,9 @@ |
339 | 317 | static function addNamespaces() { |
340 | 318 | global $wgAuth; |
341 | 319 | global $wgOpenStackManagerLDAPProjectBaseDN; |
342 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
343 | 320 | global $wgExtraNamespaces; |
344 | | - global $wgOpenStackManagerLDAPDomain; |
345 | 321 | |
346 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
347 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 322 | + OpenStackNovaLdapConnection::connect(); |
348 | 323 | |
349 | 324 | $result = ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPProjectBaseDN, 'owner=*' ); |
350 | 325 | $entries = ldap_get_entries( $wgAuth->ldapconn, $result ); |
Index: trunk/extensions/OpenStackManager/OpenStackNovaDomain.php |
— | — | @@ -12,25 +12,11 @@ |
13 | 13 | */ |
14 | 14 | function __construct( $domainname ) { |
15 | 15 | $this->domainname = $domainname; |
16 | | - $this->connect(); |
| 16 | + OpenStackNovaLdapConnection::connect(); |
17 | 17 | $this->fetchDomainInfo(); |
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | | - * Connect to LDAP as the open stack manager account using wgAuth |
22 | | - * |
23 | | - * @return void |
24 | | - */ |
25 | | - function connect() { |
26 | | - global $wgAuth; |
27 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
28 | | - global $wgOpenStackManagerLDAPDomain; |
29 | | - |
30 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
31 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
32 | | - } |
33 | | - |
34 | | - /** |
35 | 21 | * Fetch the domain from LDAP and initialize the object |
36 | 22 | * |
37 | 23 | * @return void |
— | — | @@ -124,12 +110,9 @@ |
125 | 111 | */ |
126 | 112 | static function getAllDomains( $type='all' ) { |
127 | 113 | global $wgAuth; |
128 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
129 | 114 | global $wgOpenStackManagerLDAPInstanceBaseDN; |
130 | | - global $wgOpenStackManagerLDAPDomain; |
131 | 115 | |
132 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
133 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 116 | + OpenStackNovaLdapConnection::connect(); |
134 | 117 | |
135 | 118 | $domains = array(); |
136 | 119 | if ( $type == 'local' ) { |
— | — | @@ -186,12 +169,9 @@ |
187 | 170 | */ |
188 | 171 | static function getDomainByHostIP( $ip ) { |
189 | 172 | global $wgAuth; |
190 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
191 | 173 | global $wgOpenStackManagerLDAPInstanceBaseDN; |
192 | | - global $wgOpenStackManagerLDAPDomain; |
193 | 174 | |
194 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
195 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 175 | + OpenStackNovaLdapConnection::connect(); |
196 | 176 | |
197 | 177 | wfSuppressWarnings(); |
198 | 178 | $result = ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, |
— | — | @@ -222,12 +202,9 @@ |
223 | 203 | */ |
224 | 204 | static function getDomainByInstanceId( $instanceid ) { |
225 | 205 | global $wgAuth; |
226 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
227 | 206 | global $wgOpenStackManagerLDAPInstanceBaseDN; |
228 | | - global $wgOpenStackManagerLDAPDomain; |
229 | 207 | |
230 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
231 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 208 | + OpenStackNovaLdapConnection::connect(); |
232 | 209 | |
233 | 210 | wfSuppressWarnings(); |
234 | 211 | $result = ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, |
— | — | @@ -263,13 +240,10 @@ |
264 | 241 | */ |
265 | 242 | static function createDomain( $domainname, $fqdn, $location ) { |
266 | 243 | global $wgAuth; |
267 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
268 | 244 | global $wgOpenStackManagerLDAPInstanceBaseDN; |
269 | 245 | global $wgOpenStackManagerDNSOptions; |
270 | | - global $wgOpenStackManagerLDAPDomain; |
271 | 246 | |
272 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
273 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 247 | + OpenStackNovaLdapConnection::connect(); |
274 | 248 | |
275 | 249 | $soa = OpenStackNovaDomain::generateSOA(); |
276 | 250 | $domain = array(); |
— | — | @@ -306,11 +280,8 @@ |
307 | 281 | */ |
308 | 282 | static function deleteDomain( $domainname ) { |
309 | 283 | global $wgAuth; |
310 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
311 | | - global $wgOpenStackManagerLDAPDomain; |
312 | 284 | |
313 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
314 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 285 | + OpenStackNovaLdapConnection::connect(); |
315 | 286 | |
316 | 287 | $domain = new OpenStackNovaDomain( $domainname ); |
317 | 288 | if ( ! $domain ) { |
Index: trunk/extensions/OpenStackManager/OpenStackNovaHost.php |
— | — | @@ -29,25 +29,11 @@ |
30 | 30 | function __construct( $hostname, $domain ) { |
31 | 31 | $this->searchvalue = $hostname; |
32 | 32 | $this->domain = $domain; |
33 | | - $this->connect(); |
| 33 | + OpenStackNovaLdapConnection::connect(); |
34 | 34 | $this->fetchHostInfo(); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | | - * Connect to LDAP as the open stack manager account using wgAuth |
39 | | - * |
40 | | - * @return void |
41 | | - */ |
42 | | - function connect() { |
43 | | - global $wgAuth; |
44 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
45 | | - global $wgOpenStackManagerLDAPDomain; |
46 | | - |
47 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
48 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
49 | | - } |
50 | | - |
51 | | - /** |
52 | 38 | * Fetch the host from LDAP and initialize the object |
53 | 39 | * |
54 | 40 | * @return void |
— | — | @@ -501,11 +487,8 @@ |
502 | 488 | */ |
503 | 489 | static function getAllHosts( $domain ) { |
504 | 490 | global $wgAuth; |
505 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
506 | | - global $wgOpenStackManagerLDAPDomain; |
507 | 491 | |
508 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
509 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 492 | + OpenStackNovaLdapConnection::connect(); |
510 | 493 | |
511 | 494 | $hosts = array(); |
512 | 495 | wfSuppressWarnings(); |
— | — | @@ -537,11 +520,8 @@ |
538 | 521 | */ |
539 | 522 | static function deleteHost( $hostname, $domain ) { |
540 | 523 | global $wgAuth; |
541 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
542 | | - global $wgOpenStackManagerLDAPDomain; |
543 | 524 | |
544 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
545 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 525 | + OpenStackNovaLdapConnection::connect(); |
546 | 526 | |
547 | 527 | $host = OpenStackNovaHost::getHostByName( $hostname, $domain ); |
548 | 528 | if ( ! $host ) { |
— | — | @@ -572,11 +552,8 @@ |
573 | 553 | */ |
574 | 554 | static function deleteHostByInstanceId( $instanceid ) { |
575 | 555 | global $wgAuth; |
576 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
577 | | - global $wgOpenStackManagerLDAPDomain; |
578 | 556 | |
579 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
580 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 557 | + OpenStackNovaLdapConnection::connect(); |
581 | 558 | |
582 | 559 | $host = OpenStackNovaHost::getHostByInstanceId( $instanceid ); |
583 | 560 | if ( ! $host ) { |
— | — | @@ -614,12 +591,9 @@ |
615 | 592 | static function addHost( $instance, $domain, $puppetinfo = array() ) { |
616 | 593 | global $wgUser, $wgLang; |
617 | 594 | global $wgAuth; |
618 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
619 | 595 | global $wgOpenStackManagerLDAPInstanceBaseDN, $wgOpenStackManagerPuppetOptions; |
620 | | - global $wgOpenStackManagerLDAPDomain; |
621 | 596 | |
622 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
623 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 597 | + OpenStackNovaLdapConnection::connect(); |
624 | 598 | |
625 | 599 | $hostname = $instance->getInstanceName(); |
626 | 600 | $instanceid = $instance->getInstanceId(); |
— | — | @@ -699,12 +673,9 @@ |
700 | 674 | */ |
701 | 675 | static function addPublicHost( $hostname, $ip, $domain ) { |
702 | 676 | global $wgAuth; |
703 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
704 | 677 | global $wgOpenStackManagerLDAPInstanceBaseDN; |
705 | | - global $wgOpenStackManagerLDAPDomain; |
706 | 678 | |
707 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
708 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
| 679 | + OpenStackNovaLdapConnection::connect(); |
709 | 680 | |
710 | 681 | $domainname = $domain->getFullyQualifiedDomainName(); |
711 | 682 | $host = OpenStackNovaHost::getHostByName( $hostname, $domain ); |
Index: trunk/extensions/OpenStackManager/OpenStackNovaUser.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | */ |
13 | 13 | function __construct( $username = '' ) { |
14 | 14 | $this->username = $username; |
15 | | - $this->connect(); |
| 15 | + OpenStackNovaLdapConnection::connect(); |
16 | 16 | $this->fetchUserInfo(); |
17 | 17 | } |
18 | 18 | |
— | — | @@ -103,8 +103,6 @@ |
104 | 104 | global $wgAuth; |
105 | 105 | global $wgOpenStackManagerLDAPProjectBaseDN; |
106 | 106 | |
107 | | - $this->connect(); |
108 | | - |
109 | 107 | # All projects have a owner attribute, project |
110 | 108 | # roles do not |
111 | 109 | $projects = array(); |
— | — | @@ -146,8 +144,6 @@ |
147 | 145 | global $wgAuth; |
148 | 146 | global $wgOpenStackManagerLDAPProjectBaseDN; |
149 | 147 | |
150 | | - $this->connect(); |
151 | | - |
152 | 148 | $filter = "(&(cn=$project)(member=$this->userDN)(owner=*))"; |
153 | 149 | wfSuppressWarnings(); |
154 | 150 | $result = ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPProjectBaseDN, $filter ); |
— | — | @@ -256,23 +252,7 @@ |
257 | 253 | } |
258 | 254 | } |
259 | 255 | |
260 | | - |
261 | 256 | /** |
262 | | - * @return void |
263 | | - */ |
264 | | - function connect() { |
265 | | - global $wgAuth; |
266 | | - global $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword; |
267 | | - global $wgOpenStackManagerLDAPDomain; |
268 | | - |
269 | | - if ( !$wgAuth instanceof LdapAuthenticationPlugin ) { |
270 | | - die( 'Install and configure the <a href="http://www.mediawiki.org/wiki/Extension:LDAP_Authentication">LDAP Authentication</a> extension' ); |
271 | | - } |
272 | | - $wgAuth->connect( $wgOpenStackManagerLDAPDomain ); |
273 | | - $wgAuth->bindAs( $wgOpenStackManagerLDAPUser, $wgOpenStackManagerLDAPUserPassword ); |
274 | | - } |
275 | | - |
276 | | - /** |
277 | 257 | * @param $key |
278 | 258 | * @return bool |
279 | 259 | */ |
— | — | @@ -493,7 +473,7 @@ |
494 | 474 | * @return bool |
495 | 475 | */ |
496 | 476 | static function LDAPSetNovaInfo( $auth ) { |
497 | | - OpenStackNovaUser::connect(); |
| 477 | + OpenStackNovaLdapConnection::connect(); |
498 | 478 | $dn = $auth->userInfo[0]['dn']; |
499 | 479 | wfSuppressWarnings(); |
500 | 480 | $result = ldap_read( $auth->ldapconn, $auth->userInfo[0]['dn'], '(objectclass=*)', array( 'secretkey', 'accesskey', 'objectclass' ) ); |
Index: trunk/extensions/OpenStackManager/OpenStackManager.php |
— | — | @@ -103,6 +103,7 @@ |
104 | 104 | $wgAutoloadClasses['OpenStackNovaArticle'] = $dir . 'OpenStackNovaArticle.php'; |
105 | 105 | $wgAutoloadClasses['OpenStackNovaHostJob'] = $dir . 'OpenStackNovaHostJob.php'; |
106 | 106 | $wgAutoloadClasses['OpenStackNovaPuppetGroup'] = $dir . 'OpenStackNovaPuppetGroup.php'; |
| 107 | +$wgAutoloadClasses['OpenStackNovaLdapConnection'] = $dir . 'OpenStackNovaLdapConnection.php'; |
107 | 108 | $wgAutoloadClasses['SpecialNovaInstance'] = $dir . 'special/SpecialNovaInstance.php'; |
108 | 109 | $wgAutoloadClasses['SpecialNovaKey'] = $dir . 'special/SpecialNovaKey.php'; |
109 | 110 | $wgAutoloadClasses['SpecialNovaProject'] = $dir . 'special/SpecialNovaProject.php'; |