Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ydb/tools/cfg/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __hash__(self):
)

KiKiMRHost = collections.namedtuple(
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "rack", "host_config_id", "port"]
"_KiKiMRHost", ["hostname", "node_id", "drives", "ic_port", "body", "datacenter", "module", "rack", "host_config_id", "port"]
)

DEFAULT_PLAN_RESOLUTION = 10
Expand Down Expand Up @@ -417,6 +417,16 @@ def _get_body(self, host_description):

return str(self._host_info_provider.get_body(host_description.get("name", host_description.get("host"))))

def _get_module(self, host_description):
if host_description.get("module") is not None:
return str(host_description.get("module"))
module = host_description.get("location", {}).get("module", None)
if module is not None:
return str(module)

module_from_provider = self._host_info_provider.get_module(host_description.get("name", host_description.get("host")))
return str(module_from_provider) if module_from_provider else ""

def _collect_drives_info(self, host_description):
host_config_id = host_description.get("host_config_id", None)
drives = host_description.get("drives", [])
Expand All @@ -439,6 +449,7 @@ def __collect_host_info(self, node_id, host_description):
ic_port=host_description.get("ic_port", DEFAULT_INTERCONNECT_PORT),
body=self._get_body(host_description),
datacenter=self._get_datacenter(host_description),
module=self._get_module(host_description),
rack=self._get_rack(host_description),
host_config_id=host_description.get("host_config_id", None),
port=host_description.get("port", DEFAULT_INTERCONNECT_PORT),
Expand Down
2 changes: 2 additions & 0 deletions ydb/tools/cfg/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ def __generate_names_txt(self):
if not self._skip_location:
if self.__cluster_details.use_walle:
node.WalleLocation.DataCenter = host.datacenter
node.WalleLocation.Module = host.module
node.WalleLocation.Rack = host.rack
node.WalleLocation.Body = int(host.body)
elif self.__cluster_details.use_k8s_api:
Expand All @@ -1517,6 +1518,7 @@ def __generate_names_txt(self):
node.Location.Body = int(host.body)
else:
node.Location.DataCenter = host.datacenter
node.Location.Module = host.module
node.Location.Rack = host.rack
node.Location.Body = int(host.body)

Expand Down
17 changes: 14 additions & 3 deletions ydb/tools/cfg/walle/walle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ class HostsInformationProvider:
__metaclass__ = ABCMeta

@abstractmethod
def get_rack(hostname):
def get_rack(self, hostname):
pass

@abstractmethod
def get_datacenter(self, hostname):
pass

@abstractmethod
def get_datacenter(hostname):
def get_body(self, hostname):
pass

@abstractmethod
def get_body(hostname):
def get_module(self, hostname):
pass


Expand All @@ -44,6 +48,9 @@ def get_datacenter(self, hostname):
def get_body(self, hostname):
return zlib.crc32(hostname.encode())

def get_module(self, hostname):
return ""


class WalleHostsInformationProvider(HostsInformationProvider):
def __init__(self, provider_url=None, cloud_mode=False):
Expand Down Expand Up @@ -103,5 +110,9 @@ def get_datacenter(self, hostname):
short_dc_name = self._ask_location(hostname)["location"]["short_datacenter_name"]
return short_dc_name if self._cloud_mode else short_dc_name.upper()

def get_module(self, hostname):
queue = self._ask_location(hostname)["location"].get("queue", "")
return queue if self._cloud_mode else queue.upper()

def get_body(self, hostname):
return self._ask_location(hostname)["inv"]