Merge lp:~ubuntu-branches/ubuntu/oneiric/cobbler/oneiric-201106090005 into lp:ubuntu/oneiric/cobbler

Proposed by James Westby
Status: Work in progress
Proposed branch: lp:~ubuntu-branches/ubuntu/oneiric/cobbler/oneiric-201106090005
Merge into: lp:ubuntu/oneiric/cobbler
Diff against target: 4459 lines (+52/-4124) (has conflicts)
24 files modified
.pc/.version (+0/-1)
.pc/05_cobbler_fix_reposync_permissions.patch/cobbler/action_reposync.py (+0/-568)
.pc/12_fix_dhcp_restart.patch/cobbler/modules/sync_post_restart_services.py (+0/-66)
.pc/21_cobbler_use_netboot.patch/cobbler/modules/manage_import_debian_ubuntu.py (+0/-777)
.pc/33_authn_configfile.patch/config/modules.conf (+0/-86)
.pc/34_fix_apache_wont_start.patch/config/cobbler_web.conf (+0/-14)
.pc/39_cw_remove_vhost.patch/config/cobbler_web.conf (+0/-14)
.pc/40_ubuntu_bind9_management.patch/cobbler/action_check.py (+0/-482)
.pc/40_ubuntu_bind9_management.patch/cobbler/modules/manage_bind.py (+0/-332)
.pc/40_ubuntu_bind9_management.patch/cobbler/modules/sync_post_restart_services.py (+0/-66)
.pc/40_ubuntu_bind9_management.patch/templates/etc/named.template (+0/-31)
.pc/41_update_tree_path_with_arch.patch/cobbler/modules/manage_import_debian_ubuntu.py (+0/-777)
.pc/42_fix_repomirror_create_sync.patch/cobbler/codes.py (+0/-98)
.pc/42_fix_repomirror_create_sync.patch/cobbler/modules/manage_import_debian_ubuntu.py (+0/-779)
.pc/applied-patches (+0/-10)
cobbler/action_check.py (+1/-1)
cobbler/action_reposync.py (+1/-6)
cobbler/codes.py (+2/-2)
cobbler/modules/manage_bind.py (+3/-3)
cobbler/modules/manage_import_debian_ubuntu.py (+18/-5)
cobbler/modules/sync_post_restart_services.py (+2/-2)
config/cobbler_web.conf (+5/-1)
config/modules.conf (+1/-1)
templates/etc/named.template (+19/-2)
Conflict: can't delete .pc because it is not empty.  Not deleting.
Conflict because .pc is not versioned, but has versioned children.  Versioned directory.
Conflict: can't delete .pc/42_fix_repomirror_create_sync.patch because it is not empty.  Not deleting.
Conflict because .pc/42_fix_repomirror_create_sync.patch is not versioned, but has versioned children.  Versioned directory.
Conflict: can't delete .pc/42_fix_repomirror_create_sync.patch/cobbler because it is not empty.  Not deleting.
Conflict because .pc/42_fix_repomirror_create_sync.patch/cobbler is not versioned, but has versioned children.  Versioned directory.
Conflict: can't delete .pc/43_fix_reposync_env_variable.patch because it is not empty.  Not deleting.
Conflict because .pc/43_fix_reposync_env_variable.patch is not versioned, but has versioned children.  Versioned directory.
Conflict: can't delete .pc/43_fix_reposync_env_variable.patch/cobbler because it is not empty.  Not deleting.
Conflict because .pc/43_fix_reposync_env_variable.patch/cobbler is not versioned, but has versioned children.  Versioned directory.
Contents conflict in .pc/43_fix_reposync_env_variable.patch/cobbler/action_reposync.py
Text conflict in cobbler/modules/manage_import_debian_ubuntu.py
To merge this branch: bzr merge lp:~ubuntu-branches/ubuntu/oneiric/cobbler/oneiric-201106090005
Reviewer Review Type Date Requested Status
Dave Walker (community) Disapprove
Ubuntu branches Pending
Review via email: mp+63942@code.launchpad.net

Description of the change

The package history in the archive and the history in the bzr branch differ. As the archive is authoritative the history of lp:ubuntu/oneiric/cobbler now reflects that and the old bzr branch has been pushed to lp:~ubuntu-branches/ubuntu/oneiric/cobbler/oneiric-201106090005. A merge should be performed if necessary.

To post a comment you must log in.
Revision history for this message
Dave Walker (davewalker) wrote :

This seems to be unintentional fallout.

review: Disapprove

Unmerged revisions

26. By Andres Rodriguez

* debian/patches/42_fix_repomirror_create_sync.patch: Improve method to
  obtain Ubuntu mirror to use if python-apt installed.
* debian/cobbler.postinst: Really fix setting of 'server'. Move the logic
  to obtain IP to debian/cobbler.config and set it default if available.

25. By Andres Rodriguez

