@@ -161,10 +161,15 @@ def process_resource_obj(self, resources):
161
161
def save_bulk_resources (self , resources ):
162
162
payload = []
163
163
resources = self .process_resource_obj (resources )
164
+ cloud_acc_id = None
164
165
for rss in resources :
165
166
obj , cloud_acc_id = self .build_payload (rss )
166
167
payload .append (obj )
167
168
if payload :
169
+ LOG .info ('Creating %s resources for cloud account %s' , len (payload ),
170
+ cloud_acc_id )
171
+ LOG .debug ('Payload build for cloud account %s resources: %s' ,
172
+ cloud_acc_id , [x ['cloud_resource_id' ] for x in payload ])
168
173
_ , response = self .rest_cl .cloud_resource_create_bulk (
169
174
cloud_acc_id , {'resources' : payload },
170
175
behavior = 'update_existing' , return_resources = True )
@@ -221,7 +226,8 @@ def res_saving(self):
221
226
return self ._res_saving
222
227
223
228
def set_discover_settings (self ):
224
- discover_size , timeout , writing_timeout , _ = self .config_cl .resource_discovery_params ()
229
+ (discover_size , timeout , writing_timeout ,
230
+ _ , _ ) = self .config_cl .resource_discovery_params ()
225
231
self .discover_size = discover_size if (
226
232
discover_size ) else DEFAULT_DISCOVER_SIZE
227
233
self .timeout = timeout
@@ -329,6 +335,8 @@ def _discover_resources(self, cloud_acc_id, resource_type):
329
335
res , gen = f .result ()
330
336
if isinstance (res , Exception ):
331
337
if self .is_404 (res ):
338
+ LOG .debug ("Got 404 exception: %s, skipping it" ,
339
+ str (res ))
332
340
continue
333
341
LOG .error ("Exception: %s %s" , str (res ),
334
342
traceback .print_tb (res .__traceback__ ))
@@ -402,15 +410,16 @@ def heartbeat(self):
402
410
403
411
if __name__ == '__main__' :
404
412
urllib3 .disable_warnings (category = urllib3 .exceptions .InsecureRequestWarning )
405
- debug = os .environ .get ('DEBUG' , False )
406
- log_level = 'INFO' if not debug else 'DEBUG'
407
- setup_logging (loglevel = log_level , loggers = ['' ])
413
+ setup_logging (loglevel = 'INFO' , loggers = ['' ])
408
414
409
415
config_cl = ConfigClient (
410
416
host = os .environ .get ('HX_ETCD_HOST' ),
411
417
port = int (os .environ .get ('HX_ETCD_PORT' )),
412
418
)
413
419
config_cl .wait_configured ()
420
+ params = config_cl .resource_discovery_params ()
421
+ log_level = 'INFO' if not params [- 1 ] else 'DEBUG'
422
+ setup_logging (loglevel = log_level , loggers = ['' ])
414
423
conn_str = 'amqp://{user}:{pass}@{host}:{port}' .format (
415
424
** config_cl .read_branch ('/rabbit' ))
416
425
with Connection (conn_str ) as conn :
0 commit comments