3 from sdcBePy import properties
4 from sdcBePy.common.healthCheck import check_backend, get_args
5 from sdcBePy.common.sdcBeProxy import SdcBeProxy
6 from sdcBePy.consumers.models.consumerCandidateList import get_consumers
7 from sdcBePy.users.run import colors
10 def be_consumers_init(be_ip, be_port, header, protocol, tls_cert, tls_key, tls_key_pw, ca_cert, consumer_candidate_list):
11 sdc_be_proxy = SdcBeProxy(be_ip, be_port, header, protocol, tls_cert, tls_key, tls_key_pw, ca_cert)
12 if check_backend(sdc_be_proxy, properties.retry_attempts):
13 for consumer in consumer_candidate_list:
14 if sdc_be_proxy.check_user(consumer.consumer_name) != 200:
15 result = sdc_be_proxy.create_consumer(*consumer.get_parameters())
17 print('[INFO]: ' + consumer.consumer_name +
18 ' created, result: [' + str(result) + ']')
20 print('[ERROR]: ' + colors.FAIL + consumer.consumer_name + colors.END_C +
21 ' error creating , result: [' + str(result) + ']')
23 print('[INFO]: ' + consumer.consumer_name + ' already exists')
25 print('[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + colors.FAIL
26 + ' Backend is DOWN :-(' + colors.END_C)
27 raise Exception("Cannot communicate with the backend!")
31 be_ip, be_port, header, protocol, tls_key, tls_cert, tls_key_pw, ca_cert = get_args()
32 be_consumers_init(be_ip, be_port, header, protocol, tls_cert, tls_key, tls_key_pw, ca_cert, get_consumers())
35 if __name__ == '__main__':