Commit 7fa310f6 authored by René Nussbaumer's avatar René Nussbaumer

RAPI: Convert instance shutdown to the new FillOpCode

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 713a79e7
......@@ -655,6 +655,9 @@ Shutdowns an instance.
It supports the ``dry-run`` argument.
.. opcode_params:: OP_INSTANCE_SHUTDOWN
:exclude: instance_name, dry_run
``/2/instances/[instance_name]/startup``
++++++++++++++++++++++++++++++++++++++++
......
......@@ -869,6 +869,19 @@ class R_2_instances_name_startup(baserlib.R_Generic):
return baserlib.SubmitJob([op])
def _ParseShutdownInstanceRequest(name, data, dry_run):
"""Parses a request for an instance shutdown.
@rtype: L{opcodes.OpInstanceShutdown}
@return: Instance shutdown opcode
"""
return baserlib.FillOpcode(opcodes.OpInstanceShutdown, data, {
"instance_name": name,
"dry_run": dry_run,
})
class R_2_instances_name_shutdown(baserlib.R_Generic):
"""/2/instances/[instance_name]/shutdown resource.
......@@ -878,10 +891,13 @@ class R_2_instances_name_shutdown(baserlib.R_Generic):
def PUT(self):
"""Shutdown an instance.
@return: a job id
"""
instance_name = self.items[0]
op = opcodes.OpInstanceShutdown(instance_name=instance_name,
dry_run=bool(self.dryRun()))
baserlib.CheckType(self.request_body, dict, "Body contents")
op = _ParseShutdownInstanceRequest(self.items[0], self.request_body,
bool(self.dryRun()))
return baserlib.SubmitJob([op])
......
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