X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=cmdatahandlers%2Fsrc%2Fcmdatahandlers%2Fhosts%2Fconfig.py;h=4d46459f0a9b550b53e348f33c6726d5540ed2e8;hb=e19e8ce998299bb201a22682215614dd981ad6fc;hp=ac86d3b47a2ddb615152d6aa222956920246a605;hpb=3cb6b540af283dac09b21c64d19d8f65527ff9ac;p=ta%2Fconfig-manager.git diff --git a/cmdatahandlers/src/cmdatahandlers/hosts/config.py b/cmdatahandlers/src/cmdatahandlers/hosts/config.py index ac86d3b..4d46459 100644 --- a/cmdatahandlers/src/cmdatahandlers/hosts/config.py +++ b/cmdatahandlers/src/cmdatahandlers/hosts/config.py @@ -82,6 +82,28 @@ class Config(config.Config): cidr = netconf.get_network_cidr(hwmgmtnet, domain) utils.validate_ip_in_network(ip, cidr) + def get_hwmgmt_priv_level(self, hostname): + """get the hwmgmt IPMI privilege level. Defaults to ADMINISTRATOR + + Arguments: + + hostname: The name of the node + + Return: + + The prvilege level, or ADMINISTRATOR if unspecified + + Raise: + + ConfigError in-case of an error + """ + self._validate_hostname(hostname) + + if 'hwmgmt' not in self.config[self.ROOT][hostname]: + raise configerror.ConfigError('No hwmgmt info defined for host') + + return self.config[self.ROOT][hostname]['hwmgmt'].get('priv_level', 'ADMINISTRATOR') + def _validate_service_profiles(self, hostname): node_profiles = self.get_service_profiles(hostname) utils.validate_list_items_unique(node_profiles) @@ -174,8 +196,24 @@ class Config(config.Config): return service_profiles[0] + def set_nodeindex(self): + hostsconf = self.confman.get_hosts_config_handler() + install_host = utils.get_installation_host_name(hostsconf) + self.config[self.ROOT][install_host]['caas_nodeindex'] = 1 + + masters = self.get_service_profile_hosts('caas_master') + masters.remove(install_host) + self._set_nodeindexes(masters, 2) + self._set_nodeindexes(self.get_service_profile_hosts('caas_worker'), 1) + + def _set_nodeindexes(self, hosts, base_index): + index = base_index + for host in hosts: + self.config[self.ROOT][host]['caas_nodeindex'] = index + index += 1 + def get_nodeindex(self, hostname): - return re.search(r'[-_](\d+)$', hostname).group(1) + return self.config[self.ROOT][hostname]['caas_nodeindex'] def get_nodename(self, hostname): return "{}{}".format(self.get_nodetype(hostname), self.get_nodeindex(hostname)) @@ -827,8 +865,7 @@ class Config(config.Config): MIDDLEWARE_RESERVED_MEMORY) def set_default_reserved_memory_to_all_hosts(self, def_memory): - self.get_hosts() - for host in hosts: + for host in self.get_hosts(): self.config[self.ROOT][host]['middleware_reserved_memory'] = def_memory