Return IP type for interfaces (fixed or floating)

Registered by Alexej Ababilov

In nova.api.openstack.views.addresses.ViewBuilderV10, public and private IPs (floating and fixed, respectively) were returned in "public" and "private" keys, so the caller could distinguish them.

In nova.api.openstack.views.addresses.ViewBuilderV11, all IPs are mixed together, so they are indistinguishable:
          "addresses": {
                "network_0809": [
                    {
                        "addr": "10.10.0.3",
                        "version": 4
                    }
                    {
                        "addr": "A.B.C.D",
                        "version": 4
                    }
                ]
            },
Here 10.10.0.3 actually is a public IP and A.B.C.D is a private one.

An additional field "is_fixed" is added with the following patch.

--- nova/api/openstack/views/addresses.py.orig 2011-08-16 19:11:50.497003804 +0300
+++ nova/api/openstack/views/addresses.py 2011-08-16 11:37:34.779002536 +0300
@@ -76,9 +76,9 @@

     def _extract_ipv4_addresses(self, interface):
         for fixed_ip in interface['fixed_ips']:
- yield self._build_ip_entity(fixed_ip['address'], 4)
+ yield self._build_ip_entity(fixed_ip['address'], 4, 1)
             for floating_ip in fixed_ip.get('floating_ips', []):
- yield self._build_ip_entity(floating_ip['address'], 4)
+ yield self._build_ip_entity(floating_ip['address'], 4, 0)

     def _extract_ipv6_address(self, interface):
         fixed_ipv6 = interface.get('fixed_ipv6')
@@ -86,4 +86,4 @@
             return self._build_ip_entity(fixed_ipv6, 6)

     def _build_ip_entity(self, address, version, is_fixed):
- return {'addr': address, 'version': version)
+ return {'addr': address, 'version': version, "is_fixed": is_fixed}

Then output will look like:
          "addresses": {
                "network_0809": [
                    {
                        "addr": "10.10.0.3",
                        "is_fixed": 1,
                        "version": 4
                    }
                    {
                        "addr": "A.B.C.D",
                        "is_fixed": 0,
                        "version": 4
                    }
                ]
            },

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
Alexej Ababilov
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Vish Ishaya

Related branches

Sprints

Whiteboard

We have labels on on the ips now. I think that is good enough to solve this use case. --Vish

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.