Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php |
— | — | @@ -127,6 +127,26 @@ |
128 | 128 | 'openstackmanager-shellaccountname' => 'Instance Shell Account Name', |
129 | 129 | 'openstackmanager-shellaccountnamehelp' => 'The shell account name must start with a-z, and can only contain a-z, 0-9, -, and _ characters', |
130 | 130 | |
| 131 | + 'openstackmanager-addresslist' => 'Public IP Address List', |
| 132 | + 'openstackmanager-address' => 'Public IP Address', |
| 133 | + 'openstackmanager-allocateaddress' => 'Allocate a new public IP address', |
| 134 | + 'openstackmanager-releaseaddress' => 'Release IP', |
| 135 | + 'openstackmanager-associateaddress' => 'Associate IP', |
| 136 | + 'openstackmanager-reassociateaddress' => 'Reassociate IP', |
| 137 | + 'openstackmanager-disassociateaddress' => 'Disassociate IP', |
| 138 | + 'openstackmanager-allocateaddressfailed' => 'Failed to allocate new public IP address', |
| 139 | + 'openstackmanager-allocatedaddress' => 'Allocated new public IP address: $1', |
| 140 | + 'openstackmanager-backaddresslist' => 'Back to address list', |
| 141 | + 'openstackmanager-allocateaddress-confirm' => 'Are you sure you would like to allocate a new public IP address in project $1?', |
| 142 | + 'openstackmanager-releasedaddress' => 'Successfully released address: $1', |
| 143 | + 'openstackmanager-releaseaddressfailed' => 'Failed to release address: $1', |
| 144 | + 'openstackmanager-associatedaddress' => 'Successfully associated $1 with instance id $2', |
| 145 | + 'openstackmanager-associateaddressfailed' => 'Failed to associate $1 with instance id $2', |
| 146 | + 'openstackmanager-disassociatedaddress' => 'Successfully disassociated $1', |
| 147 | + 'openstackmanager-disassociateaddressfailed' => 'Failed to disassociate $1', |
| 148 | + 'openstackmanager-disassociateaddress-confirm' => 'Are you sure you would like to disassociate $1?', |
| 149 | + 'openstackmanager-releaseaddress-confirm' => 'Are you sure you would like to release $1?', |
| 150 | + |
131 | 151 | ); |
132 | 152 | |
133 | 153 | /** Message documentation (Message documentation) |
Index: trunk/extensions/OpenStackManager/OpenStackNovaController.php |
— | — | @@ -5,8 +5,9 @@ |
6 | 6 | |
7 | 7 | var $novaConnection; |
8 | 8 | var $instances, $images, $keypairs, $availabilityZones; |
| 9 | + var $addresses; |
9 | 10 | |
10 | | - var $instanceTypes = array( 'm1.small', 'm1.large', 'm1.xlarge', 'm2.xlarge', 'm2.2xlarge', |
| 11 | + var $instanceTypes = array( 'm1.tiny', 'm1.small', 'm1.large', 'm1.xlarge', 'm2.xlarge', 'm2.2xlarge', |
11 | 12 | 'm2.4xlarge', 'c1.medium', 'c1.xlarge', 'cc1.4xlarge' ); |
12 | 13 | |
13 | 14 | # TODO: Make disable_ssl, hostname, and resource_prefix config options |
— | — | @@ -21,6 +22,18 @@ |
22 | 23 | $this->instances = array(); |
23 | 24 | } |
24 | 25 | |
| 26 | + function getAddresses() { |
| 27 | + $this->addresses = array(); |
| 28 | + $response = $this->novaConnection->describe_addresses(); |
| 29 | + $addresses = $response->body->addressesSet->item; |
| 30 | + foreach ( $addresses as $address ) { |
| 31 | + $address = new OpenStackNovaAddress( $address ); |
| 32 | + $ip = $address->getPublicIp(); |
| 33 | + $this->addresses["$ip"] = $address; |
| 34 | + } |
| 35 | + return $this->addresses; |
| 36 | + } |
| 37 | + |
25 | 38 | function getInstance( $instanceId ) { |
26 | 39 | $this->getInstances(); |
27 | 40 | if ( isset( $this->instances["$instanceId"] ) ) { |
— | — | @@ -120,4 +133,38 @@ |
121 | 134 | return $keypair; |
122 | 135 | } |
123 | 136 | |
| 137 | + function allocateAddress() { |
| 138 | + $response = $this->novaConnection->allocate_address(); |
| 139 | + if ( ! $response->isOK() ) { |
| 140 | + return null; |
| 141 | + } else { |
| 142 | + $address = new OpenStackNovaAddress( $response->body->addressSet->item ); |
| 143 | + $this->addresses["$ip"] = $address; |
| 144 | + return $address; |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + function releaseAddress( $ip ) { |
| 149 | + $response = $this->novaConnection->release_address( $ip ); |
| 150 | + |
| 151 | + return $response->isOK(); |
| 152 | + } |
| 153 | + |
| 154 | + function associateAddress( $instanceid, $ip ) { |
| 155 | + $response = $this->novaConnection->associate_address( $instanceid, $ip ); |
| 156 | + if ( ! $response->isOK() ) { |
| 157 | + return null; |
| 158 | + } else { |
| 159 | + $address = new OpenStackNovaAddress( $response->body->addressSet->item ); |
| 160 | + $this->addresses["$ip"] = $address; |
| 161 | + return $address; |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + function disassociateAddress( $ip ) { |
| 166 | + $response = $this->novaConnection->disassociate_address( $ip ); |
| 167 | + |
| 168 | + return $response->isOK(); |
| 169 | + } |
| 170 | + |
124 | 171 | } |
Index: trunk/extensions/OpenStackManager/OpenStackManager.php |
— | — | @@ -62,10 +62,12 @@ |
63 | 63 | $wgAutoloadClasses['OpenStackNovaUser'] = $dir . 'OpenStackNovaUser.php'; |
64 | 64 | $wgAutoloadClasses['OpenStackNovaDomain'] = $dir . 'OpenStackNovaDomain.php'; |
65 | 65 | $wgAutoloadClasses['OpenStackNovaHost'] = $dir . 'OpenStackNovaHost.php'; |
| 66 | +$wgAutoloadClasses['OpenStackNovaAddress'] = $dir . 'OpenStackNovaAddress.php'; |
66 | 67 | $wgAutoloadClasses['SpecialNovaInstance'] = $dir . 'SpecialNovaInstance.php'; |
67 | 68 | $wgAutoloadClasses['SpecialNovaKey'] = $dir . 'SpecialNovaKey.php'; |
68 | 69 | $wgAutoloadClasses['SpecialNovaProject'] = $dir . 'SpecialNovaProject.php'; |
69 | 70 | $wgAutoloadClasses['SpecialNovaDomain'] = $dir . 'SpecialNovaDomain.php'; |
| 71 | +$wgAutoloadClasses['SpecialNovaAddress'] = $dir . 'SpecialNovaAddress.php'; |
70 | 72 | $wgAutoloadClasses['SpecialNova'] = $dir . 'SpecialNova.php'; |
71 | 73 | $wgAutoloadClasses['OpenStackNovaHostJob'] = $dir . 'OpenStackNovaHostJob.php'; |
72 | 74 | $wgAutoloadClasses['AmazonEC2'] = $dir . 'aws-sdk/sdk.class.php'; |
— | — | @@ -77,6 +79,8 @@ |
78 | 80 | $wgSpecialPageGroups['NovaProject'] = 'other'; |
79 | 81 | $wgSpecialPages['NovaDomain'] = 'SpecialNovaDomain'; |
80 | 82 | $wgSpecialPageGroups['NovaDomain'] = 'other'; |
| 83 | +$wgSpecialPages['NovaAddress'] = 'SpecialNovaAddress'; |
| 84 | +$wgSpecialPageGroups['NovaAddress'] = 'other'; |
81 | 85 | $wgJobClasses['addDNSHostToLDAP'] = 'OpenStackNovaHostJob'; |
82 | 86 | |
83 | 87 | $wgHooks['LDAPSetCreationValues'][] = 'OpenStackNovaUser::LDAPSetCreationValues'; |