Commit 1c7fd467 authored by Michael Hanselmann's avatar Michael Hanselmann

Add support for query resources in RAPI URIs

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent c1391810
...@@ -150,7 +150,8 @@ class R_2(baserlib.R_Generic): ...@@ -150,7 +150,8 @@ class R_2(baserlib.R_Generic):
def GetHandlers(node_name_pattern, instance_name_pattern, def GetHandlers(node_name_pattern, instance_name_pattern,
group_name_pattern, job_id_pattern, disk_pattern): group_name_pattern, job_id_pattern, disk_pattern,
query_res_pattern):
"""Returns all supported resources and their handlers. """Returns all supported resources and their handlers.
""" """
...@@ -246,4 +247,5 @@ def GetHandlers(node_name_pattern, instance_name_pattern, ...@@ -246,4 +247,5 @@ def GetHandlers(node_name_pattern, instance_name_pattern,
CONNECTOR.update(GetHandlers(_NAME_PATTERN, _NAME_PATTERN, _NAME_PATTERN, CONNECTOR.update(GetHandlers(_NAME_PATTERN, _NAME_PATTERN, _NAME_PATTERN,
constants.JOB_ID_TEMPLATE, _DISK_PATTERN)) constants.JOB_ID_TEMPLATE, _DISK_PATTERN,
_NAME_PATTERN))
...@@ -95,9 +95,10 @@ class TestDocs(unittest.TestCase): ...@@ -95,9 +95,10 @@ class TestDocs(unittest.TestCase):
group_name = re.escape("[group_name]") group_name = re.escape("[group_name]")
job_id = re.escape("[job_id]") job_id = re.escape("[job_id]")
disk_index = re.escape("[disk_index]") disk_index = re.escape("[disk_index]")
query_res = re.escape("[resource]")
resources = connector.GetHandlers(node_name, instance_name, group_name, resources = connector.GetHandlers(node_name, instance_name, group_name,
job_id, disk_index) job_id, disk_index, query_res)
handler_dups = utils.FindDuplicates(resources.values()) handler_dups = utils.FindDuplicates(resources.values())
self.assertFalse(handler_dups, self.assertFalse(handler_dups,
...@@ -110,6 +111,7 @@ class TestDocs(unittest.TestCase): ...@@ -110,6 +111,7 @@ class TestDocs(unittest.TestCase):
re.compile(group_name): "group4440", re.compile(group_name): "group4440",
re.compile(job_id): "9409", re.compile(job_id): "9409",
re.compile(disk_index): "123", re.compile(disk_index): "123",
re.compile(query_res): "lock",
} }
assert compat.all(VALID_URI_RE.match(value) assert compat.all(VALID_URI_RE.match(value)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment