Fix container port ipaddress setting in ipvlan/macvlan drivers
Currently ipaddress is being set from nova instance port and thus making vm ip and container ip same. Fix this by using container port dict for getting container IP. Another change is renaming 'nested_port', which is actually Nova instance port, to 'vm_port', for the sake of avoiding ambiguity. Change-Id: I9ea93c88c2889c5a6b7eff230ffdfb87b96b0e25 Closes-bug: #1641537
This commit is contained in:
parent
bd7bbfd470
commit
1939273877
|
@ -13,19 +13,20 @@ from oslo_config import cfg
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
|
|
||||||
def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None):
|
||||||
"""Binds the Neutron port to the network interface on the host.
|
"""Binds the Neutron port to the network interface on the host.
|
||||||
|
|
||||||
:param endpoint_id: the ID of the endpoint as string
|
:param endpoint_id: the ID of the endpoint as string
|
||||||
:param port: the instance Neutron port dictionary as returned by
|
:param port: the container Neutron port dictionary as returned by
|
||||||
python-neutronclient
|
python-neutronclient
|
||||||
:param subnets: an iterable of all the Neutron subnets which the
|
:param subnets: an iterable of all the Neutron subnets which the
|
||||||
endpoint is trying to join
|
endpoint is trying to join
|
||||||
:param network: the Neutron network which the endpoint is trying to
|
:param network: the Neutron network which the endpoint is trying to
|
||||||
join
|
join
|
||||||
:param nested_port: the dictionary, as returned by python-neutronclient,
|
:param vm_port: the Nova instance port dictionary, as returned by
|
||||||
of the port that that is used when running inside
|
python-neutronclient. Binding is being done for the
|
||||||
another instance (either ipvlan/macvlan or a subport)
|
port of a container which is running inside this Nova
|
||||||
|
instance (either ipvlan/macvlan or a subport).
|
||||||
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
||||||
and stderr returned by processutils.execute invoked with the
|
and stderr returned by processutils.execute invoked with the
|
||||||
executable script for binding
|
executable script for binding
|
||||||
|
@ -35,7 +36,7 @@ def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
||||||
driver = importutils.import_module(cfg.CONF.binding.driver)
|
driver = importutils.import_module(cfg.CONF.binding.driver)
|
||||||
|
|
||||||
return driver.port_bind(endpoint_id, port, subnets, network=network,
|
return driver.port_bind(endpoint_id, port, subnets, network=network,
|
||||||
nested_port=nested_port)
|
vm_port=vm_port)
|
||||||
|
|
||||||
|
|
||||||
def port_unbind(endpoint_id, neutron_port):
|
def port_unbind(endpoint_id, neutron_port):
|
||||||
|
|
|
@ -20,19 +20,19 @@ KIND = 'ipvlan'
|
||||||
IPVLAN_MODE_L2 = ifinfmsg.ifinfo.ipvlan_data.modes['IPVLAN_MODE_L2']
|
IPVLAN_MODE_L2 = ifinfmsg.ifinfo.ipvlan_data.modes['IPVLAN_MODE_L2']
|
||||||
|
|
||||||
|
|
||||||
def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None):
|
||||||
"""Binds the Neutron port to the network interface on the host.
|
"""Binds the Neutron port to the network interface on the host.
|
||||||
|
|
||||||
:param endpoint_id: the ID of the endpoint as string
|
:param endpoint_id: the ID of the endpoint as string
|
||||||
:param port: the instance Neutron port dictionary as returned by
|
:param port: the container Neutron port dictionary as returned by
|
||||||
python-neutronclient
|
python-neutronclient
|
||||||
:param subnets: an iterable of all the Neutron subnets which the
|
:param subnets: an iterable of all the Neutron subnets which the
|
||||||
endpoint is trying to join
|
endpoint is trying to join
|
||||||
:param network: the Neutron network which the endpoint is trying to
|
:param network: the Neutron network which the endpoint is trying to
|
||||||
join
|
join
|
||||||
:param nested_port: the dictionary, as returned by python-neutronclient,
|
:param vm_port: the Nova instance port dictionary, as returned by
|
||||||
of the port that that is used when running inside
|
python-neutronclient. Container is running inside
|
||||||
another instance (either ipvlan/macvlan or a subport)
|
this instance (either ipvlan/macvlan or a subport)
|
||||||
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
||||||
and stderr returned by processutils.execute invoked with the
|
and stderr returned by processutils.execute invoked with the
|
||||||
executable script for binding
|
executable script for binding
|
||||||
|
@ -42,14 +42,14 @@ def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
||||||
ip = utils.get_ipdb()
|
ip = utils.get_ipdb()
|
||||||
port_id = port['id']
|
port_id = port['id']
|
||||||
_, devname = utils.get_veth_pair_names(port_id)
|
_, devname = utils.get_veth_pair_names(port_id)
|
||||||
link_iface = nested.get_link_iface(port)
|
link_iface = nested.get_link_iface(vm_port)
|
||||||
|
|
||||||
with ip.create(ifname=devname, kind=KIND,
|
with ip.create(ifname=devname, kind=KIND,
|
||||||
link=ip.interfaces[link_iface],
|
link=ip.interfaces[link_iface],
|
||||||
mode=IPVLAN_MODE_L2) as container_iface:
|
mode=IPVLAN_MODE_L2) as container_iface:
|
||||||
utils._configure_container_iface(
|
utils._configure_container_iface(
|
||||||
container_iface, subnets,
|
container_iface, subnets,
|
||||||
fixed_ips=nested_port.get(utils.FIXED_IP_KEY))
|
fixed_ips=port.get(utils.FIXED_IP_KEY))
|
||||||
|
|
||||||
return None, devname, ('', None)
|
return None, devname, ('', None)
|
||||||
|
|
||||||
|
|
|
@ -19,19 +19,19 @@ KIND = 'macvlan'
|
||||||
MACVLAN_MODE_BRIDGE = 'bridge'
|
MACVLAN_MODE_BRIDGE = 'bridge'
|
||||||
|
|
||||||
|
|
||||||
def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None):
|
||||||
"""Binds the Neutron port to the network interface on the host.
|
"""Binds the Neutron port to the network interface on the host.
|
||||||
|
|
||||||
:param endpoint_id: the ID of the endpoint as string
|
:param endpoint_id: the ID of the endpoint as string
|
||||||
:param port: the instance Neutron port dictionary as returned by
|
:param port: the container Neutron port dictionary as returned by
|
||||||
python-neutronclient
|
python-neutronclient
|
||||||
:param subnets: an iterable of all the Neutron subnets which the
|
:param subnets: an iterable of all the Neutron subnets which the
|
||||||
endpoint is trying to join
|
endpoint is trying to join
|
||||||
:param network: the Neutron network which the endpoint is trying to
|
:param network: the Neutron network which the endpoint is trying to
|
||||||
join
|
join
|
||||||
:param nested_port: the dictionary, as returned by python-neutronclient,
|
:param vm_port: the Nova instance port dictionary, as returned by
|
||||||
of the port that that is used when running inside
|
python-neutronclient. Container is running inside
|
||||||
another instance
|
instance.
|
||||||
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
||||||
and stderr returned by processutils.execute invoked with the
|
and stderr returned by processutils.execute invoked with the
|
||||||
executable script for binding
|
executable script for binding
|
||||||
|
@ -41,14 +41,14 @@ def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
||||||
ip = utils.get_ipdb()
|
ip = utils.get_ipdb()
|
||||||
port_id = port['id']
|
port_id = port['id']
|
||||||
_, devname = utils.get_veth_pair_names(port_id)
|
_, devname = utils.get_veth_pair_names(port_id)
|
||||||
link_iface = nested.get_link_iface(port)
|
link_iface = nested.get_link_iface(vm_port)
|
||||||
|
|
||||||
with ip.create(ifname=devname, kind=KIND,
|
with ip.create(ifname=devname, kind=KIND,
|
||||||
link=ip.interfaces[link_iface],
|
link=ip.interfaces[link_iface],
|
||||||
macvlan_mode=MACVLAN_MODE_BRIDGE) as container_iface:
|
macvlan_mode=MACVLAN_MODE_BRIDGE) as container_iface:
|
||||||
utils._configure_container_iface(
|
utils._configure_container_iface(
|
||||||
container_iface, subnets,
|
container_iface, subnets,
|
||||||
fixed_ips=nested_port.get(utils.FIXED_IP_KEY))
|
fixed_ips=port.get(utils.FIXED_IP_KEY))
|
||||||
|
|
||||||
return None, devname, ('', None)
|
return None, devname, ('', None)
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,20 @@ VIF_DETAILS_KEY = 'binding:vif_details'
|
||||||
VIF_TYPE_KEY = 'binding:vif_type'
|
VIF_TYPE_KEY = 'binding:vif_type'
|
||||||
|
|
||||||
|
|
||||||
def port_bind(endpoint_id, port, subnets, network=None, nested_port=None):
|
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None):
|
||||||
"""Binds the Neutron port to the network interface on the host.
|
"""Binds the Neutron port to the network interface on the host.
|
||||||
|
|
||||||
:param endpoint_id: the ID of the endpoint as string
|
:param endpoint_id: the ID of the endpoint as string
|
||||||
:param port: the instance Neutron port dictionary as returned by
|
:param port: the container Neutron port dictionary as returned by
|
||||||
python-neutronclient
|
python-neutronclient
|
||||||
:param subnets: an iterable of all the Neutron subnets which the
|
:param subnets: an iterable of all the Neutron subnets which the
|
||||||
endpoint is trying to join
|
endpoint is trying to join
|
||||||
:param network: the Neutron network which the endpoint is trying to
|
:param network: the Neutron network which the endpoint is trying to
|
||||||
join
|
join
|
||||||
:param nested_port: the dictionary, as returned by python-neutronclient,
|
:param vm_port: the Nova instance dictionary, as returned by
|
||||||
of the port that that is used when running inside
|
python-neutronclient. Container port under binding is
|
||||||
another instance (either ipvlan/macvlan or a subport)
|
running inside this instance (either ipvlan/macvlan or
|
||||||
|
a subport)
|
||||||
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
:returns: the tuple of the names of the veth pair and the tuple of stdout
|
||||||
and stderr returned by processutils.execute invoked with the
|
and stderr returned by processutils.execute invoked with the
|
||||||
executable script for binding
|
executable script for binding
|
||||||
|
|
Loading…
Reference in New Issue