refactor: use specific IDs for VMs
This commit is contained in:
parent
30b15202ba
commit
5ffeba96ed
29
main.py
29
main.py
@ -46,27 +46,38 @@ def main():
|
||||
'worker1': f'{prefix}-node1',
|
||||
'worker2': f'{prefix}-node2',
|
||||
}
|
||||
vm_ids = {
|
||||
'master': 500,
|
||||
'worker1': 501,
|
||||
'worker2': 502,
|
||||
}
|
||||
|
||||
vm_id_master, upid_master = clone_template(
|
||||
proxmox,
|
||||
node,
|
||||
template_id,
|
||||
newid=vm_ids['master'],
|
||||
name=vm_names['master'],
|
||||
)
|
||||
assert vm_id_master == vm_ids['master']
|
||||
|
||||
vm_id_worker1, upid_worker1 = clone_template(
|
||||
proxmox,
|
||||
node,
|
||||
template_id,
|
||||
newid=vm_ids['worker1'],
|
||||
name=vm_names['worker1'],
|
||||
)
|
||||
assert vm_id_worker1 == vm_ids['worker1']
|
||||
|
||||
vm_id_worker2, upid_worker2 = clone_template(
|
||||
proxmox,
|
||||
node,
|
||||
template_id,
|
||||
newid=vm_ids['worker2'],
|
||||
name=vm_names['worker2'],
|
||||
)
|
||||
assert vm_id_worker2 == vm_ids['worker2']
|
||||
|
||||
logger.info('Waiting for clone tasks to complete...')
|
||||
wait_status(
|
||||
@ -81,14 +92,14 @@ def main():
|
||||
logger.info('Tasks completed!')
|
||||
|
||||
logger.info('Starting VMs...')
|
||||
proxmox.nodes(node).qemu(vm_id_master).status.start.post()
|
||||
proxmox.nodes(node).qemu(vm_id_worker1).status.start.post()
|
||||
proxmox.nodes(node).qemu(vm_id_worker2).status.start.post()
|
||||
proxmox.nodes(node).qemu(vm_ids['master']).status.start.post()
|
||||
proxmox.nodes(node).qemu(vm_ids['worker1']).status.start.post()
|
||||
proxmox.nodes(node).qemu(vm_ids['worker2']).status.start.post()
|
||||
wait_status(
|
||||
[
|
||||
proxmox.nodes(node).qemu(vm_id_master).status.current.get,
|
||||
proxmox.nodes(node).qemu(vm_id_worker1).status.current.get,
|
||||
proxmox.nodes(node).qemu(vm_id_worker2).status.current.get,
|
||||
proxmox.nodes(node).qemu(vm_ids['master']).status.current.get,
|
||||
proxmox.nodes(node).qemu(vm_ids['worker1']).status.current.get,
|
||||
proxmox.nodes(node).qemu(vm_ids['worker2']).status.current.get,
|
||||
],
|
||||
'running'
|
||||
)
|
||||
@ -96,9 +107,9 @@ def main():
|
||||
sleep(40)
|
||||
logger.info('VMs are running!')
|
||||
|
||||
vm_ip_master = get_vm_ip(proxmox, node, vm_id_master)
|
||||
vm_ip_worker1 = get_vm_ip(proxmox, node, vm_id_worker1)
|
||||
vm_ip_worker2 = get_vm_ip(proxmox, node, vm_id_worker2)
|
||||
vm_ip_master = get_vm_ip(proxmox, node, vm_ids['master'])
|
||||
vm_ip_worker1 = get_vm_ip(proxmox, node, vm_ids['worker1'])
|
||||
vm_ip_worker2 = get_vm_ip(proxmox, node, vm_ids['worker2'])
|
||||
proxmox.logout()
|
||||
|
||||
with open('run/vm_ids' ,'w') as ofile:
|
||||
|
Loading…
Reference in New Issue
Block a user