Skip to content

Commit 36bfea3

Browse files
author
arnetogo
committed
added methods to poweroff/shutdown vms hard
1 parent 3f3723c commit 36bfea3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

oca/tests/test_virtualmachine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ def test_save_disk(self):
8989
def test_actions(self):
9090
oca.client = oca.Client('test:test')
9191
vm = oca.VirtualMachine(self.xml, self.client)
92-
for action in ['shutdown', 'hold', 'release', 'stop', 'cancel',
92+
for action in ['shutdown', 'shutdown_hard', 'poweroff', 'poweroff_hard', 'hold', 'release', 'stop', 'cancel',
9393
'suspend', 'resume', 'restart', 'finalize', 'delete']:
9494
self.client.call = Mock(return_value='')
9595
getattr(vm, action)()
96+
if action in ('shutdown_hard', 'poweroff_hard', 'undeploy_hard'):
97+
action = action.replace("_", "-")
9698
self.client.call.assert_called_once_with('vm.action', action, '6')
9799

98100
def test_repr(self):

oca/vm.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,24 @@ def shutdown(self):
170170
'''
171171
self._action('shutdown')
172172

173+
def shutdown_hard(self):
174+
'''
175+
Shutdown hard an already deployed VM
176+
'''
177+
self._action('shutdown-hard')
178+
179+
def poweroff(self):
180+
'''
181+
Power off an running vm
182+
'''
183+
self._action('poweroff')
184+
185+
def poweroff_hard(self):
186+
'''
187+
Power off hard an running vm
188+
'''
189+
self._action('poweroff-hard')
190+
173191
def cancel(self):
174192
'''
175193
Cancels a running VM

0 commit comments

Comments
 (0)