Merge lp:~nuclearbob/utah/mount-iso into lp:utah

Proposed by Max Brustkern
Status: Merged
Merged at revision: 807
Proposed branch: lp:~nuclearbob/utah/mount-iso
Merge into: lp:utah
Diff against target: 136 lines (+27/-28)
2 files modified
utah/iso.py (+0/-7)
utah/provisioning/baremetal/cobbler.py (+27/-21)
To merge this branch: bzr merge lp:~nuclearbob/utah/mount-iso
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Max Brustkern (community) Needs Resubmitting
Javier Collado (community) Needs Information
Review via email: mp+144593@code.launchpad.net

Description of the change

This branch mounts desktop images for nfs export for cobbler installs instead of extracting every file using bsdtar. I've tested it in magners, which should indicate the rest of the changes in the current dev branch are also fine for baremetal installations, which is good to know.

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

Do you want to remove lines 43-45?

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

I think everything looks fine, but I need some comment to know (and remind me
later) why mount/umount are preferred over fuseiso/fusermount.

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

I think this may not work on server images, actually. I'm going to test and figure that out.

When I tried to export a directory containing a fuseiso mounted image over nfs, I was unable to connect to it properly, using the installer or the normal nfs mount commands.

review: Needs Information
lp:~nuclearbob/utah/mount-iso updated
813. By Max Brustkern

Added image mounting for server and alternate installs

814. By Max Brustkern

Changing initrd setup to use isodir

815. By Max Brustkern

Removed cinitrd overwrite

816. By Max Brustkern

Removed old code

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

This should work on server images now as well.

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

Looks good to me.

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

