@@ -60,10 +60,11 @@ def merge_with_default(dft, override):
60
60
61
61
62
62
class KiKiMRDrive (object ):
63
- def __init__ (self , type , path , shared_with_os = False , expected_slot_count = None , kind = None ):
63
+ def __init__ (self , type , path , shared_with_os = False , expected_slot_count = None , kind = None , pdisk_config = None ):
64
64
self .type = type
65
65
self .path = path
66
66
self .shared_with_os = shared_with_os
67
+ self .pdisk_config = pdisk_config
67
68
self .expected_slot_count = expected_slot_count
68
69
self .kind = kind
69
70
@@ -74,10 +75,11 @@ def __eq__(self, other):
74
75
and self .shared_with_os == other .shared_with_os
75
76
and self .expected_slot_count == other .expected_slot_count
76
77
and self .kind == other .kind
78
+ and self .pdisk_config == other .pdisk_config
77
79
)
78
80
79
81
def __hash__ (self ):
80
- return hash ("\0 " .join (map (str , (self .type , self .path , self .shared_with_os , self .expected_slot_count , self .kind ))))
82
+ return hash ("\0 " .join (map (str , (self .type , self .path , self .shared_with_os , self .expected_slot_count , self .kind , self . pdisk_config ))))
81
83
82
84
83
85
Domain = collections .namedtuple (
@@ -264,7 +266,7 @@ def normalize_domain(domain_name):
264
266
265
267
266
268
class ClusterDetailsProvider (object ):
267
- def __init__ (self , template , walle_provider , validator = None , database = None , use_new_style_cfg = False ):
269
+ def __init__ (self , template , host_info_provider , validator = None , database = None , use_new_style_cfg = False ):
268
270
if not validator :
269
271
validator = validation .default_validator ()
270
272
@@ -277,10 +279,14 @@ def __init__(self, template, walle_provider, validator=None, database=None, use_
277
279
if database is not None :
278
280
self .__cluster_description = self .get_subjective_description (self .__cluster_description , database , self .__validator )
279
281
280
- self ._use_walle = self .__cluster_description .get ("use_walle" , True )
281
- if not walle_provider :
282
- walle_provider = walle .NopHostsInformationProvider ()
283
- self ._walle = walle_provider
282
+ self ._use_walle = self .__cluster_description .get ("use_walle" , False )
283
+ self ._k8s_settings = self .__cluster_description .get ("k8s_settings" , {"use" : False })
284
+
285
+ if host_info_provider is not None :
286
+ self ._host_info_provider = host_info_provider
287
+ else :
288
+ self ._host_info_provider = walle .NopHostsInformationProvider
289
+
284
290
self .__translated_storage_pools_deprecated = None
285
291
self .__translated_hosts = None
286
292
self .__racks = {}
@@ -299,6 +305,7 @@ def __init__(self, template, walle_provider, validator=None, database=None, use_
299
305
self .blob_storage_config = self .__cluster_description .get ("blob_storage_config" )
300
306
self .memory_controller_config = self .__cluster_description .get ("memory_controller_config" , {})
301
307
self .channel_profile_config = self .__cluster_description .get ("channel_profile_config" )
308
+ self .immediate_controls_config = self .__cluster_description .get ("immediate_controls_config" )
302
309
self .pdisk_key_config = self .__cluster_description .get ("pdisk_key_config" , {})
303
310
if not self .need_txt_files and not self .use_new_style_kikimr_cfg :
304
311
assert "cannot remove txt files without new style kikimr cfg!"
@@ -344,6 +351,18 @@ def storage_config_generation(self):
344
351
def use_walle (self ):
345
352
return self ._use_walle
346
353
354
+ @property
355
+ def use_k8s_api (self ):
356
+ return self ._k8s_settings .get ("use" )
357
+
358
+ @property
359
+ def k8s_rack_label (self ):
360
+ return self ._k8s_settings .get ("k8s_rack_label" )
361
+
362
+ @property
363
+ def k8s_dc_label (self ):
364
+ return self ._k8s_settings .get ("k8s_dc_label" )
365
+
347
366
@property
348
367
def security_settings (self ):
349
368
return self .__cluster_description .get ("security_settings" , {})
@@ -358,23 +377,29 @@ def _get_datacenter(self, host_description):
358
377
dc = host_description .get ("location" , {}).get ("data_center" , None )
359
378
if dc :
360
379
return str (dc )
361
- return str (self ._walle .get_datacenter (host_description .get ("name" , host_description .get ("host" ))))
380
+ return str (self ._host_info_provider .get_datacenter (host_description .get ("name" , host_description .get ("host" ))))
362
381
363
382
def _get_rack (self , host_description ):
364
383
if host_description .get ("rack" ) is not None :
365
384
return str (host_description .get ("rack" ))
366
385
rack = host_description .get ("location" , {}).get ("rack" , None )
367
386
if rack :
368
387
return str (rack )
369
- return str (self ._walle .get_rack (host_description .get ("name" , host_description .get ("host" ))))
388
+
389
+ hostname = host_description .get ("name" , host_description .get ("host" ))
390
+
391
+ if isinstance (self ._host_info_provider , walle .NopHostsInformationProvider ):
392
+ raise RuntimeError (f"there is no 'rack' specified for host { hostname } in template, and no host info provider has been specified" )
393
+
394
+ return str (self ._host_info_provider .get_rack (hostname ))
370
395
371
396
def _get_body (self , host_description ):
372
397
if host_description .get ("body" ) is not None :
373
398
return str (host_description .get ("body" ))
374
399
body = host_description .get ("location" , {}).get ("body" , None )
375
400
if body :
376
401
return str (body )
377
- return str (self ._walle .get_body (host_description .get ("name" , host_description .get ("host" ))))
402
+ return str (self ._host_info_provider .get_body (host_description .get ("name" , host_description .get ("host" ))))
378
403
379
404
def _collect_drives_info (self , host_description ):
380
405
host_config_id = host_description .get ("host_config_id" , None )
@@ -670,6 +695,10 @@ def grpc_config(self):
670
695
def dynamicnameservice_config (self ):
671
696
return merge_with_default (DYNAMIC_NAME_SERVICE , self .__cluster_description .get ("dynamicnameservice" , {}))
672
697
698
+ @property
699
+ def nameservice_config (self ):
700
+ return self .__cluster_description .get ("nameservice_config" )
701
+
673
702
@property
674
703
def grpc_port (self ):
675
704
return self .grpc_config .get ("port" )
0 commit comments