Fix /NetworkDriver.CreateEndpoint to return allocated IP addreses
The current /NetworkDriver.CreateEnpoint returns Address or AddressIPv6
given by users in the request. However libnetwork as of Docker 1.8.0
doesn't give any Interfaces property, thus IP addresses returned are
allocated with Neutron's IPAM mechanism. So Kuryr should return the
allocated IP addresses properly if there's no IP addresses specified by
default.
This patch makes Kuryr return allocated IP addresses correctly but
libnetwork requires Address and AddressIPv6 to be CIDR as well as
they're in the request. So Kuryr retrieves the subnets associated with
the allocated IP addresses, which are given in "subnet_id" in the top
level scope or "subnet_id"s in a list under the "fixed_ips" property,
take the prefix lengthof the subnet and combine it with the "ip_address"
of the same entry in "fixed_ips".
For example, the following two types of ports are supported.
Reviewed: https:/ /review. openstack. org/227962 /git.openstack. org/cgit/ openstack/ kuryr/commit/ ?id=2b03783273e 5b8a71f361b6650 d058081acbded0
Committed: https:/
Submitter: Jenkins
Branch: master
commit 2b03783273e5b8a 71f361b6650d058 081acbded0
Author: Taku Fukushima <email address hidden>
Date: Sat Sep 26 01:38:15 2015 +0900
Fix /NetworkDriver. CreateEndpoint to return allocated IP addreses
The current /NetworkDriver. CreateEnpoint returns Address or AddressIPv6
given by users in the request. However libnetwork as of Docker 1.8.0
doesn't give any Interfaces property, thus IP addresses returned are
allocated with Neutron's IPAM mechanism. So Kuryr should return the
allocated IP addresses properly if there's no IP addresses specified by
default.
This patch makes Kuryr return allocated IP addresses correctly but
libnetwork requires Address and AddressIPv6 to be CIDR as well as
they're in the request. So Kuryr retrieves the subnets associated with
the allocated IP addresses, which are given in "subnet_id" in the top
level scope or "subnet_id"s in a list under the "fixed_ips" property,
take the prefix lengthof the subnet and combine it with the "ip_address"
of the same entry in "fixed_ips".
For example, the following two types of ports are supported.
{
"status" : "ACTIVE",
"allowed_ address_ pairs": [],
"admin_ state_up" : true,
"network_ id": "70c1db1f- b701-45bd- 96e0-a313ee3430 b3",
"tenant_ id": "",
"extra_ dhcp_opts" : [],
"device_ owner": "network: router_ gateway" ,
"mac_ address" : "fa:16: 3e:58:42: ed",
"fixed_ ips": [{
"subnet_ id": "008ba151- 0b8c-4a67- 98b5-0d2b876660 62",
"ip_address" : "172.24.4.2" 4fc1-49f3- 952e-1e2ab7081d 8b",
"security_ groups" : [],
"device_ id": "9ae135f4- b6e0-4dad- 9e91-3c223e3858 24"
"name": "",
}],
"id": "d80b1a3b-
}
and
{
"status" : "ACTIVE",
"allowed_ address_ pairs": [],
"admin_ state_up" : true,
"network_ id": "70c1db1f- b701-45bd- 96e0-a313ee3430 b3",
"tenant_ id": "",
"extra_ dhcp_opts" : [],
"device_ owner": "network: router_ gateway" ,
"mac_ address" : "fa:16: 3e:58:42: ed",
"fixed_ ips": [],
"subnet_ id": "008ba151- 0b8c-4a67- 98b5-0d2b876660 62",
"ip_ address" : "172.24.4.2" 4fc1-49f3- 952e-1e2ab7081d 8b",
"security_ groups" : [],
"device_ id": "9ae135f4- b6e0-4dad- 9e91-3c223e3858 24"
"name": "",
"id": "d80b1a3b-
}
Change-Id: If71f6225ec83c3 8798ae970ab30bf 48979db30aa
Signed-off-by: Taku Fukushima <email address hidden>
Closes-Bug: #1499796