Support disabling fuzzy limit matching
Used for the APIs when they filter by name but we don't want a fuzzy limit since we specified an exact name.
This commit is contained in:
parent
dc16f51b2a
commit
18520d6c77
|
@ -348,13 +348,14 @@ def unset_osd(zk_conn, option):
|
||||||
|
|
||||||
return success, message
|
return success, message
|
||||||
|
|
||||||
def get_list_osd(zk_conn, limit):
|
def get_list_osd(zk_conn, limit, is_fuzzy=True):
|
||||||
osd_list = []
|
osd_list = []
|
||||||
full_osd_list = zkhandler.listchildren(zk_conn, '/ceph/osds')
|
full_osd_list = zkhandler.listchildren(zk_conn, '/ceph/osds')
|
||||||
|
|
||||||
for osd in full_osd_list:
|
for osd in full_osd_list:
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implicitly assume fuzzy limits
|
# Implicitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
|
@ -674,13 +675,14 @@ def remove_pool(zk_conn, name):
|
||||||
|
|
||||||
return success, message
|
return success, message
|
||||||
|
|
||||||
def get_list_pool(zk_conn, limit):
|
def get_list_pool(zk_conn, limit, is_fuzzy=True):
|
||||||
pool_list = []
|
pool_list = []
|
||||||
full_pool_list = zkhandler.listchildren(zk_conn, '/ceph/pools')
|
full_pool_list = zkhandler.listchildren(zk_conn, '/ceph/pools')
|
||||||
|
|
||||||
for pool in full_pool_list:
|
for pool in full_pool_list:
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implicitly assume fuzzy limits
|
# Implicitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
|
@ -942,7 +944,7 @@ def remove_volume(zk_conn, pool, name):
|
||||||
|
|
||||||
return success, message
|
return success, message
|
||||||
|
|
||||||
def get_list_volume(zk_conn, pool, limit):
|
def get_list_volume(zk_conn, pool, limit, is_fuzzy=True):
|
||||||
volume_list = []
|
volume_list = []
|
||||||
if pool and not verifyPool(zk_conn, name):
|
if pool and not verifyPool(zk_conn, name):
|
||||||
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name)
|
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(name)
|
||||||
|
@ -953,6 +955,7 @@ def get_list_volume(zk_conn, pool, limit):
|
||||||
pool_name, volume_name = volume.split('/')
|
pool_name, volume_name = volume.split('/')
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implicitly assume fuzzy limits
|
# Implicitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
|
@ -1158,7 +1161,7 @@ def remove_snapshot(zk_conn, pool, volume, name):
|
||||||
|
|
||||||
return success, message
|
return success, message
|
||||||
|
|
||||||
def get_list_snapshot(zk_conn, pool, volume, limit):
|
def get_list_snapshot(zk_conn, pool, volume, limit, is_fuzzy=True):
|
||||||
snapshot_list = []
|
snapshot_list = []
|
||||||
if pool and not verifyPool(zk_conn, pool):
|
if pool and not verifyPool(zk_conn, pool):
|
||||||
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(pool)
|
return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format(pool)
|
||||||
|
@ -1173,11 +1176,13 @@ def get_list_snapshot(zk_conn, pool, volume, limit):
|
||||||
pool_name, volume_name = volume.split('/')
|
pool_name, volume_name = volume.split('/')
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implicitly assume fuzzy limits
|
# Implicitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
if not re.match('.*\$', limit):
|
if not re.match('.*\$', limit):
|
||||||
limit = limit + '.*'
|
limit = limit + '.*'
|
||||||
|
|
||||||
if re.match(limit, snapshot):
|
if re.match(limit, snapshot):
|
||||||
snapshot_list.append(getVolumeInformation(zk_conn, pool_name, volume_name, snapshot_name))
|
snapshot_list.append(getVolumeInformation(zk_conn, pool_name, volume_name, snapshot_name))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -491,7 +491,7 @@ def get_info(zk_conn, network):
|
||||||
|
|
||||||
return True, network_information
|
return True, network_information
|
||||||
|
|
||||||
def get_list(zk_conn, limit):
|
def get_list(zk_conn, limit, is_fuzzy=True):
|
||||||
net_list = []
|
net_list = []
|
||||||
full_net_list = zkhandler.listchildren(zk_conn, '/networks')
|
full_net_list = zkhandler.listchildren(zk_conn, '/networks')
|
||||||
|
|
||||||
|
@ -499,6 +499,7 @@ def get_list(zk_conn, limit):
|
||||||
description = zkhandler.readdata(zk_conn, '/networks/{}'.format(net))
|
description = zkhandler.readdata(zk_conn, '/networks/{}'.format(net))
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implcitly assume fuzzy limits
|
# Implcitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
|
@ -517,7 +518,7 @@ def get_list(zk_conn, limit):
|
||||||
#output_string = formatNetworkList(zk_conn, net_list)
|
#output_string = formatNetworkList(zk_conn, net_list)
|
||||||
return True, net_list
|
return True, net_list
|
||||||
|
|
||||||
def get_list_dhcp(zk_conn, network, limit, only_static=False):
|
def get_list_dhcp(zk_conn, network, limit, only_static=False, is_fuzzy=True):
|
||||||
# Validate and obtain alternate passed value
|
# Validate and obtain alternate passed value
|
||||||
net_vni = getNetworkVNI(zk_conn, network)
|
net_vni = getNetworkVNI(zk_conn, network)
|
||||||
if not net_vni:
|
if not net_vni:
|
||||||
|
@ -532,7 +533,7 @@ def get_list_dhcp(zk_conn, network, limit, only_static=False):
|
||||||
full_dhcp_list = getNetworkDHCPLeases(zk_conn, net_vni)
|
full_dhcp_list = getNetworkDHCPLeases(zk_conn, net_vni)
|
||||||
reservations = False
|
reservations = False
|
||||||
|
|
||||||
if limit:
|
if limit and is_fuzzy:
|
||||||
try:
|
try:
|
||||||
# Implcitly assume fuzzy limits
|
# Implcitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
|
@ -559,7 +560,7 @@ def get_list_dhcp(zk_conn, network, limit, only_static=False):
|
||||||
#output_string = formatDHCPLeaseList(zk_conn, net_vni, dhcp_list, reservations=reservations)
|
#output_string = formatDHCPLeaseList(zk_conn, net_vni, dhcp_list, reservations=reservations)
|
||||||
return True, dhcp_list
|
return True, dhcp_list
|
||||||
|
|
||||||
def get_list_acl(zk_conn, network, limit, direction):
|
def get_list_acl(zk_conn, network, limit, direction, is_fuzzy=True):
|
||||||
# Validate and obtain alternate passed value
|
# Validate and obtain alternate passed value
|
||||||
net_vni = getNetworkVNI(zk_conn, network)
|
net_vni = getNetworkVNI(zk_conn, network)
|
||||||
if not net_vni:
|
if not net_vni:
|
||||||
|
@ -576,7 +577,7 @@ def get_list_acl(zk_conn, network, limit, direction):
|
||||||
acl_list = []
|
acl_list = []
|
||||||
full_acl_list = getNetworkACLs(zk_conn, net_vni, direction)
|
full_acl_list = getNetworkACLs(zk_conn, net_vni, direction)
|
||||||
|
|
||||||
if limit:
|
if limit and is_fuzzy:
|
||||||
try:
|
try:
|
||||||
# Implcitly assume fuzzy limits
|
# Implcitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
|
|
|
@ -231,13 +231,14 @@ def get_info(zk_conn, node):
|
||||||
|
|
||||||
return True, node_information
|
return True, node_information
|
||||||
|
|
||||||
def get_list(zk_conn, limit):
|
def get_list(zk_conn, limit, is_fuzzy=True):
|
||||||
node_list = []
|
node_list = []
|
||||||
full_node_list = zkhandler.listchildren(zk_conn, '/nodes')
|
full_node_list = zkhandler.listchildren(zk_conn, '/nodes')
|
||||||
|
|
||||||
for node in full_node_list:
|
for node in full_node_list:
|
||||||
if limit:
|
if limit:
|
||||||
try:
|
try:
|
||||||
|
if is_fuzzy:
|
||||||
# Implcitly assume fuzzy limits
|
# Implcitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
limit = '.*' + limit
|
limit = '.*' + limit
|
||||||
|
|
|
@ -560,7 +560,7 @@ def get_info(zk_conn, domain):
|
||||||
|
|
||||||
return True, domain_information
|
return True, domain_information
|
||||||
|
|
||||||
def get_list(zk_conn, node, state, limit):
|
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):
|
||||||
|
@ -575,7 +575,7 @@ def get_list(zk_conn, node, state, limit):
|
||||||
vm_list = []
|
vm_list = []
|
||||||
|
|
||||||
# Set our limit to a sensible regex
|
# Set our limit to a sensible regex
|
||||||
if limit:
|
if limit and is_fuzzy:
|
||||||
try:
|
try:
|
||||||
# Implcitly assume fuzzy limits
|
# Implcitly assume fuzzy limits
|
||||||
if not re.match('\^.*', limit):
|
if not re.match('\^.*', limit):
|
||||||
|
|
Loading…
Reference in New Issue