Skip to content
Snippets Groups Projects
Commit 2276aa29 authored by Oleksiy Mishchenko's avatar Oleksiy Mishchenko
Browse files

RAPI: Implement an instance reboot

Reviewed-by: imsnah
parent 8049a1d7
No related branches found
No related tags found
No related merge requests found
......@@ -140,5 +140,7 @@ CONNECTOR.update({
"/2/instances": rlib2.R_2_instances,
re.compile(r'^/2/instances/([\w\._-]+)$'): rlib1.R_instances_name,
re.compile(r'^/2/instances/([\w\._-]+)/tags$'): rlib2.R_2_instances_name_tags,
re.compile(r'^/2/instances/([\w\._-]+)/reboot$'):
rlib2.R_2_instances_name_reboot,
re.compile(r'/2/jobs/(%s)$' % constants.JOB_ID_TEMPLATE): rlib2.R_2_jobs_id,
})
......@@ -245,6 +245,33 @@ class R_2_instances(baserlib.R_Generic):
return job_id
class R_2_instances_name_reboot(baserlib.R_Generic):
"""/2/instances/[instance_name]/reboot resource.
Implements an instance reboot.
"""
DOC_URI = "/2/instances/[instance_name]/reboot"
def GET(self):
"""Reboot an instance.
"""
instance_name = self.items[0]
reboot_type = self.queryargs.get('reboot_type',
constants.INSTANCE_REBOOT_HARD)
ignore_secondaries = self.queryargs.get('ignore_secondaries', False)
op = ganeti.opcodes.OpRebootInstance(
instance_name=instance_name,
reboot_type=reboot_type,
ignore_secondaries=ignore_secondaries)
job_id = ganeti.cli.SendJob([op])
return job_id
class R_2_instances_name_tags(baserlib.R_Generic):
"""/2/instances/[instance_name]/tags resource.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment