summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-04-11 12:17:42 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-04-11 12:17:42 -0400
commit5da91f89c12b998a4e83db4d21ec6086aca37feb (patch)
tree5f516fd5e23c601194702a8360c5aedc0ed134e1
parent249ccbea4d2615a7623ac91149dda863eefec093 (diff)
downloadthird_party-cobbler-5da91f89c12b998a4e83db4d21ec6086aca37feb.tar.gz
third_party-cobbler-5da91f89c12b998a4e83db4d21ec6086aca37feb.tar.xz
third_party-cobbler-5da91f89c12b998a4e83db4d21ec6086aca37feb.zip
Import now takes an --arch, which is now a recommended field, to ensure
best practices in naming.
-rw-r--r--CHANGELOG1
-rw-r--r--cobbler/action_check.py22
-rw-r--r--cobbler/action_import.py23
-rw-r--r--cobbler/api.py4
-rw-r--r--cobbler/modules/cli_misc.py8
-rw-r--r--cobbler/utils.py56
-rwxr-xr-xconfig/cobblerd19
-rw-r--r--docs/cobbler.pod12
-rw-r--r--website/new/download.html25
9 files changed, 110 insertions, 60 deletions
diff --git a/CHANGELOG b/CHANGELOG
index dee7f3c..80aa334 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@ Cobbler CHANGELOG
- update menu.c32 to 3.62 to allow for timeouts during menu (and future submenu)
- update PXE defaults to invoke menu.c32 automatically w/ timeout
- removed dependency on rhpl
+- import can now take an --arch (and is recommended usage)
- ??? - 0.8.3
- Make createrepo get run for local cobbler reposync invocations as needed
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index 85084d7..e91396f 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -19,7 +19,6 @@ import sub_process
import action_sync
import utils
from utils import _
-
class BootCheck:
def __init__(self,config):
@@ -61,10 +60,18 @@ class BootCheck:
return status
def check_service(self, status, which):
- if os.path.exists("/etc/rc.d/init.d/%s" % which):
- rc = sub_process.call("/sbin/service %s status >/dev/null 2>/dev/null" % which, shell=True)
- if rc != 0:
- status.append(_("service %s is not running") % which)
+ if utils.check_dist() == "redhat":
+ if os.path.exists("/etc/rc.d/init.d/%s" % which):
+ rc = sub_process.call("/sbin/service %s status >/dev/null 2>/dev/null" % which, shell=True)
+ if rc != 0:
+ status.append(_("service %s is not running") % which)
+ elif utils.check_dist() == "debian":
+ if os.path.exists("/etc/init.d/%s" % which):
+ rc = sub_process.call("/etc/init.d/%s status /dev/null 2>/dev/null" % which, shell=True)
+ if rc != 0:
+ status.append(_("service %s is not running") % which)
+ else:
+ status.append(_("Unknown distribution type, cannot check for running service %s" % which))
def check_iptables(self, status):
if os.path.exists("/etc/rc.d/init.d/iptables"):
@@ -95,10 +102,7 @@ class BootCheck:
"""
Check if Apache is installed.
"""
- if not os.path.exists(self.settings.httpd_bin):
- status.append(_("Apache doesn't appear to be installed"))
- else:
- self.check_service(status,"httpd")
+ self.check_service(status,"httpd")
def check_dhcpd_bin(self,status):
diff --git a/cobbler/action_import.py b/cobbler/action_import.py
index d224e55..7f5409b 100644
--- a/cobbler/action_import.py
+++ b/cobbler/action_import.py
@@ -36,7 +36,7 @@ TRY_LIST = [
class Importer:
- def __init__(self,api,config,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None):
+ def __init__(self,api,config,mirror,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None):
"""
Performs an import of a install tree (or trees) from the given
mirror address. The prefix of the distro is to be specified
@@ -59,6 +59,7 @@ class Importer:
self.distros_added = []
self.kickstart_file = kickstart_file
self.rsync_flags = rsync_flags
+ self.arch = arch
# ----------------------------------------------------------------------
@@ -67,6 +68,26 @@ class Importer:
raise CX(_("import failed. no --mirror specified"))
if self.mirror_name is None:
raise CX(_("import failed. no --name specified"))
+ if self.arch is not None:
+ self.arch = self.arch.lower()
+ if self.arch not in [ "x86", "ia64", "x86_64" ]:
+ raise CX(_("arch must be x86, x86_64, or ia64"))
+
+ mpath = os.path.join(self.settings.webdir, "ks_mirror", self.mirror_name)
+ if os.path.exists(mpath) and self.arch is None:
+ if not found:
+ raise CX(_("Something already exists at this import location (%s). You must specify --arch to avoid potentially overwriting existing files.") % mpath)
+
+ if self.arch:
+ # append the arch path to the name if the arch is not already
+ # found in the name.
+ found = False
+ for x in [ "ia64", "i386", "x86_64", "x86" ]:
+ if self.mirror_name.lower().find(x) != -1:
+ found = True
+ break
+ if not found:
+ self.mirror_name = self.mirror_name + "-" + self.arch
if self.mirror_name is None:
raise CX(_("import failed. no --name specified"))
diff --git a/cobbler/api.py b/cobbler/api.py
index 0eacb78..ef6fa8e 100644
--- a/cobbler/api.py
+++ b/cobbler/api.py
@@ -336,7 +336,7 @@ class BootAPI:
statusifier = action_status.BootStatusReport(self._config, mode)
return statusifier.run()
- def import_tree(self,mirror_url,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None):
+ def import_tree(self,mirror_url,mirror_name,network_root=None,kickstart_file=None,rsync_flags=None,arch=None):
"""
Automatically import a directory tree full of distribution files.
mirror_url can be a string that represents a path, a user@host
@@ -346,7 +346,7 @@ class BootAPI:
"""
self.log("import_tree",[mirror_url, mirror_name, network_root, kickstart_file, rsync_flags])
importer = action_import.Importer(
- self, self._config, mirror_url, mirror_name, network_root, kickstart_file, rsync_flags
+ self, self._config, mirror_url, mirror_name, network_root, kickstart_file, rsync_flags, arch
)
return importer.run()
diff --git a/cobbler/modules/cli_misc.py b/cobbler/modules/cli_misc.py
index 0fd44a6..f8b0a7d 100644
--- a/cobbler/modules/cli_misc.py
+++ b/cobbler/modules/cli_misc.py
@@ -73,11 +73,12 @@ class ImportFunction(commands.CobblerFunction):
return "import"
def add_options(self, p, args):
+ p.add_option("--arch", dest="arch", help="explicitly specify the architecture being imported (RECOMENDED)")
p.add_option("--path", dest="mirror", help="local path or rsync location (REQUIRED)")
p.add_option("--mirror", dest="mirror_alt", help="alias for --path")
p.add_option("--name", dest="name", help="name, ex 'RHEL-5', (REQUIRED)")
- p.add_option("--available-as", dest="available_as", help="do not mirror, use this as install tree")
- p.add_option("--kickstart", dest="kickstart_file", help="use the kickstart file specified as the profile's kickstart file")
+ p.add_option("--available-as", dest="available_as", help="do not mirror, use this as install tree base")
+ p.add_option("--kickstart", dest="kickstart_file", help="use the kickstart file specified as the profile's kickstart file, do not auto-assign")
p.add_option("--rsync-flags", dest="rsync_flags", help="pass additional flags to rsync")
def run(self):
@@ -92,7 +93,8 @@ class ImportFunction(commands.CobblerFunction):
self.options.name,
network_root=self.options.available_as,
kickstart_file=self.options.kickstart_file,
- rsync_flags=self.options.rsync_flags
+ rsync_flags=self.options.rsync_flags,
+ arch=self.options.arch
)
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 8757762..d8cf6fc 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -487,28 +487,44 @@ def fix_mod_python_select_submission(repos):
repos = repos.replace('"',"")
repos = repos.lstrip().rstrip()
return repos
+def check_dist():
+ if os.path.exists("/etc/debian_version"):
+ return "debian"
+ else:
+ return "redhat"
def redhat_release():
- if not os.path.exists("/bin/rpm"):
- return ("unknown", 0)
- args = ["/bin/rpm", "-q", "--whatprovides", "redhat-release"]
- cmd = sub_process.Popen(args,shell=False,stdout=sub_process.PIPE)
- data = cmd.communicate()[0]
- data = data.rstrip().lower()
- make = "other"
- if data.find("redhat") != -1:
- make = "redhat"
- elif data.find("centos") != -1:
- make = "centos"
- elif data.find("fedora") != -1:
- make = "fedora"
- version = data.split("release-")[-1]
- rest = 0
- if version.find("-"):
- parts = version.split("-")
- version = parts[0]
- rest = parts[1]
- return (make, float(version), rest)
+ if check_dist() == "redhat":
+
+ if not os.path.exists("/bin/rpm"):
+ return ("unknown", 0)
+ args = ["/bin/rpm", "-q", "--whatprovides", "redhat-release"]
+ cmd = sub_process.Popen(args,shell=False,stdout=sub_process.PIPE)
+ data = cmd.communicate()[0]
+ data = data.rstrip().lower()
+ make = "other"
+ if data.find("redhat") != -1:
+ make = "redhat"
+ elif data.find("centos") != -1:
+ make = "centos"
+ elif data.find("fedora") != -1:
+ make = "fedora"
+ version = data.split("release-")[-1]
+ rest = 0
+ if version.find("-"):
+ parts = version.split("-")
+ version = parts[0]
+ rest = parts[1]
+ return (make, float(version), rest)
+ elif check_dist() == "debian":
+ fd = open("/etc/debian_version")
+ parts = fd.read().split(".")
+ version = parts[0]
+ rest = parts[1]
+ make = "debian"
+ return (make, float(version), rest)
+ else:
+ return ("unknown",0)
def tftpboot_location():
diff --git a/config/cobblerd b/config/cobblerd
index 6b52956..7d6d571 100755
--- a/config/cobblerd
+++ b/config/cobblerd
@@ -25,12 +25,23 @@
# Sanity checks.
[ -x /usr/bin/cobblerd ] || exit 0
+DEBIAN_VERSION=/etc/debian_version
# Source function library.
-. /etc/rc.d/init.d/functions
+if [ -e $DEBIAN_VERSION ]; then
+
+ . /etc/init.d/functions
+else
+ . /etc/rc.d/init.d/functions
+fi
SERVICE=cobblerd
PROCESS=cobblerd
CONFIG_ARGS=" "
+if [ -e $DEBIAN_VERSION ]; then
+ LOCKFILE=/var/lock/$SERVICE
+else
+ LOCKFILE=/var/lock/subsys/$SERVICE
+fi
RETVAL=0
@@ -39,7 +50,7 @@ start() {
daemon --check $SERVICE $PROCESS --daemon $CONFIG_ARGS
RETVAL=$?
echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
@@ -49,7 +60,7 @@ stop() {
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
- rm -f /var/lock/subsys/$SERVICE
+ rm -f $LOCKFILE
rm -f /var/run/$SERVICE.pid
fi
}
@@ -69,7 +80,7 @@ case "$1" in
RETVAL=$?
;;
condrestart)
- [ -f /var/lock/subsys/$SERVICE ] && restart || :
+ [ -f $LOCKFILE ] && restart || :
;;
reload)
echo "can't reload configuration, you have to restart it"
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index 719850d..d7a4550 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -410,20 +410,22 @@ run after systems are added to regenerate and reload the DHCP configuration.
=head2 IMPORT WORKFLOW
-This example shows how to create a provisioning infrastructure from a distribution mirror.
+This example shows how to create a provisioning infrastructure from a distribution mirror or DVD ISO.
Then a default PXE configuration is created, so that by default systems will PXE boot into
a fully automated install process for that distribution.
You can use a network rsync mirror, a mounted DVD location, or a tree you have available
via a network filesystem.
+Import knows how to autodetect the architecture of what is being imported, though to make sure things are named correctly, it's always a good idea to specify --arch. For instance, if you import a distribution named "fedora8" from an ISO, and it's an x86_64 ISO, specify --arch=x86_64 and the distro will be named "fedora8-x86_64" automatically, and the right architecture field will also be set on the distribution object. If you are batch importing an entire mirror (containing multiple distributions and arches), you don't have to do this, as cobbler will set the names for things based on the paths it finds.
+
B<cobbler check>
-B<cobbler import --path=rsync://yourfavoritemirror.com/foo --name=anyname>
+B<cobbler import --path=rsync://yourfavoritemirror.com/foo --name=rhel5 --arch=x86>
# OR
-B<cobbler import --path=/mnt/dvd --name=anyname>
+B<cobbler import --path=/mnt/dvd --name=rhel5 --arch=x86_64>
# OR (using an eternal NAS box without mirroring)
@@ -576,11 +578,11 @@ After an import is run, cobbler will try to detect the distribution type and aut
Mirrored content is saved automatically in /var/www/cobbler/ks_mirror.
-Example: B<cobbler import --mirror=rsync://mirrorserver.example.com/path/ --name=fedora>
+Example: B<cobbler import --mirror=rsync://mirrorserver.example.com/path/ --name=fedora --arch=x86>
Example2: B<cobbler import --mirror=root@192.168.1.10:/stuff --name=bar>
-Example3: B<cobbler import --mirror=/mnt/dvd --name=baz>
+Example3: B<cobbler import --mirror=/mnt/dvd --name=baz --arch=x86_64>
Example4: B<cobbler import --mirror=/path/to/stuff --name=glorp>
diff --git a/website/new/download.html b/website/new/download.html
index 821d684..977fb1b 100644
--- a/website/new/download.html
+++ b/website/new/download.html
@@ -48,31 +48,24 @@ The lastest stable releases of Cobbler and Koan are included in <A HREF="http://
<font size="-1">
<blockquote>
<ul>
- <li>wget http://www.python.org/pyvault/centos-4-i386/python23-cheetah-0.9.18-1.el4.pyv.i386.rpm</li>
- <li>wget ftp://ftp.freshrpms.net/pub/dag/redhat/el4/en/i386/dag/RPMS/syslinux-3.50-1.el4.rf.i386.rpm</li>
- <li>rpm -i python*cheetah*.rpm</i>
- <li>rpm -Uvh syslinux*.rpm</li>
- <li>wget http://cobbler.et.redhat.com/download/cobbler-$version.src.rpm</li>
- <li>rpmbuild --rebuild cobbler-$version.src.rpm</li>
- <li>rpm -i /usr/src/redhat/RPMS/noarch/cobbler-$version.src.rpm</li>
+ <li>For starters, grab python-setuputils, python-cheetah, and yum from <A HREF="http://fedoraproject.org/wiki/EPEL">EPEL</A> and install them. These are found in the main EPEL repo, not EPEL testing -- here's the link: <A HREF="http://download.fedora.redhat.com/pub/epel/4/i386/">i386</A> and <A HREF="http://download.fedora.redhat.com/pub/epel/4/x86_64/">x86_64</A>.</li>
+ <li>now rpmbuild --rebuild cobbler*.src.rpm</li>
+ <li>install the RPM, which is now built in /usr/src/redhat/RPMS/noarch</li>
+ <li>satisfy any dependencies you have by using yum and the EPEL 4 repos</li>
</ul>
</blockquote>
</font>
</p>
-<h4>Source RPM Build Instructions for RHEL5</h4>
+<h4>Source RPM Build Instructions for RHEL 4/5</h4>
<p>
<font size="-1">
<blockquote>
<ul>
-<!--
- <li>wget ftp://ftp.freshrpms.net/pub/dag/redhat/el5/en/i386/RPMS.dag/syslinux-3.50-1.el5.rf.i386.rpm</i>
- <li>rpm -Uvh syslinux*.rpm</li>
--->
- <li>Grab python-setuputils from <A HREF="ftp://rpmfind.net/linux/fedora/extras/6/SRPMS/python-setuptools-0.6c5-1.fc6.src.rpm">here</A></li>
- <li>Grab python-cheetah and yum-utils from here: <A HREF="ftp://mirror.linux.duke.edu/pub/fedora/linux/extras/6/SRPMS/">here</A></li>
- <li>rpmbuild --rebuild those RPMs and then install them</li>
- <li>now rebuild --rebuild and install Cobbler from it's source RPM</li>
+ <li>Grab python-setuputils and python-cheetah from <A HREF="http://fedoraproject.org/wiki/EPEL">EPEL</A> and install them. These are found in the main EPEL repo, not EPEL testing -- here's the link: <A HREF="http://download.fedora.redhat.com/pub/epel/5/i386/">i386</A> and <A HREF="http://download.fedora.redhat.com/pub/epel/5/x86_64/">x86_64</A>.</li>
+ <li>now rpmbuild --rebuild cobbler*.src.rpm</li>
+ <li>install the RPM, which is now built in /usr/src/redhat/RPMS/noarch</li>
+ <li>satisfy any dependencies you have by using yum and the EPEL 5 repos</li>
</ul>
</blockquote>
</font>