diff --git a/doc/rapi.rst b/doc/rapi.rst index ac20323b4e269b3c6806c0c0c0a2e910c22d7eee..9f8b1b9d146eac7fb6dd505f84af12ce56f1ed9c 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -628,6 +628,25 @@ to URI like:: It supports the ``dry-run`` argument. +``/2/instances-multi-alloc`` +++++++++++++++++++++++++++++ + +Tries to allocate multiple instances. + +It supports the following commands: ``POST`` + +``POST`` +~~~~~~~~ + +The parameters: + +.. opcode_params:: OP_INSTANCE_MULTI_ALLOC + +Job result: + +.. opcode_result:: OP_INSTANCE_MULTI_ALLOC + + ``/2/instances`` ++++++++++++++++ diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index b701d7141c34170258e3c26f87e73375f838a5ac..0fe7071e1fc5df650361b9310b461bd8919a3163 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -185,6 +185,7 @@ def GetHandlers(node_name_pattern, instance_name_pattern, re.compile(r"^/2/jobs/(%s)/wait$" % job_id_pattern): rlib2.R_2_jobs_id_wait, + "/2/instances-multi-alloc": rlib2.R_2_instances_multi_alloc, "/2/tags": rlib2.R_2_tags, "/2/info": rlib2.R_2_info, "/2/os": rlib2.R_2_os, diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index e77dca8a8c7ccc50558393b2104bba830412f2c2..b5514c42a5905c647b3bcc8a2f8806dcf7d76c7e 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -812,6 +812,24 @@ class R_2_instances(baserlib.OpcodeResource): }) +class R_2_instances_multi_alloc(baserlib.OpcodeResource): + """/2/instances-multi-alloc resource. + + """ + POST_OPCODE = opcodes.OpInstanceMultiAlloc + + def GetPostOpInput(self): + """Try to allocate multiple instances. + + @return: A dict with submitted jobs, allocatable instances and failed + allocations + + """ + return (self.request_body, { + "dry_run": self.dryRun(), + }) + + class R_2_instances_name(baserlib.OpcodeResource): """/2/instances/[instance_name] resource. diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index a09d4a2e2795e533d590d551f6b63d0e7c702148..ade61908cec54d78f52c4bc32d7e124e4373004e 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -46,6 +46,7 @@ import testutils _KNOWN_UNUSED = set([ rlib2.R_root, rlib2.R_2, + rlib2.R_2_instances_multi_alloc, ]) # Global variable for collecting used handlers