Merge lp:~nuclearbob/utah/cobbler-power-workaround into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 750
Proposed branch: lp:~nuclearbob/utah/cobbler-power-workaround
Merge into: lp:utah
Diff against target: 68 lines (+17/-14)
1 file modified
utah/provisioning/baremetal/cobbler.py (+17/-14)
To merge this branch: bzr merge lp:~nuclearbob/utah/cobbler-power-workaround
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+134559@code.launchpad.net

Description of the change

This branch modifies the CobblerMachine to use non-cobbler power management scripts if the cobbler ones fail.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks okay to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/baremetal/cobbler.py'
2--- utah/provisioning/baremetal/cobbler.py 2012-11-07 19:49:03 +0000
3+++ utah/provisioning/baremetal/cobbler.py 2012-11-15 20:05:31 +0000
4@@ -16,10 +16,11 @@
5 SSHMixin,
6 )
7 from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException
8+from utah.provisioning.baremetal.power import PowerMixin
9 from utah.retry import retry
10
11
12-class CobblerMachine(CustomInstallMixin, SSHMixin, Machine):
13+class CobblerMachine(CustomInstallMixin, SSHMixin, PowerMixin, Machine):
14 """
15 Provide a class to provision a machine via cobbler.
16 """
17@@ -34,6 +35,10 @@
18 'No cobbler arguments given for machine creation')
19 else:
20 self.cargs = cargs
21+ self.power = {}
22+ for item in cargs:
23+ if 'power' in item:
24+ self.power[item] = cargs[item]
25 self.inventory = inventory
26 if preseed is None:
27 preseed = '/etc/utah/default-preseed.cfg'
28@@ -228,29 +233,27 @@
29 def _start(self):
30 """
31 Use cobbler to start the machine.
32+ If that fails, use the powercommand generated by PowerMachine.
33 """
34 self.logger.debug('Starting system')
35- self._cobble(['system', 'poweron', '--name=' + self.name])
36+ try:
37+ self._cobble(['system', 'poweron', '--name=' + self.name])
38+ except UTAHBMProvisioningException:
39+ self._runargs(self.powercommand() + ['on'])
40 self.active = True
41
42 def stop(self):
43 """
44 Use cobbler to stop the machine.
45+ If that fails, use the powercommand generated by PowerMachine.
46 """
47 self.logger.debug('Stopping system')
48- self._cobble(['system', 'poweroff', '--name=' + self.name])
49+ try:
50+ self._cobble(['system', 'poweroff', '--name=' + self.name])
51+ except UTAHBMProvisioningException:
52+ self._runargs(self.powercommand() + ['off'])
53 self.active = False
54-
55- def restart(self):
56- """
57- Stop the machine, wait powertimeout, then start it/
58- """
59- self.logger.info('Restarting system')
60- self.stop()
61- self.logger.debug('Waiting ' + str(config.powertimeout) + ' seconds')
62- time.sleep(config.powertimeout)
63- self._start()
64-
65+
66 def __del__(self):
67 """
68 If the machine has an inventory, tell the inventory to release the

Subscribers

People subscribed via source and target branches