summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-07-14 14:23:23 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-07-14 14:23:23 -0400
commit38233d72aff36fbdb0fd49755458b7b5100366e1 (patch)
tree29dbf1221d7c243568b46121d73b6c82b19e2c1a /nova/api
parent27b8d75f9b666ce08472270b38685d8e36a612d8 (diff)
downloadnova-38233d72aff36fbdb0fd49755458b7b5100366e1.tar.gz
nova-38233d72aff36fbdb0fd49755458b7b5100366e1.tar.xz
nova-38233d72aff36fbdb0fd49755458b7b5100366e1.zip
exposing floating ips
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/views/addresses.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/nova/api/openstack/views/addresses.py b/nova/api/openstack/views/addresses.py
index b127ac38c..a242efa45 100644
--- a/nova/api/openstack/views/addresses.py
+++ b/nova/api/openstack/views/addresses.py
@@ -46,24 +46,26 @@ class ViewBuilderV11(ViewBuilder):
networks = {}
for interface in interfaces:
network_label = interface['network']['label']
+
if network_label not in networks:
networks[network_label] = []
- for fixed_ip in interface['fixed_ips']:
- ip = {'addr': fixed_ip['address'], 'version': 4}
- networks[network_label].append(ip)
+ networks[network_label].extend(self._extract_ipv4(interface))
+
return networks
def build_network(self, interfaces, network_label):
for interface in interfaces:
if interface['network']['label'] == network_label:
- ips = self._extract_fixed_ips(interface)
- return {network_label: ips}
+ ips = self._extract_ipv4(interface)
+ return {network_label: list(ips)}
return None
- def _extract_fixed_ips(self, interface):
- fixed_ips = []
+ def _extract_ipv4(self, interface):
for fixed_ip in interface['fixed_ips']:
- ip = {'addr': fixed_ip['address'], 'version': 4}
- fixed_ips.append(ip)
- return fixed_ips
+ yield self._build_ip_entity(fixed_ip['address'], 4)
+ for floating_ip in fixed_ip.get('floating_ips', []):
+ yield self._build_ip_entity(floating_ip['address'], 4)
+
+ def _build_ip_entity(self, address, version):
+ return {'addr': address, 'version': version}