I'm going to merge this and https://code.launchpad.net/~javier.collado/utah/bug1101189-2/+merge/144755 and begin testing for a potential new stable version.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/iso.py'
2--- utah/iso.py 2012-12-12 10:54:13 +0000
3+++ utah/iso.py 2013-01-25 20:43:21 +0000
4@@ -266,13 +266,6 @@
5
6 return stdout
7
8- def extractall(self):
9- """
10- Extract all files to the current directory.
11- """
12- for myfile in self.listfiles(returnlist=True):
13- self.extract(myfile)
14-
15 def getmd5(self, path):
16 """
17 Return the md5 checksum of a file.
18
19=== modified file 'utah/provisioning/baremetal/cobbler.py'
20--- utah/provisioning/baremetal/cobbler.py 2013-01-18 18:29:31 +0000
21+++ utah/provisioning/baremetal/cobbler.py 2013-01-25 20:43:21 +0000
22@@ -63,6 +63,8 @@
23 self._custominit()
24 self._depcheck()
25
26+ self.isodir = None
27+
28 # TODO: Rework cinitrd to be less of a confusing collection of kludges
29 self.cinitrd = None
30 if self.installtype in ['alternate', 'server']:
31@@ -98,19 +100,22 @@
32 """
33 self.tmpdir = tempfile.mkdtemp(prefix='/tmp/' + self.name + '_')
34 self.cleanfile(self.tmpdir)
35- os.chdir(self.tmpdir)
36+ os.chmod(self.tmpdir, 0775)
37
38- # TODO: try to remove this step, mount the iso and import that
39- # with a specified kernel/preseed/initrd from the tmpdir
40 if self.installtype in ['alternate', 'desktop', 'server']:
41- self.logger.info('Extracting image to ' + self.tmpdir)
42- self.image.extractall()
43+ self.logger.info('Mounting image')
44+ self.isodir = os.path.join(self.tmpdir, 'iso.d')
45+ self.cleanfunction(self._removenfs)
46+ os.makedirs(self.isodir, mode=0775)
47+ self.logger.debug('Mounting ISO')
48+ self._runargs(['sudo', 'mount', '-o', 'loop', self.image.image,
49+ self.isodir])
50
51 kernel = self._preparekernel()
52 if self.cinitrd is None:
53 cinitrd = None
54 else:
55- cinitrd = os.path.join(self.tmpdir, self.cinitrd)
56+ cinitrd = os.path.join(self.isodir, self.cinitrd)
57 initrd = self._prepareinitrd(initrd=cinitrd)
58 self._unpackinitrd(initrd=initrd)
59 self._setuplatecommand()
60@@ -126,20 +131,17 @@
61 self._setuppreseed()
62 initrd = self._repackinitrd()
63
64- if cinitrd is not None and initrd != cinitrd:
65- os.chmod(cinitrd, 0755)
66- shutil.copyfile(initrd, cinitrd)
67-
68 self.logger.info('Setting up system with cobbler')
69 self._cleanupcobbler()
70
71 preseed = os.path.join(self.tmpdir, 'initrd.d', 'preseed.cfg')
72
73 if self.installtype in ['alternate', 'server']:
74- # TODO: maybe do this without unpacking ISO
75 self.logger.info('Importing image')
76 self._cobble(['import', '--name=' + self.cname,
77- '--path=' + self.tmpdir, '--arch=' + self.carch])
78+ '--path=' + self.isodir, '--arch=' + self.carch])
79+ self._cobble(['distro', 'edit', '--name=' + self.cname,
80+ '--kernel=' + kernel, '--initrd=' + initrd])
81 elif self.installtype in ['mini', 'desktop']:
82 self.logger.info('Creating distro')
83 self._cobble(['distro', 'add', '--name=' + self.cname,
84@@ -151,11 +153,10 @@
85 if self.installtype == 'desktop':
86 self.logger.info('Setting up NFS for desktop install')
87 self.logger.debug('Adding export to NFS config file')
88- self.cleanfunction(self._removenfs)
89 pipe = pipes.Template()
90 pipe.append('sudo tee -a ' + str(config.nfsconfigfile) +
91 ' >/dev/null', '-.')
92- pipe.open('/dev/null', 'w').write(self.tmpdir + ' ' +
93+ pipe.open('/dev/null', 'w').write(self.isodir + ' ' +
94 config.nfsoptions + "\n")
95 self.logger.debug('Reloading NFS config')
96 self._runargs(config.nfscommand + ['reload'])
97@@ -166,7 +167,7 @@
98 iface = config.bridge
99 ip = netifaces.ifaddresses(iface)[netifaces.AF_INET][0]['addr']
100 self.cmdline += (' root=/dev/nfs netboot=nfs nfsroot=' +
101- ip + ':' + self.tmpdir)
102+ ip + ':' + self.isodir)
103 self.cmdline = self.cmdline.strip()
104
105 self.cleanfunction(self._cleanupcobbler)
106@@ -199,7 +200,6 @@
107 retry(self.sshcheck, checktimeout, logmethod=self.logger.info)
108
109 if self.installtype == 'desktop':
110- self.logger.info('Removing NFS share')
111 self._removenfs()
112
113 self.provisioned = True
114@@ -268,11 +268,17 @@
115 """
116 Remove our NFS configuration and reload NFS.
117 """
118- self.logger.info('Removing NFS share')
119- self._runargs(['sudo', 'sed', '/' + self.tmpdir.replace('/', '\/') +
120- '/d', '-i', config.nfsconfigfile])
121- self.logger.debug('Reloading NFS config')
122- self._runargs(config.nfscommand + ['reload'])
123+ if self.isodir is not None:
124+ self.logger.info('Removing NFS share')
125+ self._runargs(['sudo', 'sed', '/' + self.isodir.replace('/', '\/')
126+ + '/d', '-i', config.nfsconfigfile])
127+ self.logger.debug('Reloading NFS config')
128+ self._runargs(config.nfscommand + ['reload'])
129+ self.logger.info('Unmounting ISO')
130+ self._runargs(['sudo', 'umount', self.isodir])
131+ self.logger.debug('Removing directory')
132+ os.rmdir(self.isodir)
133+ self.isodir = None
134
135 def _depcheck(self):
136 """

Subscribers

People subscribed via source and target branches