r80548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80547‎ | r80548 | r80549 >
Date:01:36, 19 January 2011
Author:laner
Status:deferred
Tags:
Comment:
Adding support for security groups to instances
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.i18n.php (modified) (history)
  • /trunk/extensions/OpenStackManager/OpenStackNovaController.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaInstance.php
@@ -148,6 +148,21 @@
149149 'label-message' => 'openstackmanager-dnsdomain',
150150 );
151151
 152+ $securityGroups = $this->adminNova->getSecurityGroups();
 153+ $group_keys = array();
 154+ foreach ( $securityGroups as $securityGroup ) {
 155+ if ( $securityGroup->getOwner() == $project ) {
 156+ $securityGroupName = $securityGroup->getGroupName();
 157+ $group_keys["$securityGroupName"] = $securityGroupName;
 158+ }
 159+ }
 160+ $instanceInfo['groups'] = array(
 161+ 'type' => 'multiselect',
 162+ 'section' => 'instance/info',
 163+ 'options' => $group_keys,
 164+ 'label-message' => 'openstackmanager-securitygroups',
 165+ );
 166+
152167 $instanceInfo['project'] = array(
153168 'type' => 'hidden',
154169 'default' => $project,
@@ -389,7 +404,7 @@
390405 $out = Html::element( 'p', array(), wfMsg( 'openstackmanager-invaliddomain' ) );
391406 return true;
392407 }
393 - $instance = $this->userNova->createInstance( $formData['instancename'], $formData['imageType'], '', $formData['instanceType'], $formData['availabilityZone'] );
 408+ $instance = $this->userNova->createInstance( $formData['instancename'], $formData['imageType'], '', $formData['instanceType'], $formData['availabilityZone'], $formData['groups'] );
394409 if ( $instance ) {
395410 $puppetinfo = array();
396411 if ( $wgOpenStackManagerPuppetOptions['enabled'] ) {
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php
@@ -78,6 +78,7 @@
7979 'openstackmanager-instancestate' => 'Instance State',
8080 'openstackmanager-instancetype' => 'Instance Type',
8181 'openstackmanager-instanceip' => 'Instance IP',
 82+ 'openstackmanager-securitygroups' => 'Security Groups',
8283 'openstackmanager-availabilityzone' => 'Availability Zone',
8384 'openstackmanager-imageid' => 'Image ID',
8485 'openstackmanager-imagetype' => 'Image Type',
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php
@@ -127,7 +127,7 @@
128128 return $this->securityGroups;
129129 }
130130
131 - function createInstance( $instanceName, $image, $key, $instanceType, $availabilityZone ) {
 131+ function createInstance( $instanceName, $image, $key, $instanceType, $availabilityZone, $groups ) {
132132 # 1, 1 is min and max number of instances to create.
133133 # We never want to make more than one at a time.
134134 $options = array();
@@ -137,6 +137,11 @@
138138 $options['InstanceType'] = $instanceType;
139139 $options['Placement.AvailabilityZone'] = $availabilityZone;
140140 $options['DisplayName'] = $instanceName;
 141+ #if ( count( $groups ) > 1 ) {
 142+ $options['SecurityGroup'] = $groups;
 143+ #} else if ( count( $groups ) == 1 ) {
 144+ # $options['SecurityGroup'] = $groups[0];
 145+ #}
141146 $response = $this->novaConnection->run_instances( $image, 1, 1, $options );
142147 if ( ! $response->isOK() ) {
143148 return null;

Status & tagging log