r77446 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77445‎ | r77446 | r77447 >
Date:23:13, 29 November 2010
Author:reedy
Status:deferred
Tags:
Comment:
Remove a couple of unused globals

Array to array, False to false

Spacing. Fix a few wrongly cased usages of variables
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackNovaController.php (modified) (history)
  • /trunk/extensions/OpenStackManager/SpecialCreateInstance.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/SpecialCreateInstance.php
@@ -12,7 +12,7 @@
1313 }
1414
1515 function execute( $par ) {
16 - global $wgRequest, $wgOut, $wgTitle;
 16+ global $wgRequest, $wgOut;
1717
1818 $this->setHeaders();
1919 $wgOut->setPagetitle("Create Instance");
@@ -100,7 +100,7 @@
101101 $instanceId = $this->adminNova->createInstance( $formData['imageType'], $formData['keypair'],
102102 $formData['instanceType'], $formData['availabilityZone'] );
103103
104 - print_r($instanceID);
 104+ print_r($instanceId);
105105
106106 $wgOut->addHTML('<p>Created instance ' . $instanceId . '</p>');
107107
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php
@@ -10,20 +10,19 @@
1111
1212 # TODO: Make disable_ssl, hostname, and resource_prefix config options
1313 function __construct( $credentials ) {
14 - global $wgOpenStackManagerNovaDisableSSL, $wgOpenStackManagerNovaPort,
15 - $wgOpenStackManagerNovaServerName, $wgOpenStackManagerNovaPort,
16 - $wgOpenStackManagerNovaResourcePrefix;
 14+ global $wgOpenStackManagerNovaDisableSSL, $wgOpenStackManagerNovaServerName,
 15+ $wgOpenStackManagerNovaPort, $wgOpenStackManagerNovaResourcePrefix;
1716 wfLoadExtensionMessages('OpenStackManager');
1817 $this->novaConnection = new AmazonEC2( $credentials['accessKey'], $credentials['secretKey'] );
1918 $this->novaConnection->disable_ssl($wgOpenStackManagerNovaDisableSSL);
2019 $this->novaConnection->set_hostname($wgOpenStackManagerNovaServerName, $wgOpenStackManagerNovaPort);
2120 $this->novaConnection->set_resource_prefix($wgOpenStackManagerNovaResourcePrefix);
22 - $this->instances = Array();
 21+ $this->instances = array();
2322 }
2423
25 - function getInstance( $instanceId, $reload=False ) {
26 - if ( isset( $this->instances[$instanceID] ) && !$reload ) {
27 - $instance = $this->instances[$instanceID];
 24+ function getInstance( $instanceId, $reload = false ) {
 25+ if ( isset( $this->instances[$instanceId] ) && !$reload ) {
 26+ $instance = $this->instances[$instanceId];
2827 } else {
2928 $instance = $this->novaConnection->describe_instances( $instanceId );
3029 $instance = $instance->body->reservationSet->item;
@@ -32,9 +31,9 @@
3332 return $instance;
3433 }
3534
36 - function getInstances( $reload=False ) {
 35+ function getInstances( $reload = false ) {
3736 if ( count( $this->instances ) == 0 || $reload ) {
38 - $this->instances = Array();
 37+ $this->instances = array();
3938 $instances = $this->novaConnection->describe_instances();
4039 $instances = $instances->body->reservationSet->item;
4140 foreach ( $instances as $instance ) {
@@ -48,9 +47,9 @@
4948 return $this->instanceTypes;
5049 }
5150
52 - function getImages( $reload=False ) {
 51+ function getImages( $reload = false ) {
5352 if ( count( $this->images ) == 0 || $reload ) {
54 - $this->images = Array();
 53+ $this->images = array();
5554 $images = $this->novaConnection->describe_images();
5655 $images = $images->body->imagesSet->item;
5756 foreach ( $images as $image ) {
@@ -63,9 +62,9 @@
6463 }
6564
6665 # TODO: make this user specific
67 - function getKeypairs( $reload=False ) {
 66+ function getKeypairs( $reload = false ) {
6867 if ( count( $this->keypairs ) == 0 || $reload ) {
69 - $this->keypairs = Array();
 68+ $this->keypairs = array();
7069 $keypairs = $this->novaConnection->describe_key_pairs();
7170 $keypairs = $keypairs->body->keypairsSet->item;
7271 foreach ( $keypairs as $keypair ) {
@@ -75,9 +74,9 @@
7675 return $this->keypairs;
7776 }
7877
79 - function getAvailabilityZones( $reload=False ) {
 78+ function getAvailabilityZones( $reload = false ) {
8079 if ( count( $this->availabilityZones ) == 0 || $reload ) {
81 - $this->availabilityZones = Array();
 80+ $this->availabilityZones = array();
8281 $availabilityZones = $this->novaConnection->describe_availability_zones();
8382 $availabilityZones = $availabilityZones->body->availabilityZoneInfo->item;
8483 foreach ( $availabilityZones as $availabilityZone ) {
@@ -92,7 +91,7 @@
9392 function createInstance( $image, $key, $instanceType, $availabilityZone ) {
9493 # 1, 1 is min and max number of instances to create.
9594 # We never want to make more than one at a time.
96 - $instance = $this->novaConnection->run_instances($image, 1, 1, Array(
 95+ $instance = $this->novaConnection->run_instances($image, 1, 1, array(
9796 'KeyName' => $key,
9897 'InstanceType' => $instanceType,
9998 'Placement.AvailabilityZone' => $availabilityZone,

Status & tagging log