add shutdown option do copy_vm_xcp
This commit is contained in:
parent
1805b22476
commit
9d4456faa4
@ -43,10 +43,11 @@ class copy_vm_xcp(backup_generic):
|
|||||||
type = 'copy-vm-xcp'
|
type = 'copy-vm-xcp'
|
||||||
|
|
||||||
required_params = backup_generic.required_params + ['server_name','storage_name','password_file','vm_name','network_name']
|
required_params = backup_generic.required_params + ['server_name','storage_name','password_file','vm_name','network_name']
|
||||||
optional_params = backup_generic.optional_params + ['start_vm','max_copies', 'delete_snapshot']
|
optional_params = backup_generic.optional_params + ['start_vm','max_copies', 'delete_snapshot', 'halt_vm']
|
||||||
|
|
||||||
start_vm = "no"
|
start_vm = "no"
|
||||||
max_copies = 1
|
max_copies = 1
|
||||||
|
halt_vm = "no"
|
||||||
delete_snapshot = "yes"
|
delete_snapshot = "yes"
|
||||||
|
|
||||||
def read_config(self,iniconf):
|
def read_config(self,iniconf):
|
||||||
@ -92,6 +93,17 @@ class copy_vm_xcp(backup_generic):
|
|||||||
result = (1,"error get VM opaqueref %s"%(error))
|
result = (1,"error get VM opaqueref %s"%(error))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
if str2bool(self.halt_vm):
|
||||||
|
status_vm = session.xenapi.VM.get_power_state(vm)
|
||||||
|
self.logger.debug("[%s] Status of VM: %s",self.backup_name,status_vm)
|
||||||
|
if status_vm == "Running":
|
||||||
|
self.logger.debug("[%s] Shudown in progress",self.backup_name)
|
||||||
|
if dry_run:
|
||||||
|
print "session.xenapi.VM.clean_shutdown(vm)"
|
||||||
|
else:
|
||||||
|
session.xenapi.VM.clean_shutdown(vm)
|
||||||
|
snapshot = vm
|
||||||
|
else:
|
||||||
#do the snapshot
|
#do the snapshot
|
||||||
self.logger.debug("[%s] Snapshot in progress",self.backup_name)
|
self.logger.debug("[%s] Snapshot in progress",self.backup_name)
|
||||||
try:
|
try:
|
||||||
@ -218,6 +230,7 @@ class copy_vm_xcp(backup_generic):
|
|||||||
if self.delete_snapshot == 'no':
|
if self.delete_snapshot == 'no':
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
if not str2bool(self.halt_vm):
|
||||||
#delete the snapshot
|
#delete the snapshot
|
||||||
try:
|
try:
|
||||||
for vbd in session.xenapi.VM.get_VBDs(snapshot):
|
for vbd in session.xenapi.VM.get_VBDs(snapshot):
|
||||||
@ -231,6 +244,13 @@ class copy_vm_xcp(backup_generic):
|
|||||||
except XenAPI.Failure, error:
|
except XenAPI.Failure, error:
|
||||||
result = (1,"error when destroy snapshot %s"%(error))
|
result = (1,"error when destroy snapshot %s"%(error))
|
||||||
return result
|
return result
|
||||||
|
else:
|
||||||
|
if status_vm == "Running":
|
||||||
|
self.logger.debug("[%s] Starting in progress",self.backup_name)
|
||||||
|
if dry_run:
|
||||||
|
print "session.xenapi.VM.start(vm,False,True)"
|
||||||
|
else:
|
||||||
|
session.xenapi.VM.start(vm,False,True)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user