summaryrefslogtreecommitdiff
path: root/ironic/dhcp
diff options
context:
space:
mode:
authorSam Betts <sam@code-smash.net>2016-11-30 18:29:04 +0000
committerVasyl Saienko <vsaienko@mirantis.com>2016-12-23 11:58:02 +0000
commit9088891ce72081684761e5cf54d3b3eabab0ca37 (patch)
tree65a82babad4dadef412730fea4bde28687bbec2f /ironic/dhcp
parent12feff85d6826d198a424a1c25efcc3d3c591299 (diff)
downloadironic-9088891ce72081684761e5cf54d3b3eabab0ca37.tar.gz
Add Virtual Network Interface Driver APIs
This patch adds the driver API interfaces for the virtual network interface API in order to abstract the task of assigning logical network interfaces to physical network interfaces. Since the OpenStack Newton release, Ironic provides an interface for pluggable network implementations. Different network implementations may want to handle how logical to physical network interface assignment happens. To do this the new API calls into new functions on the network implementation loaded for the specified node. This is part 1 of 3, and adds four new functions vif_attach, vif_detach, vif_list, port_changed, portgroup_changed, get_current_vif to the base network interface class, which should be overridden by network interface implementations. DHCP provider update_mac_address method was deprecated, network interface port_changed() and portgroup_changed() should be used instead. Co-Authored-By: Vasyl Saienko (vsaienko@mirantis.com) Change-Id: I0b84cfd85557d18254697f2e539c583ea0f8e88c Partial-Bug: #1582188 Closes-Bug: #1158684
Diffstat (limited to 'ironic/dhcp')
-rw-r--r--ironic/dhcp/base.py4
-rw-r--r--ironic/dhcp/neutron.py49
-rw-r--r--ironic/dhcp/none.py2
3 files changed, 17 insertions, 38 deletions
diff --git a/ironic/dhcp/base.py b/ironic/dhcp/base.py
index 6eb013ad9..e0663186e 100644
--- a/ironic/dhcp/base.py
+++ b/ironic/dhcp/base.py
@@ -47,7 +47,8 @@ class BaseDHCP(object):
:raises: FailedToUpdateDHCPOptOnPort
"""
- @abc.abstractmethod
+ # TODO(vsaienko) Remove this method when deprecation period is passed
+ # in Pike.
def update_port_address(self, port_id, address, token=None):
"""Update a port's MAC address.
@@ -57,6 +58,7 @@ class BaseDHCP(object):
:raises: FailedToUpdateMacOnPort
"""
+ pass
@abc.abstractmethod
def update_dhcp_opts(self, task, options, vifs=None):
diff --git a/ironic/dhcp/neutron.py b/ironic/dhcp/neutron.py
index eccb8ec1b..ef706ecae 100644
--- a/ironic/dhcp/neutron.py
+++ b/ironic/dhcp/neutron.py
@@ -31,6 +31,8 @@ from ironic import objects
LOG = logging.getLogger(__name__)
+update_port_address_deprecation = False
+
class NeutronDHCPApi(base.BaseDHCP):
"""API for communicating to neutron 2.x API."""
@@ -65,16 +67,8 @@ class NeutronDHCPApi(base.BaseDHCP):
LOG.exception(_LE("Failed to update Neutron port %s."), port_id)
raise exception.FailedToUpdateDHCPOptOnPort(port_id=port_id)
- def _get_binding(self, client, port_id):
- """Get binding:host_id property from Neutron."""
- try:
- return client.show_port(port_id).get('port', {}).get(
- 'binding:host_id')
- except neutron_client_exc.NeutronClientException:
- LOG.exception(_LE('Failed to get the current binding on Neutron '
- 'port %s.'), port_id)
- raise exception.FailedToUpdateMacOnPort(port_id=port_id)
-
+ # TODO(vsaienko) Remove this method when deprecation period is passed
+ # in Pike.
def update_port_address(self, port_id, address, token=None):
"""Update a port's mac address.
@@ -83,27 +77,14 @@ class NeutronDHCPApi(base.BaseDHCP):
:param token: optional auth token.
:raises: FailedToUpdateMacOnPort
"""
- client = neutron.get_client(token)
- port_req_body = {'port': {'mac_address': address}}
-
- current_binding = self._get_binding(client, port_id)
- if current_binding:
- binding_clean_body = {'port': {'binding:host_id': ''}}
- try:
- client.update_port(port_id, binding_clean_body)
- except neutron_client_exc.NeutronClientException:
- LOG.exception(_LE("Failed to remove the current binding from "
- "Neutron port %s."), port_id)
- raise exception.FailedToUpdateMacOnPort(port_id=port_id)
-
- port_req_body['port']['binding:host_id'] = current_binding
+ global update_port_address_deprecation
+ if not update_port_address_deprecation:
+ LOG.warning(_LW('update_port_address via DHCP provider is '
+ 'deprecated. The node.network_interface '
+ 'port_changed() should be used instead.'))
+ update_port_address_deprecation = True
- try:
- neutron.get_client(token).update_port(port_id, port_req_body)
- except neutron_client_exc.NeutronClientException:
- LOG.exception(_LE("Failed to update MAC address on Neutron "
- "port %s."), port_id)
- raise exception.FailedToUpdateMacOnPort(port_id=port_id)
+ neutron.update_port_address(port_id, address, token)
def update_dhcp_opts(self, task, options, vifs=None):
"""Send or update the DHCP BOOT options for this node.
@@ -227,13 +208,7 @@ class NeutronDHCPApi(base.BaseDHCP):
:raises: InvalidIPv4Address
"""
- # NOTE(vdrok): We are booting the node only in one network at a time,
- # and presence of cleaning_vif_port_id means we're doing cleaning, of
- # provisioning_vif_port_id - provisioning. Otherwise it's a tenant
- # network
- vif = (p_obj.internal_info.get('cleaning_vif_port_id') or
- p_obj.internal_info.get('provisioning_vif_port_id') or
- p_obj.extra.get('vif_port_id'))
+ vif = task.driver.network.get_current_vif(task, p_obj)
if not vif:
obj_name = 'portgroup'
if isinstance(p_obj, objects.Port):
diff --git a/ironic/dhcp/none.py b/ironic/dhcp/none.py
index bfe6c2d69..65b4f52a8 100644
--- a/ironic/dhcp/none.py
+++ b/ironic/dhcp/none.py
@@ -25,6 +25,8 @@ class NoneDHCPApi(base.BaseDHCP):
def update_dhcp_opts(self, task, options, vifs=None):
pass
+ # TODO(vsaienko) Remove this method when deprecation period is passed
+ # in Pike.
def update_port_address(self, port_id, address, token=None):
pass