diff --git a/controllerconfig/controllerconfig/scripts/controller_config b/controllerconfig/controllerconfig/scripts/controller_config index 17f4ff1fef..3e9fb964ea 100755 --- a/controllerconfig/controllerconfig/scripts/controller_config +++ b/controllerconfig/controllerconfig/scripts/controller_config @@ -652,11 +652,11 @@ start() # Apply the puppet manifest HIERADATA_PATH=${PUPPET_CACHE}/hieradata - HOST_HIERA=${HIERADATA_PATH}/${IPADDR}.yaml + HOST_HIERA=${HIERADATA_PATH}/${HOST}.yaml if [ -f ${HOST_HIERA} ]; then echo "$0: Running puppet manifest apply" - puppet-manifest-apply.sh ${HIERADATA_PATH} ${IPADDR} ${subfunction} + puppet-manifest-apply.sh ${HIERADATA_PATH} ${HOST} ${subfunction} RC=$? if [ $RC -ne 0 ] then diff --git a/storageconfig/storageconfig/storage_config b/storageconfig/storageconfig/storage_config index 2051989c7a..12a02bc5de 100644 --- a/storageconfig/storageconfig/storage_config +++ b/storageconfig/storageconfig/storage_config @@ -165,10 +165,10 @@ start() fi # Apply the puppet manifest - HOST_HIERA=${PUPPET_PATH}/hieradata/${IPADDR}.yaml + HOST_HIERA=${PUPPET_PATH}/hieradata/${HOST}.yaml if [ -f ${HOST_HIERA} ]; then echo "$0: Running puppet manifest apply" - puppet-manifest-apply.sh ${PUPPET_PATH}/hieradata ${IPADDR} storage + puppet-manifest-apply.sh ${PUPPET_PATH}/hieradata ${HOST} storage RC=$? if [ $RC -ne 0 ]; then @@ -177,7 +177,7 @@ start() fi else umount $PLATFORM_DIR - fatal_error "Host configuration not yet available for this node ($(hostname)=${IPADDR}); aborting configuration." + fatal_error "Host configuration not yet available for this node ($(hostname)=${HOST}); aborting configuration." fi # Unmount diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost.py b/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost.py index 22d439ef48..700b48247a 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/tests/v1/test_ihost.py @@ -30,7 +30,6 @@ IHOST = {'id': 123, 'hostname': 'cgtshost', 'personality': 'controller', 'mgmt_mac': '11:22:33:44:55:66', - 'mgmt_ip': '192.168.24.11', 'serialid': 'sn123456', 'location': {'City': 'Ottawa'}, 'boot_device': 'sda', diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py b/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py index e976d8a664..5eb21a69fb 100755 --- a/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/v1/iHost_shell.py @@ -28,7 +28,7 @@ def _print_ihost_show(ihost, columns=None, output_format=None): else: fields = ['id', 'uuid', 'personality', 'hostname', 'invprovision', 'administrative', 'operational', 'availability', 'task', - 'action', 'mgmt_mac', 'mgmt_ip', 'serialid', 'capabilities', + 'action', 'mgmt_mac', 'serialid', 'capabilities', 'bm_type', 'bm_username', 'bm_ip', 'config_applied', 'config_target', 'config_status', 'location', 'uptime', 'reserved', 'created_at', 'updated_at', 'boot_device', @@ -169,10 +169,6 @@ def do_kube_host_upgrade_list(cc, args): @utils.arg('-m', '--mgmt_mac', metavar='', help='MAC Address of the host mgmt interface [REQUIRED]') -@utils.arg('-i', '--mgmt_ip', - metavar='', - help='IP Address of the host mgmt interface (when using static ' - 'address allocation)') @utils.arg('-I', '--bm_ip', metavar='', help="IP Address of the host board management interface, " @@ -220,7 +216,7 @@ def do_kube_host_upgrade_list(cc, args): def do_host_add(cc, args): """Add a new host.""" field_list = ['hostname', 'personality', 'subfunctions', 'mgmt_mac', - 'mgmt_ip', 'bm_ip', 'bm_type', 'bm_username', 'bm_password', + 'bm_ip', 'bm_type', 'bm_username', 'bm_password', 'boot_device', 'rootfs_device', 'hw_settle', 'install_output', 'console', 'vsc_controllers', 'location', 'ttys_dcd', 'clock_synchronization'] diff --git a/sysinv/cgts-client/cgts-client/cgtsclient/v1/ihost.py b/sysinv/cgts-client/cgts-client/cgtsclient/v1/ihost.py index 3b8e0463b6..3bb2207729 100644 --- a/sysinv/cgts-client/cgts-client/cgtsclient/v1/ihost.py +++ b/sysinv/cgts-client/cgts-client/cgtsclient/v1/ihost.py @@ -14,7 +14,7 @@ from cgtsclient.v1 import icpu CREATION_ATTRIBUTES = ['hostname', 'personality', 'subfunctions', 'mgmt_mac', - 'mgmt_ip', 'bm_ip', 'bm_type', 'bm_username', + 'bm_ip', 'bm_type', 'bm_username', 'bm_password', 'serialid', 'location', 'boot_device', 'rootfs_device', 'hw_settle', 'install_output', 'console', 'tboot', 'vsc_controllers', 'ttys_dcd', diff --git a/sysinv/sysinv/sysinv/sysinv/agent/manager.py b/sysinv/sysinv/sysinv/sysinv/agent/manager.py index 4c2c97d43f..f551c57c07 100644 --- a/sysinv/sysinv/sysinv/sysinv/agent/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/agent/manager.py @@ -214,6 +214,7 @@ class AgentManager(service.PeriodicService): self._ihost_rootfs_device = "" self._agent_throttle = 0 self._mgmt_ip = None + self._hostname = None self._prev_disk = None self._prev_partition = None self._prev_lvg = None @@ -833,6 +834,7 @@ class AgentManager(service.PeriodicService): """ ihost = None + mgmt_addr = None rpcapi = conductor_rpcapi.ConductorAPI( topic=conductor_rpcapi.MANAGER_TOPIC) @@ -848,7 +850,21 @@ class AgentManager(service.PeriodicService): while (timeutils.utcnow() - wait_time).total_seconds() < MAXSLEEP: # wait for controller to come up first may be a DOR try: - ihost = rpcapi.get_ihost_by_macs(icontext, host_macs) + ihost, mgmt_addr = rpcapi.get_ihost_by_macs(icontext, host_macs) + except ValueError: + # Retry because the N-1 host does not support the mgmt_addr + # parameter during upgrade + try: + ihost = rpcapi.get_ihost_by_macs(icontext, host_macs) + except Timeout: + if not rpc_timeout: + rpc_timeout = True + LOG.info("get_ihost_by_macs rpc Timeout.") + time.sleep(5) # avoid calling timedout RPC in sequence + continue + except Exception: + LOG.warn("Conductor RPC get_ihost_by_macs exception " + "response") except Timeout: if not rpc_timeout: rpc_timeout = True @@ -877,11 +893,25 @@ class AgentManager(service.PeriodicService): if ihost: ipersonality = ihost.get('personality') or "" + if not mgmt_addr: + try: + mgmt_addr = rpcapi.get_address_by_host_networktype( + icontext, ihost.get('hostname'), constants.NETWORK_TYPE_MGMT) + except Timeout: + if not rpc_timeout: + rpc_timeout = True + LOG.info("get_address_by_host_networktype rpc Timeout.") + time.sleep(5) # avoid calling timedout RPC in sequence + continue + except Exception as ex: + LOG.warn("Conductor RPC get_address_by_host_networktype " + "exception response %s" % ex) if ihost and ipersonality: self._ihost_uuid = ihost['uuid'] self._ihost_personality = ihost['personality'] - self._mgmt_ip = ihost['mgmt_ip'] + self._mgmt_ip = mgmt_addr + self._hostname = ihost['hostname'] self._ihost_rootfs_device = ihost['rootfs_device'] # new fields in ihost: cstates_available and min_cpu_mhz_allowed # TODO: These checks are only required for upgrade from version stx8.0. @@ -2010,7 +2040,7 @@ class AgentManager(service.PeriodicService): with open(tmpfile, 'w') as f: yaml.dump(config, f, default_flow_style=False) - puppet.puppet_apply_manifest(self._mgmt_ip, + puppet.puppet_apply_manifest(self._hostname, personality, 'runtime', tmpfile, hieradata_path=hieradata_path) diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py index 52cc03720d..0c8f9c356a 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/host.py @@ -1581,11 +1581,13 @@ class HostController(rest.RestController): pecan.request.dbapi.network_get_by_type(constants.NETWORK_TYPE_MGMT) # Configure the new ihost - ihost_ret = pecan.request.rpcapi.configure_ihost(pecan.request.context, - ihost_obj) + pecan.request.rpcapi.configure_ihost(pecan.request.context, ihost_obj) # Notify maintenance about updated mgmt_ip - ihost_obj['mgmt_ip'] = ihost_ret.mgmt_ip + address_name = cutils.format_address_name(ihost_obj.hostname, + constants.NETWORK_TYPE_MGMT) + address = pecan.request.dbapi.address_get_by_name(address_name) + ihost_obj['mgmt_ip'] = address.address # Add ihost to mtc new_ihost_mtc = ihost_obj.as_dict() @@ -2168,14 +2170,16 @@ class HostController(rest.RestController): raise wsme.exc.ClientSideError( _("Please provision 'hostname' and 'personality'.")) - ihost_ret = pecan.request.rpcapi.configure_ihost( - pecan.request.context, ihost_obj) + pecan.request.rpcapi.configure_ihost(pecan.request.context, ihost_obj) pecan.request.dbapi.ihost_update( ihost_obj['uuid'], {'capabilities': ihost_obj['capabilities']}) # Notify maintenance about updated mgmt_ip - ihost_obj['mgmt_ip'] = ihost_ret.mgmt_ip + address_name = cutils.format_address_name(ihost_obj.hostname, + constants.NETWORK_TYPE_MGMT) + address = pecan.request.dbapi.address_get_by_name(address_name) + ihost_obj['mgmt_ip'] = address.address hostupdate.notify_mtce = True @@ -5505,7 +5509,6 @@ class HostController(rest.RestController): # To unlock, we need the following additional fields if not (hostupdate.ihost_patch['mgmt_mac'] and - hostupdate.ihost_patch['mgmt_ip'] and hostupdate.ihost_patch['hostname'] and hostupdate.ihost_patch['personality'] and hostupdate.ihost_patch['subfunctions']): diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 1d39d4f85d..87bb4b208c 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -1003,7 +1003,6 @@ class ConductorManager(service.PeriodicService): "Invalid method call: create_ihost requires mgmt_mac.")) try: - mgmt_update_required = False mac = values['mgmt_mac'] mac = mac.rstrip() mac = cutils.validate_and_normalize_mac(mac) @@ -1011,34 +1010,6 @@ class ConductorManager(service.PeriodicService): LOG.info("Not creating ihost for mac: %s because it " "already exists with uuid: %s" % (values['mgmt_mac'], ihost['uuid'])) - mgmt_ip = values.get('mgmt_ip') or "" - - if mgmt_ip and not ihost.mgmt_ip: - LOG.info("%s create_ihost setting mgmt_ip to %s" % - (ihost.uuid, mgmt_ip)) - mgmt_update_required = True - elif mgmt_ip and ihost.mgmt_ip and \ - (ihost.mgmt_ip.strip() != mgmt_ip.strip()): - # Changing the management IP on an already configured - # host should not occur nor be allowed. - LOG.error("DANGER %s create_ihost mgmt_ip dnsmasq change " - "detected from %s to %s." % - (ihost.uuid, ihost.mgmt_ip, mgmt_ip)) - - if mgmt_update_required: - ihost = self.dbapi.ihost_update(ihost.uuid, values) - - if ihost.personality and ihost.hostname: - ihost_mtc = ihost.as_dict() - ihost_mtc['operation'] = 'modify' - ihost_mtc = cutils.removekeys_nonmtce(ihost_mtc) - LOG.info("%s create_ihost update mtce %s " % - (ihost.hostname, ihost_mtc)) - mtce_api.host_modify( - self._api_token, self._mtc_address, self._mtc_port, - ihost_mtc, - constants.MTC_DEFAULT_TIMEOUT_IN_SECS) - return ihost except exception.NodeNotFound: # If host is not found, check if this is cloning scenario. @@ -1749,13 +1720,12 @@ class ConductorManager(service.PeriodicService): Does the following tasks: - Check if addresses exist for host - Allocate addresses for host from pools - - Update ihost with mgmt address - Regenerate the dnsmasq hosts file :param context: request context :param host: host object """ - mgmt_ip = host.mgmt_ip + mgmt_interfaces = self.iinterfaces_get_by_ihost_nettype( context, host.uuid, constants.NETWORK_TYPE_MGMT ) @@ -1763,32 +1733,27 @@ class ConductorManager(service.PeriodicService): if mgmt_interfaces: mgmt_interface_id = mgmt_interfaces[0]['id'] hostname = host.hostname - address_name = cutils.format_address_name(hostname, - constants.NETWORK_TYPE_MGMT) - # if ihost has mgmt_ip, make sure address in address table + + # check for static mgmt IP + mgmt_ip = self._lookup_static_ip_address( + hostname, constants.NETWORK_TYPE_MGMT + ) + # make sure address in address table and update dnsmasq host file if mgmt_ip: + LOG.info("Static mgmt ip {} for host{}".format(mgmt_ip, hostname)) self._create_or_update_address(context, hostname, mgmt_ip, constants.NETWORK_TYPE_MGMT, mgmt_interface_id) - # if ihost has no management IP, check for static mgmt IP - if not mgmt_ip: - mgmt_ip = self._lookup_static_ip_address( - hostname, constants.NETWORK_TYPE_MGMT - ) - if mgmt_ip: - host.mgmt_ip = mgmt_ip - self.update_ihost(context, host) # if no static address, then allocate one if not mgmt_ip: mgmt_pool = self.dbapi.network_get_by_type( constants.NETWORK_TYPE_MGMT ).pool_uuid - + address_name = cutils.format_address_name(hostname, + constants.NETWORK_TYPE_MGMT) mgmt_ip = self._allocate_pool_address(mgmt_interface_id, mgmt_pool, address_name).address - if mgmt_ip: - host.mgmt_ip = mgmt_ip - self.update_ihost(context, host) + LOG.info("Allocated mgmt ip {} for host{}".format(mgmt_ip, hostname)) self._generate_dnsmasq_hosts_file(existing_host=host) self._allocate_cluster_host_address_for_host(host) @@ -2519,9 +2484,9 @@ class ConductorManager(service.PeriodicService): if do_worker_apply: # Apply the manifests immediately - puppet_common.puppet_apply_manifest(host.mgmt_ip, - constants.WORKER, - do_reboot=True) + puppet_common.puppet_apply_manifest(host.hostname, + constants.WORKER, + do_reboot=True) return host def unconfigure_ihost(self, context, ihost_obj): @@ -6135,7 +6100,7 @@ class ConductorManager(service.PeriodicService): :param context: an admin context :param ihost_macs: list of mac addresses - :returns: ihost object, including all fields. + :returns: ihost object, including all fields and mgmt address. """ ihosts = self.dbapi.ihost_get_list() @@ -6152,7 +6117,11 @@ class ConductorManager(service.PeriodicService): for host in ihosts: if host.mgmt_mac == mac: LOG.info("Host found ihost db for macs: %s" % host.hostname) - return host + mgmt_addr = None + mgmt_addr = self.get_address_by_host_networktype( + context, host.hostname, + constants.NETWORK_TYPE_MGMT) + return host, mgmt_addr LOG.debug("RPC get_ihost_by_macs called but found no ihost.") def get_ihost_by_hostname(self, context, ihost_hostname): @@ -6176,6 +6145,24 @@ class ConductorManager(service.PeriodicService): LOG.debug("RPC ihost_get_by_hostname called but found no ihost.") + def get_address_by_host_networktype(self, context, name, networktype): + """Finds configured address based on name and network type. + + This method returns an address of the network type for the host. + + :param context: an admin context + :param ihost_hostname: ihost hostname + :returns: ihost object, including all fields. + """ + + try: + name = cutils.format_address_name(name, networktype) + address = self.dbapi.address_get_by_name(name) + return address.address + except exception.AddressNotFoundByName: + pass + LOG.info("RPC get_address_by_host_networktype called but found no address.") + @staticmethod def _controller_config_active_check(): """Determine whether the active configuration has been finalized""" @@ -15516,12 +15503,6 @@ class ConductorManager(service.PeriodicService): inventory_completed = False if inventory_completed: - controller_0_address = self.dbapi.address_get_by_name( - constants.CONTROLLER_0_MGMT) - if controller_0_address.address != host.mgmt_ip: - self.dbapi.ihost_update( - host.uuid, {'mgmt_ip': controller_0_address.address}) - personalities = [constants.CONTROLLER] config_uuid = self._config_update_hosts(context, personalities) config_dict = { diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py index 957f04dce2..72f322db2c 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py @@ -206,7 +206,7 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy): :param context: an admin context :param ihost_macs: list of mac addresses - :returns: ihost object, including all fields. + :returns: ihost object, including all fields and mgmt address. """ return self.call(context, @@ -228,6 +228,23 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy): self.make_msg('get_ihost_by_hostname', ihost_hostname=ihost_hostname)) + def get_address_by_host_networktype(self, context, name, networktype): + """Finds ihost db entry based upon the ihost hostname + + This method returns an ihost if it matches the + hostname. + + :param context: an admin context + :param name: ihost hostname + :param networktype: network type + :returns: ihost object, including all fields. + """ + + return self.call(context, + self.make_msg('get_address_by_host_networktype', + name=name, + networktype=networktype)) + def iport_update_by_ihost(self, context, ihost_uuid, inic_dict_array): """Create iports for an ihost with the supplied data. diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/fm.py b/sysinv/sysinv/sysinv/sysinv/puppet/fm.py index 3ff218b0fc..81de4ab6ac 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/fm.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/fm.py @@ -113,7 +113,10 @@ class FmPuppet(openstack.OpenstackBasePuppet): if host.hostname == constants.CONTROLLER_1_HOSTNAME: host_ip = constants.CONTROLLER_1_FQDN else: - host_ip = host.mgmt_ip + address = self._get_address_by_name( + host.hostname, + constants.NETWORK_TYPE_MGMT) + host_ip = address.address config = { 'platform::fm::params::api_host': host_ip } diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/keystone.py b/sysinv/sysinv/sysinv/sysinv/puppet/keystone.py index 2756e140f1..cb25abd12f 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/keystone.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/keystone.py @@ -164,12 +164,13 @@ class KeystonePuppet(openstack.OpenstackBasePuppet): # The valid format for IPv6 addresses is: inet6:[]:port # Although, for IPv4, the "inet" part is not mandatory, we # specify if anyway, for consistency purposes. - if self._get_address_by_name( - constants.CONTROLLER_HOSTNAME, - constants.NETWORK_TYPE_MGMT).family == constants.IPV6_FAMILY: - backend_endpoint = "[%s]:11211" % host.mgmt_ip + address = self._get_address_by_name( + host.hostname, + constants.NETWORK_TYPE_MGMT) + if address.family == constants.IPV6_FAMILY: + backend_endpoint = "[%s]:11211" % address.address else: - backend_endpoint = "%s:11211" % host.mgmt_ip + backend_endpoint = "%s:11211" % address.address config.update({ 'keystone::cache::enabled': True, diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py b/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py index fdc023e27e..3ec96922b5 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/puppet.py @@ -19,6 +19,7 @@ from tsconfig import tsconfig from oslo_log import log as logging from sysinv.puppet import common +from sysinv.common import utils LOG = logging.getLogger(__name__) @@ -213,8 +214,16 @@ class PuppetOperator(object): "target_load: %s config: %s" % (host.hostname, config_uuid, target_load, config)) + def _get_address_by_name(self, name, networktype): + """ + Retrieve an address entry by name and scoped by network type + """ + address_name = utils.format_address_name(name, networktype) + address = self.dbapi.address_get_by_name(address_name) + return address + def _merge_host_config(self, host, target_load, config): - filename = host.mgmt_ip + '.yaml' + filename = host.hostname + '.yaml' path = os.path.join( tsconfig.PLATFORM_PATH, 'puppet', @@ -232,18 +241,18 @@ class PuppetOperator(object): def remove_host_config(self, host): """Remove the configuration for the supplied host""" try: - filename = "%s.yaml" % host.mgmt_ip + filename = "%s.yaml" % host.hostname self._remove_config(filename) except Exception: LOG.exception("failed to remove host config: %s" % host.uuid) def _write_host_config(self, host, config, path=None): """Update the configuration for a specific host""" - filename = "%s.yaml" % host.mgmt_ip + filename = "%s.yaml" % host.hostname self._write_config(filename, config, path) def _read_host_config(self, host, path): - filename = "%s.yaml" % host.mgmt_ip + filename = "%s.yaml" % host.hostname return self._read_config(filename, path) def _read_config(self, filename, path): diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/smapi.py b/sysinv/sysinv/sysinv/sysinv/puppet/smapi.py index ccfc69958b..0cf1d07f4c 100644 --- a/sysinv/sysinv/sysinv/sysinv/puppet/smapi.py +++ b/sysinv/sysinv/sysinv/sysinv/puppet/smapi.py @@ -71,8 +71,9 @@ class SmPuppet(openstack.OpenstackBasePuppet): elif host.hostname == constants.CONTROLLER_1_HOSTNAME: host_ip = constants.CONTROLLER_1_FQDN else: - host_ip = host.mgmt_ip - + address = self._get_address_by_name( + host.hostname, constants.NETWORK_TYPE_MGMT) + host_ip = address.address config = { 'platform::smapi::params::bind_ip': host_ip, } diff --git a/sysinv/sysinv/sysinv/sysinv/tests/api/test_host.py b/sysinv/sysinv/sysinv/sysinv/tests/api/test_host.py index c59fa09c5b..3a14309ed0 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/api/test_host.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/api/test_host.py @@ -340,6 +340,7 @@ class TestPostWorkerMixin(object): def test_create_host_worker(self): # Test creation of worker + self._create_test_host_addresses('worker-0') ndict = dbutils.post_get_test_ihost(hostname='worker-0', personality='worker', subfunctions=None, @@ -371,6 +372,7 @@ class TestPostEdgeworkerMixin(object): def test_create_host_worker(self): # Test creation of worker + self._create_test_host_addresses('edgeworker-0') ndict = dbutils.post_get_test_ihost(hostname='edgeworker-0', personality='edgeworker', subfunctions=None, @@ -1850,6 +1852,7 @@ class TestDelete(TestHost): # Create controller-0 self._create_controller_0() # Create a worker host + self._create_test_host_addresses('worker-0') ndict = dbutils.post_get_test_ihost(hostname='worker-0', personality='worker', subfunctions=None, @@ -1925,6 +1928,7 @@ class TestListHosts(TestHost): self._create_controller_0() # Test creation of worker + self._create_test_host_addresses('worker-0') ndict = dbutils.post_get_test_ihost(hostname='worker-0', personality='worker', subfunctions=None, @@ -2592,6 +2596,7 @@ class TestPatch(TestHost): availability=constants.AVAILABILITY_ONLINE) self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus(w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) # Unlock worker host response = self._patch_host_action(w0_host['hostname'], @@ -2638,6 +2643,7 @@ class TestPatch(TestHost): self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus( w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) # Unlock worker host while lock action in progress response = self._patch_host_action(w0_host['hostname'], @@ -2678,6 +2684,7 @@ class TestPatch(TestHost): self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus( w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) # Unlock worker host while lock action in progress response = self._patch_host_action(w0_host['hostname'], @@ -2856,6 +2863,7 @@ class TestPatch(TestHost): self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus(w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) w0_hostname = w0_host['hostname'] response = self._patch_host_action( @@ -2900,6 +2908,7 @@ class TestPatch(TestHost): self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus(w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) w0_hostname = w0_host['hostname'] response = self._patch_host_action( @@ -3681,6 +3690,7 @@ class TestHostPTPValidation(TestHost): availability=constants.AVAILABILITY_ONLINE) self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus(w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) # Host with PTP must have at least one ptp interface interface = { @@ -3737,6 +3747,7 @@ class TestHostPTPValidation(TestHost): availability=constants.AVAILABILITY_ONLINE) self._create_test_host_platform_interface(w0_host) self._create_test_host_cpus(w0_host, platform=1, vswitch=2, application=12) + self._create_test_host_addresses(w0_host.hostname) # Host with PTP must have at least one ptp interface response = self._patch_host_action( diff --git a/sysinv/sysinv/sysinv/sysinv/tests/conductor/test_manager.py b/sysinv/sysinv/sysinv/sysinv/tests/conductor/test_manager.py index ef77ac8e1e..5a4af57ba2 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/conductor/test_manager.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/conductor/test_manager.py @@ -2987,8 +2987,14 @@ class ManagerTestCase(base.DbTestCase): def test_get_ihost_by_macs(self): self._create_test_ihosts() + mgmt_net, pxeboot_net = self._create_test_networks(0) + address = {'name': 'controller-1-mgmt', + 'family': 4, + 'prefix': 24, + 'address': '192.168.204.3'} + utils.create_test_address(**address) ihost_macs = ['22:44:33:55:11:66', '22:44:33:88:11:66'] - ihost = self.service.get_ihost_by_macs(self.context, ihost_macs) + ihost, mgmt_addr = self.service.get_ihost_by_macs(self.context, ihost_macs) self.assertEqual(ihost.mgmt_mac, '22:44:33:55:11:66') def test_get_ihost_by_macs_no_match(self): diff --git a/sysinv/sysinv/sysinv/sysinv/tests/db/base.py b/sysinv/sysinv/sysinv/sysinv/tests/db/base.py index 18c205de78..5454a9c504 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/db/base.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/db/base.py @@ -452,12 +452,12 @@ class BaseHostTestCase(BaseSystemTestCase): allocated_function=function)) cpu = cpu + 1 - def _create_test_host_addresses(self, host): + def _create_test_host_addresses(self, hostname): self._create_test_addresses( - [host.hostname], self.mgmt_subnet, + [hostname], self.mgmt_subnet, constants.NETWORK_TYPE_MGMT, start=10) self._create_test_addresses( - [host.hostname], self.cluster_host_subnet, + [hostname], self.cluster_host_subnet, constants.NETWORK_TYPE_CLUSTER_HOST, start=10) def _create_test_host_platform_interface(self, host): @@ -544,7 +544,7 @@ class WorkerHostTestCase(BaseHostTestCase): super(WorkerHostTestCase, self).setUp() self.host = self._create_test_host(constants.WORKER) self._create_test_host_cpus(self.host, platform=1, vswitch=2, application=12) - self._create_test_host_addresses(self.host) + self._create_test_host_addresses(self.host.hostname) class StorageHostTestCase(BaseHostTestCase): @@ -553,7 +553,7 @@ class StorageHostTestCase(BaseHostTestCase): super(StorageHostTestCase, self).setUp() self.host = self._create_test_host(constants.STORAGE) self._create_test_host_cpus(self.host, platform=8) - self._create_test_host_addresses(self.host) + self._create_test_host_addresses(self.host.hostname) class AIOHostTestCase(BaseHostTestCase): diff --git a/workerconfig/workerconfig/worker_config b/workerconfig/workerconfig/worker_config index d1dd50fe6e..b05feba9d7 100644 --- a/workerconfig/workerconfig/worker_config +++ b/workerconfig/workerconfig/worker_config @@ -307,17 +307,17 @@ start() fi # Apply the puppet manifest - HOST_HIERA=${PUPPET_PATH}/hieradata/${IPADDR}.yaml + HOST_HIERA=${PUPPET_PATH}/hieradata/${HOST}.yaml if [ -f ${HOST_HIERA} ]; then echo "$0: Running puppet manifest apply" - puppet-manifest-apply.sh ${PUPPET_PATH}/hieradata ${IPADDR} worker + puppet-manifest-apply.sh ${PUPPET_PATH}/hieradata ${HOST} worker RC=$? if [ $RC -ne 0 ]; then fatal_error "Failed to run the puppet manifest (RC:$RC)" fi else - fatal_error "Host configuration not yet available for this node ($(hostname)=${IPADDR}); aborting configuration." + fatal_error "Host configuration not yet available for this node ($(hostname)=${HOST}); aborting configuration." fi # Load Network Block Device