Merge lp:~nuclearbob/utah/cobbler-mini into lp:utah

Proposed by Max Brustkern
Status: Rejected
Rejected by: Max Brustkern
Proposed branch: lp:~nuclearbob/utah/cobbler-mini
Merge into: lp:utah
Diff against target: 102 lines (+40/-21)
1 file modified
utah/provisioning/baremetal/cobbler.py (+40/-21)
To merge this branch: bzr merge lp:~nuclearbob/utah/cobbler-mini
Reviewer Review Type Date Requested Status
Max Brustkern (community) Disapprove
Review via email: mp+121917@code.launchpad.net

Description of the change

Add support for mini/netboot images to CobblerMachine. I've tested this in magners-orchestra with good results.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

In the following piece of code:

          if self.installtype in ['alternate', 'server']:
              self.cinitrd = os.path.join('install', 'netboot',
                                          'ubuntu-installer', self.arch,
                                          'initrd.gz')
          elif self.installtype != 'mini':
              raise UTAHBMProvisioningException(
                      'Only alternate and server images currently supported '
                      'for cobbler provisioning')

I think the error message should be updated to include `mini` images as well since they are supported at least from what I've seen.

Also, even if the changes look good, I don't know how would I test this to exercise the code. Maybe could you provide some information here or offline? Thanks.

lp:~nuclearbob/utah/cobbler-mini updated
679. By Max Brustkern

Modified error based on Javier's feedback

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

Good call. I tested it by logging into the utah user on magners-orchestra, running python, and doing something like this:

from utah.provisioning.inventory.sqlite import ManualCobblerSQLiteInventory
i = ManualCobblerSQLiteInventory(db='~/.utah-cobbler-inventory', lockfile='~/.utah-cobbler-lock')
m = i.request(image='/home/ubuntu/precise-mini-i386.iso', debug=True)
m.installclient()
m.destroy()

Now that I think of it, it should work from the scripts as well, so something like

run_utah_tests.py -m physical --name 'acer-veriton-03' -i '/home/ubuntu/precise-mini-i386.iso' /usr/share/utah/client/examples/pass.run

should also work.

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

@Max

What would the prerequisites to test this with a physical machine at home? Do I need any specific hardware or a computer connected to a router is just enough? I tried to create the sqlite database as explained in utah/provisioning/inventory/sqlite.py, but when I run the command I'm asked for the utah password forever, so I must be missing something.

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

I'm working on a version of this with desktop support, so I'm going to withdraw this proposal and submit that once I've tested it.

review: Disapprove
lp:~nuclearbob/utah/cobbler-mini updated
680. By Max Brustkern

Moved directory removal to after installation to facilitate desktop nfs boot

681. By Max Brustkern

Added config options for NFS and changed log options to support hostname

682. By Max Brustkern

Added an additional nfs config option

683. By Max Brustkern

Initial test of NFS stuff

684. By Max Brustkern

Fixed typos

685. By Max Brustkern

Fixed the typo better

686. By Max Brustkern

Fixed typos and did more to ensure removal of tmpdir and nfs share

687. By Max Brustkern

Fixed tmpdir to self.tmpdir

688. By Max Brustkern

Added image extraction for desktop

689. By Max Brustkern

Setting kickstart in profile

690. By Max Brustkern

Put restart back in

691. By Max Brustkern

Using IP instead of hostname for NFS

692. By Max Brustkern

Fixed typo

693. By Max Brustkern

Using IP instead of hostname

