Merge lp:~nuclearbob/utah/loop-exception into lp:utah

Proposed by Max Brustkern
Status: Merged
Approved by: Max Brustkern
Approved revision: 821
Merged at revision: 815
Proposed branch: lp:~nuclearbob/utah/loop-exception
Merge into: lp:utah
Diff against target: 47 lines (+12/-7)
1 file modified
utah/provisioning/baremetal/cobbler.py (+12/-7)
To merge this branch: bzr merge lp:~nuclearbob/utah/loop-exception
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Max Brustkern (community) Needs Resubmitting
Javier Collado (community) Approve
Review via email: mp+148216@code.launchpad.net

Description of the change

This branch raises an exception when an attempt to mount an ISO fails. If the status is 2, the exception suggests a lack of loop devices as the most likely cause.

To test this, I copied the inventory database from mangers-orchestra, installed NFS on my local machine, mounted enough ISOs to fill up all of my loop devices, and ran this command from the branch directory:
PYTHONPATH=. ./examples/run_test_cobbler.py --name acer-veriton-03 /usr/share/utah/client/examples/pass.run -i /var/cache/utah/iso/precise-desktop-i386.iso

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

Looks good to me.

On line 41 perhaps you could just have:

raise UTAHBMProvisioningException(
    'NFS needed for {}'.format(self.installtype)
)

review: Approve
Revision history for this message
Andy Doan (doanac) wrote :

On 02/13/2013 09:46 AM, Max Brustkern wrote:
> + raise UTAHBMProvisioningException(
> + 'Mount failed with return code: {}'
> + .format(returncode))

Could you add the command's output to this as well?

lp:~nuclearbob/utah/loop-exception updated
818. By Max Brustkern

Improved exception install type specification

Revision history for this message
Joe Talbott (joetalbott) wrote :

Comment on line 33 needs to be updated as well.

Revision history for this message
Javier Collado (javier.collado) wrote :

I reproduced the problem as explained in the merge description and worked as expected.

review: Approve
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Implemented that.

review: Needs Resubmitting
lp:~nuclearbob/utah/loop-exception updated
819. By Max Brustkern

Finished sentence

820. By Max Brustkern

Added output to exception

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Initially I didn't include the output because I was worried it might be long, but as I've tested various mount errors, it seems to mostly be reasonably compact. I'm removed the special check for return status 2 and just return the output for all failures, since the loop device failure will show up in the output.

review: Needs Resubmitting
lp:~nuclearbob/utah/loop-exception updated
821. By Max Brustkern

Fixed now-erroneous comment

Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks good to me. Thanks.

review: Approve
Revision history for this message
Andy Doan (doanac) wrote :

+1 - thanks

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 2013-01-29 16:43:59 +0000
3+++ utah/provisioning/baremetal/cobbler.py 2013-02-13 16:47:23 +0000
4@@ -20,7 +20,6 @@
5 import netifaces
6 import os
7 import pipes
8-import shutil
9 import subprocess
10 import tempfile
11 import time
12@@ -107,8 +106,14 @@
13 self.cleanfunction(self._removenfs)
14 os.makedirs(self.isodir, mode=0775)
15 self.logger.debug('Mounting ISO')
16- self._runargs(['sudo', 'mount', '-o', 'loop', self.image.image,
17- self.isodir])
18+ result = self._runargs(['sudo', 'mount', '-o', 'loop',
19+ self.image.image,
20+ self.isodir])
21+ returncode = result['returncode']
22+ if returncode != 0:
23+ raise UTAHBMProvisioningException(
24+ 'Mount failed with return code: {} Output: {}'
25+ .format(returncode, result['output]'))
26
27 kernel = self._preparekernel()
28 if self.cinitrd is None:
29@@ -282,14 +287,14 @@
30
31 def _depcheck(self):
32 """
33- Check for NFS if installtype is desktop.
34+ Check for NFS if installtype requires it.
35 """
36 super(CobblerMachine, self)._depcheck()
37- if self.installtype == 'desktop':
38+ if self.installtype in ['alternate', 'desktop', 'server']:
39 cmd = config.nfscommand + ['status']
40 if self._runargs(cmd)['returncode'] != 0:
41- raise UTAHBMProvisioningException('NFS needed for desktop'
42- ' install')
43+ raise UTAHBMProvisioningException(
44+ 'NFS needed for {} install'.format(self.installtype))
45 if not os.path.isfile(config.nfsconfigfile):
46 raise UTAHBMProvisioningException(
47 'NFS config file: {nfsconfigfile} not available'

Subscribers

People subscribed via source and target branches