Add quotes around vars in all return messages
This commit is contained in:
parent
dd78aa8fb8
commit
a3de9da513
|
@ -208,7 +208,7 @@ def add_osd(zk_conn, node, device, weight):
|
||||||
# Verify target block device isn't in use
|
# Verify target block device isn't in use
|
||||||
block_osd = verifyOSDBlock(zk_conn, node, device)
|
block_osd = verifyOSDBlock(zk_conn, node, device)
|
||||||
if block_osd:
|
if block_osd:
|
||||||
return False, 'ERROR: Block device {} on node {} is used by OSD {}'.format(device, node, block_osd)
|
return False, 'ERROR: Block device "{}" on node "{}" is used by OSD "{}"'.format(device, node, block_osd)
|
||||||
|
|
||||||
# Tell the cluster to create a new OSD for the host
|
# Tell the cluster to create a new OSD for the host
|
||||||
add_osd_string = 'osd_add {},{},{}'.format(node, device, weight)
|
add_osd_string = 'osd_add {},{},{}'.format(node, device, weight)
|
||||||
|
@ -253,7 +253,7 @@ def remove_osd(zk_conn, osd_id):
|
||||||
try:
|
try:
|
||||||
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
||||||
if result == 'success-osd_remove':
|
if result == 'success-osd_remove':
|
||||||
message = 'Removed OSD {} from the cluster.'.format(osd_id)
|
message = 'Removed OSD "{}" from the cluster.'.format(osd_id)
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
message = 'ERROR: Failed to remove OSD; check node logs for details.'
|
message = 'ERROR: Failed to remove OSD; check node logs for details.'
|
||||||
|
@ -702,7 +702,7 @@ def remove_pool(zk_conn, name):
|
||||||
try:
|
try:
|
||||||
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
||||||
if result == 'success-pool_remove':
|
if result == 'success-pool_remove':
|
||||||
message = 'Removed RBD pool {} and all volumes.'.format(name)
|
message = 'Removed RBD pool "{}" and all volumes.'.format(name)
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
message = 'ERROR: Failed to remove pool; check node logs for details.'
|
message = 'ERROR: Failed to remove pool; check node logs for details.'
|
||||||
|
@ -981,7 +981,7 @@ def remove_volume(zk_conn, pool, name):
|
||||||
try:
|
try:
|
||||||
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
||||||
if result == 'success-volume_remove':
|
if result == 'success-volume_remove':
|
||||||
message = 'Removed RBD volume {} in pool {}.'.format(name, pool)
|
message = 'Removed RBD volume "{}" in pool "{}".'.format(name, pool)
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
message = 'ERROR: Failed to remove volume; check node logs for details.'
|
message = 'ERROR: Failed to remove volume; check node logs for details.'
|
||||||
|
@ -1198,7 +1198,7 @@ def remove_snapshot(zk_conn, pool, volume, name):
|
||||||
try:
|
try:
|
||||||
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
result = zkhandler.readdata(zk_conn, '/ceph/cmd').split()[0]
|
||||||
if result == 'success-snapshot_remove':
|
if result == 'success-snapshot_remove':
|
||||||
message = 'Removed RBD snapshot {} and all volumes.'.format(name)
|
message = 'Removed RBD snapshot "{}" of volume "{}" in pool "{}".'.format(name, volume, pool)
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
message = 'ERROR: Failed to remove snapshot; check node logs for details.'
|
message = 'ERROR: Failed to remove snapshot; check node logs for details.'
|
||||||
|
|
|
@ -231,11 +231,11 @@ def add_network(zk_conn, vni, description, nettype,
|
||||||
|
|
||||||
# Check if a network with this VNI or description already exists
|
# Check if a network with this VNI or description already exists
|
||||||
if zkhandler.exists(zk_conn, '/networks/{}'.format(vni)):
|
if zkhandler.exists(zk_conn, '/networks/{}'.format(vni)):
|
||||||
return False, 'ERROR: A network with VNI {} already exists!'.format(vni)
|
return False, 'ERROR: A network with VNI "{}" already exists!'.format(vni)
|
||||||
for network in zkhandler.listchildren(zk_conn, '/networks'):
|
for network in zkhandler.listchildren(zk_conn, '/networks'):
|
||||||
network_description = zkhandler.readdata(zk_conn, '/networks/{}'.format(network))
|
network_description = zkhandler.readdata(zk_conn, '/networks/{}'.format(network))
|
||||||
if network_description == description:
|
if network_description == description:
|
||||||
return False, 'ERROR: A network with description {} already exists!'.format(description)
|
return False, 'ERROR: A network with description "{}" already exists!'.format(description)
|
||||||
|
|
||||||
# We're generating the default gateway to be ip6_network::1/YY
|
# We're generating the default gateway to be ip6_network::1/YY
|
||||||
if ip6_network:
|
if ip6_network:
|
||||||
|
|
|
@ -112,7 +112,7 @@ def secondary_node(zk_conn, node):
|
||||||
'/primary_node': 'none'
|
'/primary_node': 'none'
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
return False, 'Node {} is already in secondary router mode.'.format(node)
|
return False, 'Node "{}" is already in secondary router mode.'.format(node)
|
||||||
|
|
||||||
return True, retmsg
|
return True, retmsg
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ def primary_node(zk_conn, node):
|
||||||
'/primary_node': node
|
'/primary_node': node
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
return False, 'Node {} is already in primary router mode.'.format(node)
|
return False, 'Node "{}" is already in primary router mode.'.format(node)
|
||||||
|
|
||||||
return True, retmsg
|
return True, retmsg
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ def define_vm(zk_conn, config_data, target_node, selector):
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
valid_node = common.verifyNode(zk_conn, target_node)
|
valid_node = common.verifyNode(zk_conn, target_node)
|
||||||
if not valid_node:
|
if not valid_node:
|
||||||
return False, "Specified node {} is invalid.".format(target_node)
|
return False, 'Specified node "{}" is invalid.'.format(target_node)
|
||||||
|
|
||||||
# Add the new domain to Zookeeper
|
# Add the new domain to Zookeeper
|
||||||
zkhandler.writedata(zk_conn, {
|
zkhandler.writedata(zk_conn, {
|
||||||
|
@ -382,7 +382,7 @@ def move_vm(zk_conn, domain, target_node, selector):
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
valid_node = common.verifyNode(zk_conn, target_node)
|
valid_node = common.verifyNode(zk_conn, target_node)
|
||||||
if not valid_node:
|
if not valid_node:
|
||||||
return False, "Specified node {} is invalid.".format(target_node)
|
return False, 'Specified node "{}" is invalid.'.format(target_node)
|
||||||
|
|
||||||
# Verify if node is current node
|
# Verify if node is current node
|
||||||
if target_node == current_node:
|
if target_node == current_node:
|
||||||
|
@ -437,7 +437,7 @@ def migrate_vm(zk_conn, domain, target_node, selector, force_migrate, is_cli=Fal
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
valid_node = common.verifyNode(zk_conn, target_node)
|
valid_node = common.verifyNode(zk_conn, target_node)
|
||||||
if not valid_node:
|
if not valid_node:
|
||||||
return False, "Specified node {} is invalid.".format(target_node)
|
return False, 'Specified node "{}" is invalid.'.format(target_node)
|
||||||
|
|
||||||
# Verify if node is current node
|
# Verify if node is current node
|
||||||
if target_node == current_node:
|
if target_node == current_node:
|
||||||
|
@ -568,7 +568,7 @@ def get_list(zk_conn, node, state, limit, is_fuzzy=True):
|
||||||
if node:
|
if node:
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
if not common.verifyNode(zk_conn, node):
|
if not common.verifyNode(zk_conn, node):
|
||||||
return False, "Specified node {} is invalid.".format(node)
|
return False, 'Specified node "{}" is invalid.'.format(node)
|
||||||
|
|
||||||
if state:
|
if state:
|
||||||
valid_states = [ 'start', 'restart', 'shutdown', 'stop', 'failed', 'migrate', 'unmigrate' ]
|
valid_states = [ 'start', 'restart', 'shutdown', 'stop', 'failed', 'migrate', 'unmigrate' ]
|
||||||
|
|
Loading…
Reference in New Issue