Unmerged revisions

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-08-24 18:26:16 +0000
3+++ utah/provisioning/baremetal/cobbler.py 2012-08-31 19:02:18 +0000
4@@ -43,17 +43,18 @@
5 'Image file required for cobbler installation')
6 self._custominit(arch=self.arch, boot=boot,
7 installtype=self.installtype, series=self.series)
8- # TODO: support mini,
9- # then desktop once we can figure out how
10+ # TODO: support desktop once we can figure out how
11+
12+ # TODO: Rework cinitrd to be less of a confusing collection of kludges
13 self.cinitrd = None
14 if self.installtype in ['alternate', 'server']:
15 self.cinitrd = os.path.join('install', 'netboot',
16 'ubuntu-installer', self.arch,
17 'initrd.gz')
18- else:
19+ elif self.installtype != 'mini':
20 raise UTAHBMProvisioningException(
21- 'Only alternate and server images currently supported '
22- 'for cobbler provisioning')
23+ 'Only alternate, server, and mini images currently '
24+ 'supported for cobbler provisioning')
25 if self.arch == 'amd64':
26 self.carch = 'x86_64'
27 else:
28@@ -73,19 +74,24 @@
29
30 # TODO: try to remove this step, mount the iso and import that
31 # with a specified kernel/preseed/initrd from the tmpdir
32- self.logger.info('Extracting image to ' + self.tmpdir)
33- self.image.extractall()
34+ if self.installtype in ['alternate', 'server']:
35+ self.logger.info('Extracting image to ' + self.tmpdir)
36+ self.image.extractall()
37
38- self._preparekernel()
39- cinitrd = os.path.join(self.tmpdir, self.cinitrd)
40+ kernel = self._preparekernel()
41+ if self.cinitrd is None:
42+ cinitrd = None
43+ else:
44+ cinitrd = os.path.join(self.tmpdir, self.cinitrd)
45 initrd = self._prepareinitrd(initrd=cinitrd)
46 self._unpackinitrd(initrd=initrd)
47 self._setuplatecommand()
48 self._setuppreseed()
49 initrd = self._repackinitrd()
50
51- os.chmod(cinitrd, 0755)
52- shutil.copyfile(initrd, cinitrd)
53+ if cinitrd is not None and initrd != cinitrd:
54+ os.chmod(cinitrd, 0755)
55+ shutil.copyfile(initrd, cinitrd)
56
57 self.logger.info('Setting up system with cobbler')
58 self.logger.debug('Removing old system')
59@@ -94,20 +100,33 @@
60 self._cobble(['profile', 'remove', '--name=' + self.cname])
61 self.logger.info('Removing old distro')
62 self._cobble(['distro', 'remove', '--name=' + self.cname])
63- # TODO: support more image types, maybe do this without unpacking ISO
64- self.logger.info('Importing image')
65- self._cobble(['import', '--name=' + self.cname,
66- '--path=' + self.tmpdir, '--arch=' + self.carch])
67- # TODO: figure out if I need kopts in both places
68- self.logger.info('Adding kernel boot options to distro')
69- self._cobble(['distro', 'edit', '--name=' + self.cname,
70- '--kopts=' + self.cmdline])
71- self.logger.info('Adding kernel boot options '
72- 'and kickstart to profile')
73+
74 preseed = os.path.join(self.tmpdir, 'initrd.d', 'preseed.cfg')
75+
76+ if self.installtype in ['alternate', 'server']:
77+ # TODO: support more image types,
78+ # maybe do this without unpacking ISO
79+ self.logger.info('Importing image')
80+ self._cobble(['import', '--name=' + self.cname,
81+ '--path=' + self.tmpdir, '--arch=' + self.carch])
82+ # TODO: figure out if I need kopts in both places
83+ self.logger.info('Adding kernel boot options to distro')
84+ self._cobble(['distro', 'edit', '--name=' + self.cname,
85+ '--kopts=' + self.cmdline])
86+ self.logger.info('Adding kernel boot options '
87+ 'and kickstart to profile')
88+ elif self.installtype == 'mini':
89+ self.logger.info('Creating distro')
90+ self._cobble(['distro', 'add', '--name=' + self.cname,
91+ '--kernel=' + kernel, '--initrd=' + initrd])
92+ self.logger.info('Creating profile')
93+ self._cobble(['profile', 'add', '--name=' + self.cname,
94+ '--distro=' + self.cname])
95+
96 self._cobble(['profile', 'edit', '--name=' + self.cname,
97 '--kickstart=' + preseed,
98 '--kopts=' + self.cmdline])
99+
100 self.logger.info('Adding system')
101 self._cobble(['system', 'add', '--name=' + self.name,
102 '--profile=' + self.cname, '--netboot-enabled=Y']

Subscribers

People subscribed via source and target branches