Un-apply all patches and remove .pc. IMO branches should not reflect patches
applied as they generate huge diff's when updating or working with them.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.pc/.version'
2--- .pc/.version 2011-01-18 12:03:14 +0000
3+++ .pc/.version 1970-01-01 00:00:00 +0000
4@@ -1,1 +0,0 @@
5-2
6
7=== removed directory '.pc/05_cobbler_fix_reposync_permissions.patch'
8=== removed directory '.pc/05_cobbler_fix_reposync_permissions.patch/cobbler'
9=== removed file '.pc/05_cobbler_fix_reposync_permissions.patch/cobbler/action_reposync.py'
10--- .pc/05_cobbler_fix_reposync_permissions.patch/cobbler/action_reposync.py 2011-01-28 14:39:12 +0000
11+++ .pc/05_cobbler_fix_reposync_permissions.patch/cobbler/action_reposync.py 1970-01-01 00:00:00 +0000
12@@ -1,568 +0,0 @@
13-"""
14-Builds out and synchronizes yum repo mirrors.
15-Initial support for rsync, perhaps reposync coming later.
16-
17-Copyright 2006-2007, Red Hat, Inc
18-Michael DeHaan <mdehaan@redhat.com>
19-
20-This program is free software; you can redistribute it and/or modify
21-it under the terms of the GNU General Public License as published by
22-the Free Software Foundation; either version 2 of the License, or
23-(at your option) any later version.
24-
25-This program is distributed in the hope that it will be useful,
26-but WITHOUT ANY WARRANTY; without even the implied warranty of
27-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-GNU General Public License for more details.
29-
30-You should have received a copy of the GNU General Public License
31-along with this program; if not, write to the Free Software
32-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33-02110-1301 USA
34-"""
35-
36-import os
37-import os.path
38-import time
39-import yaml # Howell-Clark version
40-import sys
41-HAS_YUM = True
42-try:
43- import yum
44-except:
45- HAS_YUM = False
46-
47-import utils
48-from cexceptions import *
49-import traceback
50-import errno
51-from utils import _
52-import clogger
53-
54-class RepoSync:
55- """
56- Handles conversion of internal state to the tftpboot tree layout
57- """
58-
59- # ==================================================================================
60-
61- def __init__(self,config,tries=1,nofail=False,logger=None):
62- """
63- Constructor
64- """
65- self.verbose = True
66- self.api = config.api
67- self.config = config
68- self.distros = config.distros()
69- self.profiles = config.profiles()
70- self.systems = config.systems()
71- self.settings = config.settings()
72- self.repos = config.repos()
73- self.rflags = self.settings.reposync_flags
74- self.tries = tries
75- self.nofail = nofail
76- self.logger = logger
77-
78- if logger is None:
79- self.logger = clogger.Logger()
80-
81- self.logger.info("hello, reposync")
82-
83-
84- # ===================================================================
85-
86- def run(self, name=None, verbose=True):
87- """
88- Syncs the current repo configuration file with the filesystem.
89- """
90-
91- self.logger.info("run, reposync, run!")
92-
93- try:
94- self.tries = int(self.tries)
95- except:
96- utils.die(self.logger,"retry value must be an integer")
97-
98- self.verbose = verbose
99-
100- report_failure = False
101- for repo in self.repos:
102-
103- env = repo.environment
104-
105- for k in env.keys():
106- self.logger.info("environment: %s=%s" % (k,env[k]))
107- if env[k] is not None:
108- os.putenv(k,env[k])
109-
110- if name is not None and repo.name != name:
111- # invoked to sync only a specific repo, this is not the one
112- continue
113- elif name is None and not repo.keep_updated:
114- # invoked to run against all repos, but this one is off
115- self.logger.info("%s is set to not be updated" % repo.name)
116- continue
117-
118- repo_mirror = os.path.join(self.settings.webdir, "repo_mirror")
119- repo_path = os.path.join(repo_mirror, repo.name)
120- mirror = repo.mirror
121-
122- if not os.path.isdir(repo_path) and not repo.mirror.lower().startswith("rhn://"):
123- os.makedirs(repo_path)
124-
125- # which may actually NOT reposync if the repo is set to not mirror locally
126- # but that's a technicality
127-
128- for x in range(self.tries+1,1,-1):
129- success = False
130- try:
131- self.sync(repo)
132- success = True
133- except:
134- utils.log_exc(self.logger)
135- self.logger.warning("reposync failed, tries left: %s" % (x-2))
136-
137- if not success:
138- report_failure = True
139- if not self.nofail:
140- utils.die(self.logger,"reposync failed, retry limit reached, aborting")
141- else:
142- self.logger.error("reposync failed, retry limit reached, skipping")
143-
144- self.update_permissions(repo_path)
145-
146- if report_failure:
147- utils.die(self.logger,"overall reposync failed, at least one repo failed to synchronize")
148-
149- return True
150-
151- # ==================================================================================
152-
153- def sync(self, repo):
154-
155- """
156- Conditionally sync a repo, based on type.
157- """
158-
159- if repo.breed == "rhn":
160- return self.rhn_sync(repo)
161- elif repo.breed == "yum":
162- return self.yum_sync(repo)
163- elif repo.breed == "apt":
164- return self.apt_sync(repo)
165- elif repo.breed == "rsync":
166- return self.rsync_sync(repo)
167- else:
168- utils.die(self.logger,"unable to sync repo (%s), unknown or unsupported repo type (%s)" % (repo.name, repo.breed))
169-
170- # ====================================================================================
171-
172- def createrepo_walker(self, repo, dirname, fnames):
173- """
174- Used to run createrepo on a copied Yum mirror.
175- """
176- if os.path.exists(dirname) or repo['breed'] == 'rsync':
177- utils.remove_yum_olddata(dirname)
178-
179- # add any repo metadata we can use
180- mdoptions = []
181- if os.path.isfile("%s/.origin/repomd.xml" % (dirname)):
182- if not HAS_YUM:
183- utils.die(self.logger,"yum is required to use this feature")
184-
185- rmd = yum.repoMDObject.RepoMD('', "%s/.origin/repomd.xml" % (dirname))
186- if rmd.repoData.has_key("group"):
187- groupmdfile = rmd.getData("group").location[1]
188- mdoptions.append("-g %s" % groupmdfile)
189- if rmd.repoData.has_key("prestodelta"):
190- # need createrepo >= 0.9.7 to add deltas
191- if utils.check_dist() == "redhat" or utils.check_dist() == "suse":
192- cmd = "/usr/bin/rpmquery --queryformat=%{VERSION} createrepo"
193- createrepo_ver = utils.subprocess_get(self.logger, cmd)
194- if createrepo_ver >= "0.9.7":
195- mdoptions.append("--deltas")
196- else:
197- self.logger.error("this repo has presto metadata; you must upgrade createrepo to >= 0.9.7 first and then need to resync the repo through cobbler.")
198-
199- blended = utils.blender(self.api, False, repo)
200- flags = blended.get("createrepo_flags","(ERROR: FLAGS)")
201- try:
202- # BOOKMARK
203- cmd = "createrepo %s %s %s" % (" ".join(mdoptions), flags, dirname)
204- utils.subprocess_call(self.logger, cmd)
205- except:
206- utils.log_exc(self.logger)
207- self.logger.error("createrepo failed.")
208- del fnames[:] # we're in the right place
209-
210- # ====================================================================================
211-
212- def rsync_sync(self, repo):
213-
214- """
215- Handle copying of rsync:// and rsync-over-ssh repos.
216- """
217-
218- repo_mirror = repo.mirror
219-
220- if not repo.mirror_locally:
221- utils.die(self.logger,"rsync:// urls must be mirrored locally, yum cannot access them directly")
222-
223- if repo.rpm_list != "" and repo.rpm_list != []:
224- self.logger.warning("--rpm-list is not supported for rsync'd repositories")
225-
226- # FIXME: don't hardcode
227- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
228-
229- spacer = ""
230- if not repo.mirror.startswith("rsync://") and not repo.mirror.startswith("/"):
231- spacer = "-e ssh"
232- if not repo.mirror.endswith("/"):
233- repo.mirror = "%s/" % repo.mirror
234-
235- # FIXME: wrapper for subprocess that logs to logger
236- cmd = "rsync -rltDv %s --delete --exclude-from=/etc/cobbler/rsync.exclude %s %s" % (spacer, repo.mirror, dest_path)
237- rc = utils.subprocess_call(self.logger, cmd)
238-
239- if rc !=0:
240- utils.die(self.logger,"cobbler reposync failed")
241- os.path.walk(dest_path, self.createrepo_walker, repo)
242- self.create_local_file(dest_path, repo)
243-
244- # ====================================================================================
245-
246- def rhn_sync(self, repo):
247-
248- """
249- Handle mirroring of RHN repos.
250- """
251-
252- repo_mirror = repo.mirror
253-
254- # FIXME? warn about not having yum-utils. We don't want to require it in the package because
255- # RHEL4 and RHEL5U0 don't have it.
256-
257- if not os.path.exists("/usr/bin/reposync"):
258- utils.die(self.logger,"no /usr/bin/reposync found, please install yum-utils")
259-
260- cmd = "" # command to run
261- has_rpm_list = False # flag indicating not to pull the whole repo
262-
263- # detect cases that require special handling
264-
265- if repo.rpm_list != "" and repo.rpm_list != []:
266- has_rpm_list = True
267-
268- # create yum config file for use by reposync
269- # FIXME: don't hardcode
270- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
271- temp_path = os.path.join(dest_path, ".origin")
272-
273- if not os.path.isdir(temp_path):
274- # FIXME: there's a chance this might break the RHN D/L case
275- os.makedirs(temp_path)
276-
277- # how we invoke yum-utils depends on whether this is RHN content or not.
278-
279-
280- # this is the somewhat more-complex RHN case.
281- # NOTE: this requires that you have entitlements for the server and you give the mirror as rhn://$channelname
282- if not repo.mirror_locally:
283- utils.die("rhn:// repos do not work with --mirror-locally=1")
284-
285- if has_rpm_list:
286- self.logger.warning("warning: --rpm-list is not supported for RHN content")
287- rest = repo.mirror[6:] # everything after rhn://
288- cmd = "/usr/bin/reposync %s -r %s --download_path=%s" % (self.rflags, rest, "/var/www/cobbler/repo_mirror")
289- if repo.name != rest:
290- args = { "name" : repo.name, "rest" : rest }
291- utils.die(self.logger,"ERROR: repository %(name)s needs to be renamed %(rest)s as the name of the cobbler repository must match the name of the RHN channel" % args)
292-
293- if repo.arch == "i386":
294- # counter-intuitive, but we want the newish kernels too
295- repo.arch = "i686"
296-
297- if repo.arch != "":
298- cmd = "%s -a %s" % (cmd, repo.arch)
299-
300- # now regardless of whether we're doing yumdownloader or reposync
301- # or whether the repo was http://, ftp://, or rhn://, execute all queued
302- # commands here. Any failure at any point stops the operation.
303-
304- if repo.mirror_locally:
305- rc = utils.subprocess_call(self.logger, cmd)
306- # Don't die if reposync fails, it is logged
307- # if rc !=0:
308- # utils.die(self.logger,"cobbler reposync failed")
309-
310- # some more special case handling for RHN.
311- # create the config file now, because the directory didn't exist earlier
312-
313- temp_file = self.create_local_file(temp_path, repo, output=False)
314-
315- # now run createrepo to rebuild the index
316-
317- if repo.mirror_locally:
318- os.path.walk(dest_path, self.createrepo_walker, repo)
319-
320- # create the config file the hosts will use to access the repository.
321-
322- self.create_local_file(dest_path, repo)
323-
324- # ====================================================================================
325-
326- def yum_sync(self, repo):
327-
328- """
329- Handle copying of http:// and ftp:// yum repos.
330- """
331-
332- repo_mirror = repo.mirror
333-
334- # warn about not having yum-utils. We don't want to require it in the package because
335- # RHEL4 and RHEL5U0 don't have it.
336-
337- if not os.path.exists("/usr/bin/reposync"):
338- utils.die(self.logger,"no /usr/bin/reposync found, please install yum-utils")
339-
340- cmd = "" # command to run
341- has_rpm_list = False # flag indicating not to pull the whole repo
342-
343- # detect cases that require special handling
344-
345- if repo.rpm_list != "" and repo.rpm_list != []:
346- has_rpm_list = True
347-
348- # create yum config file for use by reposync
349- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
350- temp_path = os.path.join(dest_path, ".origin")
351-
352- if not os.path.isdir(temp_path) and repo.mirror_locally:
353- # FIXME: there's a chance this might break the RHN D/L case
354- os.makedirs(temp_path)
355-
356- # create the config file that yum will use for the copying
357-
358- if repo.mirror_locally:
359- temp_file = self.create_local_file(temp_path, repo, output=False)
360-
361- if not has_rpm_list and repo.mirror_locally:
362- # if we have not requested only certain RPMs, use reposync
363- cmd = "/usr/bin/reposync %s --config=%s --repoid=%s --download_path=%s" % (self.rflags, temp_file, repo.name, "/var/www/cobbler/repo_mirror")
364- if repo.arch != "":
365- if repo.arch == "x86":
366- repo.arch = "i386" # FIX potential arch errors
367- if repo.arch == "i386":
368- # counter-intuitive, but we want the newish kernels too
369- cmd = "%s -a i686" % (cmd)
370- else:
371- cmd = "%s -a %s" % (cmd, repo.arch)
372-
373- elif repo.mirror_locally:
374-
375- # create the output directory if it doesn't exist
376- if not os.path.exists(dest_path):
377- os.makedirs(dest_path)
378-
379- use_source = ""
380- if repo.arch == "src":
381- use_source = "--source"
382-
383- # older yumdownloader sometimes explodes on --resolvedeps
384- # if this happens to you, upgrade yum & yum-utils
385- extra_flags = self.settings.yumdownloader_flags
386- cmd = "/usr/bin/yumdownloader %s %s --disablerepo=* --enablerepo=%s -c %s --destdir=%s %s" % (extra_flags, use_source, repo.name, temp_file, dest_path, " ".join(repo.rpm_list))
387-
388- # now regardless of whether we're doing yumdownloader or reposync
389- # or whether the repo was http://, ftp://, or rhn://, execute all queued
390- # commands here. Any failure at any point stops the operation.
391-
392- if repo.mirror_locally:
393- rc = utils.subprocess_call(self.logger, cmd)
394- if rc !=0:
395- utils.die(self.logger,"cobbler reposync failed")
396-
397- repodata_path = os.path.join(dest_path, "repodata")
398-
399- if not os.path.exists("/usr/bin/wget"):
400- utils.die(self.logger,"no /usr/bin/wget found, please install wget")
401-
402- # grab repomd.xml and use it to download any metadata we can use
403- cmd2 = "/usr/bin/wget -q %s/repodata/repomd.xml -O %s/repomd.xml" % (repo_mirror, temp_path)
404- rc = utils.subprocess_call(self.logger,cmd2)
405- if rc == 0:
406- # create our repodata directory now, as any extra metadata we're
407- # about to download probably lives there
408- if not os.path.isdir(repodata_path):
409- os.makedirs(repodata_path)
410- rmd = yum.repoMDObject.RepoMD('', "%s/repomd.xml" % (temp_path))
411- for mdtype in rmd.repoData.keys():
412- # don't download metadata files that are created by default
413- if mdtype not in ["primary", "primary_db", "filelists", "filelists_db", "other", "other_db"]:
414- mdfile = rmd.getData(mdtype).location[1]
415- cmd3 = "/usr/bin/wget -q %s/%s -O %s/%s" % (repo_mirror, mdfile, dest_path, mdfile)
416- utils.subprocess_call(self.logger,cmd3)
417- if rc !=0:
418- utils.die(self.logger,"wget failed")
419-
420- # now run createrepo to rebuild the index
421-
422- if repo.mirror_locally:
423- os.path.walk(dest_path, self.createrepo_walker, repo)
424-
425- # create the config file the hosts will use to access the repository.
426-
427- self.create_local_file(dest_path, repo)
428-
429- # ====================================================================================
430-
431-
432- def apt_sync(self, repo):
433-
434- """
435- Handle copying of http:// and ftp:// debian repos.
436- """
437-
438- repo_mirror = repo.mirror
439-
440- # warn about not having mirror program.
441-
442- mirror_program = "/usr/bin/debmirror"
443- if not os.path.exists(mirror_program):
444- utils.die(self.logger,"no %s found, please install it"%(mirror_program))
445-
446- cmd = "" # command to run
447- has_rpm_list = False # flag indicating not to pull the whole repo
448-
449- # detect cases that require special handling
450-
451- if repo.rpm_list != "" and repo.rpm_list != []:
452- utils.die(self.logger,"has_rpm_list not yet supported on apt repos")
453-
454- if not repo.arch:
455- utils.die(self.logger,"Architecture is required for apt repositories")
456-
457- # built destination path for the repo
458- dest_path = os.path.join("/var/www/cobbler/repo_mirror", repo.name)
459-
460- if repo.mirror_locally:
461- mirror = repo.mirror.replace("@@suite@@",repo.os_version)
462-
463- idx = mirror.find("://")
464- method = mirror[:idx]
465- mirror = mirror[idx+3:]
466-
467- idx = mirror.find("/")
468- host = mirror[:idx]
469- mirror = mirror[idx+1:]
470-
471- idx = mirror.rfind("/dists/")
472- suite = mirror[idx+7:]
473- mirror = mirror[:idx]
474-
475- mirror_data = "--method=%s --host=%s --root=%s --dist=%s " % ( method , host , mirror , suite )
476-
477- # FIXME : flags should come from repo instead of being hardcoded
478-
479- rflags = "--passive --nocleanup"
480- for x in repo.yumopts:
481- if repo.yumopts[x]:
482- rflags += " %s %s" % ( x , repo.yumopts[x] )
483- else:
484- rflags += " %s" % x
485- cmd = "%s %s %s %s" % (mirror_program, rflags, mirror_data, dest_path)
486- if repo.arch == "src":
487- cmd = "%s --source" % cmd
488- else:
489- arch = repo.arch
490- if arch == "x86":
491- arch = "i386" # FIX potential arch errors
492- if arch == "x86_64":
493- arch = "amd64" # FIX potential arch errors
494- cmd = "%s --nosource -a %s" % (cmd, arch)
495-
496- rc = utils.subprocess_call(self.logger, cmd)
497- if rc !=0:
498- utils.die(self.logger,"cobbler reposync failed")
499-
500-
501- def create_local_file(self, dest_path, repo, output=True):
502- """
503-
504- Creates Yum config files for use by reposync
505-
506- Two uses:
507- (A) output=True, Create local files that can be used with yum on provisioned clients to make use of this mirror.
508- (B) output=False, Create a temporary file for yum to feed into yum for mirroring
509- """
510-
511- # the output case will generate repo configuration files which are usable
512- # for the installed systems. They need to be made compatible with --server-override
513- # which means they are actually templates, which need to be rendered by a cobbler-sync
514- # on per profile/system basis.
515-
516- if output:
517- fname = os.path.join(dest_path,"config.repo")
518- else:
519- fname = os.path.join(dest_path, "%s.repo" % repo.name)
520- self.logger.debug("creating: %s" % fname)
521- if not os.path.exists(dest_path):
522- utils.mkdir(dest_path)
523- config_file = open(fname, "w+")
524- config_file.write("[%s]\n" % repo.name)
525- config_file.write("name=%s\n" % repo.name)
526- optenabled = False
527- optgpgcheck = False
528- if output:
529- if repo.mirror_locally:
530- line = "baseurl=http://${server}/cobbler/repo_mirror/%s\n" % (repo.name)
531- else:
532- mstr = repo.mirror
533- if mstr.startswith("/"):
534- mstr = "file://%s" % mstr
535- line = "baseurl=%s\n" % mstr
536-
537- config_file.write(line)
538- # user may have options specific to certain yum plugins
539- # add them to the file
540- for x in repo.yumopts:
541- config_file.write("%s=%s\n" % (x, repo.yumopts[x]))
542- if x == "enabled":
543- optenabled = True
544- if x == "gpgcheck":
545- optgpgcheck = True
546- else:
547- mstr = repo.mirror
548- if mstr.startswith("/"):
549- mstr = "file://%s" % mstr
550- line = "baseurl=%s\n" % mstr
551- if self.settings.http_port not in (80, '80'):
552- http_server = "%s:%s" % (self.settings.server, self.settings.http_port)
553- else:
554- http_server = self.settings.server
555- line = line.replace("@@server@@",http_server)
556- config_file.write(line)
557- if not optenabled:
558- config_file.write("enabled=1\n")
559- config_file.write("priority=%s\n" % repo.priority)
560- # FIXME: potentially might want a way to turn this on/off on a per-repo basis
561- if not optgpgcheck:
562- config_file.write("gpgcheck=0\n")
563- config_file.close()
564- return fname
565-
566- # ==================================================================================
567-
568- def update_permissions(self, repo_path):
569- """
570- Verifies that permissions and contexts after an rsync are as expected.
571- Sending proper rsync flags should prevent the need for this, though this is largely
572- a safeguard.
573- """
574- # all_path = os.path.join(repo_path, "*")
575- cmd1 = "chown -R root:apache %s" % repo_path
576- utils.subprocess_call(self.logger, cmd1)
577-
578- cmd2 = "chmod -R 755 %s" % repo_path
579- utils.subprocess_call(self.logger, cmd2)
580-
581
582=== removed directory '.pc/12_fix_dhcp_restart.patch'
583=== removed directory '.pc/12_fix_dhcp_restart.patch/cobbler'
584=== removed directory '.pc/12_fix_dhcp_restart.patch/cobbler/modules'
585=== removed file '.pc/12_fix_dhcp_restart.patch/cobbler/modules/sync_post_restart_services.py'
586--- .pc/12_fix_dhcp_restart.patch/cobbler/modules/sync_post_restart_services.py 2011-01-28 14:39:12 +0000
587+++ .pc/12_fix_dhcp_restart.patch/cobbler/modules/sync_post_restart_services.py 1970-01-01 00:00:00 +0000
588@@ -1,66 +0,0 @@
589-import distutils.sysconfig
590-import sys
591-import os
592-import traceback
593-import cexceptions
594-import os
595-import sys
596-import xmlrpclib
597-import cobbler.module_loader as module_loader
598-import cobbler.utils as utils
599-
600-plib = distutils.sysconfig.get_python_lib()
601-mod_path="%s/cobbler" % plib
602-sys.path.insert(0, mod_path)
603-
604-def register():
605- # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.
606- # the return of this method indicates the trigger type
607- return "/var/lib/cobbler/triggers/sync/post/*"
608-
609-def run(api,args,logger):
610-
611- settings = api.settings()
612-
613- manage_dhcp = str(settings.manage_dhcp).lower()
614- manage_dns = str(settings.manage_dns).lower()
615- manage_tftpd = str(settings.manage_tftpd).lower()
616- restart_dhcp = str(settings.restart_dhcp).lower()
617- restart_dns = str(settings.restart_dns).lower()
618-
619- which_dhcp_module = module_loader.get_module_from_file("dhcp","module",just_name=True).strip()
620- which_dns_module = module_loader.get_module_from_file("dns","module",just_name=True).strip()
621-
622- # special handling as we don't want to restart it twice
623- has_restarted_dnsmasq = False
624-
625- rc = 0
626- if manage_dhcp != "0":
627- if which_dhcp_module == "manage_isc":
628- if restart_dhcp != "0":
629- rc = utils.subprocess_call(logger, "dhcpd -t -q", shell=True)
630- if rc != 0:
631- logger.error("dhcpd -t failed")
632- return 1
633- rc = utils.subprocess_call(logger,"service dhcpd restart", shell=True)
634- elif which_dhcp_module == "manage_dnsmasq":
635- if restart_dhcp != "0":
636- rc = utils.subprocess_call(logger, "service dnsmasq restart")
637- has_restarted_dnsmasq = True
638- else:
639- logger.error("unknown DHCP engine: %s" % which_dhcp_module)
640- rc = 411
641-
642- if manage_dns != "0" and restart_dns != "0":
643- if which_dns_module == "manage_bind":
644- rc = utils.subprocess_call(logger, "service named restart", shell=True)
645- elif which_dns_module == "manage_dnsmasq" and not has_restarted_dnsmasq:
646- rc = utils.subprocess_call(logger, "service dnsmasq restart", shell=True)
647- elif which_dns_module == "manage_dnsmasq" and has_restarted_dnsmasq:
648- rc = 0
649- else:
650- logger.error("unknown DNS engine: %s" % which_dns_module)
651- rc = 412
652-
653- return rc
654-
655
656=== removed directory '.pc/21_cobbler_use_netboot.patch'
657=== removed directory '.pc/21_cobbler_use_netboot.patch/cobbler'
658=== removed directory '.pc/21_cobbler_use_netboot.patch/cobbler/modules'
659=== removed file '.pc/21_cobbler_use_netboot.patch/cobbler/modules/manage_import_debian_ubuntu.py'
660--- .pc/21_cobbler_use_netboot.patch/cobbler/modules/manage_import_debian_ubuntu.py 2011-01-18 12:03:14 +0000
661+++ .pc/21_cobbler_use_netboot.patch/cobbler/modules/manage_import_debian_ubuntu.py 1970-01-01 00:00:00 +0000
662@@ -1,777 +0,0 @@
663-"""
664-This is some of the code behind 'cobbler sync'.
665-
666-Copyright 2006-2009, Red Hat, Inc
667-Michael DeHaan <mdehaan@redhat.com>
668-John Eckersberg <jeckersb@redhat.com>
669-
670-This program is free software; you can redistribute it and/or modify
671-it under the terms of the GNU General Public License as published by
672-the Free Software Foundation; either version 2 of the License, or
673-(at your option) any later version.
674-
675-This program is distributed in the hope that it will be useful,
676-but WITHOUT ANY WARRANTY; without even the implied warranty of
677-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
678-GNU General Public License for more details.
679-
680-You should have received a copy of the GNU General Public License
681-along with this program; if not, write to the Free Software
682-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
683-02110-1301 USA
684-"""
685-
686-import os
687-import os.path
688-import shutil
689-import time
690-import sys
691-import glob
692-import traceback
693-import errno
694-import re
695-from utils import popen2
696-from shlex import shlex
697-
698-
699-import utils
700-from cexceptions import *
701-import templar
702-
703-import item_distro
704-import item_profile
705-import item_repo
706-import item_system
707-
708-from utils import _
709-
710-def register():
711- """
712- The mandatory cobbler module registration hook.
713- """
714- return "manage/import"
715-
716-
717-class ImportDebianUbuntuManager:
718-
719- def __init__(self,config,logger):
720- """
721- Constructor
722- """
723- self.logger = logger
724- self.config = config
725- self.api = config.api
726- self.distros = config.distros()
727- self.profiles = config.profiles()
728- self.systems = config.systems()
729- self.settings = config.settings()
730- self.repos = config.repos()
731- self.templar = templar.Templar(config)
732-
733- # required function for import modules
734- def what(self):
735- return "import/debian_ubuntu"
736-
737- # required function for import modules
738- def check_for_signature(self,path,cli_breed):
739- signatures = [
740- 'pool',
741- ]
742-
743- #self.logger.info("scanning %s for a debian/ubuntu distro signature" % path)
744- for signature in signatures:
745- d = os.path.join(path,signature)
746- if os.path.exists(d):
747- self.logger.info("Found a debian/ubuntu compatible signature: %s" % signature)
748- return (True,signature)
749-
750- if cli_breed and cli_breed in self.get_valid_breeds():
751- self.logger.info("Warning: No distro signature for kernel at %s, using value from command line" % path)
752- return (True,None)
753-
754- return (False,None)
755-
756- # required function for import modules
757- def run(self,pkgdir,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None,breed=None,os_version=None):
758- self.pkgdir = pkgdir
759- self.mirror = mirror
760- self.mirror_name = mirror_name
761- self.network_root = network_root
762- self.kickstart_file = kickstart_file
763- self.rsync_flags = rsync_flags
764- self.arch = arch
765- self.breed = breed
766- self.os_version = os_version
767-
768- # some fixups for the XMLRPC interface, which does not use "None"
769- if self.arch == "": self.arch = None
770- if self.mirror == "": self.mirror = None
771- if self.mirror_name == "": self.mirror_name = None
772- if self.kickstart_file == "": self.kickstart_file = None
773- if self.os_version == "": self.os_version = None
774- if self.rsync_flags == "": self.rsync_flags = None
775- if self.network_root == "": self.network_root = None
776-
777- # If no breed was specified on the command line, figure it out
778- if self.breed == None:
779- self.breed = self.get_breed_from_directory()
780- if not self.breed:
781- utils.die(self.logger,"import failed - could not determine breed of debian-based distro")
782-
783- # debug log stuff for testing
784- #self.logger.info("DEBUG: self.pkgdir = %s" % str(self.pkgdir))
785- #self.logger.info("DEBUG: self.mirror = %s" % str(self.mirror))
786- #self.logger.info("DEBUG: self.mirror_name = %s" % str(self.mirror_name))
787- #self.logger.info("DEBUG: self.network_root = %s" % str(self.network_root))
788- #self.logger.info("DEBUG: self.kickstart_file = %s" % str(self.kickstart_file))
789- #self.logger.info("DEBUG: self.rsync_flags = %s" % str(self.rsync_flags))
790- #self.logger.info("DEBUG: self.arch = %s" % str(self.arch))
791- #self.logger.info("DEBUG: self.breed = %s" % str(self.breed))
792- #self.logger.info("DEBUG: self.os_version = %s" % str(self.os_version))
793-
794- # both --import and --name are required arguments
795-
796- if self.mirror is None:
797- utils.die(self.logger,"import failed. no --path specified")
798- if self.mirror_name is None:
799- utils.die(self.logger,"import failed. no --name specified")
800-
801- # if --arch is supplied, validate it to ensure it's valid
802-
803- if self.arch is not None and self.arch != "":
804- self.arch = self.arch.lower()
805- if self.arch == "x86":
806- # be consistent
807- self.arch = "i386"
808- if self.arch not in self.get_valid_arches():
809- utils.die(self.logger,"arch must be one of: %s" % string.join(self.get_valid_arches(),", "))
810-
811- # if we're going to do any copying, set where to put things
812- # and then make sure nothing is already there.
813-
814- self.path = os.path.normpath( "%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name) )
815- if os.path.exists(self.path) and self.arch is None:
816- # FIXME : Raise exception even when network_root is given ?
817- utils.die(self.logger,"Something already exists at this import location (%s). You must specify --arch to avoid potentially overwriting existing files." % self.path)
818-
819- # import takes a --kickstart for forcing selection that can't be used in all circumstances
820-
821- if self.kickstart_file and not self.breed:
822- utils.die(self.logger,"Kickstart file can only be specified when a specific breed is selected")
823-
824- if self.os_version and not self.breed:
825- utils.die(self.logger,"OS version can only be specified when a specific breed is selected")
826-
827- if self.breed and self.breed.lower() not in self.get_valid_breeds():
828- utils.die(self.logger,"Supplied import breed is not supported by this module")
829-
830- # if --arch is supplied, make sure the user is not importing a path with a different
831- # arch, which would just be silly.
832-
833- if self.arch:
834- # append the arch path to the name if the arch is not already
835- # found in the name.
836- for x in self.get_valid_arches():
837- if self.path.lower().find(x) != -1:
838- if self.arch != x :
839- utils.die(self.logger,"Architecture found on pathname (%s) does not fit the one given in command line (%s)"%(x,self.arch))
840- break
841- else:
842- # FIXME : This is very likely removed later at get_proposed_name, and the guessed arch appended again
843- self.path += ("-%s" % self.arch)
844-
845- # make the output path and mirror content but only if not specifying that a network
846- # accessible support location already exists (this is --available-as on the command line)
847-
848- if self.network_root is None:
849- # we need to mirror (copy) the files
850-
851- utils.mkdir(self.path)
852-
853- if self.mirror.startswith("http://") or self.mirror.startswith("ftp://") or self.mirror.startswith("nfs://"):
854-
855- # http mirrors are kind of primative. rsync is better.
856- # that's why this isn't documented in the manpage and we don't support them.
857- # TODO: how about adding recursive FTP as an option?
858-
859- utils.die(self.logger,"unsupported protocol")
860-
861- else:
862-
863- # good, we're going to use rsync..
864- # we don't use SSH for public mirrors and local files.
865- # presence of user@host syntax means use SSH
866-
867- # kick off the rsync now
868-
869- if not utils.rsync_files(self.mirror, self.path, self.rsync_flags, self.logger):
870- utils.die(self.logger, "failed to rsync the files")
871-
872- else:
873-
874- # rather than mirroring, we're going to assume the path is available
875- # over http, ftp, and nfs, perhaps on an external filer. scanning still requires
876- # --mirror is a filesystem path, but --available-as marks the network path
877-
878- if not os.path.exists(self.mirror):
879- utils.die(self.logger, "path does not exist: %s" % self.mirror)
880-
881- # find the filesystem part of the path, after the server bits, as each distro
882- # URL needs to be calculated relative to this.
883-
884- if not self.network_root.endswith("/"):
885- self.network_root = self.network_root + "/"
886- self.path = os.path.normpath( self.mirror )
887- valid_roots = [ "nfs://", "ftp://", "http://" ]
888- for valid_root in valid_roots:
889- if self.network_root.startswith(valid_root):
890- break
891- else:
892- utils.die(self.logger, "Network root given to --available-as must be nfs://, ftp://, or http://")
893- if self.network_root.startswith("nfs://"):
894- try:
895- (a,b,rest) = self.network_root.split(":",3)
896- except:
897- utils.die(self.logger, "Network root given to --available-as is missing a colon, please see the manpage example.")
898-
899- # now walk the filesystem looking for distributions that match certain patterns
900-
901- self.logger.info("adding distros")
902- distros_added = []
903- # FIXME : search below self.path for isolinux configurations or known directories from TRY_LIST
904- os.path.walk(self.path, self.distro_adder, distros_added)
905-
906- # find out if we can auto-create any repository records from the install tree
907-
908- if self.network_root is None:
909- self.logger.info("associating repos")
910- # FIXME: this automagic is not possible (yet) without mirroring
911- self.repo_finder(distros_added)
912-
913- # find the most appropriate answer files for each profile object
914-
915- self.logger.info("associating kickstarts")
916- self.kickstart_finder(distros_added)
917-
918- # ensure bootloaders are present
919- self.api.pxegen.copy_bootloaders()
920-
921- return True
922-
923- # required function for import modules
924- def get_valid_arches(self):
925- return ["i386", "ppc", "x86_64", "x86",]
926-
927- # required function for import modules
928- def get_valid_breeds(self):
929- return ["debian","ubuntu"]
930-
931- # required function for import modules
932- def get_valid_os_versions(self):
933- if self.breed == "debian":
934- return ["etch", "lenny", "squeeze", "sid", "stable", "testing", "unstable", "experimental",]
935- elif self.breed == "ubuntu":
936- return ["dapper", "hardy", "karmic", "lucid", "maverick", "natty",]
937- else:
938- return []
939-
940- def get_valid_repo_breeds(self):
941- return ["apt",]
942-
943- def get_release_files(self):
944- """
945- Find distro release packages.
946- """
947- return glob.glob(os.path.join(self.get_rootdir(), "dists/*"))
948-
949- def get_breed_from_directory(self):
950- for breed in self.get_valid_breeds():
951- # NOTE : Although we break the loop after the first match,
952- # multiple debian derived distros can actually live at the same pool -- JP
953- d = os.path.join(self.mirror, breed)
954- if (os.path.islink(d) and os.path.isdir(d) and os.path.realpath(d) == os.path.realpath(self.mirror)) or os.path.basename(self.mirror) == breed:
955- return breed
956- else:
957- return None
958-
959- def get_tree_location(self, distro):
960- """
961- Once a distribution is identified, find the part of the distribution
962- that has the URL in it that we want to use for kickstarting the
963- distribution, and create a ksmeta variable $tree that contains this.
964- """
965-
966- base = self.get_rootdir()
967-
968- if self.network_root is None:
969- dists_path = os.path.join(self.path, "dists")
970- if os.path.isdir(dists_path):
971- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
972- else:
973- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
974- self.set_install_tree(distro, tree)
975- else:
976- # where we assign the kickstart source is relative to our current directory
977- # and the input start directory in the crawl. We find the path segments
978- # between and tack them on the network source path to find the explicit
979- # network path to the distro that Anaconda can digest.
980- tail = self.path_tail(self.path, base)
981- tree = self.network_root[:-1] + tail
982- self.set_install_tree(distro, tree)
983-
984- return
985-
986- def repo_finder(self, distros_added):
987- for distro in distros_added:
988- self.logger.info("traversing distro %s" % distro.name)
989- # FIXME : Shouldn't decide this the value of self.network_root ?
990- if distro.kernel.find("ks_mirror") != -1:
991- basepath = os.path.dirname(distro.kernel)
992- top = self.get_rootdir()
993- self.logger.info("descent into %s" % top)
994- dists_path = os.path.join(self.path, "dists")
995- if not os.path.isdir(dists_path):
996- self.process_repos()
997- else:
998- self.logger.info("this distro isn't mirrored")
999-
1000- def process_repos(self):
1001- pass
1002-
1003- def distro_adder(self,distros_added,dirname,fnames):
1004- """
1005- This is an os.path.walk routine that finds distributions in the directory
1006- to be scanned and then creates them.
1007- """
1008-
1009- # FIXME: If there are more than one kernel or initrd image on the same directory,
1010- # results are unpredictable
1011-
1012- initrd = None
1013- kernel = None
1014-
1015- for x in fnames:
1016- adtls = []
1017-
1018- fullname = os.path.join(dirname,x)
1019- if os.path.islink(fullname) and os.path.isdir(fullname):
1020- if fullname.startswith(self.path):
1021- self.logger.warning("avoiding symlink loop")
1022- continue
1023- self.logger.info("following symlink: %s" % fullname)
1024- os.path.walk(fullname, self.distro_adder, distros_added)
1025-
1026- if ( x.startswith("initrd") or x.startswith("ramdisk.image.gz") or x.startswith("vmkboot.gz") ) and x != "initrd.size":
1027- initrd = os.path.join(dirname,x)
1028- if ( x.startswith("vmlinu") or x.startswith("kernel.img") or x.startswith("linux") or x.startswith("mboot.c32") ) and x.find("initrd") == -1:
1029- kernel = os.path.join(dirname,x)
1030-
1031- # if we've collected a matching kernel and initrd pair, turn the in and add them to the list
1032- if initrd is not None and kernel is not None:
1033- adtls.append(self.add_entry(dirname,kernel,initrd))
1034- kernel = None
1035- initrd = None
1036-
1037- for adtl in adtls:
1038- distros_added.extend(adtl)
1039-
1040- def add_entry(self,dirname,kernel,initrd):
1041- """
1042- When we find a directory with a valid kernel/initrd in it, create the distribution objects
1043- as appropriate and save them. This includes creating xen and rescue distros/profiles
1044- if possible.
1045- """
1046-
1047- proposed_name = self.get_proposed_name(dirname,kernel)
1048- proposed_arch = self.get_proposed_arch(dirname)
1049-
1050- if self.arch and proposed_arch and self.arch != proposed_arch:
1051- utils.die(self.logger,"Arch from pathname (%s) does not match with supplied one %s"%(proposed_arch,self.arch))
1052-
1053- archs = self.learn_arch_from_tree()
1054- if not archs:
1055- if self.arch:
1056- archs.append( self.arch )
1057- else:
1058- if self.arch and self.arch not in archs:
1059- utils.die(self.logger, "Given arch (%s) not found on imported tree %s"%(self.arch,self.get_pkgdir()))
1060- if proposed_arch:
1061- if archs and proposed_arch not in archs:
1062- self.logger.warning("arch from pathname (%s) not found on imported tree %s" % (proposed_arch,self.get_pkgdir()))
1063- return
1064-
1065- archs = [ proposed_arch ]
1066-
1067- if len(archs)>1:
1068- self.logger.warning("- Warning : Multiple archs found : %s" % (archs))
1069-
1070- distros_added = []
1071-
1072- for pxe_arch in archs:
1073- name = proposed_name + "-" + pxe_arch
1074- existing_distro = self.distros.find(name=name)
1075-
1076- if existing_distro is not None:
1077- self.logger.warning("skipping import, as distro name already exists: %s" % name)
1078- continue
1079-
1080- else:
1081- self.logger.info("creating new distro: %s" % name)
1082- distro = self.config.new_distro()
1083-
1084- if name.find("-autoboot") != -1:
1085- # this is an artifact of some EL-3 imports
1086- continue
1087-
1088- distro.set_name(name)
1089- distro.set_kernel(kernel)
1090- distro.set_initrd(initrd)
1091- distro.set_arch(pxe_arch)
1092- distro.set_breed(self.breed)
1093- # If a version was supplied on command line, we set it now
1094- if self.os_version:
1095- distro.set_os_version(self.os_version)
1096-
1097- self.distros.add(distro,save=True)
1098- distros_added.append(distro)
1099-
1100- existing_profile = self.profiles.find(name=name)
1101-
1102- # see if the profile name is already used, if so, skip it and
1103- # do not modify the existing profile
1104-
1105- if existing_profile is None:
1106- self.logger.info("creating new profile: %s" % name)
1107- #FIXME: The created profile holds a default kickstart, and should be breed specific
1108- profile = self.config.new_profile()
1109- else:
1110- self.logger.info("skipping existing profile, name already exists: %s" % name)
1111- continue
1112-
1113- # save our minimal profile which just points to the distribution and a good
1114- # default answer file
1115-
1116- profile.set_name(name)
1117- profile.set_distro(name)
1118- profile.set_kickstart(self.kickstart_file)
1119-
1120- # depending on the name of the profile we can define a good virt-type
1121- # for usage with koan
1122-
1123- if name.find("-xen") != -1:
1124- profile.set_virt_type("xenpv")
1125- elif name.find("vmware") != -1:
1126- profile.set_virt_type("vmware")
1127- else:
1128- profile.set_virt_type("qemu")
1129-
1130- # save our new profile to the collection
1131-
1132- self.profiles.add(profile,save=True)
1133-
1134- return distros_added
1135-
1136- def get_proposed_name(self,dirname,kernel=None):
1137- """
1138- Given a directory name where we have a kernel/initrd pair, try to autoname
1139- the distribution (and profile) object based on the contents of that path
1140- """
1141-
1142- if self.network_root is not None:
1143- name = self.mirror_name + "-".join(self.path_tail(os.path.dirname(self.path),dirname).split("/"))
1144- else:
1145- # remove the part that says /var/www/cobbler/ks_mirror/name
1146- name = "-".join(dirname.split("/")[5:])
1147-
1148- if kernel is not None and kernel.find("PAE") != -1:
1149- name = name + "-PAE"
1150-
1151- # These are all Ubuntu's doing, the netboot images are buried pretty
1152- # deep. ;-) -JC
1153- name = name.replace("-netboot","")
1154- name = name.replace("-ubuntu-installer","")
1155- name = name.replace("-amd64","")
1156- name = name.replace("-i386","")
1157-
1158- # we know that some kernel paths should not be in the name
1159-
1160- name = name.replace("-images","")
1161- name = name.replace("-pxeboot","")
1162- name = name.replace("-install","")
1163- name = name.replace("-isolinux","")
1164-
1165- # some paths above the media root may have extra path segments we want
1166- # to clean up
1167-
1168- name = name.replace("-os","")
1169- name = name.replace("-tree","")
1170- name = name.replace("var-www-cobbler-", "")
1171- name = name.replace("ks_mirror-","")
1172- name = name.replace("--","-")
1173-
1174- # remove any architecture name related string, as real arch will be appended later
1175-
1176- name = name.replace("chrp","ppc64")
1177-
1178- for separator in [ '-' , '_' , '.' ] :
1179- for arch in [ "i386" , "x86_64" , "ia64" , "ppc64", "ppc32", "ppc", "x86" , "s390x", "s390" , "386" , "amd" ]:
1180- name = name.replace("%s%s" % ( separator , arch ),"")
1181-
1182- return name
1183-
1184- def get_proposed_arch(self,dirname):
1185- """
1186- Given an directory name, can we infer an architecture from a path segment?
1187- """
1188- if dirname.find("x86_64") != -1 or dirname.find("amd") != -1:
1189- return "x86_64"
1190- if dirname.find("ia64") != -1:
1191- return "ia64"
1192- if dirname.find("i386") != -1 or dirname.find("386") != -1 or dirname.find("x86") != -1:
1193- return "i386"
1194- if dirname.find("s390x") != -1:
1195- return "s390x"
1196- if dirname.find("s390") != -1:
1197- return "s390"
1198- if dirname.find("ppc64") != -1 or dirname.find("chrp") != -1:
1199- return "ppc64"
1200- if dirname.find("ppc32") != -1:
1201- return "ppc"
1202- if dirname.find("ppc") != -1:
1203- return "ppc"
1204- return None
1205-
1206- def arch_walker(self,foo,dirname,fnames):
1207- """
1208- See docs on learn_arch_from_tree.
1209-
1210- The TRY_LIST is used to speed up search, and should be dropped for default importer
1211- Searched kernel names are kernel-header, linux-headers-, kernel-largesmp, kernel-hugemem
1212-
1213- This method is useful to get the archs, but also to package type and a raw guess of the breed
1214- """
1215-
1216- # try to find a kernel header RPM and then look at it's arch.
1217- for x in fnames:
1218- if self.match_kernelarch_file(x):
1219- for arch in self.get_valid_arches():
1220- if x.find(arch) != -1:
1221- foo[arch] = 1
1222- for arch in [ "i686" , "amd64" ]:
1223- if x.find(arch) != -1:
1224- foo[arch] = 1
1225-
1226- def kickstart_finder(self,distros_added):
1227- """
1228- For all of the profiles in the config w/o a kickstart, use the
1229- given kickstart file, or look at the kernel path, from that,
1230- see if we can guess the distro, and if we can, assign a kickstart
1231- if one is available for it.
1232- """
1233- for profile in self.profiles:
1234- distro = self.distros.find(name=profile.get_conceptual_parent().name)
1235- if distro is None or not (distro in distros_added):
1236- continue
1237-
1238- kdir = os.path.dirname(distro.kernel)
1239- if self.kickstart_file == None:
1240- for file in self.get_release_files():
1241- results = self.scan_pkg_filename(file)
1242- # FIXME : If os is not found on tree but set with CLI, no kickstart is searched
1243- if results is None:
1244- self.logger.warning("skipping %s" % file)
1245- continue
1246- (flavor, major, minor, release) = results
1247- # Why use set_variance()? scan_pkg_filename() does everything we need now - jcammarata
1248- #version , ks = self.set_variance(flavor, major, minor, distro.arch)
1249- if self.os_version:
1250- if self.os_version != flavor:
1251- utils.die(self.logger,"CLI version differs from tree : %s vs. %s" % (self.os_version,flavor))
1252- distro.set_comment("%s %s (%s.%s.%s) %s" % (self.breed,flavor,major,minor,release,self.arch))
1253- distro.set_os_version(flavor)
1254- # is this even valid for debian/ubuntu? - jcammarata
1255- #ds = self.get_datestamp()
1256- #if ds is not None:
1257- # distro.set_tree_build_time(ds)
1258- profile.set_kickstart("/var/lib/cobbler/kickstarts/sample.seed")
1259- self.profiles.add(profile,save=True)
1260-
1261- self.configure_tree_location(distro)
1262- self.distros.add(distro,save=True) # re-save
1263- self.api.serialize()
1264-
1265- def configure_tree_location(self, distro):
1266- """
1267- Once a distribution is identified, find the part of the distribution
1268- that has the URL in it that we want to use for kickstarting the
1269- distribution, and create a ksmeta variable $tree that contains this.
1270- """
1271-
1272- base = self.get_rootdir()
1273-
1274- if self.network_root is None:
1275- dists_path = os.path.join( self.path , "dists" )
1276- if os.path.isdir( dists_path ):
1277- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
1278- else:
1279- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
1280- self.set_install_tree(distro, tree)
1281- else:
1282- # where we assign the kickstart source is relative to our current directory
1283- # and the input start directory in the crawl. We find the path segments
1284- # between and tack them on the network source path to find the explicit
1285- # network path to the distro that Anaconda can digest.
1286- tail = utils.path_tail(self.path, base)
1287- tree = self.network_root[:-1] + tail
1288- self.set_install_tree(distro, tree)
1289-
1290- def get_rootdir(self):
1291- return self.mirror
1292-
1293- def get_pkgdir(self):
1294- if not self.pkgdir:
1295- return None
1296- return os.path.join(self.get_rootdir(),self.pkgdir)
1297-
1298- def set_install_tree(self, distro, url):
1299- distro.ks_meta["tree"] = url
1300-
1301- def learn_arch_from_tree(self):
1302- """
1303- If a distribution is imported from DVD, there is a good chance the path doesn't
1304- contain the arch and we should add it back in so that it's part of the
1305- meaningful name ... so this code helps figure out the arch name. This is important
1306- for producing predictable distro names (and profile names) from differing import sources
1307- """
1308- result = {}
1309- # FIXME : this is called only once, should not be a walk
1310- if self.get_pkgdir():
1311- os.path.walk(self.get_pkgdir(), self.arch_walker, result)
1312- if result.pop("amd64",False):
1313- result["x86_64"] = 1
1314- if result.pop("i686",False):
1315- result["i386"] = 1
1316- return result.keys()
1317-
1318- def match_kernelarch_file(self, filename):
1319- """
1320- Is the given filename a kernel filename?
1321- """
1322- if not filename.endswith("deb"):
1323- return False
1324- if filename.startswith("linux-headers-"):
1325- return True
1326- return False
1327-
1328- def scan_pkg_filename(self, file):
1329- """
1330- Determine what the distro is based on the release package filename.
1331- """
1332- # FIXME: all of these dist_names should probably be put in a function
1333- # which would be called in place of looking in codes.py. Right now
1334- # you have to update both codes.py and this to add a new release
1335- if self.breed == "debian":
1336- dist_names = ['etch','lenny',]
1337- elif self.breed == "ubuntu":
1338- dist_names = ['dapper','hardy','intrepid','jaunty','karmic','lynx','maverick','natty',]
1339- else:
1340- return None
1341-
1342- if os.path.basename(file) in dist_names:
1343- release_file = os.path.join(file,'Release')
1344- self.logger.info("Found %s release file: %s" % (self.breed,release_file))
1345-
1346- f = open(release_file,'r')
1347- lines = f.readlines()
1348- f.close()
1349-
1350- for line in lines:
1351- if line.lower().startswith('version: '):
1352- version = line.split(':')[1].strip()
1353- values = version.split('.')
1354- if len(values) == 1:
1355- # I don't think you'd ever hit this currently with debian or ubuntu,
1356- # just including it for safety reasons
1357- return (os.path.basename(file), values[0], "0", "0")
1358- elif len(values) == 2:
1359- return (os.path.basename(file), values[0], values[1], "0")
1360- elif len(values) > 2:
1361- return (os.path.basename(file), values[0], values[1], values[2])
1362- return None
1363-
1364- def get_datestamp(self):
1365- """
1366- Not used for debian/ubuntu... should probably be removed? - jcammarata
1367- """
1368- pass
1369-
1370- def set_variance(self, flavor, major, minor, arch):
1371- """
1372- Set distro specific versioning.
1373- """
1374- # I don't think this is required anymore, as the scan_pkg_filename() function
1375- # above does everything we need it to - jcammarata
1376- #
1377- #if self.breed == "debian":
1378- # dist_names = { '4.0' : "etch" , '5.0' : "lenny" }
1379- # dist_vers = "%s.%s" % ( major , minor )
1380- # os_version = dist_names[dist_vers]
1381- #
1382- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
1383- #elif self.breed == "ubuntu":
1384- # # Release names taken from wikipedia
1385- # dist_names = { '6.4' :"dapper",
1386- # '8.4' :"hardy",
1387- # '8.10' :"intrepid",
1388- # '9.4' :"jaunty",
1389- # '9.10' :"karmic",
1390- # '10.4' :"lynx",
1391- # '10.10':"maverick",
1392- # '11.4' :"natty",
1393- # }
1394- # dist_vers = "%s.%s" % ( major , minor )
1395- # if not dist_names.has_key( dist_vers ):
1396- # dist_names['4ubuntu2.0'] = "IntrepidIbex"
1397- # os_version = dist_names[dist_vers]
1398- #
1399- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
1400- #else:
1401- # return None
1402- pass
1403-
1404- def process_repos(self, main_importer, distro):
1405- # Create a disabled repository for the new distro, and the security updates
1406- #
1407- # NOTE : We cannot use ks_meta nor os_version because they get fixed at a later stage
1408-
1409- repo = item_repo.Repo(main_importer.config)
1410- repo.set_breed( "apt" )
1411- repo.set_arch( distro.arch )
1412- repo.set_keep_updated( False )
1413- repo.yumopts["--ignore-release-gpg"] = None
1414- repo.yumopts["--verbose"] = None
1415- repo.set_name( distro.name )
1416- repo.set_os_version( distro.os_version )
1417- # NOTE : The location of the mirror should come from timezone
1418- repo.set_mirror( "http://ftp.%s.debian.org/debian/dists/%s" % ( 'us' , '@@suite@@' ) )
1419-
1420- security_repo = item_repo.Repo(main_importer.config)
1421- security_repo.set_breed( "apt" )
1422- security_repo.set_arch( distro.arch )
1423- security_repo.set_keep_updated( False )
1424- security_repo.yumopts["--ignore-release-gpg"] = None
1425- security_repo.yumopts["--verbose"] = None
1426- security_repo.set_name( distro.name + "-security" )
1427- security_repo.set_os_version( distro.os_version )
1428- # There are no official mirrors for security updates
1429- security_repo.set_mirror( "http://security.debian.org/debian-security/dists/%s/updates" % '@@suite@@' )
1430-
1431- self.logger.info("Added repos for %s" % distro.name)
1432- repos = main_importer.config.repos()
1433- repos.add(repo,save=True)
1434- repos.add(security_repo,save=True)
1435-
1436-# ==========================================================================
1437-
1438-def get_import_manager(config,logger):
1439- return ImportDebianUbuntuManager(config,logger)
1440
1441=== removed directory '.pc/33_authn_configfile.patch'
1442=== removed directory '.pc/33_authn_configfile.patch/config'
1443=== removed file '.pc/33_authn_configfile.patch/config/modules.conf'
1444--- .pc/33_authn_configfile.patch/config/modules.conf 2011-04-04 12:55:44 +0000
1445+++ .pc/33_authn_configfile.patch/config/modules.conf 1970-01-01 00:00:00 +0000
1446@@ -1,86 +0,0 @@
1447-# cobbler module configuration file
1448-# =================================
1449-
1450-# authentication:
1451-# what users can log into the WebUI and Read-Write XMLRPC?
1452-# choices:
1453-# authn_denyall -- no one (default)
1454-# authn_configfile -- use /etc/cobbler/users.digest (for basic setups)
1455-# authn_passthru -- ask Apache to handle it (used for kerberos)
1456-# authn_ldap -- authenticate against LDAP
1457-# authn_spacewalk -- ask Spacewalk/Satellite (experimental)
1458-# authn_testing -- username/password is always testing/testing (debug)
1459-# (user supplied) -- you may write your own module
1460-# WARNING: this is a security setting, do not choose an option blindly.
1461-# for more information:
1462-# https://fedorahosted.org/cobbler/wiki/CobblerWebInterface
1463-# https://fedorahosted.org/cobbler/wiki/CustomizableSecurity
1464-# https://fedorahosted.org/cobbler/wiki/CobblerWithKerberos
1465-# https://fedorahosted.org/cobbler/wiki/CobblerWithLdap
1466-
1467-[authentication]
1468-module = authn_denyall
1469-
1470-# authorization:
1471-# once a user has been cleared by the WebUI/XMLRPC, what can they do?
1472-# choices:
1473-# authz_allowall -- full access for all authneticated users (default)
1474-# authz_ownership -- use users.conf, but add object ownership semantics
1475-# (user supplied) -- you may write your own module
1476-# WARNING: this is a security setting, do not choose an option blindly.
1477-# If you want to further restrict cobbler with ACLs for various groups,
1478-# pick authz_ownership. authz_allowall does not support ACLs. configfile
1479-# does but does not support object ownership which is useful as an additional
1480-# layer of control.
1481-
1482-# for more information:
1483-# https://fedorahosted.org/cobbler/wiki/CobblerWebInterface
1484-# https://fedorahosted.org/cobbler/wiki/CustomizableSecurity
1485-# https://fedorahosted.org/cobbler/wiki/CustomizableAuthorization
1486-# https://fedorahosted.org/cobbler/wiki/AuthorizationWithOwnership
1487-# https://fedorahosted.org/cobbler/wiki/AclFeature
1488-
1489-[authorization]
1490-module = authz_allowall
1491-
1492-# dns:
1493-# chooses the DNS management engine if manage_dns is enabled
1494-# in /etc/cobbler/settings, which is off by default.
1495-# choices:
1496-# manage_bind -- default, uses BIND/named
1497-# manage_dnsmasq -- uses dnsmasq, also must select dnsmasq for dhcp below
1498-# NOTE: more configuration is still required in /etc/cobbler
1499-# for more information:
1500-# https://fedorahosted.org/cobbler/wiki/ManageDns
1501-
1502-[dns]
1503-module = manage_bind
1504-
1505-# dhcp:
1506-# chooses the DHCP management engine if manage_dhcp is enabled
1507-# in /etc/cobbler/settings, which is off by default.
1508-# choices:
1509-# manage_isc -- default, uses ISC dhcpd
1510-# manage_dnsmasq -- uses dnsmasq, also must select dnsmasq for dns above
1511-# NOTE: more configuration is still required in /etc/cobbler
1512-# for more information:
1513-# https://fedorahosted.org/cobbler/wiki/ManageDhcp
1514-
1515-[dhcp]
1516-module = manage_isc
1517-
1518-# tftpd:
1519-# chooses the TFTP management engine if manage_tftp is enabled
1520-# in /etc/cobbler/settings, which is ON by default.
1521-#
1522-# choices:
1523-# manage_in_tftpd -- default, uses the system's tftp server
1524-# manage_tftpd_py -- uses cobbler's tftp server
1525-#
1526-# for more information:
1527-# https://fedorahosted.org/cobbler/wiki/ManageTftp
1528-
1529-[tftpd]
1530-module = manage_in_tftpd
1531-
1532-#--------------------------------------------------
1533
1534=== removed directory '.pc/34_fix_apache_wont_start.patch'
1535=== removed directory '.pc/34_fix_apache_wont_start.patch/config'
1536=== removed file '.pc/34_fix_apache_wont_start.patch/config/cobbler_web.conf'
1537--- .pc/34_fix_apache_wont_start.patch/config/cobbler_web.conf 2011-04-04 12:55:44 +0000
1538+++ .pc/34_fix_apache_wont_start.patch/config/cobbler_web.conf 1970-01-01 00:00:00 +0000
1539@@ -1,14 +0,0 @@
1540-# This configuration file enables the cobbler web
1541-# interface (django version)
1542-
1543-<VirtualHost *:80>
1544-
1545-# Do not log the requests generated from the event notification system
1546-SetEnvIf Request_URI ".*/op/events/user/.*" dontlog
1547-# Log only what remains
1548-CustomLog logs/access_log combined env=!dontlog
1549-
1550-WSGIScriptAlias /cobbler_web /usr/share/cobbler/web/cobbler.wsgi
1551-
1552-</VirtualHost>
1553-
1554
1555=== removed directory '.pc/39_cw_remove_vhost.patch'
1556=== removed directory '.pc/39_cw_remove_vhost.patch/config'
1557=== removed file '.pc/39_cw_remove_vhost.patch/config/cobbler_web.conf'
1558--- .pc/39_cw_remove_vhost.patch/config/cobbler_web.conf 2011-04-15 12:47:39 +0000
1559+++ .pc/39_cw_remove_vhost.patch/config/cobbler_web.conf 1970-01-01 00:00:00 +0000
1560@@ -1,14 +0,0 @@
1561-# This configuration file enables the cobbler web
1562-# interface (django version)
1563-
1564-<VirtualHost *:80>
1565-
1566-# Do not log the requests generated from the event notification system
1567-SetEnvIf Request_URI ".*/op/events/user/.*" dontlog
1568-# Log only what remains
1569-#CustomLog logs/access_log combined env=!dontlog
1570-
1571-WSGIScriptAlias /cobbler_web /usr/share/cobbler/web/cobbler.wsgi
1572-
1573-</VirtualHost>
1574-
1575
1576=== removed directory '.pc/40_ubuntu_bind9_management.patch'
1577=== removed directory '.pc/40_ubuntu_bind9_management.patch/cobbler'
1578=== removed file '.pc/40_ubuntu_bind9_management.patch/cobbler/action_check.py'
1579--- .pc/40_ubuntu_bind9_management.patch/cobbler/action_check.py 2011-04-18 11:15:59 +0000
1580+++ .pc/40_ubuntu_bind9_management.patch/cobbler/action_check.py 1970-01-01 00:00:00 +0000
1581@@ -1,482 +0,0 @@
1582-"""
1583-Validates whether the system is reasonably well configured for
1584-serving up content. This is the code behind 'cobbler check'.
1585-
1586-Copyright 2006-2009, Red Hat, Inc
1587-Michael DeHaan <mdehaan@redhat.com>
1588-
1589-This program is free software; you can redistribute it and/or modify
1590-it under the terms of the GNU General Public License as published by
1591-the Free Software Foundation; either version 2 of the License, or
1592-(at your option) any later version.
1593-
1594-This program is distributed in the hope that it will be useful,
1595-but WITHOUT ANY WARRANTY; without even the implied warranty of
1596-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1597-GNU General Public License for more details.
1598-
1599-You should have received a copy of the GNU General Public License
1600-along with this program; if not, write to the Free Software
1601-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1602-02110-1301 USA
1603-"""
1604-
1605-import os
1606-import re
1607-import action_sync
1608-import utils
1609-import glob
1610-from utils import _
1611-import clogger
1612-
1613-class BootCheck:
1614-
1615- def __init__(self,config,logger=None):
1616- """
1617- Constructor
1618- """
1619- self.config = config
1620- self.settings = config.settings()
1621- if logger is None:
1622- logger = clogger.Logger()
1623- self.logger = logger
1624-
1625-
1626- def run(self):
1627- """
1628- Returns None if there are no errors, otherwise returns a list
1629- of things to correct prior to running application 'for real'.
1630- (The CLI usage is "cobbler check" before "cobbler sync")
1631- """
1632- status = []
1633- self.checked_dist = utils.check_dist()
1634- self.check_name(status)
1635- self.check_selinux(status)
1636- if self.settings.manage_dhcp:
1637- mode = self.config.api.get_sync().dhcp.what()
1638- if mode == "isc":
1639- self.check_dhcpd_bin(status)
1640- self.check_dhcpd_conf(status)
1641- self.check_service(status,"dhcpd")
1642- elif mode == "dnsmasq":
1643- self.check_dnsmasq_bin(status)
1644- self.check_service(status,"dnsmasq")
1645-
1646- if self.settings.manage_dns:
1647- mode = self.config.api.get_sync().dns.what()
1648- if mode == "bind":
1649- self.check_bind_bin(status)
1650- self.check_service(status,"named")
1651- elif mode == "dnsmasq" and not self.settings.manage_dhcp:
1652- self.check_dnsmasq_bin(status)
1653- self.check_service(status,"dnsmasq")
1654-
1655- mode = self.config.api.get_sync().tftpd.what()
1656- if mode == "in_tftpd":
1657- self.check_tftpd_bin(status)
1658- self.check_tftpd_dir(status)
1659- self.check_tftpd_conf(status)
1660- elif mode == "tftpd_py":
1661- self.check_ctftpd_bin(status)
1662- self.check_ctftpd_dir(status)
1663- self.check_ctftpd_conf(status)
1664-
1665- self.check_service(status, "cobblerd")
1666-
1667- self.check_bootloaders(status)
1668- self.check_rsync_conf(status)
1669- self.check_httpd(status)
1670- self.check_iptables(status)
1671- self.check_yum(status)
1672- self.check_debmirror(status)
1673- self.check_for_ksvalidator(status)
1674- self.check_for_default_password(status)
1675- self.check_for_unreferenced_repos(status)
1676- self.check_for_unsynced_repos(status)
1677- self.check_for_cman(status)
1678-
1679- return status
1680-
1681- def check_for_ksvalidator(self, status):
1682- if self.checked_dist in ["debian", "ubuntu"]:
1683- return
1684-
1685- if not os.path.exists("/usr/bin/ksvalidator"):
1686- status.append("ksvalidator was not found, install pykickstart")
1687-
1688- return True
1689-
1690- def check_for_cman(self, status):
1691- # not doing rpm -q here to be cross-distro friendly
1692- if not os.path.exists("/sbin/fence_ilo") and not os.path.exists("/usr/sbin/fence_ilo"):
1693- status.append("fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them")
1694- return True
1695-
1696- def check_service(self, status, which, notes=""):
1697- if notes != "":
1698- notes = " (NOTE: %s)" % notes
1699- rc = 0
1700- if self.checked_dist == "redhat" or self.checked_dist == "suse":
1701- if os.path.exists("/etc/rc.d/init.d/%s" % which):
1702- rc = utils.subprocess_call(self.logger,"/sbin/service %s status > /dev/null 2>/dev/null" % which, shell=True)
1703- if rc != 0:
1704- status.append(_("service %s is not running%s") % (which,notes))
1705- return False
1706- elif self.checked_dist in ["debian", "ubuntu"]:
1707- # we still use /etc/init.d
1708- if os.path.exists("/etc/init.d/%s" % which):
1709- rc = utils.subprocess_call(self.logger,"/etc/init.d/%s status /dev/null 2>/dev/null" % which, shell=True)
1710- if rc != 0:
1711- status.append(_("service %s is not running%s") % which,notes)
1712- return False
1713- elif self.checked_dist == "ubuntu":
1714- if os.path.exists("/etc/init/%s.conf" % which):
1715- rc = utils.subprocess_call(self.logger,"status %s > /dev/null 2>&1" % which, shell=True)
1716- if rc != 0:
1717- status.append(_("service %s is not running%s") % (which,notes))
1718- else:
1719- status.append(_("Unknown distribution type, cannot check for running service %s" % which))
1720- return False
1721- return True
1722-
1723- def check_iptables(self, status):
1724- if os.path.exists("/etc/rc.d/init.d/iptables"):
1725- rc = utils.subprocess_call(self.logger,"/sbin/service iptables status >/dev/null 2>/dev/null", shell=True)
1726- if rc == 0:
1727- status.append(_("since iptables may be running, ensure 69, 80, and %(xmlrpc)s are unblocked") % { "xmlrpc" : self.settings.xmlrpc_port })
1728-
1729- def check_yum(self,status):
1730- if self.checked_dist in ["debian", "ubuntu"]:
1731- return
1732-
1733- if not os.path.exists("/usr/bin/createrepo"):
1734- status.append(_("createrepo package is not installed, needed for cobbler import and cobbler reposync, install createrepo?"))
1735- if not os.path.exists("/usr/bin/reposync"):
1736- status.append(_("reposync is not installed, need for cobbler reposync, install/upgrade yum-utils?"))
1737- if not os.path.exists("/usr/bin/yumdownloader"):
1738- status.append(_("yumdownloader is not installed, needed for cobbler repo add with --rpm-list parameter, install/upgrade yum-utils?"))
1739- if self.settings.reposync_flags.find("-l"):
1740- if self.checked_dist == "redhat" or self.checked_dist == "suse":
1741- yum_utils_ver = utils.subprocess_get(self.logger,"/usr/bin/rpmquery --queryformat=%{VERSION} yum-utils", shell=True)
1742- if yum_utils_ver < "1.1.17":
1743- status.append(_("yum-utils need to be at least version 1.1.17 for reposync -l, current version is %s") % yum_utils_ver )
1744-
1745- def check_debmirror(self,status):
1746- if not os.path.exists("/usr/bin/debmirror"):
1747- status.append(_("debmirror package is not installed, it will be required to manage debian deployments and repositories"))
1748- if os.path.exists("/etc/debmirror.conf"):
1749- f = open("/etc/debmirror.conf")
1750- re_dists = re.compile(r'@dists=')
1751- re_arches = re.compile(r'@arches=')
1752- for line in f.readlines():
1753- if re_dists.search(line) and not line.strip().startswith("#"):
1754- status.append(_("comment 'dists' on /etc/debmirror.conf for proper debian support"))
1755- if re_arches.search(line) and not line.strip().startswith("#"):
1756- status.append(_("comment 'arches' on /etc/debmirror.conf for proper debian support"))
1757-
1758-
1759- def check_name(self,status):
1760- """
1761- If the server name in the config file is still set to localhost
1762- kickstarts run from koan will not have proper kernel line
1763- parameters.
1764- """
1765- if self.settings.server == "127.0.0.1":
1766- status.append(_("The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it."))
1767- if self.settings.next_server == "127.0.0.1":
1768- status.append(_("For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network."))
1769-
1770- def check_selinux(self,status):
1771- """
1772- Suggests various SELinux rules changes to run Cobbler happily with
1773- SELinux in enforcing mode. FIXME: this method could use some
1774- refactoring in the future.
1775- """
1776- if self.checked_dist in ["debian", "ubuntu"]:
1777- return
1778-
1779- enabled = self.config.api.is_selinux_enabled()
1780- if enabled:
1781- data2 = utils.subprocess_get(self.logger,"/usr/sbin/getsebool -a",shell=True)
1782- for line in data2.split("\n"):
1783- if line.find("httpd_can_network_connect ") != -1:
1784- if line.find("off") != -1:
1785- status.append(_("Must enable a selinux boolean to enable vital web services components, run: setsebool -P httpd_can_network_connect true"))
1786- if line.find("rsync_disable_trans ") != -1:
1787- if line.find("on") != -1:
1788- status.append(_("Must enable the cobbler import and replicate commands, run: setsebool -P rsync_disable_trans=1"))
1789-
1790- data3 = utils.subprocess_get(self.logger,"/usr/sbin/semanage fcontext -l | grep public_content_t",shell=True)
1791-
1792- rule1 = False
1793- rule2 = False
1794- rule3 = False
1795- selinux_msg = "/usr/sbin/semanage fcontext -a -t public_content_t \"%s\""
1796- for line in data3.split("\n"):
1797- if line.startswith("/tftpboot/.*"):
1798- rule1 = True
1799- if line.startswith("/var/lib/tftpboot/.*"):
1800- rule2 = True
1801- if line.startswith("/var/www/cobbler/images/.*"):
1802- rule3 = True
1803-
1804- rules = []
1805- if os.path.exists("/tftpboot") and not rule1:
1806- rules.append(selinux_msg % "/tftpboot/.*")
1807- else:
1808- if not rule2:
1809- rules.append(selinux_msg % "/var/lib/tftpboot/.*")
1810- if not rule3:
1811- rules.append(selinux_msg % "/var/www/cobbler/images/.*")
1812- if len(rules) > 0:
1813- status.append("you need to set some SELinux content rules to ensure cobbler serves content correctly in your SELinux environment, run the following: %s" % " && ".join(rules))
1814-
1815- # now check to see that the Django sessions path is accessible
1816- # by Apache
1817-
1818- data4 = utils.subprocess_get(self.logger,"/usr/sbin/semanage fcontext -l | grep httpd_sys_content_rw_t",shell=True)
1819- selinux_msg = "you need to set some SELinux rules if you want to use cobbler-web (an optional package), run the following: /usr/sbin/semanage fcontext -a -t httpd_sys_content_rw_t \"%s\""
1820- rule4 = False
1821- for line in data4.split("\n"):
1822- if line.startswith("/var/lib/cobbler/webui_sessions/.*"):
1823- rule4 = True
1824- if not rule4:
1825- status.append(selinux_msg % "/var/lib/cobbler/webui_sessions/.*")
1826-
1827-
1828- def check_for_default_password(self,status):
1829- default_pass = self.settings.default_password_crypted
1830- if default_pass == "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac.":
1831- status.append(_("The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: \"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'\" to generate new one"))
1832-
1833-
1834- def check_for_unreferenced_repos(self,status):
1835- repos = []
1836- referenced = []
1837- not_found = []
1838- for r in self.config.api.repos():
1839- repos.append(r.name)
1840- for p in self.config.api.profiles():
1841- my_repos = p.repos
1842- if my_repos != "<<inherit>>":
1843- referenced.extend(my_repos)
1844- for r in referenced:
1845- if r not in repos and r != "<<inherit>>":
1846- not_found.append(r)
1847- if len(not_found) > 0:
1848- status.append(_("One or more repos referenced by profile objects is no longer defined in cobbler: %s") % ", ".join(not_found))
1849-
1850- def check_for_unsynced_repos(self,status):
1851- need_sync = []
1852- for r in self.config.repos():
1853- if r.mirror_locally == 1:
1854- lookfor = os.path.join(self.settings.webdir, "repo_mirror", r.name)
1855- if not os.path.exists(lookfor):
1856- need_sync.append(r.name)
1857- if len(need_sync) > 0:
1858- status.append(_("One or more repos need to be processed by cobbler reposync for the first time before kickstarting against them: %s") % ", ".join(need_sync))
1859-
1860-
1861- def check_httpd(self,status):
1862- """
1863- Check if Apache is installed.
1864- """
1865- if self.checked_dist in [ "suse", "redhat" ]:
1866- rc = utils.subprocess_get(self.logger,"httpd -v")
1867- else:
1868- rc = utils.subprocess_get(self.logger,"apache2 -v")
1869- if rc.find("Server") == -1:
1870- status.append("Apache (httpd) is not installed and/or in path")
1871-
1872-
1873- def check_dhcpd_bin(self,status):
1874- """
1875- Check if dhcpd is installed
1876- """
1877- if not os.path.exists("/usr/sbin/dhcpd"):
1878- status.append("dhcpd is not installed")
1879-
1880- def check_dnsmasq_bin(self,status):
1881- """
1882- Check if dnsmasq is installed
1883- """
1884- rc = utils.subprocess_get(self.logger,"dnsmasq --help")
1885- if rc.find("Valid options") == -1:
1886- status.append("dnsmasq is not installed and/or in path")
1887-
1888- def check_bind_bin(self,status):
1889- """
1890- Check if bind is installed.
1891- """
1892- rc = utils.subprocess_get(self.logger,"named -v")
1893- # it should return something like "BIND 9.6.1-P1-RedHat-9.6.1-6.P1.fc11"
1894- if rc.find("BIND") == -1:
1895- status.append("named is not installed and/or in path")
1896-
1897- def check_bootloaders(self,status):
1898- """
1899- Check if network bootloaders are installed
1900- """
1901- # FIXME: move zpxe.rexx to loaders
1902-
1903- bootloaders = {
1904- "elilo" : [ "/var/lib/cobbler/loaders/elilo*.efi" ],
1905- "menu.c32" : [ "/usr/share/syslinux/menu.c32",
1906- "/usr/lib/syslinux/menu.c32",
1907- "/var/lib/cobbler/loaders/menu.c32" ],
1908- "yaboot" : [ "/var/lib/cobbler/loaders/yaboot*" ],
1909- "pxelinux.0" : [ "/usr/share/syslinux/pxelinux.0",
1910- "/usr/lib/syslinux/pxelinux.0",
1911- "/var/lib/cobbler/loaders/pxelinux.0" ],
1912- "efi" : [ "/var/lib/cobbler/loaders/grub-x86.efi",
1913- "/var/lib/cobbler/loaders/grub-x86_64.efi" ],
1914- }
1915-
1916- # look for bootloaders at the glob locations above
1917- found_bootloaders = []
1918- items = bootloaders.keys()
1919- for loader_name in items:
1920- patterns = bootloaders[loader_name]
1921- for pattern in patterns:
1922- matches = glob.glob(pattern)
1923- if len(matches) > 0:
1924- found_bootloaders.append(loader_name)
1925- not_found = []
1926-
1927- # invert the list of what we've found so we can report on what we haven't found
1928- for loader_name in items:
1929- if loader_name not in found_bootloaders:
1930- not_found.append(loader_name)
1931-
1932- if len(not_found) > 0:
1933- status.append("some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.")
1934-
1935- def check_tftpd_bin(self,status):
1936- """
1937- Check if tftpd is installed
1938- """
1939- if self.checked_dist in ["debian", "ubuntu"]:
1940- return
1941-
1942- if not os.path.exists("/etc/xinetd.d/tftp"):
1943- status.append("missing /etc/xinetd.d/tftp, install tftp-server?")
1944-
1945- def check_tftpd_dir(self,status):
1946- """
1947- Check if cobbler.conf's tftpboot directory exists
1948- """
1949- if self.checked_dist in ["debian", "ubuntu"]:
1950- return
1951-
1952- bootloc = utils.tftpboot_location()
1953- if not os.path.exists(bootloc):
1954- status.append(_("please create directory: %(dirname)s") % { "dirname" : bootloc })
1955-
1956-
1957- def check_tftpd_conf(self,status):
1958- """
1959- Check that configured tftpd boot directory matches with actual
1960- Check that tftpd is enabled to autostart
1961- """
1962- if self.checked_dist in ["debian", "ubuntu"]:
1963- return
1964-
1965- if os.path.exists("/etc/xinetd.d/tftp"):
1966- f = open("/etc/xinetd.d/tftp")
1967- re_disable = re.compile(r'disable.*=.*yes')
1968- for line in f.readlines():
1969- if re_disable.search(line) and not line.strip().startswith("#"):
1970- status.append(_("change 'disable' to 'no' in %(file)s") % { "file" : "/etc/xinetd.d/tftp" })
1971- else:
1972- status.append("missing configuration file: /etc/xinetd.d/tftp")
1973-
1974- def check_ctftpd_bin(self,status):
1975- """
1976- Check if the Cobbler tftp server is installed
1977- """
1978- if self.checked_dist in ["debian", "ubuntu"]:
1979- return
1980-
1981- if not os.path.exists("/etc/xinetd.d/ctftp"):
1982- status.append("missing /etc/xinetd.d/ctftp")
1983-
1984- def check_ctftpd_dir(self,status):
1985- """
1986- Check if cobbler.conf's tftpboot directory exists
1987- """
1988- if self.checked_dist in ["debian", "ubuntu"]:
1989- return
1990-
1991- bootloc = utils.tftpboot_location()
1992- if not os.path.exists(bootloc):
1993- status.append(_("please create directory: %(dirname)s") % { "dirname" : bootloc })
1994-
1995- def check_ctftpd_conf(self,status):
1996- """
1997- Check that configured tftpd boot directory matches with actual
1998- Check that tftpd is enabled to autostart
1999- """
2000- if self.checked_dist in ["debian", "ubuntu"]:
2001- return
2002-
2003- if os.path.exists("/etc/xinetd.d/tftp"):
2004- f = open("/etc/xinetd.d/tftp")
2005- re_disable = re.compile(r'disable.*=.*no')
2006- for line in f.readlines():
2007- if re_disable.search(line) and not line.strip().startswith("#"):
2008- status.append(_("change 'disable' to 'yes' in %(file)s") % { "file" : "/etc/xinetd.d/tftp" })
2009- if os.path.exists("/etc/xinetd.d/ctftp"):
2010- f = open("/etc/xinetd.d/ctftp")
2011- re_disable = re.compile(r'disable.*=.*yes')
2012- for line in f.readlines():
2013- if re_disable.search(line) and not line.strip().startswith("#"):
2014- status.append(_("change 'disable' to 'no' in %(file)s") % { "file" : "/etc/xinetd.d/ctftp" })
2015- else:
2016- status.append("missing configuration file: /etc/xinetd.d/ctftp")
2017-
2018- def check_rsync_conf(self,status):
2019- """
2020- Check that rsync is enabled to autostart
2021- """
2022- if self.checked_dist in ["debian", "ubuntu"]:
2023- return
2024-
2025- if os.path.exists("/etc/xinetd.d/rsync"):
2026- f = open("/etc/xinetd.d/rsync")
2027- re_disable = re.compile(r'disable.*=.*yes')
2028- for line in f.readlines():
2029- if re_disable.search(line) and not line.strip().startswith("#"):
2030- status.append(_("change 'disable' to 'no' in %(file)s") % { "file" : "/etc/xinetd.d/rsync" })
2031- else:
2032- status.append(_("file %(file)s does not exist") % { "file" : "/etc/xinetd.d/rsync" })
2033-
2034-
2035- def check_dhcpd_conf(self,status):
2036- """
2037- NOTE: this code only applies if cobbler is *NOT* set to generate
2038- a dhcp.conf file
2039-
2040- Check that dhcpd *appears* to be configured for pxe booting.
2041- We can't assure file correctness. Since a cobbler user might
2042- have dhcp on another server, it's okay if it's not there and/or
2043- not configured correctly according to automated scans.
2044- """
2045- if not (self.settings.manage_dhcp == 0):
2046- return
2047-
2048- if os.path.exists(self.settings.dhcpd_conf):
2049- match_next = False
2050- match_file = False
2051- f = open(self.settings.dhcpd_conf)
2052- for line in f.readlines():
2053- if line.find("next-server") != -1:
2054- match_next = True
2055- if line.find("filename") != -1:
2056- match_file = True
2057- if not match_next:
2058- status.append(_("expecting next-server entry in %(file)s") % { "file" : self.settings.dhcpd_conf })
2059- if not match_file:
2060- status.append(_("missing file: %(file)s") % { "file" : self.settings.dhcpd_conf })
2061- else:
2062- status.append(_("missing file: %(file)s") % { "file" : self.settings.dhcpd_conf })
2063-
2064
2065=== removed directory '.pc/40_ubuntu_bind9_management.patch/cobbler/modules'
2066=== removed file '.pc/40_ubuntu_bind9_management.patch/cobbler/modules/manage_bind.py'
2067--- .pc/40_ubuntu_bind9_management.patch/cobbler/modules/manage_bind.py 2011-04-18 11:15:59 +0000
2068+++ .pc/40_ubuntu_bind9_management.patch/cobbler/modules/manage_bind.py 1970-01-01 00:00:00 +0000
2069@@ -1,332 +0,0 @@
2070-"""
2071-This is some of the code behind 'cobbler sync'.
2072-
2073-Copyright 2006-2009, Red Hat, Inc
2074-Michael DeHaan <mdehaan@redhat.com>
2075-John Eckersberg <jeckersb@redhat.com>
2076-
2077-This program is free software; you can redistribute it and/or modify
2078-it under the terms of the GNU General Public License as published by
2079-the Free Software Foundation; either version 2 of the License, or
2080-(at your option) any later version.
2081-
2082-This program is distributed in the hope that it will be useful,
2083-but WITHOUT ANY WARRANTY; without even the implied warranty of
2084-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2085-GNU General Public License for more details.
2086-
2087-You should have received a copy of the GNU General Public License
2088-along with this program; if not, write to the Free Software
2089-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2090-02110-1301 USA
2091-"""
2092-
2093-import os
2094-import os.path
2095-import shutil
2096-import time
2097-import sys
2098-import glob
2099-import traceback
2100-import errno
2101-import re
2102-from shlex import shlex
2103-
2104-
2105-import utils
2106-from cexceptions import *
2107-import templar
2108-
2109-import item_distro
2110-import item_profile
2111-import item_repo
2112-import item_system
2113-
2114-from utils import _
2115-
2116-
2117-def register():
2118- """
2119- The mandatory cobbler module registration hook.
2120- """
2121- return "manage"
2122-
2123-
2124-class BindManager:
2125-
2126- def what(self):
2127- return "bind"
2128-
2129- def __init__(self,config,logger):
2130- """
2131- Constructor
2132- """
2133- self.logger = logger
2134- self.config = config
2135- self.api = config.api
2136- self.distros = config.distros()
2137- self.profiles = config.profiles()
2138- self.systems = config.systems()
2139- self.settings = config.settings()
2140- self.repos = config.repos()
2141- self.templar = templar.Templar(config)
2142-
2143- def regen_hosts(self):
2144- pass # not used
2145-
2146- def __forward_zones(self):
2147- """
2148- Returns a map of zones and the records that belong
2149- in them
2150- """
2151- zones = {}
2152- forward_zones = self.settings.manage_forward_zones
2153- if type(forward_zones) != type([]):
2154- # gracefully handle when user inputs only a single zone
2155- # as a string instead of a list with only a single item
2156- forward_zones = [forward_zones]
2157-
2158- for zone in forward_zones:
2159- zones[zone] = {}
2160-
2161- for system in self.systems:
2162- for (name, interface) in system.interfaces.iteritems():
2163- host = interface["dns_name"]
2164- ip = interface["ip_address"]
2165- if not system.is_management_supported(cidr_ok=False):
2166- continue
2167- if not host or not ip:
2168- # gotsta have some dns_name and ip or else!
2169- continue
2170- if host.find(".") == -1:
2171- continue
2172-
2173- # match the longest zone!
2174- # e.g. if you have a host a.b.c.d.e
2175- # if manage_forward_zones has:
2176- # - c.d.e
2177- # - b.c.d.e
2178- # then a.b.c.d.e should go in b.c.d.e
2179- best_match = ''
2180- for zone in zones.keys():
2181- if re.search('\.%s$' % zone, host) and len(zone) > len(best_match):
2182- best_match = zone
2183-
2184- if best_match == '': # no match
2185- continue
2186-
2187- # strip the zone off the dns_name and append the
2188- # remainder + ip to the zone list
2189- host = re.sub('\.%s$' % best_match, '', host)
2190-
2191- zones[best_match][host] = ip
2192-
2193- return zones
2194-
2195- def __reverse_zones(self):
2196- """
2197- Returns a map of zones and the records that belong
2198- in them
2199- """
2200- zones = {}
2201- reverse_zones = self.settings.manage_reverse_zones
2202- if type(reverse_zones) != type([]):
2203- # gracefully handle when user inputs only a single zone
2204- # as a string instead of a list with only a single item
2205- reverse_zones = [reverse_zones]
2206-
2207- for zone in reverse_zones:
2208- zones[zone] = {}
2209-
2210- for sys in self.systems:
2211- for (name, interface) in sys.interfaces.iteritems():
2212- host = interface["dns_name"]
2213- ip = interface["ip_address"]
2214- if not sys.is_management_supported(cidr_ok=False):
2215- continue
2216- if not host or not ip:
2217- # gotsta have some dns_name and ip or else!
2218- continue
2219-
2220- # match the longest zone!
2221- # e.g. if you have an ip 1.2.3.4
2222- # if manage_reverse_zones has:
2223- # - 1.2
2224- # - 1.2.3
2225- # then 1.2.3.4 should go in 1.2.3
2226- best_match = ''
2227- for zone in zones.keys():
2228- if re.search('^%s\.' % zone, ip) and len(zone) > len(best_match):
2229- best_match = zone
2230-
2231- if best_match == '': # no match
2232- continue
2233-
2234- # strip the zone off the front of the ip
2235- # reverse the rest of the octets
2236- # append the remainder + dns_name
2237- ip = ip.replace(best_match, '', 1)
2238- if ip[0] == '.': # strip leading '.' if it's there
2239- ip = ip[1:]
2240- tokens = ip.split('.')
2241- tokens.reverse()
2242- ip = '.'.join(tokens)
2243- zones[best_match][ip] = host + '.'
2244-
2245- return zones
2246-
2247-
2248- def __write_named_conf(self):
2249- """
2250- Write out the named.conf main config file from the template.
2251- """
2252- settings_file = "/etc/named.conf"
2253- template_file = "/etc/cobbler/named.template"
2254- forward_zones = self.settings.manage_forward_zones
2255- reverse_zones = self.settings.manage_reverse_zones
2256-
2257- metadata = {'forward_zones': self.__forward_zones().keys(),
2258- 'reverse_zones': [],
2259- 'zone_include': ''}
2260-
2261- for zone in metadata['forward_zones']:
2262- txt = """
2263-zone "%(zone)s." {
2264- type master;
2265- file "%(zone)s";
2266-};
2267-""" % {'zone': zone}
2268- metadata['zone_include'] = metadata['zone_include'] + txt
2269-
2270- for zone in self.__reverse_zones().keys():
2271- tokens = zone.split('.')
2272- tokens.reverse()
2273- arpa = '.'.join(tokens) + '.in-addr.arpa'
2274- metadata['reverse_zones'].append((zone, arpa))
2275- txt = """
2276-zone "%(arpa)s." {
2277- type master;
2278- file "%(zone)s";
2279-};
2280-""" % {'arpa': arpa, 'zone': zone}
2281- metadata['zone_include'] = metadata['zone_include'] + txt
2282-
2283- try:
2284- f2 = open(template_file,"r")
2285- except:
2286- raise CX(_("error reading template from file: %s") % template_file)
2287- template_data = ""
2288- template_data = f2.read()
2289- f2.close()
2290-
2291- if self.logger is not None:
2292- self.logger.info("generating %s" % settings_file)
2293- self.templar.render(template_data, metadata, settings_file, None)
2294-
2295- def __ip_sort(self, ips):
2296- """
2297- Sorts IP addresses (or partial addresses) in a numerical fashion per-octet
2298- """
2299- # strings to integer octet chunks so we can sort numerically
2300- octets = map(lambda x: [int(i) for i in x.split('.')], ips)
2301- octets.sort()
2302- # integers back to strings
2303- octets = map(lambda x: [str(i) for i in x], octets)
2304- return ['.'.join(i) for i in octets]
2305-
2306- def __pretty_print_host_records(self, hosts, rectype='A', rclass='IN'):
2307- """
2308- Format host records by order and with consistent indentation
2309- """
2310- names = [k for k,v in hosts.iteritems()]
2311- if not names: return '' # zones with no hosts
2312-
2313- if rectype == 'PTR':
2314- names = self.__ip_sort(names)
2315- else:
2316- names.sort()
2317-
2318- max_name = max([len(i) for i in names])
2319-
2320- s = ""
2321- for name in names:
2322- spacing = " " * (max_name - len(name))
2323- my_name = "%s%s" % (name, spacing)
2324- my_host = hosts[name]
2325- s += "%s %s %s %s\n" % (my_name, rclass, rectype, my_host)
2326- return s
2327-
2328- def __write_zone_files(self):
2329- """
2330- Write out the forward and reverse zone files for all configured zones
2331- """
2332- default_template_file = "/etc/cobbler/zone.template"
2333- cobbler_server = self.settings.server
2334- serial = int(time.time())
2335- forward = self.__forward_zones()
2336- reverse = self.__reverse_zones()
2337-
2338- try:
2339- f2 = open(default_template_file,"r")
2340- except:
2341- raise CX(_("error reading template from file: %s") % default_template_file)
2342- default_template_data = ""
2343- default_template_data = f2.read()
2344- f2.close()
2345-
2346- for (zone, hosts) in forward.iteritems():
2347- metadata = {
2348- 'cobbler_server': cobbler_server,
2349- 'serial': serial,
2350- 'host_record': ''
2351- }
2352-
2353- # grab zone-specific template if it exists
2354- try:
2355- fd = open('/etc/cobbler/zone_templates/%s' % zone)
2356- template_data = fd.read()
2357- fd.close()
2358- except:
2359- template_data = default_template_data
2360-
2361- metadata['host_record'] = self.__pretty_print_host_records(hosts)
2362-
2363- zonefilename='/var/named/' + zone
2364- if self.logger is not None:
2365- self.logger.info("generating (forward) %s" % zonefilename)
2366- self.templar.render(template_data, metadata, zonefilename, None)
2367-
2368- for (zone, hosts) in reverse.iteritems():
2369- metadata = {
2370- 'cobbler_server': cobbler_server,
2371- 'serial': serial,
2372- 'host_record': ''
2373- }
2374-
2375- # grab zone-specific template if it exists
2376- try:
2377- fd = open('/etc/cobbler/zone_templates/%s' % zone)
2378- template_data = fd.read()
2379- fd.close()
2380- except:
2381- template_data = default_template_data
2382-
2383- metadata['host_record'] = self.__pretty_print_host_records(hosts, rectype='PTR')
2384-
2385- zonefilename='/var/named/' + zone
2386- if self.logger is not None:
2387- self.logger.info("generating (reverse) %s" % zonefilename)
2388- self.templar.render(template_data, metadata, zonefilename, None)
2389-
2390-
2391- def write_dns_files(self):
2392- """
2393- BIND files are written when manage_dns is set in
2394- /var/lib/cobbler/settings.
2395- """
2396-
2397- self.__write_named_conf()
2398- self.__write_zone_files()
2399-
2400-def get_manager(config,logger):
2401- return BindManager(config,logger)
2402
2403=== removed file '.pc/40_ubuntu_bind9_management.patch/cobbler/modules/sync_post_restart_services.py'
2404--- .pc/40_ubuntu_bind9_management.patch/cobbler/modules/sync_post_restart_services.py 2011-04-18 11:15:59 +0000
2405+++ .pc/40_ubuntu_bind9_management.patch/cobbler/modules/sync_post_restart_services.py 1970-01-01 00:00:00 +0000
2406@@ -1,66 +0,0 @@
2407-import distutils.sysconfig
2408-import sys
2409-import os
2410-import traceback
2411-import cexceptions
2412-import os
2413-import sys
2414-import xmlrpclib
2415-import cobbler.module_loader as module_loader
2416-import cobbler.utils as utils
2417-
2418-plib = distutils.sysconfig.get_python_lib()
2419-mod_path="%s/cobbler" % plib
2420-sys.path.insert(0, mod_path)
2421-
2422-def register():
2423- # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.
2424- # the return of this method indicates the trigger type
2425- return "/var/lib/cobbler/triggers/sync/post/*"
2426-
2427-def run(api,args,logger):
2428-
2429- settings = api.settings()
2430-
2431- manage_dhcp = str(settings.manage_dhcp).lower()
2432- manage_dns = str(settings.manage_dns).lower()
2433- manage_tftpd = str(settings.manage_tftpd).lower()
2434- restart_dhcp = str(settings.restart_dhcp).lower()
2435- restart_dns = str(settings.restart_dns).lower()
2436-
2437- which_dhcp_module = module_loader.get_module_from_file("dhcp","module",just_name=True).strip()
2438- which_dns_module = module_loader.get_module_from_file("dns","module",just_name=True).strip()
2439-
2440- # special handling as we don't want to restart it twice
2441- has_restarted_dnsmasq = False
2442-
2443- rc = 0
2444- if manage_dhcp != "0":
2445- if which_dhcp_module == "manage_isc":
2446- if restart_dhcp != "0":
2447- rc = utils.subprocess_call(logger, "dhcpd -t -q", shell=True)
2448- if rc != 0:
2449- logger.error("dhcpd -t failed")
2450- return 1
2451- rc = utils.subprocess_call(logger,"service isc-dhcp-server restart", shell=True)
2452- elif which_dhcp_module == "manage_dnsmasq":
2453- if restart_dhcp != "0":
2454- rc = utils.subprocess_call(logger, "service dnsmasq restart")
2455- has_restarted_dnsmasq = True
2456- else:
2457- logger.error("unknown DHCP engine: %s" % which_dhcp_module)
2458- rc = 411
2459-
2460- if manage_dns != "0" and restart_dns != "0":
2461- if which_dns_module == "manage_bind":
2462- rc = utils.subprocess_call(logger, "service named restart", shell=True)
2463- elif which_dns_module == "manage_dnsmasq" and not has_restarted_dnsmasq:
2464- rc = utils.subprocess_call(logger, "service dnsmasq restart", shell=True)
2465- elif which_dns_module == "manage_dnsmasq" and has_restarted_dnsmasq:
2466- rc = 0
2467- else:
2468- logger.error("unknown DNS engine: %s" % which_dns_module)
2469- rc = 412
2470-
2471- return rc
2472-
2473
2474=== removed directory '.pc/40_ubuntu_bind9_management.patch/templates'
2475=== removed directory '.pc/40_ubuntu_bind9_management.patch/templates/etc'
2476=== removed file '.pc/40_ubuntu_bind9_management.patch/templates/etc/named.template'
2477--- .pc/40_ubuntu_bind9_management.patch/templates/etc/named.template 2011-04-18 11:15:59 +0000
2478+++ .pc/40_ubuntu_bind9_management.patch/templates/etc/named.template 1970-01-01 00:00:00 +0000
2479@@ -1,31 +0,0 @@
2480-options {
2481- listen-on port 53 { 127.0.0.1; };
2482- directory "/var/named";
2483- dump-file "/var/named/data/cache_dump.db";
2484- statistics-file "/var/named/data/named_stats.txt";
2485- memstatistics-file "/var/named/data/named_mem_stats.txt";
2486- allow-query { localhost; };
2487- recursion yes;
2488-};
2489-
2490-logging {
2491- channel default_debug {
2492- file "data/named.run";
2493- severity dynamic;
2494- };
2495-};
2496-
2497-#for $zone in $forward_zones
2498-zone "${zone}." {
2499- type master;
2500- file "$zone";
2501-};
2502-
2503-#end for
2504-#for $zone, $arpa in $reverse_zones
2505-zone "${arpa}." {
2506- type master;
2507- file "$zone";
2508-};
2509-
2510-#end for
2511
2512=== removed directory '.pc/41_update_tree_path_with_arch.patch'
2513=== removed directory '.pc/41_update_tree_path_with_arch.patch/cobbler'
2514=== removed directory '.pc/41_update_tree_path_with_arch.patch/cobbler/modules'
2515=== removed file '.pc/41_update_tree_path_with_arch.patch/cobbler/modules/manage_import_debian_ubuntu.py'
2516--- .pc/41_update_tree_path_with_arch.patch/cobbler/modules/manage_import_debian_ubuntu.py 2011-05-02 18:26:03 +0000
2517+++ .pc/41_update_tree_path_with_arch.patch/cobbler/modules/manage_import_debian_ubuntu.py 1970-01-01 00:00:00 +0000
2518@@ -1,777 +0,0 @@
2519-"""
2520-This is some of the code behind 'cobbler sync'.
2521-
2522-Copyright 2006-2009, Red Hat, Inc
2523-Michael DeHaan <mdehaan@redhat.com>
2524-John Eckersberg <jeckersb@redhat.com>
2525-
2526-This program is free software; you can redistribute it and/or modify
2527-it under the terms of the GNU General Public License as published by
2528-the Free Software Foundation; either version 2 of the License, or
2529-(at your option) any later version.
2530-
2531-This program is distributed in the hope that it will be useful,
2532-but WITHOUT ANY WARRANTY; without even the implied warranty of
2533-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2534-GNU General Public License for more details.
2535-
2536-You should have received a copy of the GNU General Public License
2537-along with this program; if not, write to the Free Software
2538-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2539-02110-1301 USA
2540-"""
2541-
2542-import os
2543-import os.path
2544-import shutil
2545-import time
2546-import sys
2547-import glob
2548-import traceback
2549-import errno
2550-import re
2551-from utils import popen2
2552-from shlex import shlex
2553-
2554-
2555-import utils
2556-from cexceptions import *
2557-import templar
2558-
2559-import item_distro
2560-import item_profile
2561-import item_repo
2562-import item_system
2563-
2564-from utils import _
2565-
2566-def register():
2567- """
2568- The mandatory cobbler module registration hook.
2569- """
2570- return "manage/import"
2571-
2572-
2573-class ImportDebianUbuntuManager:
2574-
2575- def __init__(self,config,logger):
2576- """
2577- Constructor
2578- """
2579- self.logger = logger
2580- self.config = config
2581- self.api = config.api
2582- self.distros = config.distros()
2583- self.profiles = config.profiles()
2584- self.systems = config.systems()
2585- self.settings = config.settings()
2586- self.repos = config.repos()
2587- self.templar = templar.Templar(config)
2588-
2589- # required function for import modules
2590- def what(self):
2591- return "import/debian_ubuntu"
2592-
2593- # required function for import modules
2594- def check_for_signature(self,path,cli_breed):
2595- signatures = [
2596- 'pool',
2597- ]
2598-
2599- #self.logger.info("scanning %s for a debian/ubuntu distro signature" % path)
2600- for signature in signatures:
2601- d = os.path.join(path,signature)
2602- if os.path.exists(d):
2603- self.logger.info("Found a debian/ubuntu compatible signature: %s" % signature)
2604- return (True,signature)
2605-
2606- if cli_breed and cli_breed in self.get_valid_breeds():
2607- self.logger.info("Warning: No distro signature for kernel at %s, using value from command line" % path)
2608- return (True,None)
2609-
2610- return (False,None)
2611-
2612- # required function for import modules
2613- def run(self,pkgdir,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None,breed=None,os_version=None):
2614- self.pkgdir = pkgdir
2615- self.mirror = mirror
2616- self.mirror_name = mirror_name
2617- self.network_root = network_root
2618- self.kickstart_file = kickstart_file
2619- self.rsync_flags = rsync_flags
2620- self.arch = arch
2621- self.breed = breed
2622- self.os_version = os_version
2623-
2624- # some fixups for the XMLRPC interface, which does not use "None"
2625- if self.arch == "": self.arch = None
2626- if self.mirror == "": self.mirror = None
2627- if self.mirror_name == "": self.mirror_name = None
2628- if self.kickstart_file == "": self.kickstart_file = None
2629- if self.os_version == "": self.os_version = None
2630- if self.rsync_flags == "": self.rsync_flags = None
2631- if self.network_root == "": self.network_root = None
2632-
2633- # If no breed was specified on the command line, figure it out
2634- if self.breed == None:
2635- self.breed = self.get_breed_from_directory()
2636- if not self.breed:
2637- utils.die(self.logger,"import failed - could not determine breed of debian-based distro")
2638-
2639- # debug log stuff for testing
2640- #self.logger.info("DEBUG: self.pkgdir = %s" % str(self.pkgdir))
2641- #self.logger.info("DEBUG: self.mirror = %s" % str(self.mirror))
2642- #self.logger.info("DEBUG: self.mirror_name = %s" % str(self.mirror_name))
2643- #self.logger.info("DEBUG: self.network_root = %s" % str(self.network_root))
2644- #self.logger.info("DEBUG: self.kickstart_file = %s" % str(self.kickstart_file))
2645- #self.logger.info("DEBUG: self.rsync_flags = %s" % str(self.rsync_flags))
2646- #self.logger.info("DEBUG: self.arch = %s" % str(self.arch))
2647- #self.logger.info("DEBUG: self.breed = %s" % str(self.breed))
2648- #self.logger.info("DEBUG: self.os_version = %s" % str(self.os_version))
2649-
2650- # both --import and --name are required arguments
2651-
2652- if self.mirror is None:
2653- utils.die(self.logger,"import failed. no --path specified")
2654- if self.mirror_name is None:
2655- utils.die(self.logger,"import failed. no --name specified")
2656-
2657- # if --arch is supplied, validate it to ensure it's valid
2658-
2659- if self.arch is not None and self.arch != "":
2660- self.arch = self.arch.lower()
2661- if self.arch == "x86":
2662- # be consistent
2663- self.arch = "i386"
2664- if self.arch not in self.get_valid_arches():
2665- utils.die(self.logger,"arch must be one of: %s" % string.join(self.get_valid_arches(),", "))
2666-
2667- # if we're going to do any copying, set where to put things
2668- # and then make sure nothing is already there.
2669-
2670- self.path = os.path.normpath( "%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name) )
2671- if os.path.exists(self.path) and self.arch is None:
2672- # FIXME : Raise exception even when network_root is given ?
2673- utils.die(self.logger,"Something already exists at this import location (%s). You must specify --arch to avoid potentially overwriting existing files." % self.path)
2674-
2675- # import takes a --kickstart for forcing selection that can't be used in all circumstances
2676-
2677- if self.kickstart_file and not self.breed:
2678- utils.die(self.logger,"Kickstart file can only be specified when a specific breed is selected")
2679-
2680- if self.os_version and not self.breed:
2681- utils.die(self.logger,"OS version can only be specified when a specific breed is selected")
2682-
2683- if self.breed and self.breed.lower() not in self.get_valid_breeds():
2684- utils.die(self.logger,"Supplied import breed is not supported by this module")
2685-
2686- # if --arch is supplied, make sure the user is not importing a path with a different
2687- # arch, which would just be silly.
2688-
2689- if self.arch:
2690- # append the arch path to the name if the arch is not already
2691- # found in the name.
2692- for x in self.get_valid_arches():
2693- if self.path.lower().find(x) != -1:
2694- if self.arch != x :
2695- utils.die(self.logger,"Architecture found on pathname (%s) does not fit the one given in command line (%s)"%(x,self.arch))
2696- break
2697- else:
2698- # FIXME : This is very likely removed later at get_proposed_name, and the guessed arch appended again
2699- self.path += ("-%s" % self.arch)
2700-
2701- # make the output path and mirror content but only if not specifying that a network
2702- # accessible support location already exists (this is --available-as on the command line)
2703-
2704- if self.network_root is None:
2705- # we need to mirror (copy) the files
2706-
2707- utils.mkdir(self.path)
2708-
2709- if self.mirror.startswith("http://") or self.mirror.startswith("ftp://") or self.mirror.startswith("nfs://"):
2710-
2711- # http mirrors are kind of primative. rsync is better.
2712- # that's why this isn't documented in the manpage and we don't support them.
2713- # TODO: how about adding recursive FTP as an option?
2714-
2715- utils.die(self.logger,"unsupported protocol")
2716-
2717- else:
2718-
2719- # good, we're going to use rsync..
2720- # we don't use SSH for public mirrors and local files.
2721- # presence of user@host syntax means use SSH
2722-
2723- # kick off the rsync now
2724-
2725- if not utils.rsync_files(self.mirror, self.path, self.rsync_flags, self.logger):
2726- utils.die(self.logger, "failed to rsync the files")
2727-
2728- else:
2729-
2730- # rather than mirroring, we're going to assume the path is available
2731- # over http, ftp, and nfs, perhaps on an external filer. scanning still requires
2732- # --mirror is a filesystem path, but --available-as marks the network path
2733-
2734- if not os.path.exists(self.mirror):
2735- utils.die(self.logger, "path does not exist: %s" % self.mirror)
2736-
2737- # find the filesystem part of the path, after the server bits, as each distro
2738- # URL needs to be calculated relative to this.
2739-
2740- if not self.network_root.endswith("/"):
2741- self.network_root = self.network_root + "/"
2742- self.path = os.path.normpath( self.mirror )
2743- valid_roots = [ "nfs://", "ftp://", "http://" ]
2744- for valid_root in valid_roots:
2745- if self.network_root.startswith(valid_root):
2746- break
2747- else:
2748- utils.die(self.logger, "Network root given to --available-as must be nfs://, ftp://, or http://")
2749- if self.network_root.startswith("nfs://"):
2750- try:
2751- (a,b,rest) = self.network_root.split(":",3)
2752- except:
2753- utils.die(self.logger, "Network root given to --available-as is missing a colon, please see the manpage example.")
2754-
2755- # now walk the filesystem looking for distributions that match certain patterns
2756-
2757- self.logger.info("adding distros")
2758- distros_added = []
2759- # FIXME : search below self.path for isolinux configurations or known directories from TRY_LIST
2760- os.path.walk(self.path, self.distro_adder, distros_added)
2761-
2762- # find out if we can auto-create any repository records from the install tree
2763-
2764- if self.network_root is None:
2765- self.logger.info("associating repos")
2766- # FIXME: this automagic is not possible (yet) without mirroring
2767- self.repo_finder(distros_added)
2768-
2769- # find the most appropriate answer files for each profile object
2770-
2771- self.logger.info("associating kickstarts")
2772- self.kickstart_finder(distros_added)
2773-
2774- # ensure bootloaders are present
2775- self.api.pxegen.copy_bootloaders()
2776-
2777- return True
2778-
2779- # required function for import modules
2780- def get_valid_arches(self):
2781- return ["i386", "ppc", "x86_64", "x86",]
2782-
2783- # required function for import modules
2784- def get_valid_breeds(self):
2785- return ["debian","ubuntu"]
2786-
2787- # required function for import modules
2788- def get_valid_os_versions(self):
2789- if self.breed == "debian":
2790- return ["etch", "lenny", "squeeze", "sid", "stable", "testing", "unstable", "experimental",]
2791- elif self.breed == "ubuntu":
2792- return ["dapper", "hardy", "karmic", "lucid", "maverick", "natty",]
2793- else:
2794- return []
2795-
2796- def get_valid_repo_breeds(self):
2797- return ["apt",]
2798-
2799- def get_release_files(self):
2800- """
2801- Find distro release packages.
2802- """
2803- return glob.glob(os.path.join(self.get_rootdir(), "dists/*"))
2804-
2805- def get_breed_from_directory(self):
2806- for breed in self.get_valid_breeds():
2807- # NOTE : Although we break the loop after the first match,
2808- # multiple debian derived distros can actually live at the same pool -- JP
2809- d = os.path.join(self.mirror, breed)
2810- if (os.path.islink(d) and os.path.isdir(d) and os.path.realpath(d) == os.path.realpath(self.mirror)) or os.path.basename(self.mirror) == breed:
2811- return breed
2812- else:
2813- return None
2814-
2815- def get_tree_location(self, distro):
2816- """
2817- Once a distribution is identified, find the part of the distribution
2818- that has the URL in it that we want to use for kickstarting the
2819- distribution, and create a ksmeta variable $tree that contains this.
2820- """
2821-
2822- base = self.get_rootdir()
2823-
2824- if self.network_root is None:
2825- dists_path = os.path.join(self.path, "dists")
2826- if os.path.isdir(dists_path):
2827- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
2828- else:
2829- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
2830- self.set_install_tree(distro, tree)
2831- else:
2832- # where we assign the kickstart source is relative to our current directory
2833- # and the input start directory in the crawl. We find the path segments
2834- # between and tack them on the network source path to find the explicit
2835- # network path to the distro that Anaconda can digest.
2836- tail = self.path_tail(self.path, base)
2837- tree = self.network_root[:-1] + tail
2838- self.set_install_tree(distro, tree)
2839-
2840- return
2841-
2842- def repo_finder(self, distros_added):
2843- for distro in distros_added:
2844- self.logger.info("traversing distro %s" % distro.name)
2845- # FIXME : Shouldn't decide this the value of self.network_root ?
2846- if distro.kernel.find("ks_mirror") != -1:
2847- basepath = os.path.dirname(distro.kernel)
2848- top = self.get_rootdir()
2849- self.logger.info("descent into %s" % top)
2850- dists_path = os.path.join(self.path, "dists")
2851- if not os.path.isdir(dists_path):
2852- self.process_repos()
2853- else:
2854- self.logger.info("this distro isn't mirrored")
2855-
2856- def process_repos(self):
2857- pass
2858-
2859- def distro_adder(self,distros_added,dirname,fnames):
2860- """
2861- This is an os.path.walk routine that finds distributions in the directory
2862- to be scanned and then creates them.
2863- """
2864-
2865- # FIXME: If there are more than one kernel or initrd image on the same directory,
2866- # results are unpredictable
2867-
2868- initrd = None
2869- kernel = None
2870-
2871- for x in fnames:
2872- adtls = []
2873-
2874- fullname = os.path.join(dirname,x)
2875- if os.path.islink(fullname) and os.path.isdir(fullname):
2876- if fullname.startswith(self.path):
2877- self.logger.warning("avoiding symlink loop")
2878- continue
2879- self.logger.info("following symlink: %s" % fullname)
2880- os.path.walk(fullname, self.distro_adder, distros_added)
2881-
2882- if ( x.startswith("initrd.gz") ) and x != "initrd.size":
2883- initrd = os.path.join(dirname,x)
2884- if ( x.startswith("linux") ) and x.find("initrd") == -1:
2885- kernel = os.path.join(dirname,x)
2886-
2887- # if we've collected a matching kernel and initrd pair, turn the in and add them to the list
2888- if initrd is not None and kernel is not None:
2889- adtls.append(self.add_entry(dirname,kernel,initrd))
2890- kernel = None
2891- initrd = None
2892-
2893- for adtl in adtls:
2894- distros_added.extend(adtl)
2895-
2896- def add_entry(self,dirname,kernel,initrd):
2897- """
2898- When we find a directory with a valid kernel/initrd in it, create the distribution objects
2899- as appropriate and save them. This includes creating xen and rescue distros/profiles
2900- if possible.
2901- """
2902-
2903- proposed_name = self.get_proposed_name(dirname,kernel)
2904- proposed_arch = self.get_proposed_arch(dirname)
2905-
2906- if self.arch and proposed_arch and self.arch != proposed_arch:
2907- utils.die(self.logger,"Arch from pathname (%s) does not match with supplied one %s"%(proposed_arch,self.arch))
2908-
2909- archs = self.learn_arch_from_tree()
2910- if not archs:
2911- if self.arch:
2912- archs.append( self.arch )
2913- else:
2914- if self.arch and self.arch not in archs:
2915- utils.die(self.logger, "Given arch (%s) not found on imported tree %s"%(self.arch,self.get_pkgdir()))
2916- if proposed_arch:
2917- if archs and proposed_arch not in archs:
2918- self.logger.warning("arch from pathname (%s) not found on imported tree %s" % (proposed_arch,self.get_pkgdir()))
2919- return
2920-
2921- archs = [ proposed_arch ]
2922-
2923- if len(archs)>1:
2924- self.logger.warning("- Warning : Multiple archs found : %s" % (archs))
2925-
2926- distros_added = []
2927-
2928- for pxe_arch in archs:
2929- name = proposed_name + "-" + pxe_arch
2930- existing_distro = self.distros.find(name=name)
2931-
2932- if existing_distro is not None:
2933- self.logger.warning("skipping import, as distro name already exists: %s" % name)
2934- continue
2935-
2936- else:
2937- self.logger.info("creating new distro: %s" % name)
2938- distro = self.config.new_distro()
2939-
2940- if name.find("-autoboot") != -1:
2941- # this is an artifact of some EL-3 imports
2942- continue
2943-
2944- distro.set_name(name)
2945- distro.set_kernel(kernel)
2946- distro.set_initrd(initrd)
2947- distro.set_arch(pxe_arch)
2948- distro.set_breed(self.breed)
2949- # If a version was supplied on command line, we set it now
2950- if self.os_version:
2951- distro.set_os_version(self.os_version)
2952-
2953- self.distros.add(distro,save=True)
2954- distros_added.append(distro)
2955-
2956- existing_profile = self.profiles.find(name=name)
2957-
2958- # see if the profile name is already used, if so, skip it and
2959- # do not modify the existing profile
2960-
2961- if existing_profile is None:
2962- self.logger.info("creating new profile: %s" % name)
2963- #FIXME: The created profile holds a default kickstart, and should be breed specific
2964- profile = self.config.new_profile()
2965- else:
2966- self.logger.info("skipping existing profile, name already exists: %s" % name)
2967- continue
2968-
2969- # save our minimal profile which just points to the distribution and a good
2970- # default answer file
2971-
2972- profile.set_name(name)
2973- profile.set_distro(name)
2974- profile.set_kickstart(self.kickstart_file)
2975-
2976- # depending on the name of the profile we can define a good virt-type
2977- # for usage with koan
2978-
2979- if name.find("-xen") != -1:
2980- profile.set_virt_type("xenpv")
2981- elif name.find("vmware") != -1:
2982- profile.set_virt_type("vmware")
2983- else:
2984- profile.set_virt_type("qemu")
2985-
2986- # save our new profile to the collection
2987-
2988- self.profiles.add(profile,save=True)
2989-
2990- return distros_added
2991-
2992- def get_proposed_name(self,dirname,kernel=None):
2993- """
2994- Given a directory name where we have a kernel/initrd pair, try to autoname
2995- the distribution (and profile) object based on the contents of that path
2996- """
2997-
2998- if self.network_root is not None:
2999- name = self.mirror_name + "-".join(self.path_tail(os.path.dirname(self.path),dirname).split("/"))
3000- else:
3001- # remove the part that says /var/www/cobbler/ks_mirror/name
3002- name = "-".join(dirname.split("/")[5:])
3003-
3004- if kernel is not None and kernel.find("PAE") != -1:
3005- name = name + "-PAE"
3006-
3007- # These are all Ubuntu's doing, the netboot images are buried pretty
3008- # deep. ;-) -JC
3009- name = name.replace("-netboot","")
3010- name = name.replace("-ubuntu-installer","")
3011- name = name.replace("-amd64","")
3012- name = name.replace("-i386","")
3013-
3014- # we know that some kernel paths should not be in the name
3015-
3016- name = name.replace("-images","")
3017- name = name.replace("-pxeboot","")
3018- name = name.replace("-install","")
3019- name = name.replace("-isolinux","")
3020-
3021- # some paths above the media root may have extra path segments we want
3022- # to clean up
3023-
3024- name = name.replace("-os","")
3025- name = name.replace("-tree","")
3026- name = name.replace("var-www-cobbler-", "")
3027- name = name.replace("ks_mirror-","")
3028- name = name.replace("--","-")
3029-
3030- # remove any architecture name related string, as real arch will be appended later
3031-
3032- name = name.replace("chrp","ppc64")
3033-
3034- for separator in [ '-' , '_' , '.' ] :
3035- for arch in [ "i386" , "x86_64" , "ia64" , "ppc64", "ppc32", "ppc", "x86" , "s390x", "s390" , "386" , "amd" ]:
3036- name = name.replace("%s%s" % ( separator , arch ),"")
3037-
3038- return name
3039-
3040- def get_proposed_arch(self,dirname):
3041- """
3042- Given an directory name, can we infer an architecture from a path segment?
3043- """
3044- if dirname.find("x86_64") != -1 or dirname.find("amd") != -1:
3045- return "x86_64"
3046- if dirname.find("ia64") != -1:
3047- return "ia64"
3048- if dirname.find("i386") != -1 or dirname.find("386") != -1 or dirname.find("x86") != -1:
3049- return "i386"
3050- if dirname.find("s390x") != -1:
3051- return "s390x"
3052- if dirname.find("s390") != -1:
3053- return "s390"
3054- if dirname.find("ppc64") != -1 or dirname.find("chrp") != -1:
3055- return "ppc64"
3056- if dirname.find("ppc32") != -1:
3057- return "ppc"
3058- if dirname.find("ppc") != -1:
3059- return "ppc"
3060- return None
3061-
3062- def arch_walker(self,foo,dirname,fnames):
3063- """
3064- See docs on learn_arch_from_tree.
3065-
3066- The TRY_LIST is used to speed up search, and should be dropped for default importer
3067- Searched kernel names are kernel-header, linux-headers-, kernel-largesmp, kernel-hugemem
3068-
3069- This method is useful to get the archs, but also to package type and a raw guess of the breed
3070- """
3071-
3072- # try to find a kernel header RPM and then look at it's arch.
3073- for x in fnames:
3074- if self.match_kernelarch_file(x):
3075- for arch in self.get_valid_arches():
3076- if x.find(arch) != -1:
3077- foo[arch] = 1
3078- for arch in [ "i686" , "amd64" ]:
3079- if x.find(arch) != -1:
3080- foo[arch] = 1
3081-
3082- def kickstart_finder(self,distros_added):
3083- """
3084- For all of the profiles in the config w/o a kickstart, use the
3085- given kickstart file, or look at the kernel path, from that,
3086- see if we can guess the distro, and if we can, assign a kickstart
3087- if one is available for it.
3088- """
3089- for profile in self.profiles:
3090- distro = self.distros.find(name=profile.get_conceptual_parent().name)
3091- if distro is None or not (distro in distros_added):
3092- continue
3093-
3094- kdir = os.path.dirname(distro.kernel)
3095- if self.kickstart_file == None:
3096- for file in self.get_release_files():
3097- results = self.scan_pkg_filename(file)
3098- # FIXME : If os is not found on tree but set with CLI, no kickstart is searched
3099- if results is None:
3100- self.logger.warning("skipping %s" % file)
3101- continue
3102- (flavor, major, minor, release) = results
3103- # Why use set_variance()? scan_pkg_filename() does everything we need now - jcammarata
3104- #version , ks = self.set_variance(flavor, major, minor, distro.arch)
3105- if self.os_version:
3106- if self.os_version != flavor:
3107- utils.die(self.logger,"CLI version differs from tree : %s vs. %s" % (self.os_version,flavor))
3108- distro.set_comment("%s %s (%s.%s.%s) %s" % (self.breed,flavor,major,minor,release,self.arch))
3109- distro.set_os_version(flavor)
3110- # is this even valid for debian/ubuntu? - jcammarata
3111- #ds = self.get_datestamp()
3112- #if ds is not None:
3113- # distro.set_tree_build_time(ds)
3114- profile.set_kickstart("/var/lib/cobbler/kickstarts/sample.seed")
3115- self.profiles.add(profile,save=True)
3116-
3117- self.configure_tree_location(distro)
3118- self.distros.add(distro,save=True) # re-save
3119- self.api.serialize()
3120-
3121- def configure_tree_location(self, distro):
3122- """
3123- Once a distribution is identified, find the part of the distribution
3124- that has the URL in it that we want to use for kickstarting the
3125- distribution, and create a ksmeta variable $tree that contains this.
3126- """
3127-
3128- base = self.get_rootdir()
3129-
3130- if self.network_root is None:
3131- dists_path = os.path.join( self.path , "dists" )
3132- if os.path.isdir( dists_path ):
3133- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
3134- else:
3135- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
3136- self.set_install_tree(distro, tree)
3137- else:
3138- # where we assign the kickstart source is relative to our current directory
3139- # and the input start directory in the crawl. We find the path segments
3140- # between and tack them on the network source path to find the explicit
3141- # network path to the distro that Anaconda can digest.
3142- tail = utils.path_tail(self.path, base)
3143- tree = self.network_root[:-1] + tail
3144- self.set_install_tree(distro, tree)
3145-
3146- def get_rootdir(self):
3147- return self.mirror
3148-
3149- def get_pkgdir(self):
3150- if not self.pkgdir:
3151- return None
3152- return os.path.join(self.get_rootdir(),self.pkgdir)
3153-
3154- def set_install_tree(self, distro, url):
3155- distro.ks_meta["tree"] = url
3156-
3157- def learn_arch_from_tree(self):
3158- """
3159- If a distribution is imported from DVD, there is a good chance the path doesn't
3160- contain the arch and we should add it back in so that it's part of the
3161- meaningful name ... so this code helps figure out the arch name. This is important
3162- for producing predictable distro names (and profile names) from differing import sources
3163- """
3164- result = {}
3165- # FIXME : this is called only once, should not be a walk
3166- if self.get_pkgdir():
3167- os.path.walk(self.get_pkgdir(), self.arch_walker, result)
3168- if result.pop("amd64",False):
3169- result["x86_64"] = 1
3170- if result.pop("i686",False):
3171- result["i386"] = 1
3172- return result.keys()
3173-
3174- def match_kernelarch_file(self, filename):
3175- """
3176- Is the given filename a kernel filename?
3177- """
3178- if not filename.endswith("deb"):
3179- return False
3180- if filename.startswith("linux-headers-"):
3181- return True
3182- return False
3183-
3184- def scan_pkg_filename(self, file):
3185- """
3186- Determine what the distro is based on the release package filename.
3187- """
3188- # FIXME: all of these dist_names should probably be put in a function
3189- # which would be called in place of looking in codes.py. Right now
3190- # you have to update both codes.py and this to add a new release
3191- if self.breed == "debian":
3192- dist_names = ['etch','lenny',]
3193- elif self.breed == "ubuntu":
3194- dist_names = ['dapper','hardy','intrepid','jaunty','karmic','lynx','maverick','natty',]
3195- else:
3196- return None
3197-
3198- if os.path.basename(file) in dist_names:
3199- release_file = os.path.join(file,'Release')
3200- self.logger.info("Found %s release file: %s" % (self.breed,release_file))
3201-
3202- f = open(release_file,'r')
3203- lines = f.readlines()
3204- f.close()
3205-
3206- for line in lines:
3207- if line.lower().startswith('version: '):
3208- version = line.split(':')[1].strip()
3209- values = version.split('.')
3210- if len(values) == 1:
3211- # I don't think you'd ever hit this currently with debian or ubuntu,
3212- # just including it for safety reasons
3213- return (os.path.basename(file), values[0], "0", "0")
3214- elif len(values) == 2:
3215- return (os.path.basename(file), values[0], values[1], "0")
3216- elif len(values) > 2:
3217- return (os.path.basename(file), values[0], values[1], values[2])
3218- return None
3219-
3220- def get_datestamp(self):
3221- """
3222- Not used for debian/ubuntu... should probably be removed? - jcammarata
3223- """
3224- pass
3225-
3226- def set_variance(self, flavor, major, minor, arch):
3227- """
3228- Set distro specific versioning.
3229- """
3230- # I don't think this is required anymore, as the scan_pkg_filename() function
3231- # above does everything we need it to - jcammarata
3232- #
3233- #if self.breed == "debian":
3234- # dist_names = { '4.0' : "etch" , '5.0' : "lenny" }
3235- # dist_vers = "%s.%s" % ( major , minor )
3236- # os_version = dist_names[dist_vers]
3237- #
3238- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
3239- #elif self.breed == "ubuntu":
3240- # # Release names taken from wikipedia
3241- # dist_names = { '6.4' :"dapper",
3242- # '8.4' :"hardy",
3243- # '8.10' :"intrepid",
3244- # '9.4' :"jaunty",
3245- # '9.10' :"karmic",
3246- # '10.4' :"lynx",
3247- # '10.10':"maverick",
3248- # '11.4' :"natty",
3249- # }
3250- # dist_vers = "%s.%s" % ( major , minor )
3251- # if not dist_names.has_key( dist_vers ):
3252- # dist_names['4ubuntu2.0'] = "IntrepidIbex"
3253- # os_version = dist_names[dist_vers]
3254- #
3255- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
3256- #else:
3257- # return None
3258- pass
3259-
3260- def process_repos(self, main_importer, distro):
3261- # Create a disabled repository for the new distro, and the security updates
3262- #
3263- # NOTE : We cannot use ks_meta nor os_version because they get fixed at a later stage
3264-
3265- repo = item_repo.Repo(main_importer.config)
3266- repo.set_breed( "apt" )
3267- repo.set_arch( distro.arch )
3268- repo.set_keep_updated( False )
3269- repo.yumopts["--ignore-release-gpg"] = None
3270- repo.yumopts["--verbose"] = None
3271- repo.set_name( distro.name )
3272- repo.set_os_version( distro.os_version )
3273- # NOTE : The location of the mirror should come from timezone
3274- repo.set_mirror( "http://ftp.%s.debian.org/debian/dists/%s" % ( 'us' , '@@suite@@' ) )
3275-
3276- security_repo = item_repo.Repo(main_importer.config)
3277- security_repo.set_breed( "apt" )
3278- security_repo.set_arch( distro.arch )
3279- security_repo.set_keep_updated( False )
3280- security_repo.yumopts["--ignore-release-gpg"] = None
3281- security_repo.yumopts["--verbose"] = None
3282- security_repo.set_name( distro.name + "-security" )
3283- security_repo.set_os_version( distro.os_version )
3284- # There are no official mirrors for security updates
3285- security_repo.set_mirror( "http://security.debian.org/debian-security/dists/%s/updates" % '@@suite@@' )
3286-
3287- self.logger.info("Added repos for %s" % distro.name)
3288- repos = main_importer.config.repos()
3289- repos.add(repo,save=True)
3290- repos.add(security_repo,save=True)
3291-
3292-# ==========================================================================
3293-
3294-def get_import_manager(config,logger):
3295- return ImportDebianUbuntuManager(config,logger)
3296
3297=== removed file '.pc/42_fix_repomirror_create_sync.patch/cobbler/codes.py'
3298--- .pc/42_fix_repomirror_create_sync.patch/cobbler/codes.py 2011-05-02 18:26:03 +0000
3299+++ .pc/42_fix_repomirror_create_sync.patch/cobbler/codes.py 1970-01-01 00:00:00 +0000
3300@@ -1,98 +0,0 @@
3301-
3302-"""
3303-various codes and constants used by Cobbler
3304-
3305-Copyright 2006-2009, Red Hat, Inc
3306-Michael DeHaan <mdehaan@redhat.com>
3307-
3308-This program is free software; you can redistribute it and/or modify
3309-it under the terms of the GNU General Public License as published by
3310-the Free Software Foundation; either version 2 of the License, or
3311-(at your option) any later version.
3312-
3313-This program is distributed in the hope that it will be useful,
3314-but WITHOUT ANY WARRANTY; without even the implied warranty of
3315-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3316-GNU General Public License for more details.
3317-
3318-You should have received a copy of the GNU General Public License
3319-along with this program; if not, write to the Free Software
3320-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
3321-02110-1301 USA
3322-"""
3323-
3324-import utils
3325-
3326-# OS variants table. This is a variance of the data from
3327-# ls /usr/lib/python2.X/site-packages/virtinst/FullVirtGuest.py
3328-# but replicated here as we can't assume cobbler is installed on a system with libvirt.
3329-# in many cases it will not be (i.e. old EL4 server, etc) and we need this info to
3330-# know how to validate --os-variant and --os-version.
3331-#
3332-# The keys of this hash correspond with the --breed flag in Cobbler.
3333-# --breed has physical provisioning semantics as well as virt semantics.
3334-#
3335-# presense of something in this table does /not/ mean it's supported.
3336-# for instance, currently, "redhat", "debian", and "suse" do something interesting.
3337-# the rest are undefined (for now), this will evolve.
3338-
3339-VALID_OS_BREEDS = [
3340- "redhat", "debian", "ubuntu", "suse", "generic", "windows", "unix", "vmware", "other"
3341-]
3342-
3343-VALID_OS_VERSIONS = {
3344- "redhat" : [ "rhel2.1", "rhel3", "rhel4", "rhel5", "rhel6", "fedora5", "fedora6", "fedora7", "fedora8", "fedora9", "fedora10", "fedora11", "fedora12", "fedora13", "fedora14", "generic24", "generic26", "virtio26", "other" ],
3345- "suse" : [ "sles10", "generic24", "generic26", "virtio26", "other" ],
3346- "debian" : [ "etch", "lenny", "squeeze", "sid", "stable", "testing", "unstable", "generic24", "generic26", "other" ],
3347- "ubuntu" : [ "dapper", "hardy", "intrepid", "jaunty", "karmic", "lucid", "maverick", "natty" ],
3348- "generic" : [ "generic24", "generic26", "other" ],
3349- "windows" : [ "winxp", "win2k", "win2k3", "vista", "other" ],
3350- "unix" : [ "solaris9", "solaris10", "freebsd6", "openbsd4", "other" ],
3351- "vmware" : [ "esx4", "esxi4" ],
3352- "other" : [ "msdos", "netware4", "netware5", "netware6", "generic", "other" ]
3353-}
3354-
3355-VALID_REPO_BREEDS = [
3356-# "rsync", "rhn", "yum", "apt"
3357- "rsync", "rhn", "yum"
3358-]
3359-
3360-def uniquify(seq, idfun=None):
3361-
3362- # this is odd (older mod_python scoping bug?) but we can't use
3363- # utils.uniquify here because on older distros (RHEL4/5)
3364- # mod_python gets another utils. As a result,
3365- # it is duplicated here for now. Bad, but ... now you know.
3366- #
3367- # credit: http://www.peterbe.com/plog/uniqifiers-benchmark
3368- # FIXME: if this is actually slower than some other way, overhaul it
3369-
3370- if idfun is None:
3371- def idfun(x):
3372- return x
3373- seen = {}
3374- result = []
3375- for item in seq:
3376- marker = idfun(item)
3377- if marker in seen:
3378- continue
3379- seen[marker] = 1
3380- result.append(item)
3381- return result
3382-
3383-
3384-def get_all_os_versions():
3385- """
3386- Collapse the above list of OS versions for usage/display by the CLI/webapp.
3387- """
3388- results = ['']
3389- for x in VALID_OS_VERSIONS.keys():
3390- for y in VALID_OS_VERSIONS[x]:
3391- results.append(y)
3392-
3393- results = uniquify(results)
3394-
3395- results.sort()
3396- return results
3397-
3398-
3399
3400=== removed directory '.pc/42_fix_repomirror_create_sync.patch/cobbler/modules'
3401=== removed file '.pc/42_fix_repomirror_create_sync.patch/cobbler/modules/manage_import_debian_ubuntu.py'
3402--- .pc/42_fix_repomirror_create_sync.patch/cobbler/modules/manage_import_debian_ubuntu.py 2011-05-02 18:26:03 +0000
3403+++ .pc/42_fix_repomirror_create_sync.patch/cobbler/modules/manage_import_debian_ubuntu.py 1970-01-01 00:00:00 +0000
3404@@ -1,779 +0,0 @@
3405-"""
3406-This is some of the code behind 'cobbler sync'.
3407-
3408-Copyright 2006-2009, Red Hat, Inc
3409-Michael DeHaan <mdehaan@redhat.com>
3410-John Eckersberg <jeckersb@redhat.com>
3411-
3412-This program is free software; you can redistribute it and/or modify
3413-it under the terms of the GNU General Public License as published by
3414-the Free Software Foundation; either version 2 of the License, or
3415-(at your option) any later version.
3416-
3417-This program is distributed in the hope that it will be useful,
3418-but WITHOUT ANY WARRANTY; without even the implied warranty of
3419-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3420-GNU General Public License for more details.
3421-
3422-You should have received a copy of the GNU General Public License
3423-along with this program; if not, write to the Free Software
3424-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
3425-02110-1301 USA
3426-"""
3427-
3428-import os
3429-import os.path
3430-import shutil
3431-import time
3432-import sys
3433-import glob
3434-import traceback
3435-import errno
3436-import re
3437-from utils import popen2
3438-from shlex import shlex
3439-
3440-
3441-import utils
3442-from cexceptions import *
3443-import templar
3444-
3445-import item_distro
3446-import item_profile
3447-import item_repo
3448-import item_system
3449-
3450-from utils import _
3451-
3452-def register():
3453- """
3454- The mandatory cobbler module registration hook.
3455- """
3456- return "manage/import"
3457-
3458-
3459-class ImportDebianUbuntuManager:
3460-
3461- def __init__(self,config,logger):
3462- """
3463- Constructor
3464- """
3465- self.logger = logger
3466- self.config = config
3467- self.api = config.api
3468- self.distros = config.distros()
3469- self.profiles = config.profiles()
3470- self.systems = config.systems()
3471- self.settings = config.settings()
3472- self.repos = config.repos()
3473- self.templar = templar.Templar(config)
3474-
3475- # required function for import modules
3476- def what(self):
3477- return "import/debian_ubuntu"
3478-
3479- # required function for import modules
3480- def check_for_signature(self,path,cli_breed):
3481- signatures = [
3482- 'pool',
3483- ]
3484-
3485- #self.logger.info("scanning %s for a debian/ubuntu distro signature" % path)
3486- for signature in signatures:
3487- d = os.path.join(path,signature)
3488- if os.path.exists(d):
3489- self.logger.info("Found a debian/ubuntu compatible signature: %s" % signature)
3490- return (True,signature)
3491-
3492- if cli_breed and cli_breed in self.get_valid_breeds():
3493- self.logger.info("Warning: No distro signature for kernel at %s, using value from command line" % path)
3494- return (True,None)
3495-
3496- return (False,None)
3497-
3498- # required function for import modules
3499- def run(self,pkgdir,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None,breed=None,os_version=None):
3500- self.pkgdir = pkgdir
3501- self.mirror = mirror
3502- self.mirror_name = mirror_name
3503- self.network_root = network_root
3504- self.kickstart_file = kickstart_file
3505- self.rsync_flags = rsync_flags
3506- self.arch = arch
3507- self.breed = breed
3508- self.os_version = os_version
3509-
3510- # some fixups for the XMLRPC interface, which does not use "None"
3511- if self.arch == "": self.arch = None
3512- if self.mirror == "": self.mirror = None
3513- if self.mirror_name == "": self.mirror_name = None
3514- if self.kickstart_file == "": self.kickstart_file = None
3515- if self.os_version == "": self.os_version = None
3516- if self.rsync_flags == "": self.rsync_flags = None
3517- if self.network_root == "": self.network_root = None
3518-
3519- # If no breed was specified on the command line, figure it out
3520- if self.breed == None:
3521- self.breed = self.get_breed_from_directory()
3522- if not self.breed:
3523- utils.die(self.logger,"import failed - could not determine breed of debian-based distro")
3524-
3525- # debug log stuff for testing
3526- #self.logger.info("DEBUG: self.pkgdir = %s" % str(self.pkgdir))
3527- #self.logger.info("DEBUG: self.mirror = %s" % str(self.mirror))
3528- #self.logger.info("DEBUG: self.mirror_name = %s" % str(self.mirror_name))
3529- #self.logger.info("DEBUG: self.network_root = %s" % str(self.network_root))
3530- #self.logger.info("DEBUG: self.kickstart_file = %s" % str(self.kickstart_file))
3531- #self.logger.info("DEBUG: self.rsync_flags = %s" % str(self.rsync_flags))
3532- #self.logger.info("DEBUG: self.arch = %s" % str(self.arch))
3533- #self.logger.info("DEBUG: self.breed = %s" % str(self.breed))
3534- #self.logger.info("DEBUG: self.os_version = %s" % str(self.os_version))
3535-
3536- # both --import and --name are required arguments
3537-
3538- if self.mirror is None:
3539- utils.die(self.logger,"import failed. no --path specified")
3540- if self.mirror_name is None:
3541- utils.die(self.logger,"import failed. no --name specified")
3542-
3543- # if --arch is supplied, validate it to ensure it's valid
3544-
3545- if self.arch is not None and self.arch != "":
3546- self.arch = self.arch.lower()
3547- if self.arch == "x86":
3548- # be consistent
3549- self.arch = "i386"
3550- if self.arch not in self.get_valid_arches():
3551- utils.die(self.logger,"arch must be one of: %s" % string.join(self.get_valid_arches(),", "))
3552-
3553- # if we're going to do any copying, set where to put things
3554- # and then make sure nothing is already there.
3555-
3556- self.path = os.path.normpath( "%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name) )
3557- if os.path.exists(self.path) and self.arch is None:
3558- # FIXME : Raise exception even when network_root is given ?
3559- utils.die(self.logger,"Something already exists at this import location (%s). You must specify --arch to avoid potentially overwriting existing files." % self.path)
3560-
3561- # import takes a --kickstart for forcing selection that can't be used in all circumstances
3562-
3563- if self.kickstart_file and not self.breed:
3564- utils.die(self.logger,"Kickstart file can only be specified when a specific breed is selected")
3565-
3566- if self.os_version and not self.breed:
3567- utils.die(self.logger,"OS version can only be specified when a specific breed is selected")
3568-
3569- if self.breed and self.breed.lower() not in self.get_valid_breeds():
3570- utils.die(self.logger,"Supplied import breed is not supported by this module")
3571-
3572- # if --arch is supplied, make sure the user is not importing a path with a different
3573- # arch, which would just be silly.
3574-
3575- if self.arch:
3576- # append the arch path to the name if the arch is not already
3577- # found in the name.
3578- for x in self.get_valid_arches():
3579- if self.path.lower().find(x) != -1:
3580- if self.arch != x :
3581- utils.die(self.logger,"Architecture found on pathname (%s) does not fit the one given in command line (%s)"%(x,self.arch))
3582- break
3583- else:
3584- # FIXME : This is very likely removed later at get_proposed_name, and the guessed arch appended again
3585- self.path += ("-%s" % self.arch)
3586- # If arch is specified we also need to update the mirror name.
3587- self.mirror_name = self.mirror_name + "-" + self.arch
3588-
3589- # make the output path and mirror content but only if not specifying that a network
3590- # accessible support location already exists (this is --available-as on the command line)
3591-
3592- if self.network_root is None:
3593- # we need to mirror (copy) the files
3594-
3595- utils.mkdir(self.path)
3596-
3597- if self.mirror.startswith("http://") or self.mirror.startswith("ftp://") or self.mirror.startswith("nfs://"):
3598-
3599- # http mirrors are kind of primative. rsync is better.
3600- # that's why this isn't documented in the manpage and we don't support them.
3601- # TODO: how about adding recursive FTP as an option?
3602-
3603- utils.die(self.logger,"unsupported protocol")
3604-
3605- else:
3606-
3607- # good, we're going to use rsync..
3608- # we don't use SSH for public mirrors and local files.
3609- # presence of user@host syntax means use SSH
3610-
3611- # kick off the rsync now
3612-
3613- if not utils.rsync_files(self.mirror, self.path, self.rsync_flags, self.logger):
3614- utils.die(self.logger, "failed to rsync the files")
3615-
3616- else:
3617-
3618- # rather than mirroring, we're going to assume the path is available
3619- # over http, ftp, and nfs, perhaps on an external filer. scanning still requires
3620- # --mirror is a filesystem path, but --available-as marks the network path
3621-
3622- if not os.path.exists(self.mirror):
3623- utils.die(self.logger, "path does not exist: %s" % self.mirror)
3624-
3625- # find the filesystem part of the path, after the server bits, as each distro
3626- # URL needs to be calculated relative to this.
3627-
3628- if not self.network_root.endswith("/"):
3629- self.network_root = self.network_root + "/"
3630- self.path = os.path.normpath( self.mirror )
3631- valid_roots = [ "nfs://", "ftp://", "http://" ]
3632- for valid_root in valid_roots:
3633- if self.network_root.startswith(valid_root):
3634- break
3635- else:
3636- utils.die(self.logger, "Network root given to --available-as must be nfs://, ftp://, or http://")
3637- if self.network_root.startswith("nfs://"):
3638- try:
3639- (a,b,rest) = self.network_root.split(":",3)
3640- except:
3641- utils.die(self.logger, "Network root given to --available-as is missing a colon, please see the manpage example.")
3642-
3643- # now walk the filesystem looking for distributions that match certain patterns
3644-
3645- self.logger.info("adding distros")
3646- distros_added = []
3647- # FIXME : search below self.path for isolinux configurations or known directories from TRY_LIST
3648- os.path.walk(self.path, self.distro_adder, distros_added)
3649-
3650- # find out if we can auto-create any repository records from the install tree
3651-
3652- if self.network_root is None:
3653- self.logger.info("associating repos")
3654- # FIXME: this automagic is not possible (yet) without mirroring
3655- self.repo_finder(distros_added)
3656-
3657- # find the most appropriate answer files for each profile object
3658-
3659- self.logger.info("associating kickstarts")
3660- self.kickstart_finder(distros_added)
3661-
3662- # ensure bootloaders are present
3663- self.api.pxegen.copy_bootloaders()
3664-
3665- return True
3666-
3667- # required function for import modules
3668- def get_valid_arches(self):
3669- return ["i386", "ppc", "x86_64", "x86",]
3670-
3671- # required function for import modules
3672- def get_valid_breeds(self):
3673- return ["debian","ubuntu"]
3674-
3675- # required function for import modules
3676- def get_valid_os_versions(self):
3677- if self.breed == "debian":
3678- return ["etch", "lenny", "squeeze", "sid", "stable", "testing", "unstable", "experimental",]
3679- elif self.breed == "ubuntu":
3680- return ["dapper", "hardy", "karmic", "lucid", "maverick", "natty",]
3681- else:
3682- return []
3683-
3684- def get_valid_repo_breeds(self):
3685- return ["apt",]
3686-
3687- def get_release_files(self):
3688- """
3689- Find distro release packages.
3690- """
3691- return glob.glob(os.path.join(self.get_rootdir(), "dists/*"))
3692-
3693- def get_breed_from_directory(self):
3694- for breed in self.get_valid_breeds():
3695- # NOTE : Although we break the loop after the first match,
3696- # multiple debian derived distros can actually live at the same pool -- JP
3697- d = os.path.join(self.mirror, breed)
3698- if (os.path.islink(d) and os.path.isdir(d) and os.path.realpath(d) == os.path.realpath(self.mirror)) or os.path.basename(self.mirror) == breed:
3699- return breed
3700- else:
3701- return None
3702-
3703- def get_tree_location(self, distro):
3704- """
3705- Once a distribution is identified, find the part of the distribution
3706- that has the URL in it that we want to use for kickstarting the
3707- distribution, and create a ksmeta variable $tree that contains this.
3708- """
3709-
3710- base = self.get_rootdir()
3711-
3712- if self.network_root is None:
3713- dists_path = os.path.join(self.path, "dists")
3714- if os.path.isdir(dists_path):
3715- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
3716- else:
3717- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
3718- self.set_install_tree(distro, tree)
3719- else:
3720- # where we assign the kickstart source is relative to our current directory
3721- # and the input start directory in the crawl. We find the path segments
3722- # between and tack them on the network source path to find the explicit
3723- # network path to the distro that Anaconda can digest.
3724- tail = self.path_tail(self.path, base)
3725- tree = self.network_root[:-1] + tail
3726- self.set_install_tree(distro, tree)
3727-
3728- return
3729-
3730- def repo_finder(self, distros_added):
3731- for distro in distros_added:
3732- self.logger.info("traversing distro %s" % distro.name)
3733- # FIXME : Shouldn't decide this the value of self.network_root ?
3734- if distro.kernel.find("ks_mirror") != -1:
3735- basepath = os.path.dirname(distro.kernel)
3736- top = self.get_rootdir()
3737- self.logger.info("descent into %s" % top)
3738- dists_path = os.path.join(self.path, "dists")
3739- if not os.path.isdir(dists_path):
3740- self.process_repos()
3741- else:
3742- self.logger.info("this distro isn't mirrored")
3743-
3744- def process_repos(self):
3745- pass
3746-
3747- def distro_adder(self,distros_added,dirname,fnames):
3748- """
3749- This is an os.path.walk routine that finds distributions in the directory
3750- to be scanned and then creates them.
3751- """
3752-
3753- # FIXME: If there are more than one kernel or initrd image on the same directory,
3754- # results are unpredictable
3755-
3756- initrd = None
3757- kernel = None
3758-
3759- for x in fnames:
3760- adtls = []
3761-
3762- fullname = os.path.join(dirname,x)
3763- if os.path.islink(fullname) and os.path.isdir(fullname):
3764- if fullname.startswith(self.path):
3765- self.logger.warning("avoiding symlink loop")
3766- continue
3767- self.logger.info("following symlink: %s" % fullname)
3768- os.path.walk(fullname, self.distro_adder, distros_added)
3769-
3770- if ( x.startswith("initrd.gz") ) and x != "initrd.size":
3771- initrd = os.path.join(dirname,x)
3772- if ( x.startswith("linux") ) and x.find("initrd") == -1:
3773- kernel = os.path.join(dirname,x)
3774-
3775- # if we've collected a matching kernel and initrd pair, turn the in and add them to the list
3776- if initrd is not None and kernel is not None:
3777- adtls.append(self.add_entry(dirname,kernel,initrd))
3778- kernel = None
3779- initrd = None
3780-
3781- for adtl in adtls:
3782- distros_added.extend(adtl)
3783-
3784- def add_entry(self,dirname,kernel,initrd):
3785- """
3786- When we find a directory with a valid kernel/initrd in it, create the distribution objects
3787- as appropriate and save them. This includes creating xen and rescue distros/profiles
3788- if possible.
3789- """
3790-
3791- proposed_name = self.get_proposed_name(dirname,kernel)
3792- proposed_arch = self.get_proposed_arch(dirname)
3793-
3794- if self.arch and proposed_arch and self.arch != proposed_arch:
3795- utils.die(self.logger,"Arch from pathname (%s) does not match with supplied one %s"%(proposed_arch,self.arch))
3796-
3797- archs = self.learn_arch_from_tree()
3798- if not archs:
3799- if self.arch:
3800- archs.append( self.arch )
3801- else:
3802- if self.arch and self.arch not in archs:
3803- utils.die(self.logger, "Given arch (%s) not found on imported tree %s"%(self.arch,self.get_pkgdir()))
3804- if proposed_arch:
3805- if archs and proposed_arch not in archs:
3806- self.logger.warning("arch from pathname (%s) not found on imported tree %s" % (proposed_arch,self.get_pkgdir()))
3807- return
3808-
3809- archs = [ proposed_arch ]
3810-
3811- if len(archs)>1:
3812- self.logger.warning("- Warning : Multiple archs found : %s" % (archs))
3813-
3814- distros_added = []
3815-
3816- for pxe_arch in archs:
3817- name = proposed_name + "-" + pxe_arch
3818- existing_distro = self.distros.find(name=name)
3819-
3820- if existing_distro is not None:
3821- self.logger.warning("skipping import, as distro name already exists: %s" % name)
3822- continue
3823-
3824- else:
3825- self.logger.info("creating new distro: %s" % name)
3826- distro = self.config.new_distro()
3827-
3828- if name.find("-autoboot") != -1:
3829- # this is an artifact of some EL-3 imports
3830- continue
3831-
3832- distro.set_name(name)
3833- distro.set_kernel(kernel)
3834- distro.set_initrd(initrd)
3835- distro.set_arch(pxe_arch)
3836- distro.set_breed(self.breed)
3837- # If a version was supplied on command line, we set it now
3838- if self.os_version:
3839- distro.set_os_version(self.os_version)
3840-
3841- self.distros.add(distro,save=True)
3842- distros_added.append(distro)
3843-
3844- existing_profile = self.profiles.find(name=name)
3845-
3846- # see if the profile name is already used, if so, skip it and
3847- # do not modify the existing profile
3848-
3849- if existing_profile is None:
3850- self.logger.info("creating new profile: %s" % name)
3851- #FIXME: The created profile holds a default kickstart, and should be breed specific
3852- profile = self.config.new_profile()
3853- else:
3854- self.logger.info("skipping existing profile, name already exists: %s" % name)
3855- continue
3856-
3857- # save our minimal profile which just points to the distribution and a good
3858- # default answer file
3859-
3860- profile.set_name(name)
3861- profile.set_distro(name)
3862- profile.set_kickstart(self.kickstart_file)
3863-
3864- # depending on the name of the profile we can define a good virt-type
3865- # for usage with koan
3866-
3867- if name.find("-xen") != -1:
3868- profile.set_virt_type("xenpv")
3869- elif name.find("vmware") != -1:
3870- profile.set_virt_type("vmware")
3871- else:
3872- profile.set_virt_type("qemu")
3873-
3874- # save our new profile to the collection
3875-
3876- self.profiles.add(profile,save=True)
3877-
3878- return distros_added
3879-
3880- def get_proposed_name(self,dirname,kernel=None):
3881- """
3882- Given a directory name where we have a kernel/initrd pair, try to autoname
3883- the distribution (and profile) object based on the contents of that path
3884- """
3885-
3886- if self.network_root is not None:
3887- name = self.mirror_name + "-".join(self.path_tail(os.path.dirname(self.path),dirname).split("/"))
3888- else:
3889- # remove the part that says /var/www/cobbler/ks_mirror/name
3890- name = "-".join(dirname.split("/")[5:])
3891-
3892- if kernel is not None and kernel.find("PAE") != -1:
3893- name = name + "-PAE"
3894-
3895- # These are all Ubuntu's doing, the netboot images are buried pretty
3896- # deep. ;-) -JC
3897- name = name.replace("-netboot","")
3898- name = name.replace("-ubuntu-installer","")
3899- name = name.replace("-amd64","")
3900- name = name.replace("-i386","")
3901-
3902- # we know that some kernel paths should not be in the name
3903-
3904- name = name.replace("-images","")
3905- name = name.replace("-pxeboot","")
3906- name = name.replace("-install","")
3907- name = name.replace("-isolinux","")
3908-
3909- # some paths above the media root may have extra path segments we want
3910- # to clean up
3911-
3912- name = name.replace("-os","")
3913- name = name.replace("-tree","")
3914- name = name.replace("var-www-cobbler-", "")
3915- name = name.replace("ks_mirror-","")
3916- name = name.replace("--","-")
3917-
3918- # remove any architecture name related string, as real arch will be appended later
3919-
3920- name = name.replace("chrp","ppc64")
3921-
3922- for separator in [ '-' , '_' , '.' ] :
3923- for arch in [ "i386" , "x86_64" , "ia64" , "ppc64", "ppc32", "ppc", "x86" , "s390x", "s390" , "386" , "amd" ]:
3924- name = name.replace("%s%s" % ( separator , arch ),"")
3925-
3926- return name
3927-
3928- def get_proposed_arch(self,dirname):
3929- """
3930- Given an directory name, can we infer an architecture from a path segment?
3931- """
3932- if dirname.find("x86_64") != -1 or dirname.find("amd") != -1:
3933- return "x86_64"
3934- if dirname.find("ia64") != -1:
3935- return "ia64"
3936- if dirname.find("i386") != -1 or dirname.find("386") != -1 or dirname.find("x86") != -1:
3937- return "i386"
3938- if dirname.find("s390x") != -1:
3939- return "s390x"
3940- if dirname.find("s390") != -1:
3941- return "s390"
3942- if dirname.find("ppc64") != -1 or dirname.find("chrp") != -1:
3943- return "ppc64"
3944- if dirname.find("ppc32") != -1:
3945- return "ppc"
3946- if dirname.find("ppc") != -1:
3947- return "ppc"
3948- return None
3949-
3950- def arch_walker(self,foo,dirname,fnames):
3951- """
3952- See docs on learn_arch_from_tree.
3953-
3954- The TRY_LIST is used to speed up search, and should be dropped for default importer
3955- Searched kernel names are kernel-header, linux-headers-, kernel-largesmp, kernel-hugemem
3956-
3957- This method is useful to get the archs, but also to package type and a raw guess of the breed
3958- """
3959-
3960- # try to find a kernel header RPM and then look at it's arch.
3961- for x in fnames:
3962- if self.match_kernelarch_file(x):
3963- for arch in self.get_valid_arches():
3964- if x.find(arch) != -1:
3965- foo[arch] = 1
3966- for arch in [ "i686" , "amd64" ]:
3967- if x.find(arch) != -1:
3968- foo[arch] = 1
3969-
3970- def kickstart_finder(self,distros_added):
3971- """
3972- For all of the profiles in the config w/o a kickstart, use the
3973- given kickstart file, or look at the kernel path, from that,
3974- see if we can guess the distro, and if we can, assign a kickstart
3975- if one is available for it.
3976- """
3977- for profile in self.profiles:
3978- distro = self.distros.find(name=profile.get_conceptual_parent().name)
3979- if distro is None or not (distro in distros_added):
3980- continue
3981-
3982- kdir = os.path.dirname(distro.kernel)
3983- if self.kickstart_file == None:
3984- for file in self.get_release_files():
3985- results = self.scan_pkg_filename(file)
3986- # FIXME : If os is not found on tree but set with CLI, no kickstart is searched
3987- if results is None:
3988- self.logger.warning("skipping %s" % file)
3989- continue
3990- (flavor, major, minor, release) = results
3991- # Why use set_variance()? scan_pkg_filename() does everything we need now - jcammarata
3992- #version , ks = self.set_variance(flavor, major, minor, distro.arch)
3993- if self.os_version:
3994- if self.os_version != flavor:
3995- utils.die(self.logger,"CLI version differs from tree : %s vs. %s" % (self.os_version,flavor))
3996- distro.set_comment("%s %s (%s.%s.%s) %s" % (self.breed,flavor,major,minor,release,self.arch))
3997- distro.set_os_version(flavor)
3998- # is this even valid for debian/ubuntu? - jcammarata
3999- #ds = self.get_datestamp()
4000- #if ds is not None:
4001- # distro.set_tree_build_time(ds)
4002- profile.set_kickstart("/var/lib/cobbler/kickstarts/sample.seed")
4003- self.profiles.add(profile,save=True)
4004-
4005- self.configure_tree_location(distro)
4006- self.distros.add(distro,save=True) # re-save
4007- self.api.serialize()
4008-
4009- def configure_tree_location(self, distro):
4010- """
4011- Once a distribution is identified, find the part of the distribution
4012- that has the URL in it that we want to use for kickstarting the
4013- distribution, and create a ksmeta variable $tree that contains this.
4014- """
4015-
4016- base = self.get_rootdir()
4017-
4018- if self.network_root is None:
4019- dists_path = os.path.join( self.path , "dists" )
4020- if os.path.isdir( dists_path ):
4021- tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.mirror_name)
4022- else:
4023- tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
4024- self.set_install_tree(distro, tree)
4025- else:
4026- # where we assign the kickstart source is relative to our current directory
4027- # and the input start directory in the crawl. We find the path segments
4028- # between and tack them on the network source path to find the explicit
4029- # network path to the distro that Anaconda can digest.
4030- tail = utils.path_tail(self.path, base)
4031- tree = self.network_root[:-1] + tail
4032- self.set_install_tree(distro, tree)
4033-
4034- def get_rootdir(self):
4035- return self.mirror
4036-
4037- def get_pkgdir(self):
4038- if not self.pkgdir:
4039- return None
4040- return os.path.join(self.get_rootdir(),self.pkgdir)
4041-
4042- def set_install_tree(self, distro, url):
4043- distro.ks_meta["tree"] = url
4044-
4045- def learn_arch_from_tree(self):
4046- """
4047- If a distribution is imported from DVD, there is a good chance the path doesn't
4048- contain the arch and we should add it back in so that it's part of the
4049- meaningful name ... so this code helps figure out the arch name. This is important
4050- for producing predictable distro names (and profile names) from differing import sources
4051- """
4052- result = {}
4053- # FIXME : this is called only once, should not be a walk
4054- if self.get_pkgdir():
4055- os.path.walk(self.get_pkgdir(), self.arch_walker, result)
4056- if result.pop("amd64",False):
4057- result["x86_64"] = 1
4058- if result.pop("i686",False):
4059- result["i386"] = 1
4060- return result.keys()
4061-
4062- def match_kernelarch_file(self, filename):
4063- """
4064- Is the given filename a kernel filename?
4065- """
4066- if not filename.endswith("deb"):
4067- return False
4068- if filename.startswith("linux-headers-"):
4069- return True
4070- return False
4071-
4072- def scan_pkg_filename(self, file):
4073- """
4074- Determine what the distro is based on the release package filename.
4075- """
4076- # FIXME: all of these dist_names should probably be put in a function
4077- # which would be called in place of looking in codes.py. Right now
4078- # you have to update both codes.py and this to add a new release
4079- if self.breed == "debian":
4080- dist_names = ['etch','lenny',]
4081- elif self.breed == "ubuntu":
4082- dist_names = ['dapper','hardy','intrepid','jaunty','karmic','lynx','maverick','natty',]
4083- else:
4084- return None
4085-
4086- if os.path.basename(file) in dist_names:
4087- release_file = os.path.join(file,'Release')
4088- self.logger.info("Found %s release file: %s" % (self.breed,release_file))
4089-
4090- f = open(release_file,'r')
4091- lines = f.readlines()
4092- f.close()
4093-
4094- for line in lines:
4095- if line.lower().startswith('version: '):
4096- version = line.split(':')[1].strip()
4097- values = version.split('.')
4098- if len(values) == 1:
4099- # I don't think you'd ever hit this currently with debian or ubuntu,
4100- # just including it for safety reasons
4101- return (os.path.basename(file), values[0], "0", "0")
4102- elif len(values) == 2:
4103- return (os.path.basename(file), values[0], values[1], "0")
4104- elif len(values) > 2:
4105- return (os.path.basename(file), values[0], values[1], values[2])
4106- return None
4107-
4108- def get_datestamp(self):
4109- """
4110- Not used for debian/ubuntu... should probably be removed? - jcammarata
4111- """
4112- pass
4113-
4114- def set_variance(self, flavor, major, minor, arch):
4115- """
4116- Set distro specific versioning.
4117- """
4118- # I don't think this is required anymore, as the scan_pkg_filename() function
4119- # above does everything we need it to - jcammarata
4120- #
4121- #if self.breed == "debian":
4122- # dist_names = { '4.0' : "etch" , '5.0' : "lenny" }
4123- # dist_vers = "%s.%s" % ( major , minor )
4124- # os_version = dist_names[dist_vers]
4125- #
4126- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
4127- #elif self.breed == "ubuntu":
4128- # # Release names taken from wikipedia
4129- # dist_names = { '6.4' :"dapper",
4130- # '8.4' :"hardy",
4131- # '8.10' :"intrepid",
4132- # '9.4' :"jaunty",
4133- # '9.10' :"karmic",
4134- # '10.4' :"lynx",
4135- # '10.10':"maverick",
4136- # '11.4' :"natty",
4137- # }
4138- # dist_vers = "%s.%s" % ( major , minor )
4139- # if not dist_names.has_key( dist_vers ):
4140- # dist_names['4ubuntu2.0'] = "IntrepidIbex"
4141- # os_version = dist_names[dist_vers]
4142- #
4143- # return os_version , "/var/lib/cobbler/kickstarts/sample.seed"
4144- #else:
4145- # return None
4146- pass
4147-
4148- def process_repos(self, main_importer, distro):
4149- # Create a disabled repository for the new distro, and the security updates
4150- #
4151- # NOTE : We cannot use ks_meta nor os_version because they get fixed at a later stage
4152-
4153- repo = item_repo.Repo(main_importer.config)
4154- repo.set_breed( "apt" )
4155- repo.set_arch( distro.arch )
4156- repo.set_keep_updated( False )
4157- repo.yumopts["--ignore-release-gpg"] = None
4158- repo.yumopts["--verbose"] = None
4159- repo.set_name( distro.name )
4160- repo.set_os_version( distro.os_version )
4161- # NOTE : The location of the mirror should come from timezone
4162- repo.set_mirror( "http://ftp.%s.debian.org/debian/dists/%s" % ( 'us' , '@@suite@@' ) )
4163-
4164- security_repo = item_repo.Repo(main_importer.config)
4165- security_repo.set_breed( "apt" )
4166- security_repo.set_arch( distro.arch )
4167- security_repo.set_keep_updated( False )
4168- security_repo.yumopts["--ignore-release-gpg"] = None
4169- security_repo.yumopts["--verbose"] = None
4170- security_repo.set_name( distro.name + "-security" )
4171- security_repo.set_os_version( distro.os_version )
4172- # There are no official mirrors for security updates
4173- security_repo.set_mirror( "http://security.debian.org/debian-security/dists/%s/updates" % '@@suite@@' )
4174-
4175- self.logger.info("Added repos for %s" % distro.name)
4176- repos = main_importer.config.repos()
4177- repos.add(repo,save=True)
4178- repos.add(security_repo,save=True)
4179-
4180-# ==========================================================================
4181-
4182-def get_import_manager(config,logger):
4183- return ImportDebianUbuntuManager(config,logger)
4184
4185=== renamed file '.pc/43_fix_reposync_env_variable.patch/cobbler/action_reposync.py' => '.pc/43_fix_reposync_env_variable.patch/cobbler/action_reposync.py.THIS'
4186=== removed file '.pc/applied-patches'
4187--- .pc/applied-patches 2011-06-03 09:25:37 +0000
4188+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
4189@@ -1,10 +0,0 @@
4190-21_cobbler_use_netboot.patch
4191-12_fix_dhcp_restart.patch
4192-05_cobbler_fix_reposync_permissions.patch
4193-33_authn_configfile.patch
4194-34_fix_apache_wont_start.patch
4195-39_cw_remove_vhost.patch
4196-40_ubuntu_bind9_management.patch
4197-41_update_tree_path_with_arch.patch
4198-42_fix_repomirror_create_sync.patch
4199-43_fix_reposync_env_variable.patch
4200
4201=== modified file 'cobbler/action_check.py'
4202--- cobbler/action_check.py 2011-04-18 11:15:59 +0000
4203+++ cobbler/action_check.py 2011-06-09 00:11:01 +0000
4204@@ -66,7 +66,7 @@
4205 mode = self.config.api.get_sync().dns.what()
4206 if mode == "bind":
4207 self.check_bind_bin(status)
4208- self.check_service(status,"bind9")
4209+ self.check_service(status,"named")
4210 elif mode == "dnsmasq" and not self.settings.manage_dhcp:
4211 self.check_dnsmasq_bin(status)
4212 self.check_service(status,"dnsmasq")
4213
4214=== modified file 'cobbler/action_reposync.py'
4215--- cobbler/action_reposync.py 2011-06-08 17:21:45 +0000
4216+++ cobbler/action_reposync.py 2011-06-09 00:11:01 +0000
4217@@ -485,11 +485,6 @@
4218 arch = "amd64" # FIX potential arch errors
4219 cmd = "%s --nosource -a %s" % (cmd, arch)
4220
4221- # Set's an environment variable for subprocess, otherwise debmirror will fail
4222- # as it needs this variable to exist.
4223- # FIXME: might this break anything? So far it doesn't
4224- os.putenv("HOME", "/var/lib/cobbler")
4225-
4226 rc = utils.subprocess_call(self.logger, cmd)
4227 if rc !=0:
4228 utils.die(self.logger,"cobbler reposync failed")
4229@@ -569,7 +564,7 @@
4230 a safeguard.
4231 """
4232 # all_path = os.path.join(repo_path, "*")
4233- cmd1 = "chown -R root:www-data %s" % repo_path
4234+ cmd1 = "chown -R root:apache %s" % repo_path
4235 utils.subprocess_call(self.logger, cmd1)
4236
4237 cmd2 = "chmod -R 755 %s" % repo_path
4238
4239=== modified file 'cobbler/codes.py'
4240--- cobbler/codes.py 2011-05-02 18:26:03 +0000
4241+++ cobbler/codes.py 2011-06-09 00:11:01 +0000
4242@@ -53,8 +53,8 @@
4243 }
4244
4245 VALID_REPO_BREEDS = [
4246- "rsync", "rhn", "yum", "apt"
4247-# "rsync", "rhn", "yum"
4248+# "rsync", "rhn", "yum", "apt"
4249+ "rsync", "rhn", "yum"
4250 ]
4251
4252 def uniquify(seq, idfun=None):
4253
4254=== modified file 'cobbler/modules/manage_bind.py'
4255--- cobbler/modules/manage_bind.py 2011-04-18 11:15:59 +0000
4256+++ cobbler/modules/manage_bind.py 2011-06-09 00:11:01 +0000
4257@@ -180,7 +180,7 @@
4258 """
4259 Write out the named.conf main config file from the template.
4260 """
4261- settings_file = "/etc/bind/named.conf.local"
4262+ settings_file = "/etc/named.conf"
4263 template_file = "/etc/cobbler/named.template"
4264 forward_zones = self.settings.manage_forward_zones
4265 reverse_zones = self.settings.manage_reverse_zones
4266@@ -291,7 +291,7 @@
4267
4268 metadata['host_record'] = self.__pretty_print_host_records(hosts)
4269
4270- zonefilename='/etc/bind/db.' + zone
4271+ zonefilename='/var/named/' + zone
4272 if self.logger is not None:
4273 self.logger.info("generating (forward) %s" % zonefilename)
4274 self.templar.render(template_data, metadata, zonefilename, None)
4275@@ -313,7 +313,7 @@
4276
4277 metadata['host_record'] = self.__pretty_print_host_records(hosts, rectype='PTR')
4278
4279- zonefilename='/etc/bind/db.' + zone
4280+ zonefilename='/var/named/' + zone
4281 if self.logger is not None:
4282 self.logger.info("generating (reverse) %s" % zonefilename)
4283 self.templar.render(template_data, metadata, zonefilename, None)
4284
4285=== modified file 'cobbler/modules/manage_import_debian_ubuntu.py'
4286--- cobbler/modules/manage_import_debian_ubuntu.py 2011-06-08 17:21:45 +0000
4287+++ cobbler/modules/manage_import_debian_ubuntu.py 2011-06-09 00:11:01 +0000
4288@@ -187,8 +187,6 @@
4289 else:
4290 # FIXME : This is very likely removed later at get_proposed_name, and the guessed arch appended again
4291 self.path += ("-%s" % self.arch)
4292- # If arch is specified we also need to update the mirror name.
4293- self.mirror_name = self.mirror_name + "-" + self.arch
4294
4295 # make the output path and mirror content but only if not specifying that a network
4296 # accessible support location already exists (this is --available-as on the command line)
4297@@ -341,10 +339,11 @@
4298 self.logger.info("descent into %s" % top)
4299 dists_path = os.path.join(self.path, "dists")
4300 if not os.path.isdir(dists_path):
4301- self.process_repos(self, distro)
4302+ self.process_repos()
4303 else:
4304 self.logger.info("this distro isn't mirrored")
4305
4306+<<<<<<< TREE
4307 def get_repo_mirror_from_apt(self):
4308 """
4309 This tries to determine the apt mirror/archive to use (when processing repos)
4310@@ -364,6 +363,11 @@
4311
4312 return mirror
4313
4314+=======
4315+ def process_repos(self):
4316+ pass
4317+
4318+>>>>>>> MERGE-SOURCE
4319 def distro_adder(self,distros_added,dirname,fnames):
4320 """
4321 This is an os.path.walk routine that finds distributions in the directory
4322@@ -387,9 +391,9 @@
4323 self.logger.info("following symlink: %s" % fullname)
4324 os.path.walk(fullname, self.distro_adder, distros_added)
4325
4326- if ( x.startswith("initrd.gz") ) and x != "initrd.size":
4327+ if ( x.startswith("initrd") or x.startswith("ramdisk.image.gz") or x.startswith("vmkboot.gz") ) and x != "initrd.size":
4328 initrd = os.path.join(dirname,x)
4329- if ( x.startswith("linux") ) and x.find("initrd") == -1:
4330+ if ( x.startswith("vmlinu") or x.startswith("kernel.img") or x.startswith("linux") or x.startswith("mboot.c32") ) and x.find("initrd") == -1:
4331 kernel = os.path.join(dirname,x)
4332
4333 # if we've collected a matching kernel and initrd pair, turn the in and add them to the list
4334@@ -788,12 +792,17 @@
4335 repo.yumopts["--verbose"] = None
4336 repo.set_name( distro.name )
4337 repo.set_os_version( distro.os_version )
4338+<<<<<<< TREE
4339
4340 if distro.breed == "ubuntu":
4341 repo.set_mirror( "%s/%s" % (mirror, distro.os_version) )
4342 else:
4343 # NOTE : The location of the mirror should come from timezone
4344 repo.set_mirror( "http://ftp.%s.debian.org/debian/dists/%s" % ( 'us' , distro.os_version ) )
4345+=======
4346+ # NOTE : The location of the mirror should come from timezone
4347+ repo.set_mirror( "http://ftp.%s.debian.org/debian/dists/%s" % ( 'us' , '@@suite@@' ) )
4348+>>>>>>> MERGE-SOURCE
4349
4350 security_repo = item_repo.Repo(main_importer.config)
4351 security_repo.set_breed( "apt" )
4352@@ -804,10 +813,14 @@
4353 security_repo.set_name( distro.name + "-security" )
4354 security_repo.set_os_version( distro.os_version )
4355 # There are no official mirrors for security updates
4356+<<<<<<< TREE
4357 if distro.breed == "ubuntu":
4358 security_repo.set_mirror( "%s/%s-security" % (mirror, distro.os_version) )
4359 else:
4360 security_repo.set_mirror( "http://security.debian.org/debian-security/dists/%s/updates" % distro.os_version )
4361+=======
4362+ security_repo.set_mirror( "http://security.debian.org/debian-security/dists/%s/updates" % '@@suite@@' )
4363+>>>>>>> MERGE-SOURCE
4364
4365 self.logger.info("Added repos for %s" % distro.name)
4366 repos = main_importer.config.repos()
4367
4368=== modified file 'cobbler/modules/sync_post_restart_services.py'
4369--- cobbler/modules/sync_post_restart_services.py 2011-04-18 11:15:59 +0000
4370+++ cobbler/modules/sync_post_restart_services.py 2011-06-09 00:11:01 +0000
4371@@ -42,7 +42,7 @@
4372 if rc != 0:
4373 logger.error("dhcpd -t failed")
4374 return 1
4375- rc = utils.subprocess_call(logger,"service isc-dhcp-server restart", shell=True)
4376+ rc = utils.subprocess_call(logger,"service dhcpd restart", shell=True)
4377 elif which_dhcp_module == "manage_dnsmasq":
4378 if restart_dhcp != "0":
4379 rc = utils.subprocess_call(logger, "service dnsmasq restart")
4380@@ -53,7 +53,7 @@
4381
4382 if manage_dns != "0" and restart_dns != "0":
4383 if which_dns_module == "manage_bind":
4384- rc = utils.subprocess_call(logger, "service bind9 restart", shell=True)
4385+ rc = utils.subprocess_call(logger, "service named restart", shell=True)
4386 elif which_dns_module == "manage_dnsmasq" and not has_restarted_dnsmasq:
4387 rc = utils.subprocess_call(logger, "service dnsmasq restart", shell=True)
4388 elif which_dns_module == "manage_dnsmasq" and has_restarted_dnsmasq:
4389
4390=== modified file 'config/cobbler_web.conf'
4391--- config/cobbler_web.conf 2011-04-15 12:47:39 +0000
4392+++ config/cobbler_web.conf 2011-06-09 00:11:01 +0000
4393@@ -1,10 +1,14 @@
4394 # This configuration file enables the cobbler web
4395 # interface (django version)
4396
4397+<VirtualHost *:80>
4398+
4399 # Do not log the requests generated from the event notification system
4400 SetEnvIf Request_URI ".*/op/events/user/.*" dontlog
4401 # Log only what remains
4402-#CustomLog logs/access_log combined env=!dontlog
4403+CustomLog logs/access_log combined env=!dontlog
4404
4405 WSGIScriptAlias /cobbler_web /usr/share/cobbler/web/cobbler.wsgi
4406
4407+</VirtualHost>
4408+
4409
4410=== modified file 'config/modules.conf'
4411--- config/modules.conf 2011-04-04 12:55:44 +0000
4412+++ config/modules.conf 2011-06-09 00:11:01 +0000
4413@@ -19,7 +19,7 @@
4414 # https://fedorahosted.org/cobbler/wiki/CobblerWithLdap
4415
4416 [authentication]
4417-module = authn_configfile
4418+module = authn_denyall
4419
4420 # authorization:
4421 # once a user has been cleared by the WebUI/XMLRPC, what can they do?
4422
4423=== modified file 'templates/etc/named.template'
4424--- templates/etc/named.template 2011-04-18 11:15:59 +0000
4425+++ templates/etc/named.template 2011-06-09 00:11:01 +0000
4426@@ -1,14 +1,31 @@
4427+options {
4428+ listen-on port 53 { 127.0.0.1; };
4429+ directory "/var/named";
4430+ dump-file "/var/named/data/cache_dump.db";
4431+ statistics-file "/var/named/data/named_stats.txt";
4432+ memstatistics-file "/var/named/data/named_mem_stats.txt";
4433+ allow-query { localhost; };
4434+ recursion yes;
4435+};
4436+
4437+logging {
4438+ channel default_debug {
4439+ file "data/named.run";
4440+ severity dynamic;
4441+ };
4442+};
4443+
4444 #for $zone in $forward_zones
4445 zone "${zone}." {
4446 type master;
4447- file "/etc/bind/db.$zone";
4448+ file "$zone";
4449 };
4450
4451 #end for
4452 #for $zone, $arpa in $reverse_zones
4453 zone "${arpa}." {
4454 type master;
4455- file "/etc/bind/db.$zone";
4456+ file "$zone";
4457 };
4458
4459 #end for

Subscribers

People subscribed via source and target branches

to all changes: