Commit a8732cfd authored by Christos's avatar Christos Committed by Christos Stavrakakis
Browse files

cyclades: Add SnapshotInstance RAPI method

Extend Ganeti RAPI client with 'SnapshotInstane' method.
parent b1cdaeab
......@@ -1051,6 +1051,13 @@ def detach_volume(vm, volume):
return client.ModifyInstance(**kwargs)
def snapshot_instance(vm, snapshot_name):
#volume = instance.volumes.all()[0]
with pooled_rapi_client(vm) as client:
return client.SnapshotInstance(instance=vm.backend_vm_id,
def get_instances(backend, bulk=True):
with pooled_rapi_client(backend) as c:
return c.GetInstances(bulk=bulk)
......@@ -546,6 +546,30 @@ class GanetiRapiClient(object): # pylint: disable=R0904
("/%s/instances/%s/deactivate-disks" %
(GANETI_RAPI_VERSION, instance)), None, None)
def SnapshotInstance(self, instance, snapshot_name, dry_run=False):
"""Replaces disks on an instance.
@type instance: str
@param instance: instance whose disks to replace
@type snapshot_name: str
@param snapshot_name: name of the new snapshot
@rtype: string
@return: job id
body = {
"disks": [(0, {"snapshot_name": snapshot_name})],
query = []
_AppendDryRunIf(query, dry_run)
return self._SendRequest(HTTP_PUT,
("/%s/instances/%s/snapshot" %
(GANETI_RAPI_VERSION, instance)), query, body)
def RecreateInstanceDisks(self, instance, disks=None, nodes=None):
"""Recreate an instance's disks.
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