@@ -30,7 +30,6 @@ def __init__(
30
30
self ._walle_provider = walle_provider
31
31
self ._cluster_details = base .ClusterDetailsProvider (template , walle_provider = self ._walle_provider )
32
32
self ._grpc_endpoint = grpc_endpoint
33
- self .__define_storage_pools_request = None
34
33
self .__configure_request = None
35
34
self .__static_config = static .StaticConfigGenerator (
36
35
template , binary_path , output_dir , walle_provider = walle_provider , local_binary_path = local_binary_path
@@ -60,6 +59,7 @@ def __init_storage_command(self, proto_file):
60
59
61
60
def __add_storage_pool (
62
61
self ,
62
+ request ,
63
63
box_id ,
64
64
storage_pool_id ,
65
65
erasure ,
@@ -72,7 +72,7 @@ def __add_storage_pool(
72
72
encryption_mode = 0 ,
73
73
generation = 0 ,
74
74
):
75
- cmd = self . __define_storage_pools_request .Command .add ()
75
+ cmd = request .Command .add ()
76
76
cmd .DefineStoragePool .BoxId = box_id
77
77
name = "Storage Pool with id: %d" % storage_pool_id if name is None else name
78
78
cmd .DefineStoragePool .ItemConfigGeneration = generation
@@ -152,8 +152,7 @@ def init_storage_commands(self):
152
152
return '\n ' .join (
153
153
[
154
154
"set -eu" ,
155
- self .__init_storage_command ("DefineBox.txt" ),
156
- self .__init_storage_command ("DefineStoragePools.txt" ),
155
+ self .__init_storage_command ("DefineBoxAndStoragePools.txt" ),
157
156
]
158
157
)
159
158
@@ -174,8 +173,8 @@ def init_root_storage(self):
174
173
def cms_init_cmd (self ):
175
174
return self .__cms_init_cmds ()
176
175
177
- def define_box_request (self ):
178
- define_box_request = bs_config .TConfigRequest ()
176
+ def define_box_and_storage_pools_request (self ):
177
+ request = bs_config .TConfigRequest ()
179
178
box_id = 1
180
179
drives_to_config_id = {}
181
180
host_config_id_iter = itertools .count (start = 1 )
@@ -195,7 +194,7 @@ def add_drive(array, drive):
195
194
196
195
for host_config in self ._cluster_details .host_configs :
197
196
at_least_one_host_config_defined = True
198
- cmd = define_box_request .Command .add ()
197
+ cmd = request .Command .add ()
199
198
cmd .DefineHostConfig .HostConfigId = host_config .host_config_id
200
199
cmd .DefineHostConfig .ItemConfigGeneration = host_config .generation
201
200
drives_to_config_id [host_config .drives ] = host_config .host_config_id
@@ -212,14 +211,14 @@ def add_drive(array, drive):
212
211
)
213
212
214
213
host_config_id = next (host_config_id_iter )
215
- cmd = define_box_request .Command .add ()
214
+ cmd = request .Command .add ()
216
215
cmd .DefineHostConfig .HostConfigId = host_config_id
217
216
for drive in host .drives :
218
217
add_drive (cmd .DefineHostConfig .Drive , drive )
219
218
220
219
drives_to_config_id [host .drives ] = host_config_id
221
220
222
- box_cmd = define_box_request .Command .add ()
221
+ box_cmd = request .Command .add ()
223
222
box_cmd .DefineBox .BoxId = box_id
224
223
box_cmd .DefineBox .ItemConfigGeneration = self ._cluster_details .storage_config_generation
225
224
for host in self ._cluster_details .hosts :
@@ -230,23 +229,20 @@ def add_drive(array, drive):
230
229
box_host .HostConfigId = host .host_config_id
231
230
else :
232
231
box_host .HostConfigId = drives_to_config_id [host .drives ]
233
- return define_box_request
234
232
235
- def define_storage_pools_request (self ):
236
- self .__define_storage_pools_request = bs_config .TConfigRequest ()
237
233
storage_pool_id = itertools .count (start = 1 )
238
234
239
235
if self ._cluster_details .storage_pools_deprecated :
240
236
for storage_pool in self ._cluster_details .storage_pools_deprecated :
241
- self .__add_storage_pool (storage_pool_id = next (storage_pool_id ), ** storage_pool .to_dict ())
237
+ self .__add_storage_pool (request , storage_pool_id = next (storage_pool_id ), ** storage_pool .to_dict ())
242
238
243
239
# for tablets in domain lets make pools
244
240
# but it is not supposed to make tablets in domain directly
245
241
for domain in self ._cluster_details .domains :
246
242
for storage_pool in domain .storage_pools :
247
- self .__add_storage_pool (storage_pool_id = next (storage_pool_id ), ** storage_pool .to_dict ())
243
+ self .__add_storage_pool (request , storage_pool_id = next (storage_pool_id ), ** storage_pool .to_dict ())
248
244
249
- return self . __define_storage_pools_request
245
+ return request
250
246
251
247
@staticmethod
252
248
def make_bind_root_storage_request (domain ):
@@ -298,8 +294,7 @@ def make_configure_request(self, domain):
298
294
299
295
def get_storage_requests (self ):
300
296
return {
301
- 'DefineBox.txt' : utils .message_to_string (self .define_box_request ()),
302
- 'DefineStoragePools.txt' : utils .message_to_string (self .define_storage_pools_request ()),
297
+ 'DefineBoxAndStoragePools.txt' : utils .message_to_string (self .define_box_and_storage_pools_request ()),
303
298
}
304
299
305
300
@staticmethod
0 commit comments