Correct controller-0 mgmt mac following bootstrap

This commit corrects the mgmt_mac of controller-0 as part
of mgmt interface provisioning following Ansible bootstrap.

Test:
  Bring up a standard system. Verify that after a force
  reboot of the active controller, the controller is able
  to recover successfully.

Closes-Bug: #1828880
Closes-Bug: #1829545
Depends-On: I9ef9d30bbf8713c75206b338aefd53c3e77db0cb

Change-Id: I3536202a396c47bc0cf8463505f6de48815fee02
Signed-off-by: Tee Ngo <tee.ngo@windriver.com>
This commit is contained in:
Tee Ngo 2019-05-17 14:23:43 -04:00 committed by Al Bailey
parent 0dddabca4d
commit 319b5602df
3 changed files with 50 additions and 2 deletions

View File

@ -23,6 +23,7 @@
import jsonpatch
import os
import six
import uuid
@ -447,6 +448,7 @@ class InterfaceController(rest.RestController):
uses = None
ports = None
ethernet_port_mac = None
networks = []
networks_to_add = []
interface_networks_to_remove = []
@ -540,6 +542,7 @@ class InterfaceController(rest.RestController):
for p in interface_ports:
if p is not None:
ports = p.name
ethernet_port_mac = p.mac
break
# Process updates
@ -747,9 +750,11 @@ class InterfaceController(rest.RestController):
else:
networktypelist = [constants.NETWORK_TYPE_NONE]
# Update address (if required)
# Update mgmt_ip and mgmt_mac (if required)
if constants.NETWORK_TYPE_MGMT in networktypelist:
_update_host_mgmt_address(ihost, interface)
_update_host_mgmt_mac(ihost, ethernet_port_mac)
if constants.NETWORK_TYPE_CLUSTER_HOST in networktypelist:
_update_host_cluster_address(ihost, interface)
if ihost['personality'] == constants.CONTROLLER:
@ -1967,6 +1972,19 @@ def _update_host_mgmt_address(host, interface):
_allocate_pool_address(interface['id'], mgmt_pool_uuid, address_name)
def _update_host_mgmt_mac(host, mgmt_mac):
"""Update host mgmt mac to reflect interface change.
"""
if (os.path.isfile(constants.ANSIBLE_BOOTSTRAP_FLAG) and
mgmt_mac is not None):
# This must be called during management interface provisioning
# following controller-0 bootstrap.
if host['mgmt_mac'] != mgmt_mac:
pecan.request.rpcapi.mgmt_mac_set_by_ihost(
pecan.request.context, host, mgmt_mac)
def _update_host_oam_address(host, interface):
if utils.get_system_mode() == constants.SYSTEM_MODE_SIMPLEX:
address_name = cutils.format_address_name(constants.CONTROLLER_HOSTNAME,

View File

@ -10707,7 +10707,7 @@ class ConductorManager(service.PeriodicService):
controller host and management/oam network change during bootstrap
playbook play and replay.
:param contex: request context.
:param context: request context.
:param host: an ihost object
"""
@ -10732,3 +10732,20 @@ class ConductorManager(service.PeriodicService):
else:
LOG.error("Received a request to reconfigure service endpoints "
"for host %s under the wrong condition." % host.hostname)
def mgmt_mac_set_by_ihost(self, context, host, mgmt_mac):
"""Update the management mac address upon management interface
during bootstrap.
:param context: request context
:param host: an ihost object
:param mgmt_mac: mac address of management interface
"""
if (os.path.isfile(constants.ANSIBLE_BOOTSTRAP_FLAG) and
host.hostname == constants.CONTROLLER_0_HOSTNAME):
self.dbapi.ihost_update(host.uuid,
{'mgmt_mac': mgmt_mac})
else:
LOG.error("Received a request to update management mac for host "
"%s under the wrong condition." % host.hostname)

View File

@ -1770,3 +1770,16 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
return self.call(context,
self.make_msg('reconfigure_service_endpoints',
host=host))
def mgmt_mac_set_by_ihost(self, context, host, mgmt_mac):
"""Update the management mac address upon management interface
during bootstrap.
:param context: request context
:param host: an ihost object
:param mgmt_mac: mac address of management interface
"""
return self.call(context,
self.make_msg('mgmt_mac_set_by_ihost',
host=host,
mgmt_mac=mgmt_mac))