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
=== modified file 'utah/provisioning/baremetal/cobbler.py'
--- utah/provisioning/baremetal/cobbler.py 2012-11-07 19:49:03 +0000
+++ utah/provisioning/baremetal/cobbler.py 2012-11-15 20:05:31 +0000
@@ -16,10 +16,11 @@
16 SSHMixin,16 SSHMixin,
17 )17 )
18from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException18from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException
19from utah.provisioning.baremetal.power import PowerMixin
19from utah.retry import retry20from utah.retry import retry
2021
2122
22class CobblerMachine(CustomInstallMixin, SSHMixin, Machine):23class CobblerMachine(CustomInstallMixin, SSHMixin, PowerMixin, Machine):
23 """24 """
24 Provide a class to provision a machine via cobbler.25 Provide a class to provision a machine via cobbler.
25 """26 """
@@ -34,6 +35,10 @@
34 'No cobbler arguments given for machine creation')35 'No cobbler arguments given for machine creation')
35 else:36 else:
36 self.cargs = cargs37 self.cargs = cargs
38 self.power = {}
39 for item in cargs:
40 if 'power' in item:
41 self.power[item] = cargs[item]
37 self.inventory = inventory42 self.inventory = inventory
38 if preseed is None:43 if preseed is None:
39 preseed = '/etc/utah/default-preseed.cfg'44 preseed = '/etc/utah/default-preseed.cfg'
@@ -228,29 +233,27 @@
228 def _start(self):233 def _start(self):
229 """234 """
230 Use cobbler to start the machine.235 Use cobbler to start the machine.
236 If that fails, use the powercommand generated by PowerMachine.
231 """237 """
232 self.logger.debug('Starting system')238 self.logger.debug('Starting system')
233 self._cobble(['system', 'poweron', '--name=' + self.name])239 try:
240 self._cobble(['system', 'poweron', '--name=' + self.name])
241 except UTAHBMProvisioningException:
242 self._runargs(self.powercommand() + ['on'])
234 self.active = True243 self.active = True
235244
236 def stop(self):245 def stop(self):
237 """246 """
238 Use cobbler to stop the machine.247 Use cobbler to stop the machine.
248 If that fails, use the powercommand generated by PowerMachine.
239 """249 """
240 self.logger.debug('Stopping system')250 self.logger.debug('Stopping system')
241 self._cobble(['system', 'poweroff', '--name=' + self.name])251 try:
252 self._cobble(['system', 'poweroff', '--name=' + self.name])
253 except UTAHBMProvisioningException:
254 self._runargs(self.powercommand() + ['off'])
242 self.active = False255 self.active = False
243256
244 def restart(self):
245 """
246 Stop the machine, wait powertimeout, then start it/
247 """
248 self.logger.info('Restarting system')
249 self.stop()
250 self.logger.debug('Waiting ' + str(config.powertimeout) + ' seconds')
251 time.sleep(config.powertimeout)
252 self._start()
253
254 def __del__(self):257 def __del__(self):
255 """258 """
256 If the machine has an inventory, tell the inventory to release the259 If the machine has an inventory, tell the inventory to release the

Subscribers

People subscribed via source and target branches