Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364124 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: I810ca14844d2ed32fc95b24c849c288ca162c93b
---
M api/ApiListNovaInstances.php
M api/ApiNovaAddress.php
M api/ApiNovaInstance.php
M api/ApiNovaProjectLimits.php
M api/ApiNovaProjects.php
M api/ApiNovaServiceGroups.php
M nova/OpenStackNovaController.php
M nova/OpenStackNovaDomain.php
M nova/OpenStackNovaHost.php
M nova/OpenStackNovaInstance.php
M nova/OpenStackNovaPrivateHost.php
M nova/OpenStackNovaProject.php
M nova/OpenStackNovaPublicHost.php
M nova/OpenStackNovaSecondaryAuthenticationProvider.php
M nova/OpenStackNovaSecurityGroupRule.php
M nova/OpenStackNovaServiceGroup.php
M nova/OpenStackNovaSudoer.php
M nova/OpenStackNovaUser.php
18 files changed, 470 insertions(+), 153 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager
refs/changes/24/364124/1
diff --git a/api/ApiListNovaInstances.php b/api/ApiListNovaInstances.php
index df39e4f..0c80880 100644
--- a/api/ApiListNovaInstances.php
+++ b/api/ApiListNovaInstances.php
@@ -30,12 +30,15 @@
}
}
- $key = wfMemcKey( 'openstackmanager', 'apilistnovainstances',
$params['region'], $params['project'] );
+ $key = wfMemcKey( 'openstackmanager', 'apilistnovainstances',
+ $params['region'], $params['project'] );
$instancesInfo = $wgMemc->get( $key );
if ( $instancesInfo === false ) {
$user = new OpenStackNovaUser(
$wgOpenStackManagerLDAPUsername );
$userNova = OpenStackNovaController::newFromUser( $user
);
- $userNova->authenticate(
$wgOpenStackManagerLDAPUsername, $wgOpenStackManagerLDAPUserPassword );
+ $userNova->authenticate(
+ $wgOpenStackManagerLDAPUsername,
$wgOpenStackManagerLDAPUserPassword
+ );
$userNova->setProject( $project->getName() );
$userNova->setRegion( $params['region'] ); // validated
by API
@@ -67,9 +70,13 @@
}
if ( defined( 'ApiResult::META_CONTENT' ) ) {
- $this->getResult()->addIndexedTagName( [ 'query',
$this->getModuleName() ], 'instance' );
+ $this->getResult()->addIndexedTagName(
+ [ 'query', $this->getModuleName() ], 'instance'
+ );
} else {
- $this->getResult()->setIndexedTagName_internal( [
'query', $this->getModuleName() ], 'instance' );
+ $this->getResult()->setIndexedTagName_internal(
+ [ 'query', $this->getModuleName() ], 'instance'
+ );
}
}
diff --git a/api/ApiNovaAddress.php b/api/ApiNovaAddress.php
index 385473e..2b616a0 100644
--- a/api/ApiNovaAddress.php
+++ b/api/ApiNovaAddress.php
@@ -9,7 +9,9 @@
if ( is_callable( [ $this, 'dieWithError' ] ) ) {
$this->dieWithError(
'openstackmanager-nonovacred' );
} else {
- $this->dieUsage( 'No credentials found for your
account.', 'openstackmanager-nonovacred' );
+ $this->dieUsage(
+ 'No credentials found for your
account.', 'openstackmanager-nonovacred'
+ );
}
}
@@ -20,7 +22,10 @@
if ( is_callable( [ $this, 'dieWithError' ] ) )
{
$this->dieWithError( [
'openstackmanager-noaccount', wfEscapeWikiText( $p ) ] );
} else {
- $this->dieUsage( 'User account is not
in the project specified.', 'openstackmanager-noaccount' );
+ $this->dieUsage(
+ 'User account is not in the
project specified.',
+ 'openstackmanager-noaccount'
+ );
}
}
@@ -32,7 +37,9 @@
wfEscapeWikiText( $p ),
] );
} else {
- $this->dieUsage( 'User account is not
in the projectadmin role.', 'openstackmanager-needrole' );
+ $this->dieUsage(
+ 'User account is not in the
projectadmin role.', 'openstackmanager-needrole'
+ );
}
}
}
@@ -53,7 +60,9 @@
if ( is_callable( [ $this, 'dieWithError' ] ) ) {
$this->dieWithError(
'openstackmanager-nonexistenthost' );
} else {
- $this->dieUsage( 'Address specified does not
exist.', 'openstackmanager-nonexistenthost' );
+ $this->dieUsage(
+ 'Address specified does not exist.',
'openstackmanager-nonexistenthost'
+ );
}
}
$ipAddr = $address->getPublicIp();
@@ -70,9 +79,15 @@
if ( !$success ) {
if ( is_callable( [ $this,
'dieWithError' ] ) ) {
- $this->dieWithError( [
'openstackmanager-disassociateaddressfailed', wfEscapeWikiText( $ipAddr ) ] );
+ $this->dieWithError( [
+
'openstackmanager-disassociateaddressfailed',
+ wfEscapeWikiText(
$ipAddr )
+ ] );
} else {
- $this->dieUsage( 'Failed to
disassociate address', 'openstackmanager-disassociateaddressfailed' );
+ $this->dieUsage(
+ 'Failed to disassociate
address',
+
'openstackmanager-disassociateaddressfailed'
+ );
}
}
@@ -133,7 +148,8 @@
*/
public function getExamples() {
return [
-
'api.php?action=novaaddress&subaction=disassociate&address=7&project=testing®ion=mars'
+ 'api.php?action=novaaddress&subaction=disassociate' .
+ '&address=7&project=testing®ion=mars'
=> 'Disassociate IP 208.80.153.198 in project testing',
];
}
diff --git a/api/ApiNovaInstance.php b/api/ApiNovaInstance.php
index 6994816..e1ed91e 100644
--- a/api/ApiNovaInstance.php
+++ b/api/ApiNovaInstance.php
@@ -9,14 +9,20 @@
if ( is_callable( [ $this, 'dieWithError' ] ) ) {
$this->dieWithError(
'openstackmanager-nonovacred' );
} else {
- $this->dieUsage( 'No credentials found for your
account.', 'openstackmanager-nonovacred' );
+ $this->dieUsage(
+ 'No credentials found for your
account.', 'openstackmanager-nonovacred'
+ );
}
}
if ( !$this->userLDAP->inProject( $this->params['project'] ) ) {
if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError( [
'openstackmanager-noaccount', wfEscapeWikiText( $this->params['project'] ) ] );
+ $this->dieWithError( [
+ 'openstackmanager-noaccount',
wfEscapeWikiText( $this->params['project'] )
+ ] );
} else {
- $this->dieUsage( 'User account is not in the
project specified.', 'openstackmanager-noaccount' );
+ $this->dieUsage(
+ 'User account is not in the project
specified.', 'openstackmanager-noaccount'
+ );
}
}
if ( !$this->userLDAP->inRole( 'projectadmin',
$this->params['project'] ) ) {
@@ -27,7 +33,9 @@
wfEscapeWikiText(
$this->params['project'] ),
] );
} else {
- $this->dieUsage( 'User account is not in the
projectadmin role.', 'openstackmanager-needrole' );
+ $this->dieUsage(
+ 'User account is not in the
projectadmin role.', 'openstackmanager-needrole'
+ );
}
}
}
@@ -46,19 +54,30 @@
$success = $this->userNova->rebootInstance(
$this->params['instanceid'] );
if ( !$success ) {
if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'openstackmanager-rebootinstancefailed', wfEscapeWikiText(
$this->params['instanceid'] ) ] );
+ $this->dieWithError( [
+
'openstackmanager-rebootinstancefailed',
+ wfEscapeWikiText(
$this->params['instanceid'] )
+ ] );
} else {
- $this->dieUsage( 'Failed to reboot
instance.', 'openstackmanager-rebootinstancefailed' );
+ $this->dieUsage(
+ 'Failed to reboot instance.',
'openstackmanager-rebootinstancefailed'
+ );
}
}
$instance = $this->userNova->getInstance(
$this->params['instanceid'] );
if ( $instance ) {
- $this->getResult()->addValue( null,
$this->getModuleName(), [ 'instancestate' => $instance->getInstanceState() ] );
+ $this->getResult()->addValue(
+ null,
+ $this->getModuleName(),
+ [ 'instancestate' =>
$instance->getInstanceState() ]
+ );
}
break;
case 'consoleoutput':
$output = $this->userNova->getConsoleOutput(
$this->params['instanceid'] );
- $this->getResult()->addValue( null,
$this->getModuleName(), [ 'consoleoutput' => $output ] );
+ $this->getResult()->addValue(
+ null, $this->getModuleName(), [ 'consoleoutput'
=> $output ]
+ );
break;
case 'delete':
$instanceOSID = $this->params['instanceid'];
@@ -67,7 +86,10 @@
if ( is_callable( [ $this, 'dieWithError' ] ) )
{
$this->dieWithError(
'openstackmanager-nonexistenthost' );
} else {
- $this->dieUsage( 'The instance
requested does not exist.', 'openstackmanager-nonexistanthost' );
+ $this->dieUsage(
+ 'The instance requested does
not exist.',
+
'openstackmanager-nonexistanthost'
+ );
}
}
$result = $instance->deleteInstance( $this->userNova );
@@ -79,7 +101,10 @@
wfEscapeWikiText(
$instance->getInstanceName() ),
] );
} else {
- $this->dieUsage( 'Failed to delete the
instance.', 'openstackmanager-deleteinstancefailed' );
+ $this->dieUsage(
+ 'Failed to delete the
instance.',
+
'openstackmanager-deleteinstancefailed'
+ );
}
}
@@ -142,10 +167,14 @@
*/
public function getExamples() {
return [
-
'api.php?action=novainstance&subaction=reboot&instanceid=eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
- => 'Reboot instance id
eb195097-8539-4e66-b0b5-be8347d8caec in project testing in region mars',
-
'api.php?action=novainstance&subaction=consoleoutput&instanceid=eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
- => 'Display console output for instance id
eb195097-8539-4e66-b0b5-be8347d8caec in project testing in region mars',
+
'api.php?action=novainstance&subaction=reboot&instanceid=' .
+
'eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
+ => 'Reboot instance id
eb195097-8539-4e66-b0b5-be8347d8caec in project testing in ' .
+ 'region mars',
+
'api.php?action=novainstance&subaction=consoleoutput&instanceid=' .
+
'eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
+ => 'Display console output for instance id
eb195097-8539-4e66-b0b5-be8347d8caec in ' .
+ 'project testing in region mars',
];
}
@@ -154,9 +183,11 @@
*/
protected function getExamplesMessages() {
return [
-
'action=novainstance&subaction=reboot&instanceid=eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
+ 'action=novainstance&subaction=reboot&instanceid=' .
+
'eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
=> 'apihelp-novainstance-example-1',
-
'action=novainstance&subaction=consoleoutput&instanceid=eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
+
'action=novainstance&subaction=consoleoutput&instanceid=' .
+
'eb195097-8539-4e66-b0b5-be8347d8caec&project=testing®ion=mars&token=123ABC'
=> 'apihelp-novainstance-example-2',
];
}
diff --git a/api/ApiNovaProjectLimits.php b/api/ApiNovaProjectLimits.php
index b1f8769..3b8b88a 100644
--- a/api/ApiNovaProjectLimits.php
+++ b/api/ApiNovaProjectLimits.php
@@ -9,15 +9,24 @@
if ( is_callable( [ $this, 'dieWithError' ] ) ) {
$this->dieWithError(
'openstackmanager-nonovacred' );
} else {
- $this->dieUsage( wfMessage(
'openstackmanager-nonovacred' )->escaped(), 'openstackmanager-nonovacred' );
+ $this->dieUsage(
+ wfMessage(
'openstackmanager-nonovacred' )->escaped(),
+ 'openstackmanager-nonovacred'
+ );
}
}
if ( in_array( 'inproject', $rights ) || in_array(
'isprojectadmin', $rights ) ) {
if ( !$this->userLDAP->inProject(
$this->params['project'] ) ) {
if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'openstackmanager-noaccount', wfEscapeWikiText( $this->params['project'] ) ] );
+ $this->dieWithError( [
+ 'openstackmanager-noaccount',
wfEscapeWikiText( $this->params['project'] )
+ ] );
} else {
- $this->dieUsage( wfMessage(
'openstackmanager-noaccount', $this->params['project'] )->escaped(),
'openstackmanager-noaccount' );
+ $this->dieUsage(
+ wfMessage(
'openstackmanager-noaccount', $this->params['project'] )
+ ->escaped(),
+ 'openstackmanager-noaccount'
+ );
}
}
}
@@ -30,7 +39,12 @@
wfEscapeWikiText(
$this->params['project'] ),
] );
} else {
- $this->dieUsage( wfMessage(
'openstackmanager-needrole', 'projectadmin', $this->params['project']
)->escaped(), 'openstackmanager-needrole' );
+ $this->dieUsage(
+ wfMessage(
+
'openstackmanager-needrole', 'projectadmin', $this->params['project']
+ )->escaped(),
+ 'openstackmanager-needrole'
+ );
}
}
}
@@ -67,7 +81,9 @@
$limitsRegion["totalSecurityGroupsUsed"] =
$limits->getSecurityGroupsUsed();
$limitsOut[$region] = [ 'absolute' =>
$limitsRegion ];
}
- $this->getResult()->addValue( null,
$this->getModuleName(), [ 'regions' => $limitsOut ] );
+ $this->getResult()->addValue(
+ null, $this->getModuleName(), [ 'regions' =>
$limitsOut ]
+ );
}
}
diff --git a/api/ApiNovaProjects.php b/api/ApiNovaProjects.php
index 09ee0f2..f7e7f5d 100644
--- a/api/ApiNovaProjects.php
+++ b/api/ApiNovaProjects.php
@@ -26,7 +26,9 @@
foreach ( $project->getRoles() as $role ) {
$roleName = $role->getRoleName();
$data[$projectName]['roles'][$roleName]
= [ 'members' => $role->getMembers() ];
- $this->getResult()->setIndexedTagName(
$data[$projectName]['roles'][$roleName]['members'], 'member' );
+ $this->getResult()->setIndexedTagName(
+
$data[$projectName]['roles'][$roleName]['members'], 'member'
+ );
}
$this->getResult()->setIndexedTagName(
$data[$projectName]['members'], 'member' );
$this->getResult()->setIndexedTagName(
$data[$projectName]['roles'], 'roles' );
diff --git a/api/ApiNovaServiceGroups.php b/api/ApiNovaServiceGroups.php
index 1daba6c..db78034 100644
--- a/api/ApiNovaServiceGroups.php
+++ b/api/ApiNovaServiceGroups.php
@@ -19,7 +19,9 @@
} else {
$data[$serviceGroupName]['members'] =
$serviceGroup->getMembers();
}
- $this->getResult()->setIndexedTagName(
$data[$serviceGroupName]['members'], 'member' );
+ $this->getResult()->setIndexedTagName(
+ $data[$serviceGroupName]['members'],
'member'
+ );
}
$this->getResult()->addValue( null,
$this->getModuleName(), $data );
break;
@@ -53,7 +55,8 @@
return array_merge( parent::getParamDescription(), [
'subaction' => 'The subaction to perform.',
'project' => 'The project to perform the subaction
upon',
- 'shellmembers' => 'Return shell account names for
service group members, rather than MediaWiki usernames',
+ 'shellmembers' => 'Return shell account names for
service group members, ' .
+ 'rather than MediaWiki usernames',
] );
}
diff --git a/nova/OpenStackNovaController.php b/nova/OpenStackNovaController.php
index eeacf52..4dc4f02 100644
--- a/nova/OpenStackNovaController.php
+++ b/nova/OpenStackNovaController.php
@@ -91,7 +91,9 @@
foreach ( $serviceCatalog as $entry ) {
if ( $entry->type === "identity" ) {
foreach ( $entry->endpoints as
$endpoint ) {
- if ( !$wgUser->isAllowed(
'accessrestrictedregions' ) && in_array( $endpoint->region,
$wgOpenStackManagerRestrictedRegions ) ) {
+ if ( !$wgUser->isAllowed(
'accessrestrictedregions' ) &&
+ in_array(
$endpoint->region, $wgOpenStackManagerRestrictedRegions )
+ ) {
continue;
}
$regions[] = $endpoint->region;
@@ -156,7 +158,10 @@
}
function createProxy( $fqdn, $backendHost, $backendPort ) {
- $data = [ 'domain' => $fqdn, 'backends' => [ 'http://' .
$backendHost . ':' . $backendPort ] ];
+ $data = [
+ 'domain' => $fqdn,
+ 'backends' => [ 'http://' . $backendHost . ':' .
$backendPort ]
+ ];
$ret = $this->restCall( 'proxy', '/mapping', 'PUT', $data );
if ( $ret['code'] !== 200 ) {
@@ -193,14 +198,17 @@
$backends = self::_get_property( $proxy, 'backends' );
if ( ( count( $backends ) ) > 1 ) {
- $ldap->printDebug( "Warning! proxy $domain has
multiple backends but we only support one backend per proxy.", NONSENSITIVE );
+ $ldap->printDebug( "Warning! proxy $domain has
multiple backends " .
+ "but we only support one backend per
proxy.", NONSENSITIVE );
}
$backend = $backends[0];
$backendarray = explode( ':', $backends[0] );
if ( strpos( $backend, "http" ) === 0 ) {
if ( ( count( $backendarray ) < 2 ) || ( count(
$backendarray ) > 3 ) ) {
- $ldap->printDebug( "Unable to parse
backend $backend, discarding.", NONSENSITIVE );
+ $ldap->printDebug(
+ "Unable to parse backend
$backend, discarding.", NONSENSITIVE
+ );
} elseif ( count( $backendarray ) == 2 ) {
$backendHost = $backend;
$backendPort = null;
@@ -210,7 +218,9 @@
}
} else {
if ( ( count( $backendarray ) < 1 ) || ( count(
$backendarray ) > 2 ) ) {
- $ldap->printDebug( "Unable to parse
backend $backend, discarding.", NONSENSITIVE );
+ $ldap->printDebug(
+ "Unable to parse backend
$backend, discarding.", NONSENSITIVE
+ );
} elseif ( count( $backendarray ) == 1 ) {
$backendHost = $backend;
$backendPort = null;
@@ -221,7 +231,9 @@
}
if ( $backendPort ) {
- $proxyObj = new OpenStackNovaProxy(
$this->project, $domain, $backendHost, $backendPort );
+ $proxyObj = new OpenStackNovaProxy(
+ $this->project, $domain, $backendHost,
$backendPort
+ );
} else {
$proxyObj = new OpenStackNovaProxy(
$this->project, $domain, $backendHost );
}
@@ -264,7 +276,9 @@
$ret = $this->restCall( 'identity', '/tokens', 'POST', $data,
$headers );
if ( $ret['code'] !== 200 ) {
$ldap = LdapAuthenticationPlugin::getInstance();
- $ldap->printDebug(
"OpenStackNovaController::_getAdminToken return code: " . $ret['code'],
NONSENSITIVE );
+ $ldap->printDebug(
+ "OpenStackNovaController::_getAdminToken return
code: " . $ret['code'], NONSENSITIVE
+ );
return "";
}
@@ -412,7 +426,9 @@
$headers = [ "X-Auth-Token: $admintoken" ];
$assignments = [];
- $ret = $this->restCall( 'identityv3',
"/role_assignments?user.id=$userid", 'GET', [], $headers );
+ $ret = $this->restCall(
+ 'identityv3', "/role_assignments?user.id=$userid",
'GET', [], $headers
+ );
$role_assignments = self::_get_property( $ret['body'],
'role_assignments' );
if ( !$role_assignments ) {
return $projects;
@@ -438,7 +454,9 @@
$assignments = [];
- $ret = $this->restCall( 'identityv3',
"/role_assignments?scope.project.id=$projectid", 'GET', [], $headers );
+ $ret = $this->restCall(
+ 'identityv3',
"/role_assignments?scope.project.id=$projectid", 'GET', [], $headers
+ );
$role_assignments = self::_get_property( $ret['body'],
'role_assignments' );
if ( !$role_assignments ) {
return $assignments;
@@ -461,7 +479,9 @@
$headers = [ "X-Auth-Token: $admintoken" ];
$rolearr = [];
- $ret = $this->restCall( 'identity',
"/tenants/$projectid/users/$userid/roles", 'GET', [], $headers );
+ $ret = $this->restCall(
+ 'identity', "/tenants/$projectid/users/$userid/roles",
'GET', [], $headers
+ );
$roles = self::_get_property( $ret['body'], 'roles' );
if ( !$roles ) {
return $rolearr;
@@ -483,7 +503,10 @@
];
$rolearr = [];
- $ret = $this->restCall( 'identity',
"/tenants/$projectid/users/$userid/roles/OS-KSADM/$roleid", 'PUT', [], $headers
);
+ $ret = $this->restCall(
+ 'identity',
"/tenants/$projectid/users/$userid/roles/OS-KSADM/$roleid",
+ 'PUT', [], $headers
+ );
if ( $ret['code'] !== 200 && $ret['code'] !== 201 ) {
return false;
}
@@ -499,7 +522,10 @@
];
$rolearr = [];
- $ret = $this->restCall( 'identity',
"/tenants/$projectid/users/$userid/roles/OS-KSADM/$roleid", 'DELETE', [],
$headers );
+ $ret = $this->restCall(
+ 'identity',
"/tenants/$projectid/users/$userid/roles/OS-KSADM/$roleid",
+ 'DELETE', [], $headers
+ );
if ( $ret['code'] !== 204 && $ret['code'] !== 200 ) {
return false;
}
@@ -691,11 +717,17 @@
$userdata .= $endl;
$userdata .= $boundary;
if (
$wgOpenStackManagerInstanceUserData['cloud-config'] ) {
- $userdata .= $endl . $this->getAttachmentMime(
Spyc::YAMLDump( $wgOpenStackManagerInstanceUserData['cloud-config'] ),
'text/cloud-config', 'cloud-config.txt' );
+ $userdata .= $endl . $this->getAttachmentMime(
+ Spyc::YAMLDump(
$wgOpenStackManagerInstanceUserData['cloud-config'] ),
+ 'text/cloud-config',
+ 'cloud-config.txt'
+ );
$userdata .= $endl . $boundary;
}
if ( $wgOpenStackManagerInstanceUserData['scripts'] ) {
- foreach (
$wgOpenStackManagerInstanceUserData['scripts'] as $scriptname => $script ) {
+ foreach (
+
$wgOpenStackManagerInstanceUserData['scripts'] as $scriptname => $script
+ ) {
wfSuppressWarnings();
$stat = stat( $script );
wfRestoreWarnings();
@@ -703,12 +735,16 @@
continue;
}
$scripttext = file_get_contents(
$script );
- $userdata .= $endl .
$this->getAttachmentMime( $scripttext, 'text/x-shellscript', $scriptname );
+ $userdata .= $endl .
$this->getAttachmentMime(
+ $scripttext,
'text/x-shellscript', $scriptname
+ );
$userdata .= $endl . $boundary;
}
}
if ( $wgOpenStackManagerInstanceUserData['upstarts'] ) {
- foreach (
$wgOpenStackManagerInstanceUserData['upstarts'] as $upstartname => $upstart ) {
+ foreach (
+
$wgOpenStackManagerInstanceUserData['upstarts'] as $upstartname => $upstart
+ ) {
wfSuppressWarnings();
$stat = stat( $upstart );
wfRestoreWarnings();
@@ -716,7 +752,9 @@
continue;
}
$upstarttext = file_get_contents(
$upstart );
- $userdata .= $endl .
$this->getAttachmentMime( $upstarttext, 'text/upstart-job', $upstartname );
+ $userdata .= $endl .
$this->getAttachmentMime(
+ $upstarttext,
'text/upstart-job', $upstartname
+ );
$userdata .= $endl . $boundary;
}
}
@@ -793,7 +831,9 @@
* @param string $group
* @return bool
*/
- function addSecurityGroupRule( $groupid, $fromport='', $toport='',
$protocol='', $range='', $group='' ) {
+ function addSecurityGroupRule(
+ $groupid, $fromport = '', $toport = '', $protocol = '', $range
= '', $group = ''
+ ) {
if ( $group && $range ) {
return false;
} elseif ( $range ) {
@@ -973,10 +1013,19 @@
'Accept: application/json',
'Content-Type: application/json',
];
- $data = [ 'auth' => [ 'passwordCredentials' => [ 'username' =>
$username, 'password' => $password ] ] ];
+ $data = [
+ 'auth' => [
+ 'passwordCredentials' => [
+ 'username' => $username,
+ 'password' => $password
+ ]
+ ]
+ ];
$ret = $this->restCall( 'identity', '/tokens', 'POST', $data,
$headers );
if ( $ret['code'] !== 200 ) {
- $ldap->printDebug(
"OpenStackNovaController::authenticate return code: " . $ret['code'],
NONSENSITIVE );
+ $ldap->printDebug(
+ "OpenStackNovaController::authenticate return
code: " . $ret['code'], NONSENSITIVE
+ );
return '';
}
$user = $ret['body'];
diff --git a/nova/OpenStackNovaDomain.php b/nova/OpenStackNovaDomain.php
index d822146..2e62bc8 100644
--- a/nova/OpenStackNovaDomain.php
+++ b/nova/OpenStackNovaDomain.php
@@ -40,9 +40,14 @@
$this->domainInfo = $domainInfo;
} else {
$ldap = LdapAuthenticationPlugin::getInstance();
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN,
- '(dc='
. $this->domainname . ')' );
- $this->domainInfo =
LdapAuthenticationPlugin::ldap_get_entries( $ldap->ldapconn, $result );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn,
+ $wgOpenStackManagerLDAPInstanceBaseDN,
+ '(dc=' . $this->domainname . ')'
+ );
+ $this->domainInfo =
LdapAuthenticationPlugin::ldap_get_entries(
+ $ldap->ldapconn, $result
+ );
$wgMemc->set( $key, $this->domainInfo, 3600 * 24 );
}
if ( $this->domainInfo ) {
@@ -93,13 +98,19 @@
$ldap = LdapAuthenticationPlugin::getInstance();
$domain = [];
$domain['soarecord'] = OpenStackNovaDomain::generateSOA();
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->domainDN, $domain );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->domainDN, $domain
+ );
if ( $success ) {
- $ldap->printDebug( "Successfully modified soarecord for
" . $this->domainDN, NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully modified soarecord for " .
$this->domainDN, NONSENSITIVE
+ );
$this->fetchDomainInfo();
return true;
} else {
- $ldap->printDebug( "Failed to modify soarecord for " .
$this->domainDN, NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to modify soarecord for " .
$this->domainDN, NONSENSITIVE
+ );
return false;
}
}
@@ -125,7 +136,9 @@
} else {
$query = '(soarecord=*)';
}
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, $query );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN,
$query
+ );
if ( $result ) {
$entries = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $entries ) {
@@ -172,8 +185,11 @@
$ldap = LdapAuthenticationPlugin::getInstance();
OpenStackNovaLdapConnection::connect();
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN,
- '(arecord=' .
$ip . ')' );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn,
+ $wgOpenStackManagerLDAPInstanceBaseDN,
+ '(arecord=' . $ip . ')'
+ );
$hostInfo = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $hostInfo['count'] == "0" ) {
return null;
@@ -272,7 +288,9 @@
$result = LdapAuthenticationPlugin::ldap_list( $ldap->ldapconn,
$dn, 'objectclass=*' );
$hosts = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $hosts['count'] != "0" ) {
- $ldap->printDebug( "Failed to delete domain
$domainname, since it had sub entries", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete domain $domainname, since it
had sub entries", NONSENSITIVE
+ );
return [ false,
'openstackmanager-failedeletedomainduplicates' ];
}
@@ -281,7 +299,9 @@
$ldap->printDebug( "Successfully deleted domain
$domainname", NONSENSITIVE );
return [ true, '' ];
} else {
- $ldap->printDebug( "Failed to delete domain
$domainname, since it had sub entries", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete domain $domainname, since it
had sub entries", NONSENSITIVE
+ );
return [ false, 'openstackmanager-failedeletedomain' ];
}
}
diff --git a/nova/OpenStackNovaHost.php b/nova/OpenStackNovaHost.php
index 524dc6c..2f6faf5 100644
--- a/nova/OpenStackNovaHost.php
+++ b/nova/OpenStackNovaHost.php
@@ -94,7 +94,9 @@
foreach ( $associateddomains as $associateddomain ) {
$values['associateddomain'][] =
$associateddomain;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->hostDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->hostDN, $values
+ );
if ( $success ) {
$ldap->printDebug( "Successfully removed $fqdn
from $this->hostDN", NONSENSITIVE );
$this->getDomain()->updateSOA();
@@ -131,7 +133,9 @@
foreach ( $arecords as $arecord ) {
$values['arecord'][] = $arecord;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->hostDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->hostDN, $values
+ );
if ( $success ) {
$ldap->printDebug( "Successfully removed $ip
from $this->hostDN", NONSENSITIVE );
$this->getDomain()->updateSOA();
@@ -300,7 +304,9 @@
$domainname = $domain->getFullyQualifiedDomainName();
$host = OpenStackNovaHost::getHostByPublicIP( $ip );
if ( $host ) {
- $ldap->printDebug( "Failed to add public host $hostname
as the DNS entry already exists", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to add public host $hostname as the DNS
entry already exists", NONSENSITIVE
+ );
return null;
}
$hostEntry = [];
@@ -329,7 +335,9 @@
*/
static function validateHostname( $hostname ) {
# Does not handle trailing dots, purposely
- return (bool)preg_match(
"/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|\b-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|\b-){0,61}[0-9A-Za-z])?)*$/",
$hostname );
+ return (bool)preg_match(
"/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|\b-){0,61}" .
+
"[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|\b-){0,61}[0-9A-Za-z])?)*$/",
$hostname
+ );
}
}
diff --git a/nova/OpenStackNovaInstance.php b/nova/OpenStackNovaInstance.php
index 678c0b9..0ba9d46 100644
--- a/nova/OpenStackNovaInstance.php
+++ b/nova/OpenStackNovaInstance.php
@@ -36,7 +36,9 @@
}
function loadHost() {
- $this->host = OpenStackNovaHost::getHostByNameAndProject(
$this->getInstanceName(), $this->getProject(), $this->region );
+ $this->host = OpenStackNovaHost::getHostByNameAndProject(
+ $this->getInstanceName(), $this->getProject(),
$this->region
+ );
}
/**
@@ -67,7 +69,9 @@
* @return string
*/
function getInstanceId() {
- return OpenStackNovaController::_get_property( $this->instance,
'OS-EXT-SRV-ATTR:instance_name' );
+ return OpenStackNovaController::_get_property(
+ $this->instance, 'OS-EXT-SRV-ATTR:instance_name'
+ );
}
/**
@@ -91,7 +95,9 @@
foreach ( $addresses as $addresslist ) {
foreach ( $addresslist as $address ) {
$addr =
OpenStackNovaController::_get_property( $address, 'addr' );
- if ( $addr && !filter_var( $addr,
FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE ) ) {
+ if ( $addr &&
+ !filter_var( $addr,
FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE )
+ ) {
$addrs[] = $addr;
}
}
@@ -113,7 +119,9 @@
foreach ( $addresses as $addresslist ) {
foreach ( $addresslist as $address ) {
$addr =
OpenStackNovaController::_get_property( $address, 'addr' );
- if ( $addr && filter_var( $addr,
FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE ) ) {
+ if ( $addr &&
+ filter_var( $addr,
FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE )
+ ) {
$addrs[] = $addr;
}
}
@@ -270,7 +278,9 @@
if ( !$success ) {
return false;
}
- OpenStackManagerEvent::createDeletionEvent(
$this->getInstanceName(), $this->getProject(), $wgUser );
+ OpenStackManagerEvent::createDeletionEvent(
+ $this->getInstanceName(), $this->getProject(), $wgUser
+ );
$this->deleteArticle();
return true;
}
diff --git a/nova/OpenStackNovaPrivateHost.php
b/nova/OpenStackNovaPrivateHost.php
index ba0620a..fc562bd 100644
--- a/nova/OpenStackNovaPrivateHost.php
+++ b/nova/OpenStackNovaPrivateHost.php
@@ -45,13 +45,16 @@
$ldap = LdapAuthenticationPlugin::getInstance();
if ( $this->getDomain() ) {
- $fqdn = $this->instancename . '.' .
$this->instanceproject . '.' .
$this->getDomain()->getFullyQualifiedDomainName();
+ $fqdn = $this->instancename . '.' .
$this->instanceproject . '.' .
+
$this->getDomain()->getFullyQualifiedDomainName();
} else {
# No domain means no instance!
$this->hostInfo = null;
return;
}
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, '(dc=' . $fqdn . ')' );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN,
'(dc=' . $fqdn . ')'
+ );
$this->hostInfo = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $this->hostInfo["count"] == "0" ) {
$this->hostInfo = null;
@@ -70,11 +73,14 @@
*/
function getFullyQualifiedDisplayName() {
if ( $this->getDomain() ) {
- $fqdn = $this->instancename . '.' .
$this->instanceproject . '.' .
$this->getDomain()->getFullyQualifiedDomainName();
+ $fqdn = $this->instancename . '.' .
$this->instanceproject . '.' .
+
$this->getDomain()->getFullyQualifiedDomainName();
return $fqdn;
} else {
$ldap = LdapAuthenticationPlugin::getInstance();
- $ldap->printDebug( "Error: Unable to determine
instancename of " . $this->instancename, NONSENSITIVE );
+ $ldap->printDebug(
+ "Error: Unable to determine instancename of " .
$this->instancename, NONSENSITIVE
+ );
return "";
}
}
@@ -89,7 +95,10 @@
$this->domainCache =
OpenStackNovaDomain::getDomainByRegion( $this->region );
if ( !$this->domainCache ) {
$ldap = LdapAuthenticationPlugin::getInstance();
- $ldap->printDebug( "Looked up domain for region
$this->region but domainCache is still empty.", NONSENSITIVE );
+ $ldap->printDebug(
+ "Looked up domain for region
$this->region but domainCache is still empty.",
+ NONSENSITIVE
+ );
}
}
return $this->domainCache;
diff --git a/nova/OpenStackNovaProject.php b/nova/OpenStackNovaProject.php
index 31358d9..228a87b 100644
--- a/nova/OpenStackNovaProject.php
+++ b/nova/OpenStackNovaProject.php
@@ -132,7 +132,9 @@
# Now we have every group. Check if
this one belongs to us.
$matchstring = $this->projectname . ".";
if ( strpos( $groupEntry['cn'][0],
$matchstring ) === 0 ) {
- $this->serviceGroups[] = new
OpenStackNovaServiceGroup( $groupEntry['cn'][0], $this );
+ $this->serviceGroups[] = new
OpenStackNovaServiceGroup(
+ $groupEntry['cn'][0],
$this
+ );
}
}
}
@@ -333,17 +335,25 @@
foreach ( $sudoers as $sudoer ) {
$success = $sudoer->deleteUser( $username );
if ( $success ) {
- $ldap->printDebug( "Successfully
removed $username from " . $sudoer->getSudoerName(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully removed $username
from " . $sudoer->getSudoerName(),
+ NONSENSITIVE
+ );
} else {
- $ldap->printDebug( "Failed to remove
$username from " . $sudoer->getSudoerName(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to remove $username
from " . $sudoer->getSudoerName(), NONSENSITIVE
+ );
}
}
$user = new OpenStackNovaUser( $username );
- $ldap->printDebug( "Successfully removed $user->userDN
from $this->projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully removed $user->userDN from
$this->projectname", NONSENSITIVE
+ );
$this->deleteRoleCaches( $username );
return true;
} else {
- $ldap->printDebug( "Failed to remove $username from
$this->projectname: " . ldap_error( $ldap->ldapconn ), NONSENSITIVE );
+ $ldap->printDebug( "Failed to remove $username from
$this->projectname: " .
+ ldap_error( $ldap->ldapconn ), NONSENSITIVE );
return false;
}
}
@@ -576,9 +586,13 @@
$ldapproject['member'] = $wgOpenStackManagerLDAPUser;
$projectdn = 'cn=' . $projectname . ',' .
$wgOpenStackManagerLDAPProjectBaseDN;
- $success = LdapAuthenticationPlugin::ldap_add(
$ldap->ldapconn, $projectdn, $ldapproject );
+ $success = LdapAuthenticationPlugin::ldap_add(
+ $ldap->ldapconn, $projectdn, $ldapproject
+ );
if ( !$success ) {
- $ldap->printDebug( "Creation of ldap project
container failed for $projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Creation of ldap project container
failed for $projectname", NONSENSITIVE
+ );
}
$ldap->printDebug( "Added ldap project container
$projectname", NONSENSITIVE );
@@ -598,14 +612,21 @@
if ( OpenStackNovaSudoer::createSudoer( 'default-sudo',
$projectname, [ $projectGroup ],
[], [ 'ALL' ],
[ '!authenticate' ] ) ) {
- $ldap->printDebug( "Successfully created
default sudo policy for $projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully created default sudo
policy for $projectname", NONSENSITIVE
+ );
}
// Now, allow all project members to sudo to all other
users.
$projectGroup = "%" . $project->getProjectGroupName();
- if ( OpenStackNovaSudoer::createSudoer(
'default-sudo-as', $projectname, [ $projectGroup ],
- [ "$projectGroup" ], [ 'ALL' ],
- [ '!authenticate' ] ) ) {
- $ldap->printDebug( "Successfully created
default sudo-as policy for $projectname", NONSENSITIVE );
+ if (
+ OpenStackNovaSudoer::createSudoer(
+ 'default-sudo-as', $projectname, [
$projectGroup ],
+ [ "$projectGroup" ], [ 'ALL' ], [
'!authenticate' ]
+ )
+ ) {
+ $ldap->printDebug(
+ "Successfully created default sudo-as
policy for $projectname", NONSENSITIVE
+ );
}
OpenStackNovaProject::createServiceGroupOUs(
$projectname );
} else {
@@ -634,11 +655,14 @@
$groups = [];
$groups['objectclass'][] = 'organizationalunit';
$groups['ou'] = 'groups';
- $groupsdn = 'ou=' . $groups['ou'] . ',' . 'cn=' . $projectname
. ',' . $wgOpenStackManagerLDAPProjectBaseDN;
+ $groupsdn = 'ou=' . $groups['ou'] . ',' . 'cn=' . $projectname
. ',' .
+ $wgOpenStackManagerLDAPProjectBaseDN;
$success = LdapAuthenticationPlugin::ldap_add( $ldap->ldapconn,
$groupsdn, $groups );
if ( !$success ) {
- $ldap->printDebug( "Failed to create service group ou
for project $projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to create service group ou for project
$projectname", NONSENSITIVE
+ );
return false;
}
@@ -646,11 +670,14 @@
$users = [];
$users['objectclass'][] = 'organizationalunit';
$users['ou'] = 'people';
- $usersdn = 'ou=' . $users['ou'] . ',' . 'cn=' . $projectname .
',' . $wgOpenStackManagerLDAPProjectBaseDN;
+ $usersdn = 'ou=' . $users['ou'] . ',' . 'cn=' . $projectname .
',' .
+ $wgOpenStackManagerLDAPProjectBaseDN;
$success = LdapAuthenticationPlugin::ldap_add( $ldap->ldapconn,
$usersdn, $users );
if ( !$success ) {
- $ldap->printDebug( "Failed to create service user ou
for project $projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to create service user ou for project
$projectname", NONSENSITIVE
+ );
return false;
}
@@ -671,22 +698,28 @@
$groups = [];
$groups['objectclass'][] = 'organizationalunit';
$groups['ou'] = 'groups';
- $groupsdn = 'ou=' . $groups['ou'] . ',' . 'cn=' .
$this->projectname . ',' . $wgOpenStackManagerLDAPProjectBaseDN;
+ $groupsdn = 'ou=' . $groups['ou'] . ',' . 'cn=' .
$this->projectname . ',' .
+ $wgOpenStackManagerLDAPProjectBaseDN;
$success = LdapAuthenticationPlugin::ldap_delete(
$ldap->ldapconn, $groupsdn );
if ( !$success ) {
- $ldap->printDebug( "Failed to delete service group ou
for project $this->projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete service group ou for project
$this->projectname", NONSENSITIVE
+ );
return false;
}
$users = [];
$users['objectclass'][] = 'organizationalunit';
$users['ou'] = 'people';
- $usersdn = 'ou=' . $users['ou'] . ',' . 'cn=' .
$this->projectname . ',' . $wgOpenStackManagerLDAPProjectBaseDN;
+ $usersdn = 'ou=' . $users['ou'] . ',' . 'cn=' .
$this->projectname . ',' .
+ $wgOpenStackManagerLDAPProjectBaseDN;
$success = LdapAuthenticationPlugin::ldap_delete(
$ldap->ldapconn, $usersdn );
if ( !$success ) {
- $ldap->printDebug( "Failed to delete service user ou
for project $this->projectname", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete service user ou for project
$this->projectname", NONSENSITIVE
+ );
return false;
}
@@ -715,18 +748,28 @@
# Projects have a sudo OU and sudoers entries below that OU, we
must delete them first
$sudoers = OpenStackNovaSudoer::getAllSudoersByProject(
$project->getProjectName() );
foreach ( $sudoers as $sudoer ) {
- $success = OpenStackNovaSudoer::deleteSudoer(
$sudoer->getSudoerName(), $project->getProjectName() );
+ $success = OpenStackNovaSudoer::deleteSudoer(
+ $sudoer->getSudoerName(),
$project->getProjectName()
+ );
if ( $success ) {
- $ldap->printDebug( "Successfully deleted sudoer
" . $sudoer->getSudoerName(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully deleted sudoer " .
$sudoer->getSudoerName(), NONSENSITIVE
+ );
} else {
- $ldap->printDebug( "Failed to delete sudoer " .
$sudoer->getSudoerName(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete sudoer " .
$sudoer->getSudoerName(), NONSENSITIVE
+ );
}
}
$success = LdapAuthenticationPlugin::ldap_delete(
$ldap->ldapconn, $project->getSudoersDN() );
if ( $success ) {
- $ldap->printDebug( "Successfully deleted sudoers OU " .
$project->getSudoersDN(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully deleted sudoers OU " .
$project->getSudoersDN(), NONSENSITIVE
+ );
} else {
- $ldap->printDebug( "Failed to delete sudoers OU " .
$project->getSudoersDN(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to delete sudoers OU " .
$project->getSudoersDN(), NONSENSITIVE
+ );
}
# And, we need to clean up service groups.
$servicegroups = $project->getServiceGroups();
@@ -734,7 +777,9 @@
$groupName = $group->groupName;
$success =
OpenStackNovaServiceGroup::deleteServiceGroup( $groupName, $project );
if ( $success ) {
- $ldap->printDebug( "Successfully deleted
service group " . $groupName, NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully deleted service group " .
$groupName, NONSENSITIVE
+ );
} else {
$ldap->printDebug( "Failed to delete service
group " . $groupName, NONSENSITIVE );
}
@@ -777,7 +822,9 @@
$text = sprintf( $format,
$this->getProjectName()
);
- OpenStackNovaArticle::editArticle( $this->getProjectName(),
$text, $wgOpenStackManagerProjectNamespace );
+ OpenStackNovaArticle::editArticle(
+ $this->getProjectName(), $text,
$wgOpenStackManagerProjectNamespace
+ );
if ( $wgOpenStackManagerCreateProjectSALPages ) {
$pagename = $this->getProjectName() . "/SAL";
$title = Title::newFromText( $pagename,
$wgOpenStackManagerProjectNamespace );
@@ -788,14 +835,18 @@
}
$text = "{{SAL|Project Name=" . $this->getProjectName()
. "}}";
if ( !strstr( $content, $text ) ) {
- OpenStackNovaArticle::editArticle( $pagename,
$text, $wgOpenStackManagerProjectNamespace );
+ OpenStackNovaArticle::editArticle(
+ $pagename, $text,
$wgOpenStackManagerProjectNamespace
+ );
}
}
}
function deleteArticle() {
global $wgOpenStackManagerProjectNamespace;
- OpenStackNovaArticle::deleteArticle( $this->getProjectName(),
$wgOpenStackManagerProjectNamespace );
+ OpenStackNovaArticle::deleteArticle(
+ $this->getProjectName(),
$wgOpenStackManagerProjectNamespace
+ );
}
/**
@@ -816,8 +867,11 @@
$pattern = $wgOpenStackManagerServiceGroupHomedirPattern;
$ldap = LdapAuthenticationPlugin::getInstance();
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPProjectBaseDN,
- '(&(cn=' .
$this->getProjectName() . ')(objectclass=groupofnames))' );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn,
+ $wgOpenStackManagerLDAPProjectBaseDN,
+ '(&(cn=' . $this->getProjectName() .
')(objectclass=groupofnames))'
+ );
$projectInfo = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( isset( $projectInfo[0]['info'] ) ) {
@@ -827,7 +881,7 @@
array_shift( $infos );
foreach ( $infos as $info ) {
$substrings = explode( '=', $info );
- if ( ( count( $substrings ) == 2 ) && (
$substrings[0] == 'servicegrouphomedirpattern' ) ) {
+ if ( count( $substrings ) == 2 &&
$substrings[0] == 'servicegrouphomedirpattern' ) {
$pattern = $substrings[1];
break;
}
diff --git a/nova/OpenStackNovaPublicHost.php b/nova/OpenStackNovaPublicHost.php
index f0101b2..b14580a 100644
--- a/nova/OpenStackNovaPublicHost.php
+++ b/nova/OpenStackNovaPublicHost.php
@@ -34,7 +34,9 @@
$ldap = LdapAuthenticationPlugin::getInstance();
$this->ip = $ldap->getLdapEscapedString( $this->ip );
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, '(dc=' . $this->ip .
')' );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN,
'(dc=' . $this->ip . ')'
+ );
$this->hostInfo = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $this->hostInfo["count"] == "0" ) {
$this->hostInfo = null;
@@ -53,7 +55,10 @@
$this->domainCache =
OpenStackNovaDomain::getDomainByHostIP( $this->ip );
if ( !$this->domainCache ) {
$ldap = LdapAuthenticationPlugin::getInstance();
- $ldap->printDebug( "Looked up domain for ip
$this->ip but domainCache is still empty.", NONSENSITIVE );
+ $ldap->printDebug(
+ "Looked up domain for ip $this->ip but
domainCache is still empty.",
+ NONSENSITIVE
+ );
}
}
return $this->domainCache;
diff --git a/nova/OpenStackNovaSecondaryAuthenticationProvider.php
b/nova/OpenStackNovaSecondaryAuthenticationProvider.php
index 0ee4a69..7573e12 100644
--- a/nova/OpenStackNovaSecondaryAuthenticationProvider.php
+++ b/nova/OpenStackNovaSecondaryAuthenticationProvider.php
@@ -32,7 +32,9 @@
$ldap->connect();
$base = $ldap->getBaseDN( USERDN );
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $base, "(uid=$shellaccountname)" );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $base, "(uid=$shellaccountname)"
+ );
if ( $result ) {
$entries = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( (int)$entries['count'] > 0 ) {
@@ -47,7 +49,12 @@
$sv = StatusValue::newGood();
if ( class_exists( 'TitleBlacklist' ) ) {
- $sv->merge( TitleBlacklistHooks::testUserName(
$shellaccountname, $creator, $override = false, $log = true ) );
+ $sv->merge( TitleBlacklistHooks::testUserName(
+ $shellaccountname,
+ $creator,
+ $override = false,
+ $log = true
+ ) );
}
return $sv;
diff --git a/nova/OpenStackNovaSecurityGroupRule.php
b/nova/OpenStackNovaSecurityGroupRule.php
index a2ac761..eb6bea6 100644
--- a/nova/OpenStackNovaSecurityGroupRule.php
+++ b/nova/OpenStackNovaSecurityGroupRule.php
@@ -53,8 +53,12 @@
*/
function getGroup() {
$properties = [];
- $properties['groupname'] =
OpenStackNovaController::_get_property( $this->rule->group, 'name' );
- $properties['project'] =
OpenStackNovaController::_get_property( $this->rule->group, 'tenant_id' );
+ $properties['groupname'] =
OpenStackNovaController::_get_property(
+ $this->rule->group, 'name'
+ );
+ $properties['project'] = OpenStackNovaController::_get_property(
+ $this->rule->group, 'tenant_id'
+ );
if ( $properties['groupname'] && $properties['project'] ) {
return $properties;
diff --git a/nova/OpenStackNovaServiceGroup.php
b/nova/OpenStackNovaServiceGroup.php
index c070593..024658c 100644
--- a/nova/OpenStackNovaServiceGroup.php
+++ b/nova/OpenStackNovaServiceGroup.php
@@ -49,7 +49,9 @@
} else {
$ldap = LdapAuthenticationPlugin::getInstance();
$result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $dn, $query );
- $this->groupInfo =
LdapAuthenticationPlugin::ldap_get_entries( $ldap->ldapconn, $result );
+ $this->groupInfo =
LdapAuthenticationPlugin::ldap_get_entries(
+ $ldap->ldapconn, $result
+ );
$wgMemc->set( $key, $this->groupInfo, 3600 * 24 );
}
@@ -165,12 +167,18 @@
foreach ( $members as $member ) {
$values['member'][] = $member;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->groupDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->groupDN, $values
+ );
if ( $success ) {
$this->fetchGroupInfo();
- $ldap->printDebug( "Successfully removed
$user->userDN from $this->groupDN", NONSENSITIVE );
+ $ldap->printDebug(
+ "Successfully removed $user->userDN
from $this->groupDN", NONSENSITIVE
+ );
} else {
- $ldap->printDebug( "Failed to remove
$user->userDN from $this->groupDN", NONSENSITIVE );
+ $ldap->printDebug(
+ "Failed to remove $user->userDN from
$this->groupDN", NONSENSITIVE
+ );
return false;
}
} else {
@@ -203,7 +211,9 @@
}
$values = [];
$values['member'] = $members;
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->groupDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->groupDN, $values
+ );
if ( $success ) {
$this->fetchGroupInfo();
$ldap->printDebug( "Successfully set members for
$this->groupDN", NONSENSITIVE );
@@ -237,7 +247,9 @@
$members[] = $userDN;
$values = [];
$values['member'] = $members;
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->groupDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->groupDN, $values
+ );
if ( $success ) {
$this->fetchGroupInfo();
$ldap->printDebug( "Successfully added $userDN to
$this->groupDN", NONSENSITIVE );
@@ -293,7 +305,10 @@
if ( $initialUser ) {
$user = new OpenStackNovaUser( $initialUser );
if ( !$user->userDN ) {
- $ldap->printDebug( "Unable to find initial user
$initialUser for new group $groupName", NONSENSITIVE );
+ $ldap->printDebug(
+ "Unable to find initial user
$initialUser for new group $groupName",
+ NONSENSITIVE
+ );
return null;
}
$initialUserDN = $user->userDN;
@@ -379,12 +394,16 @@
$ldap = LdapAuthenticationPlugin::getInstance();
$group = self::getServiceGroupByName( $groupName, $project );
if ( !$group ) {
- $ldap->printDebug( "We are trying to delete a
nonexistent service group, $groupName", NONSENSITIVE );
+ $ldap->printDebug(
+ "We are trying to delete a nonexistent service
group, $groupName", NONSENSITIVE
+ );
return false;
}
# Delete our special member.
- $success = LdapAuthenticationPlugin::ldap_delete(
$ldap->ldapconn, $group->getSpecialUserDN() );
+ $success = LdapAuthenticationPlugin::ldap_delete(
+ $ldap->ldapconn, $group->getSpecialUserDN()
+ );
if ( $success ) {
$ldap->printDebug( "Successfully deleted service user
$groupName", NONSENSITIVE );
} else {
diff --git a/nova/OpenStackNovaSudoer.php b/nova/OpenStackNovaSudoer.php
index 90e1e62..08a4b7f 100644
--- a/nova/OpenStackNovaSudoer.php
+++ b/nova/OpenStackNovaSudoer.php
@@ -33,7 +33,9 @@
function fetchSudoerInfo() {
global $wgMemc;
- $key = wfMemcKey( 'openstackmanager', 'sudoerinfo',
$this->project->getProjectName() . $this->sudoername );
+ $key = wfMemcKey( 'openstackmanager', 'sudoerinfo',
+ $this->project->getProjectName() . $this->sudoername
+ );
$sudoerInfo = $wgMemc->get( $key );
@@ -41,9 +43,14 @@
$this->sudoerInfo = $sudoerInfo;
} else {
$ldap = LdapAuthenticationPlugin::getInstance();
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $this->project->getSudoersDN(),
- '(cn='
. $this->sudoername . ')' );
- $this->sudoerInfo =
LdapAuthenticationPlugin::ldap_get_entries( $ldap->ldapconn, $result );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn,
+ $this->project->getSudoersDN(),
+ '(cn=' . $this->sudoername . ')'
+ );
+ $this->sudoerInfo =
LdapAuthenticationPlugin::ldap_get_entries(
+ $ldap->ldapconn, $result
+ );
$wgMemc->set( $key, $this->sudoerInfo, 3600 * 24 );
}
if ( $this->sudoerInfo ) {
@@ -150,10 +157,14 @@
$sudoer['sudooption'][] = $option;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->sudoerDN, $sudoer );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->sudoerDN, $sudoer
+ );
if ( $success ) {
$ldap->printDebug( "Successfully modified sudoer
$this->sudoerDN", NONSENSITIVE );
- $key = wfMemcKey( 'openstackmanager', 'sudoerinfo',
$this->project->getProjectName() . $this->sudoername );
+ $key = wfMemcKey( 'openstackmanager', 'sudoerinfo',
+ $this->project->getProjectName() .
$this->sudoername
+ );
$wgMemc->delete( $key );
return true;
} else {
@@ -180,9 +191,13 @@
foreach ( $sudousers as $sudouser ) {
$values['sudouser'][] = $sudouser;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->sudoerDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->sudoerDN, $values
+ );
if ( $success ) {
- $key = wfMemcKey( 'openstackmanager',
'sudoerinfo', $this->project->getProjectName() . $this->sudoername );
+ $key = wfMemcKey( 'openstackmanager',
'sudoerinfo',
+ $this->project->getProjectName() .
$this->sudoername
+ );
$wgMemc->delete( $key );
return true;
}
@@ -202,7 +217,9 @@
$sudoers = [];
$project = OpenStackNovaProject::getProjectByName( $projectName
);
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $project->getSudoersDN(), '(&(cn=*)(objectclass=sudorole))' );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $project->getSudoersDN(),
'(&(cn=*)(objectclass=sudorole))'
+ );
if ( $result ) {
$entries = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( $entries ) {
@@ -248,7 +265,9 @@
* @param $options
* @return null|OpenStackNovaSudoer
*/
- static function createSudoer( $sudoername, $projectName, $users,
$runasuser, $commands, $options ) {
+ static function createSudoer(
+ $sudoername, $projectName, $users, $runasuser, $commands,
$options
+ ) {
$ldap = LdapAuthenticationPlugin::getInstance();
OpenStackNovaLdapConnection::connect();
diff --git a/nova/OpenStackNovaUser.php b/nova/OpenStackNovaUser.php
index 6dfb120..6bf4226 100644
--- a/nova/OpenStackNovaUser.php
+++ b/nova/OpenStackNovaUser.php
@@ -34,7 +34,9 @@
$ldap->printDebug( "Fetching userdn using username:
$this->userDN ", NONSENSITIVE );
if ( !$this->userDN ) {
$this->userDN = $ldap->getUserDN( strtolower(
$this->username ), false, "uid" );
- $ldap->printDebug( "Fetching userdn using shell
name: $this->userDN ", NONSENSITIVE );
+ $ldap->printDebug(
+ "Fetching userdn using shell name:
$this->userDN ", NONSENSITIVE
+ );
# We want the actual username, not the id that
was passed in.
$this->userInfo = $ldap->userInfo;
@@ -43,7 +45,9 @@
} else {
$this->userDN = $ldap->getUserDN( strtolower(
$wgUser->getName() ) );
$this->username = $wgUser->getName();
- $ldap->printDebug( "Fetching userdn using wiki name: "
. $wgUser->getName(), NONSENSITIVE );
+ $ldap->printDebug(
+ "Fetching userdn using wiki name: " .
$wgUser->getName(), NONSENSITIVE
+ );
}
$this->userInfo = $ldap->userInfo;
}
@@ -308,7 +312,9 @@
foreach ( $keypairs as $keypair ) {
$values['sshpublickey'][] = $keypair;
}
- $success = LdapAuthenticationPlugin::ldap_modify(
$ldap->ldapconn, $this->userDN, $values );
+ $success = LdapAuthenticationPlugin::ldap_modify(
+ $ldap->ldapconn, $this->userDN, $values
+ );
if ( $success ) {
$ldap->printDebug( "Successfully deleted the
user's sshpublickey", NONSENSITIVE );
$key = wfMemcKey( 'ldapauthentication',
"userinfo", $this->userDN );
@@ -370,7 +376,9 @@
$highest = array_pop( $uids ) + 1;
}
} else {
- $auth->printDebug( "Failed to find any entries
when searching for next $attr", NONSENSITIVE );
+ $auth->printDebug(
+ "Failed to find any entries when
searching for next $attr", NONSENSITIVE
+ );
}
} else {
$auth->printDebug( "Failed to get a result searching
for next $attr", NONSENSITIVE );
@@ -396,7 +404,9 @@
* @param $result
* @return bool
*/
- static function LDAPSetCreationValues( $auth, $username, &$values,
$writeloc, &$userdn, &$result ) {
+ static function LDAPSetCreationValues(
+ $auth, $username, &$values, $writeloc, &$userdn, &$result
+ ) {
global $wgOpenStackManagerLDAPDefaultGid;
global $wgOpenStackManagerLDAPDefaultShell;
global $wgRequest;
@@ -415,7 +425,9 @@
if ( '' !== $auth->realname ) {
$values['displayname'] = $auth->realname;
}
- if ( class_exists( \MediaWiki\Auth\AuthManager::class ) &&
empty( $wgDisableAuthManager ) ) {
+ if ( class_exists( \MediaWiki\Auth\AuthManager::class ) &&
+ empty( $wgDisableAuthManager )
+ ) {
$shellaccountname =
\MediaWiki\Auth\AuthManager::singleton()
->getAuthenticationSessionData(
'osm-shellaccountname', '' );
} else {
@@ -436,7 +448,9 @@
$base = $auth->getBaseDN( USERDN );
# Though the LDAP plugin checks to see if the user account
exists,
# it does not check to see if the uid attribute is already used.
- $result = LdapAuthenticationPlugin::ldap_search(
$auth->ldapconn, $base, "(uid=$shellaccountname)" );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $auth->ldapconn, $base, "(uid=$shellaccountname)"
+ );
if ( $result ) {
$entries = LdapAuthenticationPlugin::ldap_get_entries(
$auth->ldapconn, $result );
if ( (int)$entries['count'] > 0 ) {
@@ -452,7 +466,9 @@
$values['loginshell'] = $wgOpenStackManagerLDAPDefaultShell;
if ( $writeloc === '' ) {
- $auth->printDebug( "Trying to set the userdn, but write
location isn't set.", NONSENSITIVE );
+ $auth->printDebug(
+ "Trying to set the userdn, but write location
isn't set.", NONSENSITIVE
+ );
return false;
} else {
$userdn = 'uid=' . $shellaccountname . ',' . $writeloc;
@@ -476,7 +492,9 @@
* @param $result
* @return bool
*/
- static function LDAPRetrySetCreationValues( $auth, $username, &$values,
$writeloc, &$userdn, &$result ) {
+ static function LDAPRetrySetCreationValues(
+ $auth, $username, &$values, $writeloc, &$userdn, &$result
+ ) {
$uidnumber = OpenStackNovaUser::getNextIdNumber( $auth,
'uidnumber' );
if ( !$uidnumber ) {
$result = false;
@@ -494,7 +512,13 @@
* @return bool
*/
static function LDAPModifyUITemplate( &$template ) {
- $input = [ 'msg' => 'openstackmanager-shellaccountname', 'type'
=> 'text', 'name' => 'shellaccountname', 'value' => '', 'helptext' =>
'openstackmanager-shellaccountnamehelp' ];
+ $input = [
+ 'msg' => 'openstackmanager-shellaccountname',
+ 'type' => 'text',
+ 'name' => 'shellaccountname',
+ 'value' => '',
+ 'helptext' => 'openstackmanager-shellaccountnamehelp'
+ ];
$template->set( 'extraInput', [ $input ] );
return true;
@@ -520,7 +544,9 @@
global $wgUser;
global $wgDisableAuthManager;
- if ( class_exists( \MediaWiki\Auth\AuthManager::class ) &&
empty( $wgDisableAuthManager ) ) {
+ if ( class_exists( \MediaWiki\Auth\AuthManager::class ) &&
+ empty( $wgDisableAuthManager )
+ ) {
// handled in
OpenStackNovaSecondaryAuthenticationProvider
return true;
}
@@ -534,7 +560,9 @@
}
$base = USERDN;
- $result = LdapAuthenticationPlugin::ldap_search(
$ldap->ldapconn, $base, "(uid=$shellaccountname)" );
+ $result = LdapAuthenticationPlugin::ldap_search(
+ $ldap->ldapconn, $base, "(uid=$shellaccountname)"
+ );
if ( $result ) {
$entries = LdapAuthenticationPlugin::ldap_get_entries(
$ldap->ldapconn, $result );
if ( (int)$entries['count'] > 0 ) {
@@ -545,7 +573,9 @@
}
if ( class_exists( 'TitleBlacklist' ) ) {
- return TitleBlacklistHooks::acceptNewUserName(
$shellaccountname, $wgUser, $message, $override = false, $log = true );
+ return TitleBlacklistHooks::acceptNewUserName(
+ $shellaccountname, $wgUser, $message, $override
= false, $log = true
+ );
} else {
return true;
}
@@ -757,10 +787,14 @@
[
'action' => 'delete',
'hash' => $hash,
- 'returnto' =>
SpecialPage::getTitleFor( 'Preferences', false, 'mw-prefsection-openstack'
)->getFullText()
+ 'returnto' =>
SpecialPage::getTitleFor(
+ 'Preferences', false,
'mw-prefsection-openstack'
+ )->getFullText()
]
);
- SpecialNova::pushRawResourceColumn( $keyRow,
SpecialNova::createResourceList( $actions ) );
+ SpecialNova::pushRawResourceColumn(
+ $keyRow,
SpecialNova::createResourceList( $actions )
+ );
$keyRows[] = $keyRow;
}
$out .= SpecialNova::createResourceTable( $headers,
$keyRows );
@@ -769,7 +803,11 @@
SpecialPage::getTitleFor( 'NovaKey' ),
wfMessage( 'openstackmanager-addkey' )->escaped(),
[],
- [ 'returnto' => SpecialPage::getTitleFor(
'Preferences', false, 'mw-prefsection-openstack' )->getFullText() ]
+ [
+ 'returnto' => SpecialPage::getTitleFor(
+ 'Preferences', false,
'mw-prefsection-openstack'
+ )->getFullText()
+ ]
);
return $out;
}
--
To view, visit https://gerrit.wikimedia.org/r/364124
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I810ca14844d2ed32fc95b24c849c288ca162c93b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits