Remove mgmt_ip field from host DB table

This commit removes the mgmt_ip field from the database i_host table.
The mgmt_ip is necessary for MTCE and other calls, this value is
returned by the database now, using the address name and network type
by the function: get_address_by_host_networktype.

Test Plan:
PASS: AIO-SX installation
PASS: AIO-SX mgmt reconfiguration
PASS: AIO-DX installation
PASS: Standard installation
PASS: DC install
PASS: DC AIO-SX mgmt reconfiguration
PASS: Sanity for AIO-SX, AIO-DX, DC

Story: 2010722
Task: 49835

Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
Change-Id: I577fa51df261846292f2e9dff2aeba5fff431848
This commit is contained in:
Teresa Ho 2024-04-08 22:14:06 -04:00 committed by Fabiano Correa Mercer
parent beef51596d
commit 937449c0af
15 changed files with 107 additions and 96 deletions

View File

@ -847,10 +847,9 @@ def apply_sriov_config(db_credentials, hostname):
conn = psycopg2.connect(connection_string) conn = psycopg2.connect(connection_string)
cur = conn.cursor() cur = conn.cursor()
cur.execute( cur.execute(
"select id, mgmt_ip from i_host where hostname=%s;", (hostname,)) "select id from i_host where hostname=%s;", (hostname,))
host = cur.fetchone() host = cur.fetchone()
host_id = host[0] host_id = host[0]
mgmt_ip = host[1]
cur.execute("select id from pci_devices " cur.execute("select id from pci_devices "
"where sriov_numvfs > 0 and host_id=%s", "where sriov_numvfs > 0 and host_id=%s",
(host_id,)) (host_id,))
@ -874,7 +873,7 @@ def apply_sriov_config(db_credentials, hostname):
with open(tmpfile, 'w') as f: with open(tmpfile, 'w') as f:
yaml.dump(config, f, default_flow_style=False) yaml.dump(config, f, default_flow_style=False)
puppet_common.puppet_apply_manifest( puppet_common.puppet_apply_manifest(
mgmt_ip, personality, manifest='runtime', runtime=tmpfile) hostname, personality, manifest='runtime', runtime=tmpfile)
os.close(fd) os.close(fd)
os.remove(tmpfile) os.remove(tmpfile)

View File

@ -24,6 +24,8 @@ from controllerconfig.common import log
PLATFORM_CONF_PATH = '/etc/platform' PLATFORM_CONF_PATH = '/etc/platform'
PLATFORM_SIMPLEX_FLAG = '/etc/platform/simplex' PLATFORM_SIMPLEX_FLAG = '/etc/platform/simplex'
# TODO(fcorream) Remove UPGRADE_DO_NOT_USE_FQDN when
# upgrade from release <= 9.0 is not supported anymore
UPGRADE_DO_NOT_USE_FQDN = PLATFORM_CONF_PATH + \ UPGRADE_DO_NOT_USE_FQDN = PLATFORM_CONF_PATH + \
'/.upgrade_do_not_use_fqdn' '/.upgrade_do_not_use_fqdn'

View File

@ -869,6 +869,7 @@ class AgentManager(service.PeriodicService):
# wait for controller to come up first may be a DOR # wait for controller to come up first may be a DOR
try: try:
ihost = rpcapi.get_ihost_by_macs(icontext, host_macs) ihost = rpcapi.get_ihost_by_macs(icontext, host_macs)
except Timeout: except Timeout:
if not rpc_timeout: if not rpc_timeout:
rpc_timeout = True rpc_timeout = True

View File

@ -105,7 +105,7 @@ LOG = log.getLogger(__name__)
KEYRING_BM_SERVICE = "BM" KEYRING_BM_SERVICE = "BM"
ERR_CODE_LOCK_SOLE_SERVICE_PROVIDER = "-1003" ERR_CODE_LOCK_SOLE_SERVICE_PROVIDER = "-1003"
HOST_XML_ATTRIBUTES = ['hostname', 'personality', 'subfunctions', 'mgmt_mac', HOST_XML_ATTRIBUTES = ['hostname', 'personality', 'subfunctions', 'mgmt_mac',
'mgmt_ip', 'bm_ip', 'bm_type', 'bm_username', 'bm_ip', 'bm_type', 'bm_username',
'bm_password', 'boot_device', 'rootfs_device', 'bm_password', 'boot_device', 'rootfs_device',
'hw_settle', 'install_output', 'console', 'hw_settle', 'install_output', 'console',
'vsc_controllers', 'power_on', 'location', 'apparmor', 'vsc_controllers', 'power_on', 'location', 'apparmor',
@ -198,6 +198,7 @@ class HostStatesController(rest.RestController):
"""List or update the state of a ihost.""" """List or update the state of a ihost."""
ihost = objects.host.get_by_uuid(pecan.request.context, ihost = objects.host.get_by_uuid(pecan.request.context,
ihost_id) ihost_id)
ihost['mgmt_ip'] = utils.get_mgmt_ip(ihost.hostname)
state = HostStates.convert_with_links(ihost) state = HostStates.convert_with_links(ihost)
return state return state
@ -1263,6 +1264,7 @@ class HostController(rest.RestController):
for h in ihosts: for h in ihosts:
self._update_controller_personality(h) self._update_controller_personality(h)
self._update_host_mgmt_ip(self, h)
return ihosts return ihosts
@ -1301,6 +1303,13 @@ class HostController(rest.RestController):
activity = 'Controller-Standby' activity = 'Controller-Standby'
host['capabilities'].update({'Personality': activity}) host['capabilities'].update({'Personality': activity})
@staticmethod
def _update_host_mgmt_ip(self, host):
try:
host['mgmt_ip'] = utils.get_mgmt_ip(host.hostname)
except exception.AddressNotFoundByName:
host['mgmt_ip'] = None
@wsme_pecan.wsexpose(HostCollection, six.text_type, six.text_type, int, six.text_type, @wsme_pecan.wsexpose(HostCollection, six.text_type, six.text_type, int, six.text_type,
six.text_type, six.text_type) six.text_type, six.text_type)
def get_all(self, isystem_id=None, marker=None, limit=None, def get_all(self, isystem_id=None, marker=None, limit=None,
@ -1356,8 +1365,6 @@ class HostController(rest.RestController):
ihost_obj = pecan.request.dbapi.ihost_get_by_mgmt_mac(mac) ihost_obj = pecan.request.dbapi.ihost_get_by_mgmt_mac(mac)
if ihost_obj['hostname']: if ihost_obj['hostname']:
hostname = ihost_obj['hostname'] hostname = ihost_obj['hostname']
mgmt_addr = ihost_obj['mgmt_ip']
if mgmt_addr is None:
address_name = cutils.format_address_name(hostname, address_name = cutils.format_address_name(hostname,
constants.NETWORK_TYPE_MGMT) constants.NETWORK_TYPE_MGMT)
address = utils.get_primary_address_by_name(address_name, address = utils.get_primary_address_by_name(address_name,
@ -1443,6 +1450,7 @@ class HostController(rest.RestController):
rpc_ihost = objects.host.get_by_uuid(pecan.request.context, rpc_ihost = objects.host.get_by_uuid(pecan.request.context,
uuid) uuid)
self._update_controller_personality(rpc_ihost) self._update_controller_personality(rpc_ihost)
self._update_host_mgmt_ip(self, rpc_ihost)
return Host.convert_with_links(rpc_ihost) return Host.convert_with_links(rpc_ihost)
@ -1475,22 +1483,6 @@ class HostController(rest.RestController):
self._block_add_host_semantic_checks(ihost_dict) self._block_add_host_semantic_checks(ihost_dict)
mgmt_network = pecan.request.dbapi.network_get_by_type(
constants.NETWORK_TYPE_MGMT)
if mgmt_network.dynamic and ihost_dict.get('mgmt_ip'):
raise wsme.exc.ClientSideError(_(
"Host-add Rejected: Cannot specify a mgmt_ip when dynamic "
"address allocation is configured"))
elif (not mgmt_network.dynamic and
not ihost_dict.get('mgmt_ip') and
ihost_dict.get('personality') not in
[constants.STORAGE, constants.CONTROLLER]):
raise wsme.exc.ClientSideError(_(
"Host-add Rejected: Cannot add a worker host without "
"specifying a mgmt_ip when static address allocation is "
"configured."))
# Check whether vsc_controllers is set and perform semantic # Check whether vsc_controllers is set and perform semantic
# checking if necessary. # checking if necessary.
if ihost_dict['vsc_controllers']: if ihost_dict['vsc_controllers']:
@ -1552,11 +1544,6 @@ class HostController(rest.RestController):
if ihost_dict['hostname'] in hostnames: if ihost_dict['hostname'] in hostnames:
raise wsme.exc.ClientSideError( raise wsme.exc.ClientSideError(
_("Host-add Rejected: Hostname already exists")) _("Host-add Rejected: Hostname already exists"))
if ihost_dict.get('mgmt_ip') and ihost_dict['mgmt_ip'] in \
[h['mgmt_ip'] for h in current_ihosts]:
raise wsme.exc.ClientSideError(
_("Host-add Rejected: Host with mgmt_ip %s already "
"exists") % ihost_dict['mgmt_ip'])
try: try:
ihost_obj = pecan.request.dbapi.ihost_get_by_mgmt_mac( ihost_obj = pecan.request.dbapi.ihost_get_by_mgmt_mac(
@ -1663,19 +1650,6 @@ class HostController(rest.RestController):
if ihost_dict['personality'] in (constants.CONTROLLER, constants.STORAGE): if ihost_dict['personality'] in (constants.CONTROLLER, constants.STORAGE):
self._controller_storage_node_setup(ihost_dict) self._controller_storage_node_setup(ihost_dict)
# Validate that management name and IP do not already exist
# If one exists, other value must match in addresses table
mgmt_address_name = cutils.format_address_name(
ihost_dict['hostname'], constants.NETWORK_TYPE_MGMT)
self._validate_address_not_allocated(mgmt_address_name,
ihost_dict.get('mgmt_ip'),
constants.NETWORK_TYPE_MGMT)
if ihost_dict.get('mgmt_ip'):
self._validate_ip_in_mgmt_network(ihost_dict['mgmt_ip'])
else:
del ihost_dict['mgmt_ip']
# Set host to reinstalling # Set host to reinstalling
ihost_dict.update({constants.HOST_ACTION_STATE: ihost_dict.update({constants.HOST_ACTION_STATE:
constants.HAS_REINSTALLING}) constants.HAS_REINSTALLING})
@ -1719,6 +1693,7 @@ class HostController(rest.RestController):
# Add ihost to mtc # Add ihost to mtc
new_ihost_mtc = ihost_obj.as_dict() new_ihost_mtc = ihost_obj.as_dict()
new_ihost_mtc.update({'operation': 'add'}) new_ihost_mtc.update({'operation': 'add'})
new_ihost_mtc['mgmt_ip'] = address.address
new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc) new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc)
mtc_response = mtce_api.host_add( mtc_response = mtce_api.host_add(
@ -1743,7 +1718,6 @@ class HostController(rest.RestController):
new_ihost_mtc.update({'action': constants.POWERON_ACTION}) new_ihost_mtc.update({'action': constants.POWERON_ACTION})
mtc_response = {'status': None} mtc_response = {'status': None}
mtc_response = mtce_api.host_modify( mtc_response = mtce_api.host_modify(
self._api_token, self._mtc_address, self._mtc_port, new_ihost_mtc, self._api_token, self._mtc_address, self._mtc_port, new_ihost_mtc,
constants.MTC_ADD_TIMEOUT_IN_SECS) constants.MTC_ADD_TIMEOUT_IN_SECS)
@ -2316,9 +2290,6 @@ class HostController(rest.RestController):
pecan.request.dbapi.ihost_update( pecan.request.dbapi.ihost_update(
ihost_obj['uuid'], {'capabilities': ihost_obj['capabilities']}) ihost_obj['uuid'], {'capabilities': ihost_obj['capabilities']})
# Notify maintenance about updated mgmt_ip
ihost_obj['mgmt_ip'] = self._get_mgmt_ip(ihost_obj.hostname)
hostupdate.notify_mtce = True hostupdate.notify_mtce = True
# Evaluate app reapply on lock/unlock/swact/reinstall # Evaluate app reapply on lock/unlock/swact/reinstall
@ -2350,9 +2321,6 @@ class HostController(rest.RestController):
LOG.info("%s Action %s perform notify_mtce" % LOG.info("%s Action %s perform notify_mtce" %
(hostupdate.displayid, myaction)) (hostupdate.displayid, myaction))
# Notify maintenance about updated mgmt_ip
ihost_obj['mgmt_ip'] = self._get_mgmt_ip(ihost_obj.hostname)
new_ihost_mtc = ihost_obj.as_dict() new_ihost_mtc = ihost_obj.as_dict()
new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc) new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc)
@ -2371,6 +2339,9 @@ class HostController(rest.RestController):
elif myaction == constants.FORCE_UNLOCK_ACTION: elif myaction == constants.FORCE_UNLOCK_ACTION:
new_ihost_mtc['action'] = constants.UNLOCK_ACTION new_ihost_mtc['action'] = constants.UNLOCK_ACTION
# Notify maintenance about updated mgmt_ip
new_ihost_mtc['mgmt_ip'] = utils.get_mgmt_ip(ihost_obj.hostname)
if new_ihost_mtc['operation'] == 'add': if new_ihost_mtc['operation'] == 'add':
# Evaluate apps reapply on new host # Evaluate apps reapply on new host
pecan.request.rpcapi.evaluate_apps_reapply( pecan.request.rpcapi.evaluate_apps_reapply(
@ -3170,6 +3141,7 @@ class HostController(rest.RestController):
new_ihost_mtc.update({'operation': 'modify'}) new_ihost_mtc.update({'operation': 'modify'})
new_ihost_mtc.update({'action': constants.REINSTALL_ACTION}) new_ihost_mtc.update({'action': constants.REINSTALL_ACTION})
new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc) new_ihost_mtc = cutils.removekeys_nonmtce(new_ihost_mtc)
new_ihost_mtc['mgmt_ip'] = utils.get_mgmt_ip(rpc_ihost.hostname)
mtc_response = mtce_api.host_modify( mtc_response = mtce_api.host_modify(
self._api_token, self._mtc_address, self._mtc_port, self._api_token, self._mtc_address, self._mtc_port,

View File

@ -41,6 +41,7 @@ from sysinv.common import constants
from sysinv.common import exception from sysinv.common import exception
from sysinv.common import health from sysinv.common import health
from sysinv.common import usm_service as usm_service from sysinv.common import usm_service as usm_service
from sysinv.common import utils as cutils
from sysinv.helm import common as helm_common from sysinv.helm import common as helm_common
@ -1105,3 +1106,16 @@ def get_primary_address_by_name(db_address_name, networktype, raise_exc=False):
if not address and raise_exc: if not address and raise_exc:
raise exception.AddressNotFoundByName(name=db_address_name) raise exception.AddressNotFoundByName(name=db_address_name)
return address return address
def get_mgmt_ip(hostname):
# During mgmt network reconfiguration, do not change the mgmt IP
# in maintencance as it will be updated after the unlock.
if os.path.isfile(tsc.MGMT_NETWORK_RECONFIGURATION_ONGOING):
return cutils.gethostbyname(constants.CONTROLLER_0_FQDN)
else:
address_name = cutils.format_address_name(hostname,
constants.NETWORK_TYPE_MGMT)
address = get_primary_address_by_name(address_name,
constants.NETWORK_TYPE_MGMT, True)
return address.address

View File

@ -3707,7 +3707,6 @@ class ConductorManager(service.PeriodicService):
addresses = self.dbapi.address_get_by_name(addr_name) addresses = self.dbapi.address_get_by_name(addr_name)
for address in addresses: for address in addresses:
self.dbapi.address_update(address['uuid'], values) self.dbapi.address_update(address['uuid'], values)
# Do any potential distributed cloud config # Do any potential distributed cloud config
# We do this here where the interface is created. # We do this here where the interface is created.
cutils.perform_distributed_cloud_config(self.dbapi, cutils.perform_distributed_cloud_config(self.dbapi,
@ -3715,7 +3714,6 @@ class ConductorManager(service.PeriodicService):
ihost) ihost)
if port: if port:
values = {'interface_id': port.interface_id} values = {'interface_id': port.interface_id}
addr_name = cutils.format_address_name(ihost.hostname, addr_name = cutils.format_address_name(ihost.hostname,
networktype) networktype)
addresses = self.dbapi.address_get_by_name(addr_name) addresses = self.dbapi.address_get_by_name(addr_name)
@ -6693,7 +6691,14 @@ class ConductorManager(service.PeriodicService):
for host in ihosts: for host in ihosts:
if host.mgmt_mac == mac: if host.mgmt_mac == mac:
LOG.info("Host found ihost db for macs: %s" % host.hostname) # TODO(fcorream): for backward compatibility the
# mgmt_ip is added to ihost.
# remove it when upgrade from Release <= 9.0
# is not supported anymore
host.mgmt_ip = self.get_address_by_host_networktype(
context, host.hostname, constants.NETWORK_TYPE_MGMT)
LOG.debug("Host found ihost db for macs: %s %s" %
(host.hostname, host.mgmt_ip))
return host return host
LOG.debug("RPC get_ihost_by_macs called but found no ihost.") LOG.debug("RPC get_ihost_by_macs called but found no ihost.")
@ -6710,7 +6715,14 @@ class ConductorManager(service.PeriodicService):
try: try:
ihost = self.dbapi.ihost_get_by_hostname(ihost_hostname) ihost = self.dbapi.ihost_get_by_hostname(ihost_hostname)
# TODO(fcorream): for backward compatibility the
# mgmt_ip is added to ihost.
# remove it when upgrade from Release <= 9.0
# is not supported anymore
ihost.mgmt_ip = self.get_address_by_host_networktype(
context, ihost.hostname, constants.NETWORK_TYPE_MGMT)
LOG.debug("Host found ihost db for hostname: %s %s" %
(ihost.hostname, ihost.mgmt_ip))
return ihost return ihost
except exception.NodeNotFound: except exception.NodeNotFound:

View File

@ -138,7 +138,6 @@ class Connection(object):
'uuid': uuidutils.generate_uuid(), 'uuid': uuidutils.generate_uuid(),
'invprovision': 'provisioned', 'invprovision': 'provisioned',
'mgmt_mac': '01:34:67:9A:CD:FE', 'mgmt_mac': '01:34:67:9A:CD:FE',
'mgmt_ip': '192.168.24.11',
'provision_state': states.NOSTATE, 'provision_state': states.NOSTATE,
'administrative': 'locked', 'administrative': 'locked',
'operational': 'disabled', 'operational': 'disabled',

View File

@ -0,0 +1,32 @@
#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from sqlalchemy import Column, MetaData, Table
ENGINE = 'InnoDB'
CHARSET = 'utf8'
def upgrade(migrate_engine):
"""
This database upgrade removes unused attributes
from i_host table.
"""
meta = MetaData()
meta.bind = migrate_engine
host_table = Table('i_host', meta, autoload=True)
host_table.drop_column(Column('mgmt_ip'))
return True
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
# Downgrade is unsupported.
raise NotImplementedError('SysInv database downgrade is unsupported.')

View File

@ -195,7 +195,6 @@ class ihost(Base):
# MAC 01:34:67:9A:CD:FG (need 16 bytes; convention here String(255)) # MAC 01:34:67:9A:CD:FG (need 16 bytes; convention here String(255))
mgmt_mac = Column(String(255), unique=True) mgmt_mac = Column(String(255), unique=True)
mgmt_ip = Column(String(255))
sw_version = Column(String(128)) sw_version = Column(String(128))

View File

@ -124,6 +124,10 @@ class Host(base.SysinvObject):
'target_load': _get_target_load 'target_load': _get_target_load
} }
_optional_fields = {
'mgmt_ip': utils.str_or_none
}
@base.remotable_classmethod @base.remotable_classmethod
def get_by_uuid(cls, context, uuid): def get_by_uuid(cls, context, uuid):
return cls.dbapi.ihost_get(uuid) return cls.dbapi.ihost_get(uuid)

View File

@ -45,7 +45,7 @@ class LdapPuppet(base.BasePuppet):
def _is_openldap_certificate_created(self): def _is_openldap_certificate_created(self):
""" Returns True when it's safe to read the openldap certificate. """ Returns True when it's safe to read the openldap certificate.
""" """
# TODO<fcorream>: Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG # TODO(fcorream): Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG
# just needed for upgrade to R9 ( 24.09 ) # just needed for upgrade to R9 ( 24.09 )
is_upgrading = utils.is_upgrade_in_progress(self.dbapi)[0] is_upgrading = utils.is_upgrade_in_progress(self.dbapi)[0]

View File

@ -109,7 +109,7 @@ class OpenstackBasePuppet(base.BasePuppet):
# to add networks etc during ansible bootstrap will fail as # to add networks etc during ansible bootstrap will fail as
# haproxy has not been configured yet. # haproxy has not been configured yet.
# TODO<fcorream>: Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG # TODO(fcorream): Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG
# just needed for upgrade to R9 # just needed for upgrade to R9
is_upgrading = cutils.is_upgrade_in_progress(self.dbapi)[0] is_upgrading = cutils.is_upgrade_in_progress(self.dbapi)[0]

View File

@ -966,7 +966,7 @@ class PlatformPuppet(base.BasePuppet):
def _get_dc_root_ca_config(self): def _get_dc_root_ca_config(self):
config = {} config = {}
system = self._get_system() system = self._get_system()
# TODO<fcorream>: Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG # TODO(fcorream): Remove OLD_ANSIBLE_BOOTSTRAP_COMPLETED_FLAG
# just needed for upgrade to R9 # just needed for upgrade to R9
is_upgrading = utils.is_upgrade_in_progress(self.dbapi)[0] is_upgrading = utils.is_upgrade_in_progress(self.dbapi)[0]

View File

@ -623,17 +623,14 @@ class ManagerTestCase(base.DbTestCase):
return ihost return ihost
def test_create_ihost(self): def test_create_ihost(self):
ihost_dict = {'mgmt_mac': '00:11:22:33:44:55', ihost_dict = {'mgmt_mac': '00:11:22:33:44:55'}
'mgmt_ip': '1.2.3.4'}
self.service.start() self.service.start()
res = self.service.create_ihost(self.context, ihost_dict) res = self.service.create_ihost(self.context, ihost_dict)
self.assertEqual(res['mgmt_mac'], '00:11:22:33:44:55') self.assertEqual(res['mgmt_mac'], '00:11:22:33:44:55')
self.assertEqual(res['mgmt_ip'], '1.2.3.4')
def test_create_duplicate_ihost(self): def test_create_duplicate_ihost(self):
ihost_dict = {'mgmt_mac': '00:11:22:33:44:55', ihost_dict = {'mgmt_mac': '00:11:22:33:44:55'}
'mgmt_ip': '1.2.3.4'}
self.service.start() self.service.start()
# Create first ihost # Create first ihost
@ -649,7 +646,7 @@ class ManagerTestCase(base.DbTestCase):
self.assertEqual(res1['serialid'], res2['serialid']) self.assertEqual(res1['serialid'], res2['serialid'])
def test_create_ihost_without_mac(self): def test_create_ihost_without_mac(self):
ihost_dict = {'mgmt_ip': '1.2.3.4'} ihost_dict = {}
self.assertRaises(exception.SysinvException, self.assertRaises(exception.SysinvException,
self.service.create_ihost, self.service.create_ihost,
@ -684,7 +681,6 @@ class ManagerTestCase(base.DbTestCase):
def test_create_ihost_with_values(self): def test_create_ihost_with_values(self):
ihost_dict = {'mgmt_mac': '00:11:22:33:44:55', ihost_dict = {'mgmt_mac': '00:11:22:33:44:55',
'mgmt_ip': '1.2.3.4',
'hostname': 'newhost', 'hostname': 'newhost',
'invprovision': 'unprovisioned', 'invprovision': 'unprovisioned',
'personality': 'worker', 'personality': 'worker',
@ -778,7 +774,6 @@ class ManagerTestCase(base.DbTestCase):
ihost = self._create_test_ihost() ihost = self._create_test_ihost()
ihost['mgmt_mac'] = '00:11:22:33:44:55' ihost['mgmt_mac'] = '00:11:22:33:44:55'
ihost['mgmt_ip'] = '1.2.3.4'
ihost['hostname'] = 'newhost' ihost['hostname'] = 'newhost'
ihost['invprovision'] = 'unprovisioned' ihost['invprovision'] = 'unprovisioned'
ihost['personality'] = 'worker' ihost['personality'] = 'worker'
@ -796,7 +791,6 @@ class ManagerTestCase(base.DbTestCase):
res = self.service.update_ihost(self.context, ihost) res = self.service.update_ihost(self.context, ihost)
self.assertEqual(res['mgmt_mac'], '00:11:22:33:44:55') self.assertEqual(res['mgmt_mac'], '00:11:22:33:44:55')
self.assertEqual(res['mgmt_ip'], '1.2.3.4')
self.assertEqual(res['hostname'], 'newhost') self.assertEqual(res['hostname'], 'newhost')
self.assertEqual(res['invprovision'], 'unprovisioned') self.assertEqual(res['invprovision'], 'unprovisioned')
self.assertEqual(res['personality'], 'worker') self.assertEqual(res['personality'], 'worker')
@ -841,7 +835,6 @@ class ManagerTestCase(base.DbTestCase):
ihost = self._create_test_ihost() ihost = self._create_test_ihost()
ihost['mgmt_mac'] = '00:11:22:33:44:55' ihost['mgmt_mac'] = '00:11:22:33:44:55'
ihost['mgmt_ip'] = '1.2.3.4'
ihost['hostname'] = 'newhost' ihost['hostname'] = 'newhost'
ihost['invprovision'] = 'unprovisioned' ihost['invprovision'] = 'unprovisioned'
ihost['personality'] = 'worker' ihost['personality'] = 'worker'
@ -879,7 +872,6 @@ class ManagerTestCase(base.DbTestCase):
ihost = self._create_test_ihost() ihost = self._create_test_ihost()
ihost['mgmt_mac'] = '00:11:22:33:44:55' ihost['mgmt_mac'] = '00:11:22:33:44:55'
ihost['mgmt_ip'] = '1.2.3.42'
ihost['hostname'] = 'newhost' ihost['hostname'] = 'newhost'
ihost['invprovision'] = 'unprovisioned' ihost['invprovision'] = 'unprovisioned'
ihost['personality'] = 'worker' ihost['personality'] = 'worker'
@ -1465,7 +1457,6 @@ class ManagerTestCase(base.DbTestCase):
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:56', mgmt_mac='00:11:22:33:44:56',
mgmt_ip='1.2.3.5',
) )
# Speed up the test # Speed up the test
@ -1684,7 +1675,6 @@ class ManagerTestCase(base.DbTestCase):
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_mac='00:11:22:33:44:55',
mgmt_ip='1.2.3.4',
) )
# Set the target version for controller-0 # Set the target version for controller-0
self.dbapi.kube_host_upgrade_update(1, {'target_version': 'v1.42.2'}) self.dbapi.kube_host_upgrade_update(1, {'target_version': 'v1.42.2'})
@ -1911,7 +1901,6 @@ class ManagerTestCase(base.DbTestCase):
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:56', mgmt_mac='00:11:22:33:44:56',
mgmt_ip='1.2.3.5',
) )
# Set the target version for controller-1 # Set the target version for controller-1
self.dbapi.kube_host_upgrade_update(2, {'target_version': 'v1.42.2'}) self.dbapi.kube_host_upgrade_update(2, {'target_version': 'v1.42.2'})
@ -2003,7 +1992,6 @@ class ManagerTestCase(base.DbTestCase):
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_mac='00:11:22:33:44:55',
mgmt_ip='1.2.3.4',
) )
# Set the target version for controller-0 # Set the target version for controller-0
self.dbapi.kube_host_upgrade_update(1, {'target_version': 'v1.42.2'}) self.dbapi.kube_host_upgrade_update(1, {'target_version': 'v1.42.2'})
@ -2021,7 +2009,6 @@ class ManagerTestCase(base.DbTestCase):
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:56', mgmt_mac='00:11:22:33:44:56',
mgmt_ip='1.2.3.5',
) )
# Set the target version for controller-1 # Set the target version for controller-1
self.dbapi.kube_host_upgrade_update(2, {'target_version': 'v1.42.2'}) self.dbapi.kube_host_upgrade_update(2, {'target_version': 'v1.42.2'})
@ -2671,7 +2658,6 @@ class ManagerTestCase(base.DbTestCase):
config_applied=config_applied, config_applied=config_applied,
config_target=config_target) config_target=config_target)
ihost['mgmt_mac'] = '00:11:22:33:44:55' ihost['mgmt_mac'] = '00:11:22:33:44:55'
ihost['mgmt_ip'] = '1.2.3.42'
ihost['hostname'] = hostname ihost['hostname'] = hostname
ihost['invprovision'] = 'provisioned' ihost['invprovision'] = 'provisioned'
ihost['personality'] = 'controller' ihost['personality'] = 'controller'
@ -2925,8 +2911,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_mac='00:11:22:33:44:55')
mgmt_ip='1.2.3.4')
# Create controller-1 # Create controller-1
config_uuid = str(uuid.uuid4()) config_uuid = str(uuid.uuid4())
self._create_test_ihost( self._create_test_ihost(
@ -2940,8 +2925,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='22:44:33:55:11:66', mgmt_mac='22:44:33:55:11:66')
mgmt_ip='1.2.3.5')
# Create compute-0 # Create compute-0
config_uuid = str(uuid.uuid4()) config_uuid = str(uuid.uuid4())
self._create_test_ihost( self._create_test_ihost(
@ -2955,8 +2939,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='22:44:33:55:11:77', mgmt_mac='22:44:33:55:11:77')
mgmt_ip='1.2.3.6')
def _create_test_iports(self): def _create_test_iports(self):
enp25s0f0 = {'dev_id': 0, 'numa_node': 0, 'sriov_numvfs': 0, 'sriov_vfs_pci_address': '', enp25s0f0 = {'dev_id': 0, 'numa_node': 0, 'sriov_numvfs': 0, 'sriov_vfs_pci_address': '',
@ -3079,7 +3062,6 @@ class ManagerTestCase(base.DbTestCase):
ihost_hostname = 'controller-1' ihost_hostname = 'controller-1'
ihost = self.service.get_ihost_by_hostname(self.context, ihost_hostname) ihost = self.service.get_ihost_by_hostname(self.context, ihost_hostname)
self.assertEqual(ihost.mgmt_mac, '22:44:33:55:11:66') self.assertEqual(ihost.mgmt_mac, '22:44:33:55:11:66')
self.assertEqual(ihost.mgmt_ip, '1.2.3.5')
self.assertEqual(ihost.hostname, 'controller-1') self.assertEqual(ihost.hostname, 'controller-1')
def test_get_ihost_by_hostname_invalid_name(self): def test_get_ihost_by_hostname_invalid_name(self):
@ -3312,7 +3294,7 @@ class ManagerTestCase(base.DbTestCase):
config_status=None, config_applied=config_uuid, config_target=config_uuid, config_status=None, config_applied=config_uuid, config_target=config_uuid,
invprovision=constants.PROVISIONED, administrative=constants.ADMIN_UNLOCKED, invprovision=constants.PROVISIONED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, availability=constants.AVAILABILITY_ONLINE, operational=constants.OPERATIONAL_ENABLED, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_ip='1.2.3.4') mgmt_mac='00:11:22:33:44:55')
self._create_test_networks(mgmt_vlan_id) self._create_test_networks(mgmt_vlan_id)
mock_find_local_mgmt_interface_vlan_id = mock.MagicMock() mock_find_local_mgmt_interface_vlan_id = mock.MagicMock()
@ -5320,8 +5302,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_mac='00:11:22:33:44:55')
mgmt_ip='1.2.3.4')
ihost = self.service.get_ihost_by_hostname(self.context, ihost = self.service.get_ihost_by_hostname(self.context,
ihost_hostname) ihost_hostname)
@ -5371,8 +5352,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='00:11:22:33:44:55', mgmt_mac='00:11:22:33:44:55')
mgmt_ip='1.2.3.4')
# Create controller-1 # Create controller-1
ihost_hostname1 = 'controller-1' ihost_hostname1 = 'controller-1'
@ -5389,8 +5369,7 @@ class ManagerTestCase(base.DbTestCase):
administrative=constants.ADMIN_UNLOCKED, administrative=constants.ADMIN_UNLOCKED,
operational=constants.OPERATIONAL_ENABLED, operational=constants.OPERATIONAL_ENABLED,
availability=constants.AVAILABILITY_ONLINE, availability=constants.AVAILABILITY_ONLINE,
mgmt_mac='22:44:33:55:11:66', mgmt_mac='22:44:33:55:11:66')
mgmt_ip='1.2.3.5')
# before - no alarm # before - no alarm
self.assertFalse(self._is_kernel_alarm_raised(alarm_id, self.assertFalse(self._is_kernel_alarm_raised(alarm_id,

View File

@ -129,8 +129,6 @@ def get_test_ihost(**kw):
'invprovision': kw.get('invprovision', 'unprovisioned'), 'invprovision': kw.get('invprovision', 'unprovisioned'),
'mgmt_mac': kw.get('mgmt_mac', 'mgmt_mac': kw.get('mgmt_mac',
'01:34:67:9A:CD:FE'), '01:34:67:9A:CD:FE'),
'mgmt_ip': kw.get('mgmt_ip',
'192.168.24.11'),
'personality': kw.get('personality', 'controller'), 'personality': kw.get('personality', 'controller'),
'administrative': kw.get('administrative', 'locked'), 'administrative': kw.get('administrative', 'locked'),
'operational': kw.get('operational', 'disabled'), 'operational': kw.get('operational', 'disabled'),