jenkins-bot has submitted this change and it was merged. Change subject: Make special/SpecialNovaProxy.php region-aware. ......................................................................
Make special/SpecialNovaProxy.php region-aware. Change-Id: I5db71fafe412169196725adb4b1afcbe2e874e97 --- M OpenStackManager.php M special/SpecialNovaProxy.php 2 files changed, 37 insertions(+), 23 deletions(-) Approvals: Andrew Bogott: Looks good to me, approved jenkins-bot: Verified diff --git a/OpenStackManager.php b/OpenStackManager.php index cc9ba6f..e26017f 100644 --- a/OpenStackManager.php +++ b/OpenStackManager.php @@ -68,9 +68,8 @@ // %u is username, %p is $wgOpenStackManagerServiceGroupPrefix. $wgOpenStackManagerServiceGroupHomedirPattern = '/home/%p%u/'; -// For the moment the instance proxy only lives in one place. -$wgOpenStackManagerProxyServiceRegion = ''; -$wgOpenStackManagerProxyGateway = ''; +// Key/value pairs like array( 'region1' => '10.4.0.11', 'region2' => '10.68.1.35' ) +$wgOpenStackManagerProxyGateways = array(); $wgOpenStackManagerIdRanges = array( 'service' => array( diff --git a/special/SpecialNovaProxy.php b/special/SpecialNovaProxy.php index 52ebe04..f8a0adf 100644 --- a/special/SpecialNovaProxy.php +++ b/special/SpecialNovaProxy.php @@ -16,7 +16,6 @@ } function execute( $par ) { - global $wgOpenStackManagerProxyServiceRegion; if ( !$this->getUser()->isLoggedIn() ) { $this->notLoggedIn(); return; @@ -32,7 +31,7 @@ $this->projectName = $this->getRequest()->getText( 'project' ); $this->project = OpenStackNovaProject::getProjectByName( $this->projectName ); - $region = $wgOpenStackManagerProxyServiceRegion; + $region = $this->getRequest()->getVal( 'region' ); $this->userNova = OpenStackNovaController::newFromUser( $this->userLDAP ); $this->userNova->setProject( $this->projectName ); $this->userNova->setRegion( $region ); @@ -71,15 +70,13 @@ return false; } $instance_keys = array(); - $regions = $this->userNova->getRegions( 'compute' ); - foreach ( $regions as $region ) { - $this->userNova->setRegion( $region ); - $instances = $this->userNova->getInstances(); - foreach ( $instances as $instance ) { - if ( $instance->getProject() === $this->projectName ) { - $instancename = $instance->getHost()->getFullyQualifiedDisplayName(); - $instance_keys[$instancename] = $instancename; - } + $region = $this->getRequest()->getText( 'region' ); + $this->userNova->setRegion( $region ); + $instances = $this->userNova->getInstances(); + foreach ( $instances as $instance ) { + if ( $instance->getProject() === $this->projectName ) { + $instancename = $instance->getHost()->getFullyQualifiedDisplayName(); + $instance_keys[$instancename] = $instancename; } } ksort( $instance_keys ); @@ -128,6 +125,11 @@ 'default' => 'create', 'name' => 'action', ); + $proxyInfo['region'] = array( + 'type' => 'hidden', + 'default' => $region, + 'name' => 'region', + ); $proxyInfo['project'] = array( 'type' => 'hidden', 'default' => $this->projectName, @@ -157,6 +159,7 @@ return false; } $proxyfqdn = $this->getRequest()->getText( 'proxyfqdn' ); + $region = $this->getRequest()->getText( 'region' ); if ( ! $this->getRequest()->wasPosted() ) { $this->getOutput()->addWikiMsg( 'openstackmanager-deleteproxy-confirm', $proxyfqdn ); } @@ -175,6 +178,11 @@ 'type' => 'hidden', 'default' => 'delete', 'name' => 'action', + ); + $proxyInfo['region'] = array( + 'type' => 'hidden', + 'default' => $region, + 'name' => 'region', ); $proxyForm = new HTMLForm( $proxyInfo, @@ -215,16 +223,21 @@ if ( !in_array( $projectName, $projectfilter ) ) { continue; } - $actions = array( 'projectadmin' => array() ); - $actions['projectadmin'][] = $this->createActionLink( 'openstackmanager-createproxy', array( 'action' => 'create', 'project' => $projectName ) ); - $out .= $this->createProjectSection( $projectName, $actions, $this->getProxies( $projectName ) ); + $this->userNova->setProject( $projectName ); + foreach ( $this->userNova->getRegions( 'proxy' ) as $region ) { + $actions = array( 'projectadmin' => array() ); + $actions['projectadmin'][] = $this->createActionLink( 'openstackmanager-createproxy', array( 'action' => 'create', 'project' => $projectName, 'region' => $region ) ); + $regions .= $this->createRegionSection( $region, $projectName, $actions, $this->getProxies( $projectName, $region ) ); + } + $out .= $this->createProjectSection( $projectName, $actions, $regions ); } $this->getOutput()->addHTML( $out ); } - function getProxies( $projectName ) { + function getProxies( $projectName, $region ) { $this->userNova->setProject( $projectName ); + $this->userNova->setRegion( $region ); $proxies = $this->userNova->getProxiesForProject(); $proxyRows = array(); foreach ( $proxies as $proxy ) { @@ -236,7 +249,7 @@ $actions = array(); $actions[] = $this->createActionLink( 'openstackmanager-delete', - array( 'action' => 'delete', 'proxyfqdn' => $fqdn, 'project' => $projectName ) ); + array( 'action' => 'delete', 'proxyfqdn' => $fqdn, 'project' => $projectName, 'region' => $region ) ); $this->pushRawResourceColumn( $proxyRow, $this->createResourceList( $actions ) ); @@ -308,10 +321,11 @@ * @return bool */ function tryDeleteSubmit( $formData, $entryPoint = 'internal' ) { - global $wgOpenStackManagerProxyGateway; + global $wgOpenStackManagerProxyGateways; $outputPage = $this->getOutput(); $fqdn = $formData['proxyfqdn']; + $region = $formData['region']; $goback = '<br />'; $goback .= Linker::link( $this->getPageTitle(), @@ -320,7 +334,7 @@ $success = $this->userNova->deleteProxy( $fqdn ); if ( $success ) { - $success = $this->deleteHost( $fqdn, $wgOpenStackManagerProxyGateway ); + $success = $this->deleteHost( $fqdn, $wgOpenStackManagerProxyGateways[$region] ); if ( ! $success ) { $outputPage->addWikiMsg( 'openstackmanager-removehostfailed', $fqdn ); } @@ -343,8 +357,7 @@ * @return bool */ function tryCreateSubmit( $formData, $entryPoint = 'internal' ) { - global $wgOpenStackManagerProxyGateway; - $gatewayIP = $wgOpenStackManagerProxyGateway; + global $wgOpenStackManagerProxyGateways; $goback = '<br />'; $goback .= Linker::link( $this->getPageTitle(), @@ -354,6 +367,8 @@ $project = $formData['project']; $backendPort = $formData['backendport']; $backendHost = $formData['backendhost']; + $region = $formData['region']; + $gatewayIP = $wgOpenStackManagerProxyGateways[$region]; $proxyName = $formData['proxyname']; $proxyDomain = $formData['domain']; -- To view, visit https://gerrit.wikimedia.org/r/116998 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5db71fafe412169196725adb4b1afcbe2e874e97 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/OpenStackManager Gerrit-Branch: master Gerrit-Owner: Andrew Bogott <abog...@wikimedia.org> Gerrit-Reviewer: Andrew Bogott <abog...@wikimedia.org> Gerrit-Reviewer: Ryan Lane <rl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits