jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/364125 )
Change subject: Break long lines ...................................................................... Break long lines Change-Id: I562a8e0c1e585d6b3e81d35a56deb4722f7e135a --- M OpenStackManager.php M OpenStackManagerEvent.php M maintenance/onInstanceActionCompletion.php M maintenance/purgeOldServiceGroups.php M maintenance/qualifyInstancePages.php M maintenance/syncProjectGroups.php M maintenance/transitionServiceGroupSchema.php M maintenance/updatedomains.php M phpcs.xml M special/SpecialNova.php M special/SpecialNovaAddress.php M special/SpecialNovaDomain.php M special/SpecialNovaKey.php M special/SpecialNovaProject.php M special/SpecialNovaProxy.php M special/SpecialNovaResources.php M special/SpecialNovaRole.php M special/SpecialNovaServiceGroup.php M special/SpecialNovaSudoer.php M special/SpecialNovaVolume.php 20 files changed, 509 insertions(+), 166 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/OpenStackManager.php b/OpenStackManager.php index 2458f63..2059f45 100644 --- a/OpenStackManager.php +++ b/OpenStackManager.php @@ -173,7 +173,8 @@ $wgAutoloadClasses['OpenStackNovaPrivateHost'] = $dir . 'nova/OpenStackNovaPrivateHost.php'; $wgAutoloadClasses['OpenStackNovaAddress'] = $dir . 'nova/OpenStackNovaAddress.php'; $wgAutoloadClasses['OpenStackNovaSecurityGroup'] = $dir . 'nova/OpenStackNovaSecurityGroup.php'; -$wgAutoloadClasses['OpenStackNovaSecurityGroupRule'] = $dir . 'nova/OpenStackNovaSecurityGroupRule.php'; +$wgAutoloadClasses['OpenStackNovaSecurityGroupRule'] = + $dir . 'nova/OpenStackNovaSecurityGroupRule.php'; $wgAutoloadClasses['OpenStackNovaRole'] = $dir . 'nova/OpenStackNovaRole.php'; $wgAutoloadClasses['OpenStackNovaServiceGroup'] = $dir . 'nova/OpenStackNovaServiceGroup.php'; $wgAutoloadClasses['OpenStackNovaVolume'] = $dir . 'nova/OpenStackNovaVolume.php'; @@ -183,8 +184,10 @@ $wgAutoloadClasses['OpenStackNovaLdapConnection'] = $dir . 'nova/OpenStackNovaLdapConnection.php'; $wgAutoloadClasses['OpenStackNovaProject'] = $dir . 'nova/OpenStackNovaProject.php'; $wgAutoloadClasses['OpenStackNovaProjectLimits'] = $dir . 'nova/OpenStackNovaProjectLimits.php'; -$wgAutoloadClasses['OpenStackNovaShellAccountNameRequest'] = $dir . 'nova/OpenStackNovaShellAccountNameRequest.php'; -$wgAutoloadClasses['OpenStackNovaSecondaryAuthenticationProvider'] = $dir . '/nova/OpenStackNovaSecondaryAuthenticationProvider.php'; +$wgAutoloadClasses['OpenStackNovaShellAccountNameRequest'] = + $dir . 'nova/OpenStackNovaShellAccountNameRequest.php'; +$wgAutoloadClasses['OpenStackNovaSecondaryAuthenticationProvider'] = + $dir . '/nova/OpenStackNovaSecondaryAuthenticationProvider.php'; $wgAutoloadClasses['SpecialNovaKey'] = $dir . 'special/SpecialNovaKey.php'; $wgAutoloadClasses['SpecialNovaProject'] = $dir . 'special/SpecialNovaProject.php'; $wgAutoloadClasses['SpecialNovaDomain'] = $dir . 'special/SpecialNovaDomain.php'; @@ -203,7 +206,8 @@ $wgAutoloadClasses['ApiNovaServiceGroups'] = $dir . 'api/ApiNovaServiceGroups.php'; $wgAutoloadClasses['ApiListNovaProjects'] = $dir . 'api/ApiListNovaProjects.php'; $wgAutoloadClasses['ApiListNovaInstances'] = $dir . 'api/ApiListNovaInstances.php'; -$wgAutoloadClasses['EchoOpenStackManagerPresentationModel'] = $dir . 'EchoOpenStackManagerPresentationModel.php'; +$wgAutoloadClasses['EchoOpenStackManagerPresentationModel'] = + $dir . 'EchoOpenStackManagerPresentationModel.php'; $wgAutoloadClasses['OpenStackManagerEvent'] = $dir . 'OpenStackManagerEvent.php'; $wgSpecialPages['NovaKey'] = 'SpecialNovaKey'; $wgSpecialPages['NovaProject'] = 'SpecialNovaProject'; @@ -311,8 +315,17 @@ switch ( $updater->getDB()->getType() ) { case 'mysql': $updater->addExtensionTable( 'openstack_tokens', "$base/schema-changes/tokens.sql" ); - $updater->addExtensionTable( 'openstack_notification_event', "$base/schema-changes/openstack_add_notification_events_table.sql" ); - $updater->addExtensionUpdate( [ 'modifyField', 'openstack_tokens', 'token', "$base/schema-changes/openstack_change_token_size.sql", true ] ); + $updater->addExtensionTable( + 'openstack_notification_event', + "$base/schema-changes/openstack_add_notification_events_table.sql" + ); + $updater->addExtensionUpdate( [ + 'modifyField', + 'openstack_tokens', + 'token', + "$base/schema-changes/openstack_change_token_size.sql", + true + ] ); break; } return true; @@ -377,7 +390,9 @@ $event->getType() == 'osm-instance-deleted' ) { $extra = $event->getExtra(); - foreach ( OpenStackNovaProject::getProjectByName( $extra['projectName'] )->getRoles() as $role ) { + foreach ( + OpenStackNovaProject::getProjectByName( $extra['projectName'] )->getRoles() as $role + ) { if ( $role->getRoleName() == 'projectadmin' ) { foreach ( $role->getMembers() as $roleMember ) { $roleMemberUser = User::newFromName( $roleMember ); diff --git a/OpenStackManagerEvent.php b/OpenStackManagerEvent.php index b1ac8f4..bc3f1f4 100644 --- a/OpenStackManagerEvent.php +++ b/OpenStackManagerEvent.php @@ -15,7 +15,8 @@ } /** - * Store the event information in a DB table. We'll get this back out in the maintenance/onInstanceActionCompletion.php script. + * Store the event information in a DB table. We'll get this back out in the + * maintenance/onInstanceActionCompletion.php script. * @param $type string * @param $user User * @param $instance OpenStackNovaInstance diff --git a/maintenance/onInstanceActionCompletion.php b/maintenance/onInstanceActionCompletion.php index a8879dd..ff92c2f 100644 --- a/maintenance/onInstanceActionCompletion.php +++ b/maintenance/onInstanceActionCompletion.php @@ -1,7 +1,7 @@ <?php /** - * This script should be run when an instance build is completed or when an instance reboot is completed. - * It triggers an Echo notification to the relevant users + * This script should be run when an instance build is completed or when an instance reboot is + * completed. It triggers an Echo notification to the relevant users * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,8 +39,10 @@ class OnInstanceActionComplete extends Maintenance { public function __construct() { parent::__construct(); - $this->addOption( 'action', 'The action which was taken. Either build or reboot.', true, true ); - $this->addOption( 'instance', 'The instance hostname, e.g. i-00000001.pmtpa.wmflabs.', true, true ); + $this->addOption( 'action', + 'The action which was taken. Either build or reboot.', true, true ); + $this->addOption( 'instance', + 'The instance hostname, e.g. i-00000001.pmtpa.wmflabs.', true, true ); } public function execute() { diff --git a/maintenance/purgeOldServiceGroups.php b/maintenance/purgeOldServiceGroups.php index 356d396..7683880 100644 --- a/maintenance/purgeOldServiceGroups.php +++ b/maintenance/purgeOldServiceGroups.php @@ -9,7 +9,8 @@ class OpenStackNovaPurgeOldServiceGroups extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Delete all service users and groups of the form n=local-<servicegroup>,ou=groups,cn=<project>,ou=projects,dc=wikimedia,dc=org"; + $this->mDescription = "Delete all service users and groups of the form " . + "n=local-<servicegroup>,ou=groups,cn=<project>,ou=projects,dc=wikimedia,dc=org"; } public function execute() { @@ -50,7 +51,9 @@ $deleteme = "cn=" . $groupEntry['cn'][0] . "," . $oldServiceGroupOUDN; print "needs deleting: " . $deleteme . "..."; $attempt_count++; - $success = LdapAuthenticationPlugin::ldap_delete( $ldap->ldapconn, $deleteme ); + $success = LdapAuthenticationPlugin::ldap_delete( + $ldap->ldapconn, $deleteme + ); if ( $success ) { $synced_count++; print "done.\n"; @@ -75,7 +78,9 @@ $deleteme = "uid=" . $groupEntry['cn'][0] . "," . $oldServiceUserOUDN; print "user needs deleting: " . $deleteme . "..."; $attempt_count++; - $success = LdapAuthenticationPlugin::ldap_delete( $ldap->ldapconn, $deleteme ); + $success = LdapAuthenticationPlugin::ldap_delete( + $ldap->ldapconn, $deleteme + ); if ( $success ) { $synced_count++; print "done.\n"; @@ -112,7 +117,8 @@ } } - $this->output( "$attempt_count items needed cleanup. $synced_count removed, $failed_count failed.\n" ); + $this->output( "$attempt_count items needed cleanup. $synced_count removed, " . + "$failed_count failed.\n" ); $this->output( "Done.\n" ); return ( $failed_count == 0 ); diff --git a/maintenance/qualifyInstancePages.php b/maintenance/qualifyInstancePages.php index 857a407..05cd5ad 100644 --- a/maintenance/qualifyInstancePages.php +++ b/maintenance/qualifyInstancePages.php @@ -23,7 +23,9 @@ # a project token is returned, so we need to feed it a project. Ideally this # should be configurable, and not hardcoded like this. $userNova->setProject( 'bastion' ); - $userNova->authenticate( $wgOpenStackManagerLDAPUsername, $wgOpenStackManagerLDAPUserPassword ); + $userNova->authenticate( + $wgOpenStackManagerLDAPUsername, $wgOpenStackManagerLDAPUserPassword + ); $regions = $userNova->getRegions( 'compute' ); foreach ( $regions as $region ) { $this->output( "Running region: " . $region . "\n" ); @@ -41,12 +43,15 @@ foreach ( $instances as $instance ) { $host = $instance->getHost(); if ( !$host ) { - $this->output( "Skipping instance due to missing host entry: " . $instance->getInstanceId() . "\n" ); + $this->output( "Skipping instance due to missing host entry: " . + $instance->getInstanceId() . "\n" ); continue; } $this->output( "Renaming instance: " . $instance->getInstanceId() . "\n" ); $ot = Title::newFromText( $instance->getInstanceId(), NS_NOVA_RESOURCE ); - $nt = Title::newFromText( $host->getFullyQualifiedHostName(), NS_NOVA_RESOURCE ); + $nt = Title::newFromText( + $host->getFullyQualifiedHostName(), NS_NOVA_RESOURCE + ); $ot->moveTo( $nt, false, 'Maintenance script move from id to fqdn.' ); } } diff --git a/maintenance/syncProjectGroups.php b/maintenance/syncProjectGroups.php index d0cb94e..6174e4b 100644 --- a/maintenance/syncProjectGroups.php +++ b/maintenance/syncProjectGroups.php @@ -9,7 +9,8 @@ class OpenStackNovaSyncProjectGroups extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Sync each cn=<project-name>,ou=projects members to cn=project-<project-name>,ou=groups"; + $this->mDescription = "Sync each cn=<project-name>,ou=projects members to " . + "cn=project-<project-name>,ou=groups"; } public function execute() { @@ -41,7 +42,9 @@ // 1: successful sync if ( $retval != 0 ) { - $this->output( ( $retval ? "Succeeded" : "Failed" ) . " syncing members for project $projectName and group " . $project->projectGroup->getProjectGroupName() ); + $this->output( ( $retval ? "Succeeded" : "Failed" ) . + " syncing members for project $projectName and group " . + $project->projectGroup->getProjectGroupName() ); if ( $retval < 0 ) { $failedSync = true; $failed_count++; @@ -56,7 +59,8 @@ // print_r( $projectGroup->getMemberDNs() ); } - $this->output( "$attempt_count project groups were synced, $synced_count changed, $failed_count failed.\n" ); + $this->output( "$attempt_count project groups were synced, $synced_count changed, " . + "$failed_count failed.\n" ); $this->output( "Done.\n" ); // return true if there were no failed syncs diff --git a/maintenance/transitionServiceGroupSchema.php b/maintenance/transitionServiceGroupSchema.php index 4360def..17f430d 100644 --- a/maintenance/transitionServiceGroupSchema.php +++ b/maintenance/transitionServiceGroupSchema.php @@ -9,7 +9,9 @@ class OpenStackNovaTransitionServiceGroups extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Copy each cn=local-<servicegroup>,ou=groups,cn=<project>,ou=projects,dc=wikimedia,dc=org to cn=<project>.<servicegroup>,ou=groups,cn=<project>,ou=projects,dc=wikimedia,dc=org"; + $this->mDescription = "Copy each cn=local-<servicegroup>,ou=groups,cn=<project>," . + "ou=projects,dc=wikimedia,dc=org to cn=<project>.<servicegroup>,ou=groups," . + "cn=<project>,ou=projects,dc=wikimedia,dc=org"; } public function updateMemberName( $member, $project ) { @@ -52,7 +54,9 @@ $fullGroupName = $serviceGroup->getGroupName(); if ( strpos( $fullGroupName, $wgOpenStackManagerServiceGroupPrefix, 0 ) === 0 ) { - $groupName = substr( $fullGroupName, strlen( $wgOpenStackManagerServiceGroupPrefix ) ); + $groupName = substr( + $fullGroupName, strlen( $wgOpenStackManagerServiceGroupPrefix ) + ); } else { $groupName = $fullGroupName; } @@ -64,7 +68,9 @@ } $originalMember = $groupMembers[0]; - $retval = OpenStackNovaServiceGroup::createServiceGroup( $groupName, $project, $this->updateMemberName( $originalMember, $project ) ); + $retval = OpenStackNovaServiceGroup::createServiceGroup( + $groupName, $project, $this->updateMemberName( $originalMember, $project ) + ); $attempt_count++; if ( $retval ) { @@ -84,7 +90,8 @@ } } - $this->output( "$attempt_count service groups were synced, $synced_count changed, $failed_count failed.\n" ); + $this->output( "$attempt_count service groups were synced, $synced_count changed, " . + "$failed_count failed.\n" ); $this->output( "Done.\n" ); // return true if there were no failed syncs diff --git a/maintenance/updatedomains.php b/maintenance/updatedomains.php index b99c6b5..bb5d3af 100644 --- a/maintenance/updatedomains.php +++ b/maintenance/updatedomains.php @@ -50,7 +50,9 @@ $userNova = OpenStackNovaController::newFromUser( $user ); $projects = OpenStackNovaProject::getAllProjects(); $userNova->setProject( 'bastion' ); - $userNova->authenticate( $wgOpenStackManagerLDAPUsername, $wgOpenStackManagerLDAPUserPassword ); + $userNova->authenticate( + $wgOpenStackManagerLDAPUsername, $wgOpenStackManagerLDAPUserPassword + ); $regions = $userNova->getRegions( 'compute' ); foreach ( $regions as $region ) { foreach ( $projects as $project ) { @@ -60,7 +62,9 @@ $instances = $userNova->getInstances(); if ( $instances ) { foreach ( $instances as $instance ) { - $instancelist[] = [ $region, $instance->getInstanceName(), $projectName ]; + $instancelist[] = [ + $region, $instance->getInstanceName(), $projectName + ]; } } } @@ -72,7 +76,11 @@ if ( !$this->hasOption( 'project' ) ) { $this->error( "--name requires --project.\n", true ); } - $instancelist = [ [ $this->getOption( 'region' ), $this->getOption( 'name' ), $this->getOption( 'project' ), ] ]; + $instancelist = [ [ + $this->getOption( 'region' ), + $this->getOption( 'name' ), + $this->getOption( 'project' ), + ] ]; } else { $this->error( "Must specify either --name or --all-instances.\n", true ); } @@ -83,15 +91,19 @@ OpenStackNovaLdapConnection::connect(); foreach ( $instancelist as $instancepair ) { list( $instanceregion, $instancename, $instanceproject ) = $instancepair; - $host = OpenStackNovaHost::getHostByNameAndProject( $instancename, $instanceproject, $instanceregion ); + $host = OpenStackNovaHost::getHostByNameAndProject( + $instancename, $instanceproject, $instanceregion + ); if ( !$host ) { print "Skipping $instancename.$instanceproject.$instanceregion; not found.\n"; continue; } - print "\nFor instance $instancename in region $instanceregion and project $instanceproject:\n\n"; + print "\nFor instance $instancename in region $instanceregion and " . + " project $instanceproject:\n\n"; - $namefqdn = $instancename . '.' . $instanceproject . '.' . $instanceregion . '.' . 'wmflabs'; + $namefqdn = $instancename . '.' . $instanceproject . '.' . $instanceregion . + '.' . 'wmflabs'; $host->addAssociatedDomain( $namefqdn ); } } diff --git a/phpcs.xml b/phpcs.xml index 64946af..e77091e 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,7 +2,6 @@ <ruleset> <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> <exclude name="PSR2.Methods.MethodDeclaration.Underscore"/> - <exclude name="Generic.Files.LineLength"/> <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName"/> <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment"/> <exclude name="MediaWiki.Commenting.FunctionComment"/> diff --git a/special/SpecialNova.php b/special/SpecialNova.php index 4a3708c..ff32ebd 100644 --- a/special/SpecialNova.php +++ b/special/SpecialNova.php @@ -54,7 +54,9 @@ */ function notInRole( $role, $project ) { $this->setHeaders(); - $this->getOutput()->setPageTitle( $this->msg( 'openstackmanager-needrole', $role, $project ) ); + $this->getOutput()->setPageTitle( + $this->msg( 'openstackmanager-needrole', $role, $project ) + ); $this->getOutput()->addWikiMsg( 'openstackmanager-needrole2', $role, $project ); } @@ -63,7 +65,9 @@ $isEnabled = false; Hooks::run( 'TwoFactorIsEnabled', [ &$isEnabled ] ); if ( !$isEnabled ) { - throw new ErrorPageError( 'openstackmanager-twofactorrequired', 'openstackmanager-twofactorrequired2' ); + throw new ErrorPageError( + 'openstackmanager-twofactorrequired', 'openstackmanager-twofactorrequired2' + ); } } } @@ -113,7 +117,9 @@ } function showProjectFilter( $projects ) { - if ( $this->getRequest()->wasPosted() && $this->getRequest()->getVal( 'action' ) !== 'setprojectfilter' ) { + if ( $this->getRequest()->wasPosted() && + $this->getRequest()->getVal( 'action' ) !== 'setprojectfilter' + ) { return null; } $showmsg = $this->getRequest()->getText( 'showmsg' ); @@ -170,7 +176,12 @@ } public static function createNovaKeyActionLink( $msg, $params ) { - return Linker::link( SpecialPage::getTitleFor( 'NovaKey' ), wfMessage( $msg )->escaped(), [], $params ); + return Linker::link( + SpecialPage::getTitleFor( 'NovaKey' ), + wfMessage( $msg )->escaped(), + [], + $params + ); } public static function createResourceList( $resources ) { diff --git a/special/SpecialNovaAddress.php b/special/SpecialNovaAddress.php index 18c8f8b..dee0fbe 100644 --- a/special/SpecialNovaAddress.php +++ b/special/SpecialNovaAddress.php @@ -435,7 +435,11 @@ $this->userNova->setProject( $projectName ); foreach ( $this->userNova->getRegions( 'compute' ) as $region ) { if ( in_array( $region, $wgOpenStackManagerReadOnlyRegions ) ) { - $regionactions = [ 'projectadmin' => [ $this->msg( 'openstackmanager-creationdisabled' ) ] ]; + $regionactions = [ + 'projectadmin' => [ + $this->msg( 'openstackmanager-creationdisabled' ) + ] + ]; } else { $regionactions = [ 'projectadmin' => [ @@ -451,7 +455,9 @@ ]; } $addresses = $this->getAddresses( $projectName, $region ); - $regions .= $this->createRegionSection( $region, $projectName, $regionactions, $addresses ); + $regions .= $this->createRegionSection( + $region, $projectName, $regionactions, $addresses + ); } $out .= $this->createProjectSection( $projectName, $projectactions, $regions ); } @@ -462,8 +468,13 @@ function getAddresses( $projectName, $region ) { $this->userNova->setRegion( $region ); - $headers = [ 'openstackmanager-address', 'openstackmanager-instanceid', 'openstackmanager-instancename', - 'openstackmanager-hostnames', 'openstackmanager-actions' ]; + $headers = [ + 'openstackmanager-address', + 'openstackmanager-instanceid', + 'openstackmanager-instancename', + 'openstackmanager-hostnames', + 'openstackmanager-actions' + ]; $addresses = $this->userNova->getAddresses(); $instances = $this->userNova->getInstances(); $addressRows = []; @@ -482,9 +493,13 @@ $instanceid = $instances[$instanceosid]->getInstanceId(); $host = $instances[$instanceosid]->getHost(); if ( $host ) { - $this->pushRawResourceColumn( $addressRow, $this->createResourceLink( $host->getFullyQualifiedHostName() ), [ - 'class' => 'instance-id' - ] ); + $this->pushRawResourceColumn( + $addressRow, + $this->createResourceLink( $host->getFullyQualifiedHostName() ), + [ + 'class' => 'instance-id' + ] + ); } else { $this->pushResourceColumn( $addressRow, $instanceid, [ 'class' => 'instance-id' @@ -557,16 +572,31 @@ } else { $actions[] = $this->createActionLink( 'openstackmanager-releaseaddress', - [ 'action' => 'release', 'id' => $id, 'project' => $projectName, 'region' => $region ] + [ + 'action' => 'release', + 'id' => $id, + 'project' => $projectName, + 'region' => $region + ] ); $actions[] = $this->createActionLink( 'openstackmanager-associateaddress', - [ 'action' => 'associate', 'id' => $id, 'project' => $projectName, 'region' => $region ] + [ + 'action' => 'associate', + 'id' => $id, + 'project' => $projectName, + 'region' => $region + ] ); } $actions[] = $this->createActionLink( 'openstackmanager-addhost', - [ 'action' => 'addhost', 'id' => $id, 'project' => $projectName, 'region' => $region ] + [ + 'action' => 'addhost', + 'id' => $id, + 'project' => $projectName, + 'region' => $region + ] ); $this->pushRawResourceColumn( $addressRow, $this->createResourceList( $actions ) ); $addressRows[] = $addressRow; diff --git a/special/SpecialNovaDomain.php b/special/SpecialNovaDomain.php index b667c81..9665ac5 100644 --- a/special/SpecialNovaDomain.php +++ b/special/SpecialNovaDomain.php @@ -118,7 +118,12 @@ $domainForm->setSubmitCallback( [ $this, 'tryCreateSubmit' ] ); $domainForm->show(); - $headers = [ 'openstackmanager-domainname', 'openstackmanager-fqdn', 'openstackmanager-location', 'openstackmanager-actions' ]; + $headers = [ + 'openstackmanager-domainname', + 'openstackmanager-fqdn', + 'openstackmanager-location', + 'openstackmanager-actions' + ]; $domains = OpenStackNovaDomain::getAllDomains(); $domainRows = []; foreach ( $domains as $domain ) { @@ -127,7 +132,13 @@ $this->pushResourceColumn( $domainRow, $domainName ); $this->pushResourceColumn( $domainRow, $domain->getFullyQualifiedDomainName() ); $this->pushResourceColumn( $domainRow, $domain->getLocation() ); - $this->pushRawResourceColumn( $domainRow, $this->createActionLink( 'openstackmanager-delete', [ 'action' => 'delete', 'domainname' => $domainName ] ) ); + $this->pushRawResourceColumn( + $domainRow, + $this->createActionLink( + 'openstackmanager-delete', + [ 'action' => 'delete', 'domainname' => $domainName ] + ) + ); $domainRows[] = $domainRow; } if ( $domainRows ) { @@ -145,7 +156,9 @@ * @return bool */ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) { - $success = OpenStackNovaDomain::createDomain( $formData['domainname'], $formData['fqdn'], $formData['location'] ); + $success = OpenStackNovaDomain::createDomain( + $formData['domainname'], $formData['fqdn'], $formData['location'] + ); if ( !$success ) { $this->getOutput()->addWikiMsg( 'openstackmanager-createdomainfailed' ); return false; diff --git a/special/SpecialNovaKey.php b/special/SpecialNovaKey.php index 8a9ce7e..cc4d090 100644 --- a/special/SpecialNovaKey.php +++ b/special/SpecialNovaKey.php @@ -201,7 +201,11 @@ 2 => [ "file", wfGetNull(), "a" ] ]; - $process = proc_open( escapeshellcmd( $wgPuttygen ) . ' -O public-openssh -o /dev/stdout /dev/stdin', $descriptorspec, $pipes ); + $process = proc_open( + escapeshellcmd( $wgPuttygen ) . ' -O public-openssh -o /dev/stdout /dev/stdin', + $descriptorspec, + $pipes + ); if ( $process === false ) { return false; } @@ -222,7 +226,9 @@ * need not to keep such information we should have never been given. */ rewind( $tmpfile ); - fwrite( $tmpfile, str_repeat( "\0", strlen( $keydata ) + 4096 - strlen( $keydata ) % 4096 ) ); + fwrite( $tmpfile, + str_repeat( "\0", strlen( $keydata ) + 4096 - strlen( $keydata ) % 4096 ) + ); fclose( $tmpfile ); if ( $data === false || !preg_match( '/(^| )ssh-(rsa|dss) /', $data ) ) { @@ -254,7 +260,9 @@ 2 => [ "file", wfGetNull(), "a" ] ]; - $process = proc_open( escapeshellcmd( $wgSshKeygen ) . ' -i -f /dev/stdin', $descriptorspec, $pipes ); + $process = proc_open( + escapeshellcmd( $wgSshKeygen ) . ' -i -f /dev/stdin', $descriptorspec, $pipes + ); if ( $process === false ) { return false; } @@ -283,41 +291,46 @@ $key = trim( $formData['key'] ); # Because people copy paste it with an accidental newline $returnto = Title::newFromText( $formData['returnto'] ); + $out = $this->getOutput(); if ( !preg_match( '/(^| )(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp256) /', $key ) ) { # This doesn't look like openssh format, it's probably a # Windows user providing it in PuTTY format. $key = self::opensshFormatKey( $key ); if ( $key === false ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-keypairformatwrong' ); + $out->addWikiMsg( 'openstackmanager-keypairformatwrong' ); if ( $returnto ) { - $this->getOutput()->addReturnTo( $returnto ); + $out->addReturnTo( $returnto ); } return false; } - $this->getOutput()->addWikiMsg( 'openstackmanager-keypairformatconverted' ); + $out->addWikiMsg( 'openstackmanager-keypairformatconverted' ); } if ( $wgOpenStackManagerNovaKeypairStorage === 'ldap' ) { $success = $this->userLDAP->importKeypair( $key ); if ( $success ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-keypairimported' ); + $out->addWikiMsg( 'openstackmanager-keypairimported' ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-keypairimportfailed' ); + $out->addWikiMsg( 'openstackmanager-keypairimportfailed' ); if ( $returnto ) { - $this->getOutput()->addReturnTo( $returnto ); + $out->addReturnTo( $returnto ); } return false; } } elseif ( $wgOpenStackManagerNovaKeypairStorage === 'nova' ) { $keypair = $this->userNova->importKeypair( $formData['keyname'], $key ); - $this->getOutput()->addWikiMsg( 'openstackmanager-keypairimportedfingerprint', $keypair->getKeyName(), $keypair->getKeyFingerprint() ); + $out->addWikiMsg( + 'openstackmanager-keypairimportedfingerprint', + $keypair->getKeyName(), + $keypair->getKeyFingerprint() + ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-invalidkeypair' ); + $out->addWikiMsg( 'openstackmanager-invalidkeypair' ); } if ( $returnto ) { - $this->getOutput()->addReturnTo( $returnto ); + $out->addReturnTo( $returnto ); } return true; } diff --git a/special/SpecialNovaProject.php b/special/SpecialNovaProject.php index 6cb5b0e..95c701e 100644 --- a/special/SpecialNovaProject.php +++ b/special/SpecialNovaProject.php @@ -58,7 +58,9 @@ $projectid = $this->getRequest()->getText( 'projectid' ); $project = new OpenStackNovaProject( $projectid ); $projectname = $project->getProjectName(); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( 'projectadmin', $projectname ) ) { + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( 'projectadmin', $projectname ) + ) { $this->notInRole( 'projectadmin', $projectname ); return false; } @@ -102,7 +104,9 @@ $projectid = $this->getRequest()->getText( 'projectid' ); $project = new OpenStackNovaProject( $projectid ); $projectname = $project->getProjectName(); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( 'projectadmin', $projectname ) ) { + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( 'projectadmin', $projectname ) + ) { $this->notInRole( 'projectadmin', $projectname ); return false; } @@ -209,7 +213,9 @@ continue; } $actions = []; - $out .= $this->createProjectSection( $projectName, $actions, $this->getProject( $project ) ); + $out .= $this->createProjectSection( + $projectName, $actions, $this->getProject( $project ) + ); } $this->getOutput()->addHTML( $out ); @@ -217,10 +223,16 @@ function getProject( $project ) { $project->fetchProjectInfo(); - $headers = [ 'openstackmanager-members', 'openstackmanager-roles', 'openstackmanager-actions' ]; + $headers = [ + 'openstackmanager-members', + 'openstackmanager-roles', + 'openstackmanager-actions' + ]; $projectRows = []; $projectRow = []; - $this->pushRawResourceColumn( $projectRow, $this->createResourceList( $project->getMembers() ) ); + $this->pushRawResourceColumn( + $projectRow, $this->createResourceList( $project->getMembers() ) + ); $roleRows = []; $projectId = $project->getId(); $projectName = $project->getProjectName(); @@ -235,24 +247,52 @@ $actions = []; $specialRoleTitle = Title::newFromText( 'Special:NovaRole' ); $actions[] = $this->createActionLink( 'openstackmanager-addrolemember', - [ 'action' => 'addmember', 'projectid' => $projectId, 'roleid' => $roleId, 'returnto' => 'Special:NovaProject' ], + [ + 'action' => 'addmember', + 'projectid' => $projectId, + 'roleid' => $roleId, + 'returnto' => 'Special:NovaProject' + ], $specialRoleTitle ); $actions[] = $this->createActionLink( 'openstackmanager-removerolemember', - [ 'action' => 'deletemember', 'projectid' => $projectId, 'roleid' => $roleId, 'returnto' => 'Special:NovaProject' ], + [ + 'action' => 'deletemember', + 'projectid' => $projectId, + 'roleid' => $roleId, + 'returnto' => 'Special:NovaProject' + ], $specialRoleTitle ); $this->pushRawResourceColumn( $roleRow, $this->createResourceList( $actions ) ); $roleRows[] = $roleRow; } - $roleheaders = [ 'openstackmanager-rolename', 'openstackmanager-members', 'openstackmanager-actions' ]; - $this->pushRawResourceColumn( $projectRow, $this->createResourceTable( $roleheaders, $roleRows ) ); + $roleheaders = [ + 'openstackmanager-rolename', + 'openstackmanager-members', + 'openstackmanager-actions' + ]; + $this->pushRawResourceColumn( + $projectRow, $this->createResourceTable( $roleheaders, $roleRows ) + ); $actions = []; - $actions[] = $this->createActionLink( 'openstackmanager-deleteproject', [ 'action' => 'delete', 'projectid' => $projectId ] ); - $actions[] = $this->createActionLink( 'openstackmanager-addmember', [ 'action' => 'addmember', 'projectid' => $projectId ] ); - $actions[] = $this->createActionLink( 'openstackmanager-removemember', [ 'action' => 'deletemember', 'projectid' => $projectId ] ); - $actions[] = $this->createActionLink( 'openstackmanager-displayquotas-action', [ 'action' => 'displayquotas', 'projectid' => $projectId ] ); + $actions[] = $this->createActionLink( + 'openstackmanager-deleteproject', + [ 'action' => 'delete', 'projectid' => $projectId ] + ); + $actions[] = $this->createActionLink( + 'openstackmanager-addmember', + [ 'action' => 'addmember', 'projectid' => $projectId ] + ); + $actions[] = $this->createActionLink( + 'openstackmanager-removemember', + [ 'action' => 'deletemember', 'projectid' => $projectId ] + ); + $actions[] = $this->createActionLink( + 'openstackmanager-displayquotas-action', + [ 'action' => 'displayquotas', 'projectid' => $projectId ] + ); $hieraTitle = Title::makeTitleSafe( NS_HIERA, $projectName ); @@ -308,8 +348,12 @@ $projectId = $this->getRequest()->getText( 'projectid' ); $project = new OpenStackNovaProject( $projectId ); $projectname = $project->getProjectName(); - $this->getOutput()->setPageTitle( $this->msg( 'openstackmanager-displayquotas', $projectId ) ); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( 'projectadmin', $projectname ) ) { + $this->getOutput()->setPageTitle( + $this->msg( 'openstackmanager-displayquotas', $projectId ) + ); + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( 'projectadmin', $projectname ) + ) { $this->notInRole( 'projectadmin', $projectname ); return false; } @@ -319,11 +363,31 @@ foreach ( $regions as $region ) { $this->userNova->setRegion( $region ); $limits = $this->userNova->getLimits(); - $ram = $this->msg( 'openstackmanager-displayquotas-ram', $limits->getRamUsed(), $limits->getRamAvailable() ); - $floatingIps = $this->msg( 'openstackmanager-displayquotas-floatingips', $limits->getFloatingIpsUsed(), $limits->getFloatingIpsAvailable() ); - $cores = $this->msg( 'openstackmanager-displayquotas-cores', $limits->getCoresUsed(), $limits->getCoresAvailable() ); - $instances = $this->msg( 'openstackmanager-displayquotas-instances', $limits->getInstancesUsed(), $limits->getInstancesAvailable() ); - $secGroups = $this->msg( 'openstackmanager-displayquotas-securitygroups', $limits->getSecurityGroupsUsed(), $limits->getSecurityGroupsAvailable() ); + $ram = $this->msg( + 'openstackmanager-displayquotas-ram', + $limits->getRamUsed(), + $limits->getRamAvailable() + ); + $floatingIps = $this->msg( + 'openstackmanager-displayquotas-floatingips', + $limits->getFloatingIpsUsed(), + $limits->getFloatingIpsAvailable() + ); + $cores = $this->msg( + 'openstackmanager-displayquotas-cores', + $limits->getCoresUsed(), + $limits->getCoresAvailable() + ); + $instances = $this->msg( + 'openstackmanager-displayquotas-instances', + $limits->getInstancesUsed(), + $limits->getInstancesAvailable() + ); + $secGroups = $this->msg( + 'openstackmanager-displayquotas-securitygroups', + $limits->getSecurityGroupsUsed(), + $limits->getSecurityGroupsAvailable() + ); $limitsOut = Html::element( 'li', [], $cores ); $limitsOut .= Html::element( 'li', [], $ram ); $limitsOut .= Html::element( 'li', [], $floatingIps ); @@ -408,7 +472,9 @@ } } } - $this->userNova->addSecurityGroupRule( $groupid, $fromport, $toport, $protocol, $range, $sourcegroupid ); + $this->userNova->addSecurityGroupRule( + $groupid, $fromport, $toport, $protocol, $range, $sourcegroupid + ); } } $project->editArticle(); @@ -458,10 +524,11 @@ $project = new OpenStackNovaProject( $formData['projectid'] ); $projectName = $project->getName(); $members = explode( ',', $formData['member'] ); + $out = $this->getOutput(); foreach ( $members as $member ) { $user = User::newFromName( $member, 'usable' ); if ( !$user ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtoadd', $member, $projectName ); + $out->addWikiMsg( 'openstackmanager-failedtoadd', $member, $projectName ); continue; } $success = $project->addMember( $member ); @@ -471,7 +538,7 @@ # successfully been added to a project $user->addGroup( 'shell' ); } - $this->getOutput()->addWikiMsg( 'openstackmanager-addedto', $member, $projectName ); + $out->addWikiMsg( 'openstackmanager-addedto', $member, $projectName ); if ( class_exists( 'EchoEvent' ) ) { EchoEvent::create( [ 'type' => 'osm-projectmembers-add', @@ -481,16 +548,16 @@ ] ); } } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtoadd', $member, $projectName ); + $out->addWikiMsg( 'openstackmanager-failedtoadd', $member, $projectName ); } } - $out = '<br />'; - $out .= Linker::link( + $outHtml = '<br />'; + $outHtml .= Linker::link( $this->getPageTitle(), $this->msg( 'openstackmanager-backprojectlist' )->escaped() ); - $this->getOutput()->addHTML( $out ); + $out->addHTML( $outHtml ); return true; } @@ -503,25 +570,26 @@ function tryDeleteMemberSubmit( $formData, $entryPoint = 'internal' ) { $project = OpenStackNovaProject::getProjectById( $formData['projectid'] ); $projectName = $project->getName(); + $out = $this->getOutput(); if ( !$project ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-nonexistentproject' ); + $out->addWikiMsg( 'openstackmanager-nonexistentproject' ); return true; } foreach ( $formData['members'] as $member ) { $success = $project->deleteMember( $member ); if ( $success ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-removedfrom', $member, $projectName ); + $out->addWikiMsg( 'openstackmanager-removedfrom', $member, $projectName ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtoremove', $member, $projectName ); + $out->addWikiMsg( 'openstackmanager-failedtoremove', $member, $projectName ); } } - $out = '<br />'; + $outHtml = '<br />'; - $out .= Linker::link( + $outHtml .= Linker::link( $this->getPageTitle(), $this->msg( 'openstackmanager-backprojectlist' )->escaped() ); - $this->getOutput()->addHTML( $out ); + $out->addHTML( $outHtml ); return true; } diff --git a/special/SpecialNovaProxy.php b/special/SpecialNovaProxy.php index 6f0b4c9..d150f8d 100644 --- a/special/SpecialNovaProxy.php +++ b/special/SpecialNovaProxy.php @@ -228,9 +228,21 @@ if ( in_array( $region, $wgOpenStackManagerReadOnlyRegions ) ) { $actions['projectadmin'][] = $this->msg( 'openstackmanager-creationdisabled' ); } else { - $actions['projectadmin'][] = $this->createActionLink( 'openstackmanager-createproxy', [ 'action' => 'create', 'project' => $projectName, 'region' => $region ] ); + $actions['projectadmin'][] = $this->createActionLink( + 'openstackmanager-createproxy', + [ + 'action' => 'create', + 'project' => $projectName, + 'region' => $region + ] + ); } - $regions .= $this->createRegionSection( $region, $projectName, $actions, $this->getProxies( $projectName, $region ) ); + $regions .= $this->createRegionSection( + $region, + $projectName, + $actions, + $this->getProxies( $projectName, $region ) + ); } $out .= $this->createProjectSection( $projectName, $projectactions, $regions ); } @@ -251,15 +263,26 @@ $this->pushResourceColumn( $proxyRow, $proxy->getBackend() ); $actions = []; - $actions[] = $this->createActionLink( 'openstackmanager-delete', - [ 'action' => 'delete', 'proxyfqdn' => $fqdn, 'project' => $projectName, 'region' => $region ] ); + $actions[] = $this->createActionLink( + 'openstackmanager-delete', + [ + 'action' => 'delete', + 'proxyfqdn' => $fqdn, + 'project' => $projectName, + 'region' => $region + ] + ); $this->pushRawResourceColumn( $proxyRow, $this->createResourceList( $actions ) ); $proxyRows[] = $proxyRow; } } if ( $proxyRows ) { - $headers = [ 'openstackmanager-proxyname', 'openstackmanager-proxybackend', 'openstackmanager-actions' ]; + $headers = [ + 'openstackmanager-proxyname', + 'openstackmanager-proxybackend', + 'openstackmanager-actions' + ]; $out = $this->createResourceTable( $headers, $proxyRows ); } else { $out = ''; @@ -396,7 +419,9 @@ $newProxy = $this->userNova->createProxy( $fqdn, $backendHost, $backendPort ); if ( $newProxy ) { - $outputPage->addWikiMsg( 'openstackmanager-createdproxy', $fqdn, $backendHost . ":" . $backendPort ); + $outputPage->addWikiMsg( + 'openstackmanager-createdproxy', $fqdn, $backendHost . ":" . $backendPort + ); } else { $outputPage->addWikiMsg( 'openstackmanager-createproxyfailed', $fqdn ); $this->deleteHost( $fqdn, $gatewayIP ); diff --git a/special/SpecialNovaResources.php b/special/SpecialNovaResources.php index 7730f3b..c38441a 100644 --- a/special/SpecialNovaResources.php +++ b/special/SpecialNovaResources.php @@ -78,11 +78,15 @@ $instances = $this->getInstances( $projectName, $region, $thisCount ); $instancesInProject += $thisCount; if ( $thisCount > 0 ) { - $regions .= $this->createRegionSection( $region, $projectName, $regionactions, $instances ); + $regions .= $this->createRegionSection( + $region, $projectName, $regionactions, $instances + ); } } if ( $instancesInProject ) { - $instanceOut .= $this->createProjectSection( $projectName, $projectactions, $regions ); + $instanceOut .= $this->createProjectSection( + $projectName, $projectactions, $regions + ); $instanceCount += $instancesInProject; } else { } @@ -91,7 +95,9 @@ $out = ''; if ( $ownedProjects ) { - $this->getOutput()->setPageTitle( $this->msg( 'openstackmanager-ownedprojects', count( $ownedProjects ) ) ); + $this->getOutput()->setPageTitle( + $this->msg( 'openstackmanager-ownedprojects', count( $ownedProjects ) ) + ); foreach ( $ownedProjects as $ownedProject ) { $projectNameOut = $this->createResourceLink( $ownedProject ); $out .= $projectNameOut . " "; @@ -101,10 +107,14 @@ } if ( $instanceCount ) { - $out .= Html::rawElement( 'h1', [], $this->msg( 'openstackmanager-ownedinstances', $instanceCount )->text() ); + $out .= Html::rawElement( 'h1', [], + $this->msg( 'openstackmanager-ownedinstances', $instanceCount )->text() + ); $out .= $instanceOut; } else { - $out .= Html::rawElement( 'h1', [], $this->msg( 'openstackmanager-noownedinstances' )->text() ); + $out .= Html::rawElement( 'h1', [], + $this->msg( 'openstackmanager-noownedinstances' )->text() + ); } $this->getOutput()->addHTML( $out ); @@ -112,7 +122,15 @@ function getInstances( $projectName, $region, &$instanceCount ) { $this->userNova->setRegion( $region ); - $headers = [ 'openstackmanager-instancename', 'openstackmanager-instanceid', 'openstackmanager-instancestate', 'openstackmanager-instanceip', 'openstackmanager-projectname', 'openstackmanager-launchtime', 'openstackmanager-instancecreator' ]; + $headers = [ + 'openstackmanager-instancename', + 'openstackmanager-instanceid', + 'openstackmanager-instancestate', + 'openstackmanager-instanceip', + 'openstackmanager-projectname', + 'openstackmanager-launchtime', + 'openstackmanager-instancecreator' + ]; $instances = $this->userNova->getInstances(); $instanceRows = []; $instanceCount = 0; @@ -126,12 +144,20 @@ } $instanceRow = []; - $this->pushResourceColumn( $instanceRow, $instance->getInstanceName(), [ 'class' => 'novainstancename' ] ); + $this->pushResourceColumn( + $instanceRow, $instance->getInstanceName(), [ 'class' => 'novainstancename' ] + ); $host = $instance->getHost(); if ( $host ) { - $this->pushRawResourceColumn( $instanceRow, $this->createResourceLink( $host->getFullyQualifiedHostName() ), [ 'class' => 'novainstanceid' ] ); + $this->pushRawResourceColumn( + $instanceRow, + $this->createResourceLink( $host->getFullyQualifiedHostName() ), + [ 'class' => 'novainstanceid' ] + ); } else { - $this->pushResourceColumn( $instanceRow, $instance->getInstanceId(), [ 'class' => 'novainstanceid' ] ); + $this->pushResourceColumn( + $instanceRow, $instance->getInstanceId(), [ 'class' => 'novainstanceid' ] + ); } $state = $instance->getInstanceState(); $taskState = $instance->getInstanceTaskState(); @@ -140,8 +166,12 @@ } else { $stateDisplay = $state; } - $this->pushResourceColumn( $instanceRow, $stateDisplay, [ 'class' => 'novainstancestate' ] ); - $this->pushRawResourceColumn( $instanceRow, $this->createResourceList( $instance->getInstancePrivateIPs() ) ); + $this->pushResourceColumn( + $instanceRow, $stateDisplay, [ 'class' => 'novainstancestate' ] + ); + $this->pushRawResourceColumn( + $instanceRow, $this->createResourceList( $instance->getInstancePrivateIPs() ) + ); $this->pushResourceColumn( $instanceRow, $projectName ); $this->pushResourceColumn( $instanceRow, $instance->getLaunchTime() ); $this->pushResourceColumn( $instanceRow, $instance->getInstanceCreator() ); diff --git a/special/SpecialNovaRole.php b/special/SpecialNovaRole.php index 25313f0..768de0a 100644 --- a/special/SpecialNovaRole.php +++ b/special/SpecialNovaRole.php @@ -50,7 +50,9 @@ $projectname = $project->getProjectName(); $rolename = $role->getRoleName(); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( $rolename, $projectname ) ) { + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( $rolename, $projectname ) + ) { $this->displayRestrictionError(); return false; } @@ -126,7 +128,9 @@ $role = new OpenStackNovaRole( $roleid, $project ); $projectname = $project->getProjectName(); $rolename = $role->getRoleName(); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( $rolename, $projectname ) ) { + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( $rolename, $projectname ) + ) { $this->displayRestrictionError(); return false; } @@ -216,7 +220,9 @@ if ( $success ) { $this->getOutput()->addWikiMsg( 'openstackmanager-addedto', $member, $rolename ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtoadd', $member, $rolename ); + $this->getOutput()->addWikiMsg( + 'openstackmanager-failedtoadd', $member, $rolename + ); } } @@ -238,10 +244,11 @@ */ function tryDeleteMemberSubmit( $formData, $entryPoint = 'internal' ) { $projectid = $formData['projectid']; + $out = $this->getOutput(); if ( $projectid ) { $project = OpenStackNovaProject::getProjectById( $projectid ); if ( !$project ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-nonexistentproject' ); + $out->addWikiMsg( 'openstackmanager-nonexistentproject' ); return true; } $role = new OpenStackNovaRole( $formData['roleid'], $project ); @@ -250,15 +257,15 @@ // TODO: display error } if ( !$role ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-nonexistentrole' ); + $out->addWikiMsg( 'openstackmanager-nonexistentrole' ); return true; } foreach ( $formData['members'] as $member ) { $success = $role->deleteMember( $member ); if ( $success ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-removedfrom', $member, $rolename ); + $out->addWikiMsg( 'openstackmanager-removedfrom', $member, $rolename ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtoremove', $member, $rolename ); + $out->addWikiMsg( 'openstackmanager-failedtoremove', $member, $rolename ); } } @@ -268,7 +275,7 @@ $returnto, $this->msg( 'openstackmanager-backprojectlist' )->escaped() ); - $this->getOutput()->addHTML( $out ); + $out->addHTML( $out ); return true; } diff --git a/special/SpecialNovaServiceGroup.php b/special/SpecialNovaServiceGroup.php index fb57e5f..fcafc0f 100644 --- a/special/SpecialNovaServiceGroup.php +++ b/special/SpecialNovaServiceGroup.php @@ -40,7 +40,9 @@ */ function manageMembers() { $this->setHeaders(); - $this->getOutput()->setPageTitle( $this->msg( 'openstackmanager-manageservicegroupmembers-title' ) ); + $this->getOutput()->setPageTitle( + $this->msg( 'openstackmanager-manageservicegroupmembers-title' ) + ); $groupInfo = []; $groupName = $this->getRequest()->getText( 'servicegroupname' ); @@ -177,7 +179,9 @@ $this->setHeaders(); $project = $this->getRequest()->getText( 'projectname' ); - if ( !$this->userCanExecute( $this->getUser() ) && !$this->userLDAP->inRole( 'projectadmin', $project ) ) { + if ( !$this->userCanExecute( $this->getUser() ) && + !$this->userLDAP->inRole( 'projectadmin', $project ) + ) { $this->notInRole( 'projectadmin', $project ); return false; } @@ -185,7 +189,9 @@ $groupName = $this->getRequest()->getText( 'groupname' ); if ( !$this->getRequest()->wasPosted() ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-removeservicegroupconfirm', $groupName ); + $this->getOutput()->addWikiMsg( + 'openstackmanager-removeservicegroupconfirm', $groupName + ); } $projectInfo = []; $projectInfo['projectname'] = [ @@ -242,8 +248,17 @@ if ( !in_array( $projectName, $projectfilter ) ) { continue; } - $actions = [ "" => [ $this->createActionLink( 'openstackmanager-addservicegroup', [ 'action' => 'addservicegroup', 'projectname' => $projectName ] ) ] ]; - $out .= $this->createProjectSection( $projectName, $actions, $this->getServiceGroups( $project ) ); + $actions = [ + "" => [ + $this->createActionLink( 'openstackmanager-addservicegroup', [ + 'action' => 'addservicegroup', + 'projectname' => $projectName + ] ) + ] + ]; + $out .= $this->createProjectSection( + $projectName, $actions, $this->getServiceGroups( $project ) + ); } $this->getOutput()->addHTML( $out ); @@ -254,19 +269,38 @@ $projectName = $project->getProjectName(); $serviceGroups = $project->getServiceGroups(); if ( $serviceGroups ) { - $headers = [ 'openstackmanager-servicegroupname', 'openstackmanager-members', 'openstackmanager-actions' ]; + $headers = [ + 'openstackmanager-servicegroupname', + 'openstackmanager-members', + 'openstackmanager-actions' + ]; foreach ( $serviceGroups as $group ) { $groupName = $group->getGroupName(); $groupRow = []; $this->pushResourceColumn( $groupRow, $groupName ); - $this->pushRawResourceColumn( $groupRow, $this->createResourceList( $group->getMembers() ) ); + $this->pushRawResourceColumn( + $groupRow, $this->createResourceList( $group->getMembers() ) + ); $actions = []; $specialGroupTitle = Title::newFromText( 'Special:NovaServiceGroup' ); - $actions[] = $this->createActionLink( 'openstackmanager-manageservicegroupmembers', - [ 'action' => 'managemembers', 'projectname' => $projectName, 'servicegroupname' => $groupName, 'returnto' => 'Special:NovaServiceGroup' ], + $actions[] = $this->createActionLink( + 'openstackmanager-manageservicegroupmembers', + [ + 'action' => 'managemembers', + 'projectname' => $projectName, + 'servicegroupname' => $groupName, + 'returnto' => 'Special:NovaServiceGroup' + ], $specialGroupTitle ); - $actions[] = $this->createActionLink( 'openstackmanager-removeservicegroup', [ 'action' => 'removeservicegroup', 'projectname' => $projectName, 'groupname' => $groupName ] ); + $actions[] = $this->createActionLink( + 'openstackmanager-removeservicegroup', + [ + 'action' => 'removeservicegroup', + 'projectname' => $projectName, + 'groupname' => $groupName + ] + ); $this->pushRawResourceColumn( $groupRow, $this->createResourceList( $actions ) ); $servicegroupRows[] = $groupRow; } @@ -317,7 +351,9 @@ $this->getOutput()->addWikiMsg( 'openstackmanager-nonexistentproject' ); return true; } - $group = OpenStackNovaServiceGroup::getServiceGroupByName( $formData['servicegroupname'], $project ); + $group = OpenStackNovaServiceGroup::getServiceGroupByName( + $formData['servicegroupname'], $project + ); $members = $formData['members']; $servicemembers = $formData['servicemembers']; } else { @@ -329,9 +365,13 @@ } $success = $group->setMembers( $members, $servicemembers ); if ( $success ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-setgroupmembers', $formData['servicegroupname'] ); + $this->getOutput()->addWikiMsg( + 'openstackmanager-setgroupmembers', $formData['servicegroupname'] + ); } else { - $this->getOutput()->addWikiMsg( 'openstackmanager-failedtosetgroupmembers', $formData['servicegroupname'] ); + $this->getOutput()->addWikiMsg( + 'openstackmanager-failedtosetgroupmembers', $formData['servicegroupname'] + ); } $out = '<br />'; diff --git a/special/SpecialNovaSudoer.php b/special/SpecialNovaSudoer.php index 959c440..be31e71 100644 --- a/special/SpecialNovaSudoer.php +++ b/special/SpecialNovaSudoer.php @@ -393,8 +393,12 @@ continue; } $actions = [ 'projectadmin' => [] ]; - $actions['projectadmin'][] = $this->createActionLink( 'openstackmanager-createsudoer', [ 'action' => 'create', 'project' => $projectName ] ); - $out .= $this->createProjectSection( $projectName, $actions, $this->getSudoers( $project ) ); + $actions['projectadmin'][] = $this->createActionLink( + 'openstackmanager-createsudoer', [ 'action' => 'create', 'project' => $projectName ] + ); + $out .= $this->createProjectSection( + $projectName, $actions, $this->getSudoers( $project ) + ); } $this->getOutput()->addHTML( $out ); @@ -421,7 +425,9 @@ if ( $leftover == $AllProjectMembers ) { array_unshift( $HRList, $this->msg( 'openstackmanager-allmembers' )->text() ); } elseif ( $leftover[0] == '%' ) { - array_unshift( $HRList, $this->msg( 'openstackmanager-membersofgroup', substr( $leftover, 1 ) ) ); + array_unshift( $HRList, + $this->msg( 'openstackmanager-membersofgroup', substr( $leftover, 1 ) ) + ); } else { array_unshift( $HRList, $leftover ); } @@ -448,12 +454,22 @@ $projectmembers = $project->getMembers(); $userNames = $this->makeHumanReadableUserlist( $sudoer->getSudoerUsers(), $project ); - $sudoRunAsUsers = $this->makeHumanReadableUserlist( $sudoer->getSudoerRunAsUsers(), $project ); + $sudoRunAsUsers = $this->makeHumanReadableUserlist( + $sudoer->getSudoerRunAsUsers(), $project + ); - $this->pushRawResourceColumn( $sudoerRow, $this->createResourceList( $userNames ) ); - $this->pushRawResourceColumn( $sudoerRow, $this->createResourceList( $sudoRunAsUsers ) ); - $this->pushRawResourceColumn( $sudoerRow, $this->createResourceList( $sudoer->getSudoerCommands() ) ); - $this->pushRawResourceColumn( $sudoerRow, $this->createResourceList( $sudoer->getSudoerOptions() ) ); + $this->pushRawResourceColumn( + $sudoerRow, $this->createResourceList( $userNames ) + ); + $this->pushRawResourceColumn( + $sudoerRow, $this->createResourceList( $sudoRunAsUsers ) + ); + $this->pushRawResourceColumn( + $sudoerRow, $this->createResourceList( $sudoer->getSudoerCommands() ) + ); + $this->pushRawResourceColumn( + $sudoerRow, $this->createResourceList( $sudoer->getSudoerOptions() ) + ); $actions = []; $actions[] = $this->createActionLink( 'openstackmanager-modify', [ 'action' => 'modify', 'sudoername' => $sudoerName, 'project' => $projectName ] @@ -485,7 +501,7 @@ function removeALLFromUserKeys( $users ) { $newusers = []; foreach ( $users as $user ) { - if ( ( $user == 'ALL' ) || ( $user == $this->msg( 'openstackmanager-allmembers' )->text() ) ) { + if ( $user == 'ALL' || $user == $this->msg( 'openstackmanager-allmembers' )->text() ) { $newusers[] = "%" . $this->project->getProjectGroupName(); } else { $newusers[] = $user; @@ -539,7 +555,14 @@ $options[] = '!authenticate'; } $runasusers = $this->removeALLFromRunAsUserKeys( $formData['runas'] ); - $success = OpenStackNovaSudoer::createSudoer( $formData['sudoername'], $formData['project'], $this->removeALLFromUserKeys( $formData['users'] ), $runasusers, $commands, $options ); + $success = OpenStackNovaSudoer::createSudoer( + $formData['sudoername'], + $formData['project'], + $this->removeALLFromUserKeys( $formData['users'] ), + $runasusers, + $commands, + $options + ); if ( !$success ) { $this->getOutput()->addWikiMsg( 'openstackmanager-createsudoerfailed' ); return false; @@ -562,7 +585,9 @@ * @return bool */ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) { - $success = OpenStackNovaSudoer::deleteSudoer( $formData['sudoername'], $formData['project'] ); + $success = OpenStackNovaSudoer::deleteSudoer( + $formData['sudoername'], $formData['project'] + ); if ( $success ) { $this->getOutput()->addWikiMsg( 'openstackmanager-deletedsudoer' ); } else { @@ -585,7 +610,9 @@ * @return bool */ function tryModifySubmit( $formData, $entryPoint = 'internal' ) { - $sudoer = OpenStackNovaSudoer::getSudoerByName( $formData['sudoername'], $formData['project'] ); + $sudoer = OpenStackNovaSudoer::getSudoerByName( + $formData['sudoername'], $formData['project'] + ); if ( $sudoer ) { if ( $formData['commands'] ) { $commands = explode( "\n", $formData['commands'] ); @@ -615,7 +642,9 @@ # Anything in this list that isn't a user or ALL # wasn't exposed to user selection so needs to stay. if ( $candidate != $projectGroup ) { - if ( ( !in_array( $candidate, $projectuids ) ) && ( !in_array( $candidate, $projectserviceusers ) ) ) { + if ( !in_array( $candidate, $projectuids ) && + !in_array( $candidate, $projectserviceusers ) + ) { $users[] = $candidate; } } @@ -624,7 +653,9 @@ $runasusers = $this->removeALLFromRunAsUserKeys( $formData['runas'] ); foreach ( $sudoer->getSudoerRunAsUsers() as $candidate ) { if ( ( $candidate != $projectGroup ) && ( $candidate != 'ALL' ) ) { - if ( ( !in_array( $candidate, $projectuids ) ) && ( !in_array( $candidate, $projectserviceusers ) ) ) { + if ( !in_array( $candidate, $projectuids ) && + !in_array( $candidate, $projectserviceusers ) + ) { $runasusers[] = $candidate; } } diff --git a/special/SpecialNovaVolume.php b/special/SpecialNovaVolume.php index 2f382ba..c02909f 100644 --- a/special/SpecialNovaVolume.php +++ b/special/SpecialNovaVolume.php @@ -354,9 +354,19 @@ $regions = ''; $this->userNova->setProject( $projectName ); foreach ( $this->userNova->getRegions( 'compute' ) as $region ) { - $regionactions = [ 'projectadmin' => [ $this->createActionLink( 'openstackmanager-createvolume', [ 'action' => 'create', 'project' => $projectName, 'region' => $region ] ) ] ]; + $regionactions = [ + 'projectadmin' => [ + $this->createActionLink( 'openstackmanager-createvolume', [ + 'action' => 'create', + 'project' => $projectName, + 'region' => $region + ] ) + ] + ]; $volumes = $this->getVolumes( $projectName, $region ); - $regions .= $this->createRegionSection( $region, $projectName, $regionactions, $volumes ); + $regions .= $this->createRegionSection( + $region, $projectName, $regionactions, $volumes + ); } $out .= $this->createProjectSection( $projectName, $projectactions, $regions ); } @@ -365,11 +375,13 @@ } function getVolumes( $projectName, $region ) { - $headers = [ 'openstackmanager-volumename', 'openstackmanager-volumeid', 'openstackmanager-volumedescription', - 'openstackmanager-volumeattachmentinstance', - 'openstackmanager-volumeattachmentdevice', 'openstackmanager-volumeattachmentstatus', - 'openstackmanager-volumesize', - 'openstackmanager-volumecreationtime', 'openstackmanager-actions' ]; + $headers = [ 'openstackmanager-volumename', + 'openstackmanager-volumeid', 'openstackmanager-volumedescription', + 'openstackmanager-volumeattachmentinstance', + 'openstackmanager-volumeattachmentdevice', 'openstackmanager-volumeattachmentstatus', + 'openstackmanager-volumesize', + 'openstackmanager-volumecreationtime', 'openstackmanager-actions' + ]; $this->userNova->setRegion( $region ); $volumes = $this->userNova->getVolumes(); $volumeRows = []; @@ -385,15 +397,18 @@ $this->pushResourceColumn( $volumeRow, $volume->getVolumeSize() ); $this->pushResourceColumn( $volumeRow, $volume->getVolumeCreationTime() ); $actions = []; - $actions[] = $this->createActionLink( 'openstackmanager-delete', - [ 'action' => 'delete', 'project' => $projectName, 'region' => $region, 'volumeid' => $volumeId ] - ); - $actions[] = $this->createActionLink( 'openstackmanager-attach', - [ 'action' => 'attach', 'project' => $projectName, 'region' => $region, 'volumeid' => $volumeId ] - ); - $actions[] = $this->createActionLink( 'openstackmanager-detach', - [ 'action' => 'detach', 'project' => $projectName, 'region' => $region, 'volumeid' => $volumeId ] - ); + $actions[] = $this->createActionLink( 'openstackmanager-delete', [ + 'action' => 'delete', 'project' => $projectName, + 'region' => $region, 'volumeid' => $volumeId + ] ); + $actions[] = $this->createActionLink( 'openstackmanager-attach', [ + 'action' => 'attach', 'project' => $projectName, + 'region' => $region, 'volumeid' => $volumeId + ] ); + $actions[] = $this->createActionLink( 'openstackmanager-detach', [ + 'action' => 'detach', 'project' => $projectName, + 'region' => $region, 'volumeid' => $volumeId + ] ); $this->pushRawResourceColumn( $volumeRow, $this->createResourceList( $actions ) ); $volumeRows[] = $volumeRow; } @@ -410,9 +425,16 @@ * @return bool */ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) { - $volume = $this->userNova->createVolume( '', $formData['volumeSize'], $formData['volumename'], $formData['volumedescription'] ); + $volume = $this->userNova->createVolume( + '', + $formData['volumeSize'], + $formData['volumename'], + $formData['volumedescription'] + ); if ( $volume ) { - $this->getOutput()->addWikiMsg( 'openstackmanager-createdvolume', $volume->getVolumeID() ); + $this->getOutput()->addWikiMsg( + 'openstackmanager-createdvolume', $volume->getVolumeID() + ); } else { $this->getOutput()->addWikiMsg( 'openstackmanager-createevolumefailed' ); } @@ -462,7 +484,9 @@ * @return bool */ function tryAttachSubmit( $formData, $entryPoint = 'internal' ) { - $success = $this->userNova->attachVolume( $formData['volumeid'], $formData['instanceid'], $formData['device'] ); + $success = $this->userNova->attachVolume( + $formData['volumeid'], $formData['instanceid'], $formData['device'] + ); if ( $success ) { $this->getOutput()->addWikiMsg( 'openstackmanager-attachedvolume' ); } else { -- To view, visit https://gerrit.wikimedia.org/r/364125 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I562a8e0c1e585d6b3e81d35a56deb4722f7e135a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OpenStackManager Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits