{
"1": {
"tgbot": {
"new_name:": "tgbot-go-7.node.eu.consul",
"os:": "Debian 10.1 x64",
"memory:": 2048,
"cpu:": 4,
"cpuNumber:": 4,
"disk:": 8192
}
},
"2": {
"tgbot": {
"new_name:": "tgbot-go-7.node.eu.consul",
"os:": "Debian 10.1 x64",
"memory:": 2048,
"cpu:": 4,
"cpuNumber:": 4,
"disk:": 8192
}
},
vm_to_create = {}
nodes = {1:0,2:0,3:0,4:0,5:0}
for vm in asl_vms:
if check_language(vm['name']) and check_os_version(vm['distribution']['description']):
first_part = get_service_name(vm['name'])
new_vm_name = get_next_hostname(vm['name'])
vm_res = {'first_part_name:' : first_part, 'os:' : vm['distribution']['description'],'memory:' : vm['memory'],'cpu:' : vm['cpu'],'cpuNumber:' : vm['cpuNumber'],'disk:' : vm['disk']}
for num in nodes:
if first_part not in nodes.values():
vm_to_create[new_vm_name] = vm_res
nodes[num] = vm_to_create
else:
continue
print(json.dumps(nodes))
node
, т.е. моя псевдо проверка: if first_part not in nodes.values():
не работает. 1 node:
aff-java-1.node.eu.consul
tgbot-go-1.node.eu.consul #tg bot не конфликтует по имени, поэтому записывается на 1 node
2 node:
aff-java-3.node.eu.consul #он не на первом, так как там уже есть aff
3 node:
0
4 node:
0
5 node: #3,4,5 создаются, но пустые, просто в данном случае машины кончились
0
node
уже такое-то имя или нет nodes = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for vm in asl_vms:
if check_language(vm['name']) and check_os_version(vm['distribution']['description']):
first_part = get_service_name(vm['name'])
vm_res = {'os:' : vm['distribution']['description'],'memory:' : vm['memory'],'cpu:' : vm['cpu'],'cpuNumber:' : vm['cpuNumber'],'disk:' : vm['disk']}
for num in nodes:
if type (nodes[num]) is dict:
if first_part not in [x.split('-')[0] for x in nodes[num].keys()]:
nodes[num][first_part]=vm_res
else:
nodes[num][first_part]=vm_res
print(json.dumps(nodes))
TypeError: 'int' object does not support item assignment
nodes = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for vm in asl_vms:
if check_language(vm['name']) == True and check_os_version(vm['distribution']['description']) == True:
fst_part = get_service_name(vm['name'])
vm_res = {'1st_part_name:' : fst_part,'os:' : vm['distribution']['description'],'memory:' : vm['memory'],'cpu:' : vm['cpu'],'cpuNumber:' : vm['cpuNumber'],'disk:' : vm['disk']}
for num in nodes:
if re.match(r'aff', list(vm_res.keys())[0]):
continue
else:
new_vm_name = get_next_hostname(vm['name'])
vm_to_create[new_vm_name] = vm_res
ready_for_nodes[num] = vm_to_create
print(json.dumps(ready_for_nodes))
vm_res = {'os:' : vm['distribution']['description'],'memory:' : vm['memory'],'cpu:' : vm['cpu'],'cpuNumber:' : vm['cpuNumber'],'disk:' : vm['disk']}
vm_to_create[new_vm_name] = vm_res
welcome-php-2.node.eu.consul
tgbot-go-1.node.eu.consul
aff-java-1337.node.eu.consul
if check_language(vm['name']) == True and check_os_version(vm['distribution']['description']) == True:
vm_to_create =
Как это сделать? if check_language(vm['name']) == True and check_os_version(vm['distribution']['description']) == True:
но это не человеку читать, а прометеусу, так что вывод не особо важен