Verify if VM name exists before starting
This commit is contained in:
parent
d4dc3ac649
commit
19a75ea92e
|
@ -660,6 +660,11 @@ def run_os_command(command_string, background=False, environment=None, timeout=N
|
||||||
stderr = ''
|
stderr = ''
|
||||||
return retcode, stdout, stderr
|
return retcode, stdout, stderr
|
||||||
|
|
||||||
|
#
|
||||||
|
# Cloned VM provisioning function - executed by the Celery worker
|
||||||
|
#
|
||||||
|
def clone_vm(self, vm_name, vm_profile):
|
||||||
|
pass
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main VM provisioning function - executed by the Celery worker
|
# Main VM provisioning function - executed by the Celery worker
|
||||||
|
@ -753,6 +758,10 @@ def create_vm(self, vm_name, vm_profile):
|
||||||
self.update_state(state='RUNNING', meta={'current': 2, 'total': 10, 'status': 'Verifying configuration against cluster'})
|
self.update_state(state='RUNNING', meta={'current': 2, 'total': 10, 'status': 'Verifying configuration against cluster'})
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Verify that a VM with this name does not already exist
|
||||||
|
if pvc_vm.searchClusterByName(zk_conn, vm_name):
|
||||||
|
raise ClusterError("A VM with the name '{}' already exists in the cluster".format(vm_name))
|
||||||
|
|
||||||
# Verify that at least one host has enough free RAM to run the VM
|
# Verify that at least one host has enough free RAM to run the VM
|
||||||
_discard, nodes = pvc_node.get_list(zk_conn, None)
|
_discard, nodes = pvc_node.get_list(zk_conn, None)
|
||||||
target_node = None
|
target_node = None
|
||||||
|
|
|
@ -1073,6 +1073,7 @@ def api_status_root(task_id):
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
#
|
#
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Start main API
|
||||||
if config['debug']:
|
if config['debug']:
|
||||||
# Run in Flask standard mode
|
# Run in Flask standard mode
|
||||||
api.run(config['listen_address'], config['listen_port'])
|
api.run(config['listen_address'], config['listen_port'])
|
||||||
|
@ -1095,4 +1096,3 @@ if __name__ == '__main__':
|
||||||
print('Starting PyWSGI server at {}:{} with SSL={}, Authentication={}'.format(config['listen_address'], config['listen_port'], config['ssl_enabled'], config['auth_enabled']))
|
print('Starting PyWSGI server at {}:{} with SSL={}, Authentication={}'.format(config['listen_address'], config['listen_port'], config['ssl_enabled'], config['auth_enabled']))
|
||||||
http_server.serve_forever()
|
http_server.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue