jenkins-bot has submitted this change and it was merged. Change subject: Update maintenance/puppetValues.php to handle regions. ......................................................................
Update maintenance/puppetValues.php to handle regions. Change-Id: I61c6549c4acc61de8ec4c2c04a0adfb28f4db7d2 --- M maintenance/puppetValues.php 1 file changed, 18 insertions(+), 5 deletions(-) Approvals: Andrew Bogott: Looks good to me, approved jenkins-bot: Verified diff --git a/maintenance/puppetValues.php b/maintenance/puppetValues.php index 09abc79..6ada199 100644 --- a/maintenance/puppetValues.php +++ b/maintenance/puppetValues.php @@ -40,6 +40,7 @@ public function __construct() { parent::__construct(); $this->addOption( 'instance', 'The instance hostname, e.g. i-00000001', false, true ); + $this->addOption( 'region', 'The instance region, e.g. pmtpa', false, true ); $this->addOption( 'all-instances', 'Run this command on every instance.', false, false ); $this->addOption( 'delete-var', 'The variable name to delete', false, true ); $this->addOption( 'delete-class', 'The class index to delete', false, true ); @@ -53,6 +54,9 @@ global $wgOpenStackManagerLDAPUserPassword; if ( $this->hasOption( 'all-instances' ) ) { + if ( $this->hasOption( 'region' ) ) { + $this->error( "--all-instances cannot be used with --region.\n", true ); + } $instancelist = array(); $user = new OpenStackNovaUser( $wgOpenStackManagerLDAPUsername ); $userNova = OpenStackNovaController::newFromUser( $user ); @@ -69,13 +73,16 @@ if ( $instances ) { foreach ( $instances as $instance ) { $id = $instance->getInstanceId(); - $instancelist[] = $instance->getInstanceId(); + $instancelist[] = array( $instance->getInstanceId(), $region ); } } } } } elseif ( $this->hasOption( 'instance' ) ) { - $instancelist = array( $this->getOption( 'instance' ) ); + if ( ! $this->hasOption( 'region' ) ) { + $this->error( "--instance requires --region.\n", true ); + } + $instancelist = array( array( $this->getOption( 'instance' ), $this->getOption( 'region' ) ) ); } else { $this->error( "Must specify either --instance or --all-instances.\n", true ); } @@ -84,9 +91,15 @@ $this->error( "Couldn't find OpenStackNovaHost class.\n", true ); } OpenStackNovaLdapConnection::connect(); - foreach ( $instancelist as $instance ) { - print "\nFor instance $instance:\n\n"; - $host = OpenStackNovaHost::getHostByInstanceId( $instance ); + foreach ( $instancelist as $instancepair ) { + $instance = $instancepair[0]; + $instanceregion = $instancepair[1]; + $host = OpenStackNovaHost::getHostByInstanceId( $instance, $instanceregion ); + if ( ! $host ) { + print "Skipping $instance.$instanceregion; not found.\n"; + continue; + } + print "\nFor instance $instance in region $instanceregion:\n\n"; $puppetconf = $host->getPuppetConfiguration(); $puppetclasses = $puppetconf['puppetclass']; $puppetvars = $puppetconf['puppetvar']; -- To view, visit https://gerrit.wikimedia.org/r/108011 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I61c6549c4acc61de8ec4c2c04a0adfb28f4db7d2 Gerrit-PatchSet: 2 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