Add pipeline for VM lock flush cmd

This commit is contained in:
2019-08-07 13:49:33 -04:00
parent d63d9637a5
commit a2a630f6a0
2 changed files with 34 additions and 3 deletions

View File

@ -64,6 +64,31 @@ def flush_locks(zk_conn, logger, dom_uuid):
continue
logger.out('Freed RBD lock "{}" on volume "{}"'.format(lock, rbd), state='o')
# Primary command function
def run_command(zk_conn, logger, this_node, data):
# Get the command and args
command, args = data.split()
# Flushing VM RBD locks
if command == 'flush_locks':
dom_uuid = args
if this_node.router_state == 'primary':
# Lock the command queue
zk_lock = zkhandler.writelock(zk_conn, '/cmd/domains')
with zk_lock:
# Add the OSD
result = flush_locks(zk_conn, logger, dom_uuid)
# Command succeeded
if result:
# Update the command queue
zkhandler.writedata(zk_conn, {'/cmd/domains': 'success-{}'.format(data)})
# Command failed
else:
# Update the command queue
zkhandler.writedata(zk_conn, {'/cmd/domains': 'failure-{}'.format(data)})
# Wait 1 seconds before we free the lock, to ensure the client hits the lock
time.sleep(1)
class VMInstance(object):
# Initialization function
def __init__(self, domuuid, zk_conn, config, logger, this_node):