[PATCH 5/5] Add support for Ubuntu distros.
by Andres Rodriguez
This patch adds support to koan, to be able to launch Ubuntu instances
when using QEMU(KVM) in the host.
---
koan/qcreate.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/koan/qcreate.py b/koan/qcreate.py
index 4a5a798..7b820a3 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -126,7 +126,7 @@ def start_install(name=None,
if profile_data.has_key("breed"):
breed = profile_data["breed"]
if breed != "other" and breed != "":
- if breed in [ "debian", "suse", "redhat" ]:
+ if breed in [ "ubuntu", "debian", "suse", "redhat" ]:
guest.set_os_type("linux")
elif breed in [ "windows" ]:
guest.set_os_type("windows")
@@ -134,7 +134,12 @@ def start_install(name=None,
guest.set_os_type("unix")
if profile_data.has_key("os_version"):
# FIXME: when os_version is not defined and it's linux, do we use generic24/generic26 ?
- version = profile_data["os_version"]
+ if breed == "ubuntu":
+ # If breed is Ubuntu, need to set the version to the type of "ubuntu<version>"
+ # as defined by virtinst. (i.e. ubuntunatty)
+ version = "ubuntu%s" % profile_data["os_version"]
+ else:
+ version = profile_data["os_version"]
if version != "other" and version != "":
try:
guest.set_os_variant(version)
--
1.7.4.1
13 years, 1 month
cobbler-web and cli inconsistencies for profiles
by Jonathan Underwood
Hi,
Just playing around with the cobbler web interface and the command
line, I see that profiles created via the two different interfaces
aren't the same. In fact, what I did is:
1) First using the cli: "cobbler profile add --name=junk
--parent=SL-EPEL-6-x86_64". At this point issuing "cobbler profile
report --name=junk" gives:
Name : junk
Comment :
DHCP Tag : <<inherit>>
Distribution : <<inherit>>
Enable PXE Menu? : <<inherit>>
Kernel Options : <<inherit>>
Kernel Options (Post Install) : <<inherit>>
Kickstart : <<inherit>>
Kickstart Metadata : <<inherit>>
Management Classes : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile : SL-EPEL-6-x86_64
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : <<inherit>>
Server Override : <<inherit>>
Template Files : <<inherit>>
Virt Auto Boot : <<inherit>>
Virt Bridge : <<inherit>>
Virt CPUs : <<inherit>>
Virt File Size(GB) : <<inherit>>
Virt Path : <<inherit>>
Virt RAM (MB) : <<inherit>>
Virt Type : <<inherit>>
2) Now I selected that profile in cobbler web, didn't change a single
setting, but clicked 'save'. Now issuing "cobbler profile report
--name=junk" gives:
Name : junk
Comment :
DHCP Tag : <<inherit>>
Distribution : <<inherit>>
Enable PXE Menu? : False
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : <<inherit>>
Kickstart Metadata : {}
Management Classes : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile : SL-EPEL-6-x86_64
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 0
Virt Bridge : <<inherit>>
Virt CPUs : <<inherit>>
Virt File Size(GB) : <<inherit>>
Virt Path : <<inherit>>
Virt RAM (MB) : <<inherit>>
Virt Type : xenpv
Notice that now the repo list is empty i.e. sub-profiles created in
the cobbler web interface don't inherit repos, whereas they do with
the cli. Furthermore, notice that other settings are now different,
including Virt Type, Virt Auto Boot, etc.
Is this different behaviour expected/by design, or have the cli and
web interfaces diverged somewhat?
Cheers,
Jonathan.
13 years, 1 month
[PATCH 4/5] Koan install tree path for Ubuntu/Debian distros.
by Andres Rodriguez
In Ubuntu/Debian distros the install_tree cannot be obtained from a
kickstart file, as preseed files are used instead. This patch adds
the functionality of obtaining the install tree for Ubuntu/Debian
in a different approach, using the url provided in ks_meta.
---
koan/app.py | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index 5b4c7fc..d8f5d3a 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -491,8 +491,13 @@ class Koan:
else:
profile_data["kickstart"] = "http://%s/cblr/svc/op/ks/system/%s" % (profile_data['http_server'], profile_data['name'])
- # find_kickstart source tree in the kickstart file
- self.get_install_tree_from_kickstart(profile_data)
+ # If breed is ubuntu/debian we need to source the install tree differently
+ # as preseeds are used instead of kickstarts.
+ if profile_data["breed"] in [ "ubuntu", "debian" ]:
+ self.get_install_tree_for_debian_ubuntu(profile_data)
+ else:
+ # find_kickstart source tree in the kickstart file
+ self.get_install_tree_from_kickstart(profile_data)
# if we found an install_tree, and we don't have a kernel or initrd
# use the ones in the install_tree
@@ -665,6 +670,26 @@ class Koan:
#---------------------------------------------------
+ def get_install_tree_for_debian_ubuntu(self, profile_data):
+ """
+ Split ks_meta to obtain the tree path. Generate the install_tree
+ using the http_server and the tree obtained from splitting ks_meta
+
+ """
+
+ try:
+ tree = profile_data["ks_meta"].split("@@")[-1].strip()
+ profile_data["install_tree"] = "http://" + profile_data["http_server"] + tree
+
+ if self.safe_load(profile_data,"install_tree"):
+ print "install_tree:", profile_data["install_tree"]
+ else:
+ print "warning: kickstart found but no install_tree found"
+ except:
+ pass
+
+ #---------------------------------------------------
+
def list(self,what):
if what not in [ "images", "profiles", "systems", "distros", "repos" ]:
raise InfoException("koan does not know how to list that")
--
1.7.4.1
13 years, 1 month
[PATCH 3/5] Fixing hardlink bin path.
by Andres Rodriguez
In Ubuntu/Debian ditros, the path for the hardlink utility differs
from other distros. Additionally, the tool also differs as it is
a different implementation. This patch fixed both, the path and
required arguments for the hardlink tool.
---
cobbler/action_hardlink.py | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cobbler/action_hardlink.py b/cobbler/action_hardlink.py
index 33881ab..e19a845 100644
--- a/cobbler/action_hardlink.py
+++ b/cobbler/action_hardlink.py
@@ -37,6 +37,14 @@ class HardLinker:
if logger is None:
logger = clogger.Logger()
self.logger = logger
+ self.distro = utils.check_dist()
+ if self.distro == "ubuntu" or self.distro == "debian":
+ self.hardlink = "/usr/bin/hardlink"
+ self.hardlink_args = "-f -p -o -t -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror"
+ else:
+ self.hardlink = "/usr/sbin/hardlink"
+ self.hardlink_args = "-c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror"
+ self.hardlink_cmd = "%s %s" % (self.hardlink, self.hardlink_args)
def run(self):
@@ -49,12 +57,12 @@ class HardLinker:
# FIXME: if these directories become configurable some
# changes will be required here.
- if not os.path.exists("/usr/sbin/hardlink"):
- utils.die(self.logger,"please install 'hardlink' (/usr/sbin/hardlink) to use this feature")
+ if not os.path.exists(self.hardlink):
+ utils.die(self.logger,"please install 'hardlink' (%s) to use this feature" % self.hardlink)
self.logger.info("now hardlinking to save space, this may take some time.")
- rc = utils.subprocess_call(self.logger,"/usr/sbin/hardlink -c -v /var/www/cobbler/ks_mirror /var/www/cobbler/repo_mirror",shell=True)
+ rc = utils.subprocess_call(self.logger,self.hardlink_cmd,shell=True)
return rc
--
1.7.4.1
13 years, 1 month
[PATCH 2/5] Do not fail when yum python module is not present.
by Andres Rodriguez
This patch is for Ubuntu/Debian distros for which do not use yum.
This fixes the failure when trying to import yum python module
while adding support to be able to use other package managers in
the future.
---
koan/configurator.py | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/koan/configurator.py b/koan/configurator.py
index 5fb3231..de351fc 100644
--- a/koan/configurator.py
+++ b/koan/configurator.py
@@ -31,13 +31,16 @@ import stat
import os.path
import sys
import time
-import yum
import pwd
import grp
import simplejson as json
-sys.path.append('/usr/share/yum-cli')
-import cli
-
+try:
+ import yum
+ sys.path.append('/usr/share/yum-cli')
+ import cli
+ yum_available = True
+except:
+ yum_available = False
class KoanConfigure:
"""
@@ -49,10 +52,16 @@ class KoanConfigure:
"""Constructor. Requires json config object."""
self.config = json.JSONDecoder().decode(config)
self.stats = {}
+ self.dist = utils.check_dist()
#----------------------------------------------------------------------
def configure_repos(self):
+ # Enables the possibility to use different types of repos
+ if yum_available and self.dist == "redhat":
+ self.configure_yum_repos()
+
+ def configure_yum_repos(self):
"""Configure YUM repositories."""
print "- Configuring Repos"
old_repo = '/etc/yum.repos.d/config.repo'
@@ -108,6 +117,11 @@ class KoanConfigure:
#----------------------------------------------------------------------
def configure_packages(self):
+ # Enables the possibility to use different types of package configurators
+ if yum_available and self.dist == "redhat":
+ self.configure_yum_packages()
+
+ def configure_yum_packages(self):
"""Configure package resources."""
print "- Configuring Packages"
runtime_start = time.time()
--
1.7.4.1
13 years, 1 month
[PATCH 1/5] Add Ubuntu/Debian support to koan utils for later use.
by Andres Rodriguez
---
koan/utils.py | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/koan/utils.py b/koan/utils.py
index 39e2b43..d0ba012 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -315,7 +315,8 @@ def check_dist():
Determines what distro we're running under.
"""
if os.path.exists("/etc/debian_version"):
- return "debian"
+ import lsb_release
+ return lsb_release.get_distro_information()['ID'].lower()
elif os.path.exists("/etc/SuSE-release"):
return "suse"
else:
@@ -351,11 +352,12 @@ def os_release():
raise CX("failed to detect local OS version from /etc/redhat-release")
elif check_dist() == "debian":
- fd = open("/etc/debian_version")
- parts = fd.read().split(".")
- version = parts[0]
- rest = parts[1]
- make = "debian"
+ import lsb_release
+ release = lsb_release.get_distro_information()['RELEASE']
+ return ("debian", release)
+ elif check_dist() == "ubuntu":
+ version = sub_process.check_output(("lsb_release","--release","--short")).rstrip()
+ make = "ubuntu"
return (make, float(version))
elif check_dist() == "suse":
fd = open("/etc/SuSE-release")
--
1.7.4.1
13 years, 1 month