import cobbler-2.0.7.1-5.module+el8+2897+4e36277a

This commit is contained in:
CentOS Sources 2019-05-07 09:37:17 -04:00 committed by Andrew Lukoshko
commit 1450175524
74 changed files with 11719 additions and 0 deletions

1
.cobbler.metadata Normal file
View File

@ -0,0 +1 @@
82da77e241cd6b12e99cdfcc577dc2f855017164 SOURCES/cobbler-2.0.7.1.tar.gz

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/cobbler-2.0.7.1.tar.gz

View File

@ -0,0 +1,99 @@
From 8d1dbdc5e56b32ad1d6493904d30e85aa3b5fa2b Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 10:47:30 +0100
Subject: [PATCH 01/17] exceptions module doesn't have to be imported
---
koan/app.py | 3 +--
koan/register.py | 3 +--
koan/utils.py | 3 +--
koan/vmwcreate.py | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index e0b2d66..d911dad 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -49,7 +49,6 @@ except:
True = 1
False = 0
-import exceptions
import time
import shutil
import errno
@@ -252,7 +251,7 @@ def main():
#=======================================================
-class InfoException(exceptions.Exception):
+class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
"""
diff --git a/koan/register.py b/koan/register.py
index 0d30c7b..9924d85 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -27,7 +27,6 @@ try:
from optparse import OptionParser
except:
from opt_parse import OptionParser # importing this for backwards compat with 2.2
-import exceptions
try:
import subprocess as sub_process
except:
@@ -100,7 +99,7 @@ def main():
#=======================================================
-class InfoException(exceptions.Exception):
+class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
"""
diff --git a/koan/utils.py b/koan/utils.py
index 7fcc12d..475bcd0 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -25,7 +25,6 @@ import random
import os
import traceback
import tempfile
-import exceptions
ANCIENT_PYTHON = 0
try:
try:
@@ -59,7 +58,7 @@ VIRT_STATE_NAME_MAP = {
6 : "crashed"
}
-class InfoException(exceptions.Exception):
+class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
"""
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index f5603d8..1bde891 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -25,7 +25,6 @@ import os, sys, time, stat
import tempfile
import random
from optparse import OptionParser
-import exceptions
import errno
import re
import virtinst
@@ -64,7 +63,7 @@ memsize = "%(MEMORY)s"
"""
#ide1:0.filename = "%(PATH_TO_ISO)s"
-class VirtCreateException(exceptions.Exception):
+class VirtCreateException(Exception):
pass
def random_mac():
--
2.5.5

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
From bad2b8a68909f7fba0252b2d61bbd98489fc4996 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:10:46 +0100
Subject: [PATCH 03/17] fixing xmlrpclib, urllib2 and local imports in Python 3
---
koan/app.py | 23 +++++++++++++----------
koan/imagecreate.py | 4 ++--
koan/qcreate.py | 4 ++--
koan/register.py | 7 +++++--
koan/utils.py | 8 ++++++--
koan/virtinstall.py | 4 ++--
koan/vmwcreate.py | 1 -
koan/xencreate.py | 4 ++--
8 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index 801fedd..e4e8a6d 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -36,10 +36,13 @@ import time
import shutil
import errno
import sys
-import xmlrpclib
+try: #python2
+ import xmlrpclib
+except ImportError: #python3
+ import xmlrpc.client as xmlrpclib
import string
import re
-import utils
+from . import utils
COBBLER_REQUIRED = 1.300
@@ -1124,9 +1127,9 @@ class Koan:
"""
pd = profile_data
# importing can't throw exceptions any more, don't put it in a sub-method
- import xencreate
- import qcreate
- import imagecreate
+ from . import xencreate
+ from . import qcreate
+ from . import imagecreate
arch = self.safe_load(pd,'arch','x86')
kextra = self.calc_kernel_args(pd)
@@ -1211,11 +1214,11 @@ class Koan:
if (self.image is not None) and (pd["image_type"] == "virt-clone"):
fullvirt = True
uuid = None
- import imagecreate
+ from . import imagecreate
creator = imagecreate.start_install
elif self.virt_type in [ "xenpv", "xenfv" ]:
uuid = self.get_uuid(self.calc_virt_uuid(pd))
- import xencreate
+ from . import xencreate
creator = xencreate.start_install
if self.virt_type == "xenfv":
fullvirt = True
@@ -1223,15 +1226,15 @@ class Koan:
elif self.virt_type == "qemu":
fullvirt = True
uuid = None
- import qcreate
+ from . import qcreate
creator = qcreate.start_install
can_poll = "qemu"
elif self.virt_type == "vmware":
- import vmwcreate
+ from . import vmwcreate
uuid = None
creator = vmwcreate.start_install
elif self.virt_type == "vmwarew":
- import vmwwcreate
+ from . import vmwwcreate
uuid = None
creator = vmwwcreate.start_install
else:
diff --git a/koan/imagecreate.py b/koan/imagecreate.py
index 6bd9d9b..d70d519 100644
--- a/koan/imagecreate.py
+++ b/koan/imagecreate.py
@@ -23,8 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
"""
-import utils
-import virtinstall
+from . import utils
+from . import virtinstall
def start_install(*args, **kwargs):
cmd = virtinstall.build_commandline("import", *args, **kwargs)
diff --git a/koan/qcreate.py b/koan/qcreate.py
index 019a266..1db3d97 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -23,8 +23,8 @@ module for creating fullvirt guests via KVM/kqemu/qemu
requires python-virtinst-0.200 (or virt-install in later distros).
"""
-import utils
-import virtinstall
+from . import utils
+from . import virtinstall
from xml.dom.minidom import parseString
def start_install(*args, **kwargs):
diff --git a/koan/register.py b/koan/register.py
index 871b8ac..cabd4a6 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -25,9 +25,12 @@ import traceback
from optparse import OptionParser
import time
import sys
-import xmlrpclib
+try: #python2
+ import xmlrpclib
+except ImportError: #python3
+ import xmlrpc.client as xmlrpclib
import socket
-import utils
+from . import utils
import string
# usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
diff --git a/koan/utils.py b/koan/utils.py
index 4a3f547..b8247e2 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -25,8 +25,12 @@ import os
import traceback
import sys
import subprocess as sub_process
-import urllib2
-import xmlrpclib
+try: #python2
+ import urllib2
+ import xmlrpclib
+except ImportError: #python3
+ import urllib.request as urllib2
+ import xmlrpc.client as xmlrpclib
import string
import shutil
import tempfile
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index 4ef7874..ca11e04 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -30,8 +30,8 @@ import os
import re
import shlex
-import app as koan
-import utils
+from . import app as koan
+from . import utils
# The virtinst module will no longer be availabe to import in some
# distros. We need to get all the info we need from the virt-install
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 3fda926..372173a 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
import os
import random
-import virtinst
IMAGE_DIR = "/var/lib/vmware/images"
VMX_DIR = "/var/lib/vmware/vmx"
diff --git a/koan/xencreate.py b/koan/xencreate.py
index c3492ed..7eda3e6 100755
--- a/koan/xencreate.py
+++ b/koan/xencreate.py
@@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
"""
-import utils
-import virtinstall
+from . import utils
+from . import virtinstall
def start_install(*args, **kwargs):
cmd = virtinstall.build_commandline("xen:///", *args, **kwargs)
--
2.5.5

View File

@ -0,0 +1,715 @@
From d045ccd1730c6211252cd68cd69d387895df9641 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:15:58 +0100
Subject: [PATCH 04/17] Python 3 compatible prints
---
koan/app.py | 106 ++++++++++++++++++++++++++--------------------------
koan/register.py | 24 ++++++------
koan/utils.py | 36 +++++++++---------
koan/virtinstall.py | 12 +++---
koan/vmwcreate.py | 22 +++++------
5 files changed, 100 insertions(+), 100 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index e4e8a6d..ce8c8c3 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -217,11 +217,11 @@ def main():
(xa, xb, tb) = sys.exc_info()
try:
getattr(e,"from_koan")
- print str(e)[1:-1] # nice exception, no traceback needed
+ print(str(e)[1:-1]) # nice exception, no traceback needed
except:
- print xa
- print xb
- print string.join(traceback.format_list(traceback.extract_tb(tb)))
+ print(xa)
+ print(xb)
+ print(string.join(traceback.format_list(traceback.extract_tb(tb))))
return 1
return 0
@@ -307,9 +307,9 @@ class Koan:
if not os.getuid() == 0:
if self.is_virt:
- print "warning: running as non root"
+ print("warning: running as non root")
else:
- print "this operation requires root access"
+ print("this operation requires root access")
return 3
# if both --profile and --system were ommitted, autodiscover
@@ -372,20 +372,20 @@ class Koan:
try:
available_profiles = self.xmlrpc_server.get_profiles()
except:
- traceback.print_exc()
+ traceback.print(_exc())
self.connect_fail()
- print "\n- which profile to install?\n"
+ print("\n- which profile to install?\n")
for x in available_profiles:
- print "%s" % x["name"]
+ print("%s" % x["name"])
sys.stdout.write("\n?>")
data = sys.stdin.readline().strip()
for x in available_profiles:
- print "comp (%s,%s)" % (x["name"],data)
+ print("comp (%s,%s)" % (x["name"],data))
if x["name"] == data:
return data
return None
@@ -432,7 +432,7 @@ class Koan:
else:
return None
elif len(detected_systems) == 1:
- print "- Auto detected: %s" % detected_systems[0]
+ print("- Auto detected: %s" % detected_systems[0])
return detected_systems[0]
#---------------------------------------------------
@@ -509,7 +509,7 @@ class Koan:
raise InfoException("xmlfile based installations are not supported")
elif profile_data.has_key("file"):
- print "- ISO or Image based installation, always uses --virt-type=qemu"
+ print("- ISO or Image based installation, always uses --virt-type=qemu")
self.virt_type = "qemu"
else:
@@ -525,7 +525,7 @@ class Koan:
# assume Xen, we'll check to see if virt-type is really usable later.
raise InfoException, "Not running a Xen kernel and qemu is not installed"
- print "- no virt-type specified, auto-selecting %s" % self.virt_type
+ print("- no virt-type specified, auto-selecting %s" % self.virt_type)
# now that we've figured out our virt-type, let's see if it is really usable
# rather than showing obscure error messages from Xen to the user :)
@@ -628,9 +628,9 @@ class Koan:
break
if self.safe_load(profile_data,"install_tree"):
- print "install_tree:", profile_data["install_tree"]
+ print("install_tree:", profile_data["install_tree"])
else:
- print "warning: kickstart found but no install_tree found"
+ print("warning: kickstart found but no install_tree found")
except:
# unstable to download the kickstart, however this might not
@@ -646,7 +646,7 @@ class Koan:
data = self.get_data(what)
for x in data:
if x.has_key("name"):
- print x["name"]
+ print(x["name"])
return True
#---------------------------------------------------
@@ -658,7 +658,7 @@ class Koan:
value = profile_data[x]
if x == 'kernel_options':
value = self.calc_kernel_args(profile_data)
- print "%20s : %s" % (x, value)
+ print("%20s : %s" % (x, value))
return self.net_install(after_download)
#---------------------------------------------------
@@ -702,9 +702,9 @@ class Koan:
template_files = utils.input_string_or_hash(template_files)
template_keys = template_files.keys()
- print "- template map: %s" % template_files
+ print("- template map: %s" % template_files)
- print "- processing for files to download..."
+ print("- processing for files to download...")
for src in template_keys:
dest = template_files[src]
save_as = dest
@@ -713,7 +713,7 @@ class Koan:
if not save_as.startswith("/"):
# this is a file in the template system that is not to be downloaded
continue
- print "- file: %s" % save_as
+ print("- file: %s" % save_as)
pattern = "http://%s/cblr/svc/op/template/%s/%s/path/%s"
if profile_data.has_key("interfaces"):
@@ -780,7 +780,7 @@ class Koan:
'--command-line=%s' % (k_args,),
self.safe_load(profile_data,'kernel_local')
])
- print "Kernel loaded; run 'kexec -e' to execute"
+ print("Kernel loaded; run 'kexec -e' to execute")
return self.net_install(after_download)
@@ -900,25 +900,25 @@ class Koan:
# Any post-grubby processing required (e.g. ybin, zipl, lilo)?
if arch.startswith("ppc") and "grub2" not in probe_output:
# FIXME - CHRP hardware uses a 'PPC PReP Boot' partition and doesn't require running ybin
- print "- applying ybin changes"
+ print("- applying ybin changes")
cmd = [ "/sbin/ybin" ]
utils.subprocess_call(cmd)
elif arch.startswith("s390"):
- print "- applying zipl changes"
+ print("- applying zipl changes")
cmd = [ "/sbin/zipl" ]
utils.subprocess_call(cmd)
else:
# if grubby --bootloader-probe returns lilo,
# apply lilo changes
if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
- print "- applying lilo changes"
+ print("- applying lilo changes")
cmd = [ "/sbin/lilo" ]
utils.subprocess_call(cmd)
if not self.add_reinstall_entry:
- print "- reboot to apply changes"
+ print("- reboot to apply changes")
else:
- print "- reinstallation entry added"
+ print("- reinstallation entry added")
return self.net_install(after_download)
@@ -986,7 +986,7 @@ class Koan:
else:
data = getattr(self.xmlrpc_server, "get_%s_for_koan" % what)(name)
except:
- traceback.print_exc()
+ traceback.print(_exc())
self.connect_fail()
if data == {}:
raise InfoException("No entry/entries found")
@@ -1049,15 +1049,15 @@ class Koan:
initrd = "http://%s/cobbler/images/%s/%s" % (self.server, distro, initrd_short)
try:
- print "downloading initrd %s to %s" % (initrd_short, initrd_save)
- print "url=%s" % initrd
+ print("downloading initrd %s to %s" % (initrd_short, initrd_save))
+ print("url=%s" % initrd)
utils.urlgrab(initrd,initrd_save)
- print "downloading kernel %s to %s" % (kernel_short, kernel_save)
- print "url=%s" % kernel
+ print("downloading kernel %s to %s" % (kernel_short, kernel_save))
+ print("url=%s" % kernel)
utils.urlgrab(kernel,kernel_save)
except:
- traceback.print_exc()
+ traceback.print(_exc())
raise InfoException, "error downloading files"
profile_data['kernel_local'] = kernel_save
profile_data['initrd_local'] = initrd_save
@@ -1166,11 +1166,11 @@ class Koan:
noreboot = self.virtinstall_noreboot,
)
- print results
+ print(results)
if can_poll is not None and self.should_poll:
import libvirt
- print "- polling for virt completion"
+ print("- polling for virt completion")
conn = None
if can_poll == "xen":
conn = libvirt.open(None)
@@ -1183,14 +1183,14 @@ class Koan:
time.sleep(3)
state = utils.get_vm_state(conn, virtname)
if state == "running":
- print "- install is still running, sleeping for 1 minute (%s)" % ct
+ print("- install is still running, sleeping for 1 minute (%s)" % ct)
ct = ct + 1
time.sleep(60)
elif state == "crashed":
- print "- the install seems to have crashed."
+ print("- the install seems to have crashed.")
return "failed"
elif state == "shutdown":
- print "- shutdown VM detected, is the install done? Restarting!"
+ print("- shutdown VM detected, is the install done? Restarting!")
utils.find_vm(conn, virtname).create()
return results
else:
@@ -1202,7 +1202,7 @@ class Koan:
elif self.virt_type == "qemu":
utils.libvirt_enable_autostart(virtname)
else:
- print "- warning: don't know how to autoboot this virt type yet"
+ print("- warning: don't know how to autoboot this virt type yet")
# else...
return results
@@ -1255,8 +1255,8 @@ class Koan:
disks.append([path,size])
counter = counter + 1
if len(disks) == 0:
- print "paths: ", paths
- print "sizes: ", sizes
+ print("paths: ", paths)
+ print("sizes: ", sizes)
raise InfoException, "Disk configuration not resolvable!"
return disks
@@ -1320,7 +1320,7 @@ class Koan:
if size is None or size == '':
err = True
if err:
- print "invalid file size specified, using defaults"
+ print("invalid file size specified, using defaults")
return default_filesize
return int(size)
@@ -1339,7 +1339,7 @@ class Koan:
if size is None or size == '' or int(size) < default_ram:
err = True
if err:
- print "invalid RAM size specified, using defaults."
+ print("invalid RAM size specified, using defaults.")
return default_ram
return int(size)
@@ -1353,7 +1353,7 @@ class Koan:
try:
isize = int(size)
except:
- traceback.print_exc()
+ traceback.print(_exc())
return default_cpus
return isize
@@ -1386,7 +1386,7 @@ class Koan:
if my_id is None or my_id == '' or not uuid_re.match(id):
err = True
if err and my_id is not None:
- print "invalid UUID specified. randomizing..."
+ print("invalid UUID specified. randomizing...")
return None
return my_id
@@ -1415,7 +1415,7 @@ class Koan:
else:
prefix = "/var/lib/vmware/images/"
if not os.path.exists(prefix):
- print "- creating: %s" % prefix
+ print("- creating: %s" % prefix)
os.makedirs(prefix)
return [ "%s/%s-disk0" % (prefix, name) ]
@@ -1456,7 +1456,7 @@ class Koan:
elif not os.path.exists(location) and os.path.isdir(os.path.dirname(location)):
return location
elif not os.path.exists(os.path.dirname(location)):
- print "- creating: %s" % os.path.dirname(location)
+ print("- creating: %s" % os.path.dirname(location))
os.makedirs(os.path.dirname(location))
return location
else:
@@ -1470,21 +1470,21 @@ class Koan:
else:
# it's a volume group, verify that it exists
args = "vgs -o vg_name"
- print "%s" % args
+ print("%s" % args)
vgnames = sub_process.Popen(args, shell=True, stdout=sub_process.PIPE).communicate()[0]
- print vgnames
+ print(vgnames)
if vgnames.find(location) == -1:
raise InfoException, "The volume group [%s] does not exist." % location
# check free space
args = "LANG=C vgs --noheadings -o vg_free --units g %s" % location
- print args
+ print(args)
cmd = sub_process.Popen(args, stdout=sub_process.PIPE, shell=True)
freespace_str = cmd.communicate()[0]
freespace_str = freespace_str.split("\n")[0].strip()
freespace_str = freespace_str.lower().replace("g","") # remove gigabytes
- print "(%s)" % freespace_str
+ print("(%s)" % freespace_str)
freespace = int(float(freespace_str))
virt_size = self.calc_virt_filesize(pd)
@@ -1498,16 +1498,16 @@ class Koan:
# look for LVM partition named foo, create if doesn't exist
args = "lvs -o lv_name %s" % location
- print "%s" % args
+ print("%s" % args)
lvs_str=sub_process.Popen(args, stdout=sub_process.PIPE, shell=True).communicate()[0]
- print lvs_str
+ print(lvs_str)
name = "%s-disk%s" % (name,offset)
# have to create it?
if lvs_str.find(name) == -1:
args = "lvcreate -L %sG -n %s %s" % (virt_size, name, location)
- print "%s" % args
+ print("%s" % args)
lv_create = sub_process.call(args, shell=True)
if lv_create != 0:
raise InfoException, "LVM creation failed"
diff --git a/koan/register.py b/koan/register.py
index cabd4a6..1157e5c 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -65,7 +65,7 @@ def main():
(options, args) = p.parse_args()
#if not os.getuid() == 0:
- # print "koan requires root access"
+ # print("koan requires root access")
# return 3
try:
@@ -80,11 +80,11 @@ def main():
(xa, xb, tb) = sys.exc_info()
try:
getattr(e,"from_koan")
- print str(e)[1:-1] # nice exception, no traceback needed
+ print(str(e)[1:-1]) # nice exception, no traceback needed
except:
- print xa
- print xb
- print string.join(traceback.format_list(traceback.extract_tb(tb)))
+ print(xa)
+ print(xb)
+ print(string.join(traceback.format_list(traceback.extract_tb(tb))))
return 1
return 0
@@ -127,13 +127,13 @@ class Register:
if os.getuid() != 0:
raise InfoException("root access is required to register")
- print "- preparing to koan home"
+ print("- preparing to koan home")
self.conn = utils.connect_to_server(self.server, self.port)
reg_info = {}
- print "- gathering network info"
+ print("- gathering network info")
netinfo = utils.get_network_info()
reg_info["interfaces"] = netinfo
- print "- checking hostname"
+ print("- checking hostname")
sysname = ""
if self.hostname != "" and self.hostname != "*AUTO*":
hostname = self.hostname
@@ -171,14 +171,14 @@ class Register:
if not self.batch:
self.conn.register_new_system(reg_info)
- print "- registration successful, new system name: %s" % sysname
+ print("- registration successful, new system name: %s" % sysname)
else:
try:
self.conn.register_new_system(reg_info)
- print "- registration successful, new system name: %s" % sysname
+ print("- registration successful, new system name: %s" % sysname)
except:
- traceback.print_exc()
- print "- registration failed, ignoring because of --batch"
+ traceback.print(_exc())
+ print("- registration failed, ignoring because of --batch")
return
diff --git a/koan/utils.py b/koan/utils.py
index b8247e2..77d53b2 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -90,7 +90,7 @@ def urlread(url):
parts of urlread and urlgrab from urlgrabber, in ways that
are less cool and less efficient.
"""
- print "- reading URL: %s" % url
+ print("- reading URL: %s" % url)
if url is None or url == "":
raise InfoException, "invalid URL: %s" % url
@@ -109,7 +109,7 @@ def urlread(url):
subprocess_call(cmd)
return data
except:
- traceback.print_exc()
+ traceback.print(_exc())
raise InfoException, "Couldn't mount and read URL: %s" % url
elif url[0:4] == "http":
@@ -119,7 +119,7 @@ def urlread(url):
fd.close()
return data
except:
- traceback.print_exc()
+ traceback.print(_exc())
raise InfoException, "Couldn't download: %s" % url
elif url[0:4] == "file":
try:
@@ -147,7 +147,7 @@ def subprocess_call(cmd,ignore_rc=0):
"""
Wrapper around subprocess.call(...)
"""
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = sub_process.call(cmd)
if rc != 0 and not ignore_rc:
raise InfoException, "command failed (%s)" % rc
@@ -157,7 +157,7 @@ def subprocess_get_response(cmd, ignore_rc=False):
"""
Wrapper around subprocess.check_output(...)
"""
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = 0
result = ""
p = sub_process.Popen(cmd, stdout=sub_process.PIPE, stderr=sub_process.STDOUT)
@@ -219,7 +219,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
def hash_to_string(hash):
"""
- Convert a hash to a printable string.
+ Convert a hash to a print(able string.)
used primarily in the kernel options string
and for some legacy stuff where koan expects strings
(though this last part should be changed to hashes)
@@ -232,7 +232,7 @@ def hash_to_string(hash):
if value is None:
buffer = buffer + str(key) + " "
elif type(value) == list:
- # this value is an array, so we print out every
+ # this value is an array, so we print(out every)
# key=value
for item in value:
buffer = buffer + str(key) + "=" + str(item) + " "
@@ -251,14 +251,14 @@ def nfsmount(input_path):
mount_cmd = [
"/bin/mount", "-t", "nfs", "-o", "ro", dirpath, tempdir
]
- print "- running: %s" % mount_cmd
+ print("- running: %s" % mount_cmd)
rc = sub_process.call(mount_cmd)
if not rc == 0:
shutil.rmtree(tempdir, ignore_errors=True)
raise koan.InfoException("nfs mount failed: %s" % dirpath)
# NOTE: option for a blocking install might be nice, so we could do this
# automatically, if supported by virt-install
- print "after install completes, you may unmount and delete %s" % tempdir
+ print("after install completes, you may unmount and delete %s" % tempdir)
return (tempdir, filename)
@@ -411,7 +411,7 @@ def get_network_info():
"module" : module
}
- # print interfaces
+ # print(interfaces)
return interfaces
def connect_to_server(server=None,port=None):
@@ -431,7 +431,7 @@ def connect_to_server(server=None,port=None):
"https://%s/cobbler_api" % (server),
]
for url in try_urls:
- print "- looking for Cobbler at %s" % url
+ print("- looking for Cobbler at %s" % url)
server = __try_connect(url)
if server is not None:
return server
@@ -467,18 +467,18 @@ def libvirt_enable_autostart(domain_name):
def make_floppy(kickstart):
(fd, floppy_path) = tempfile.mkstemp(suffix='.floppy', prefix='tmp', dir="/tmp")
- print "- creating floppy image at %s" % floppy_path
+ print("- creating floppy image at %s" % floppy_path)
# create the floppy image file
cmd = "dd if=/dev/zero of=%s bs=1440 count=1024" % floppy_path
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
raise InfoException("dd failed")
# vfatify
cmd = "mkdosfs %s" % floppy_path
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
raise InfoException("mkdosfs failed")
@@ -486,19 +486,19 @@ def make_floppy(kickstart):
# mount the floppy
mount_path = tempfile.mkdtemp(suffix=".mnt", prefix='tmp', dir="/tmp")
cmd = "mount -o loop -t vfat %s %s" % (floppy_path, mount_path)
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
raise InfoException("mount failed")
# download the kickstart file onto the mounted floppy
- print "- downloading %s" % kickstart
+ print("- downloading %s" % kickstart)
save_file = os.path.join(mount_path, "unattended.txt")
urlgrabber.urlgrab(kickstart,filename=save_file)
# umount
cmd = "umount %s" % mount_path
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
raise InfoException("umount failed")
@@ -522,7 +522,7 @@ def __try_connect(url):
xmlrpc_server.ping()
return xmlrpc_server
except:
- traceback.print_exc()
+ traceback.print(_exc())
return None
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index ca11e04..2d1f3df 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -191,7 +191,7 @@ def build_commandline(uri,
oldstyle_accelerate = False
if not virtinst_version:
- print ("- warning: old virt-install detected, a lot of features will be disabled")
+ print(("- warning: old virt-install detected, a lot of features will be disabled"))
disable_autostart = True
disable_boot_opt = True
disable_virt_type = True
@@ -239,7 +239,7 @@ def build_commandline(uri,
# this is an image based installation
input_path = profile_data["file"]
- print "- using image location %s" % input_path
+ print("- using image location %s" % input_path)
if input_path.find(":") == -1:
# this is not an NFS path
cdrom = input_path
@@ -251,7 +251,7 @@ def build_commandline(uri,
if kickstart != "":
# we have a (windows?) answer file we have to provide
# to the ISO.
- print "I want to make a floppy for %s" % kickstart
+ print("I want to make a floppy for %s" % kickstart)
floppy = utils.make_floppy(kickstart)
elif is_qemu or is_xen:
# images don't need to source this
@@ -378,7 +378,7 @@ def build_commandline(uri,
# compatibility in virt-install grumble grumble.
cmd += "--os-variant %s" % os_version + ".0 "
else:
- print ("- warning: virt-install doesn't know this os_version, defaulting to generic26")
+ print(("- warning: virt-install doesn't know this os_version, defaulting to generic26"))
cmd += "--os-variant generic26 "
else:
distro = "unix"
@@ -394,8 +394,8 @@ def build_commandline(uri,
cmd += "--disk path=%s " % importpath
for path, size, driver_type in disks:
- print ("- adding disk: %s of size %s (driver type=%s)" %
- (path, size, driver_type))
+ print(("- adding disk: %s of size %s (driver type=%s)" %
+ (path, size, driver_type)))
cmd += "--disk path=%s" % (path)
if str(size) != "0":
cmd += ",size=%s" % size
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 372173a..97e0ba2 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -77,7 +77,7 @@ def random_mac():
def make_disk(disksize,image):
cmd = "vmware-vdiskmanager -c -a lsilogic -s %sGb -t 0 %s" % (disksize, image)
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if rc != 0:
raise VirtCreateException("command failed")
@@ -96,7 +96,7 @@ def make_vmx(path,vmdk_image,image_name,mac_address,memory):
def register_vmx(vmx_file):
cmd = "vmware-cmd -s register %s" % vmx_file
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if rc!=0:
raise VirtCreateException("vmware registration failed")
@@ -104,7 +104,7 @@ def register_vmx(vmx_file):
def start_vm(vmx_file):
os.chmod(vmx_file,0755)
cmd = "vmware-cmd %s start" % vmx_file
- print "- %s" % cmd
+ print("- %s" % cmd)
rc = os.system(cmd)
if rc != 0:
raise VirtCreateException("vm start failed")
@@ -129,19 +129,19 @@ def start_install(name=None,
mac = None
if not profile_data.has_key("interfaces"):
- print "- vmware installation requires a system, not a profile"
+ print("- vmware installation requires a system, not a profile")
return 1
for iname in profile_data["interfaces"]:
intf = profile_data["interfaces"][iname]
mac = intf["mac_address"]
if mac is None:
- print "- no MAC information available in this record, cannot install"
+ print("- no MAC information available in this record, cannot install")
return 1
- print "DEBUG: name=%s" % name
- print "DEBUG: ram=%s" % ram
- print "DEBUG: mac=%s" % mac
- print "DEBUG: disks=%s" % disks
+ print("DEBUG: name=%s" % name)
+ print("DEBUG: ram=%s" % ram)
+ print("DEBUG: mac=%s" % mac)
+ print("DEBUG: disks=%s" % disks)
# starts vmware using PXE. disk/mem info come from Cobbler
# rest of the data comes from PXE which is also intended
# to be managed by Cobbler.
@@ -158,10 +158,10 @@ def start_install(name=None,
disksize = disks[0][1]
image = "%s/%s" % (IMAGE_DIR, name)
- print "- saving virt disk image as %s" % image
+ print("- saving virt disk image as %s" % image)
make_disk(disksize,image)
vmx = "%s/%s" % (VMX_DIR, name)
- print "- saving vmx file as %s" % vmx
+ print("- saving vmx file as %s" % vmx)
make_vmx(vmx,image,name,mac,ram)
register_vmx(vmx)
start_vm(vmx)
--
2.5.5

View File

@ -0,0 +1,448 @@
From af3fa33d008de48edc76edafbae034512481cc28 Mon Sep 17 00:00:00 2001
From: Jan Dobes <jdobes@redhat.com>
Date: Wed, 11 Oct 2017 16:53:07 +0200
Subject: [PATCH 05/17] Python 3 compatible exceptions
(cherry picked from commit 1d94e4941822ecb18f8d67672aace41f029141d4)
Conflicts:
koan/app.py
koan/utils.py
---
koan/app.py | 91 +++++++++++++++++++++++++++++++++----------------------
koan/qcreate.py | 1 +
koan/register.py | 4 +--
koan/utils.py | 24 +++++++--------
koan/vmwcreate.py | 2 ++
5 files changed, 72 insertions(+), 50 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index ce8c8c3..c1d79c2 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -213,21 +213,38 @@ def main():
k.port = options.port
k.run()
- except Exception, e:
+ except Exception as e:
(xa, xb, tb) = sys.exc_info()
try:
- getattr(e,"from_koan")
- print(str(e)[1:-1]) # nice exception, no traceback needed
+ getattr(e, "from_koan")
+ print(str(e)[1:-1]) # nice exception, no traceback needed
except:
print(xa)
print(xb)
- print(string.join(traceback.format_list(traceback.extract_tb(tb))))
+ print("".join(traceback.format_list(traceback.extract_tb(tb))))
return 1
return 0
#=======================================================
+
+class KoanException(Exception):
+
+ def __init__(self, value, *args):
+ self.value = value % args
+ # this is a hack to work around some odd exception handling
+ # in older pythons
+ self.from_koan = 1
+
+ def __str__(self):
+ return repr(self.value)
+
+
+class KX(KoanException):
+ pass
+
+
class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
@@ -283,7 +300,7 @@ class Koan:
# we can get the info we need from either the cobbler server
# or a kickstart file
if self.server is None:
- raise InfoException, "no server specified"
+ raise InfoException("no server specified")
# check to see that exclusive arguments weren't used together
found = 0
@@ -291,13 +308,13 @@ class Koan:
if x:
found = found+1
if found != 1:
- raise InfoException, "choose: --virt, --replace-self, --update-files, --list=what, or --display"
+ raise InfoException("choose: --virt, --replace-self, --update-files, --list=what, or --display")
# This set of options are only valid with --server
if not self.server or self.server == "":
if self.list_items or self.profile or self.system or self.port:
- raise InfoException, "--server is required"
+ raise InfoException("--server is required")
self.xmlrpc_server = utils.connect_to_server(server=self.server, port=self.port)
@@ -315,7 +332,7 @@ class Koan:
# if both --profile and --system were ommitted, autodiscover
if self.is_virt:
if (self.profile is None and self.system is None and self.image is None):
- raise InfoException, "must specify --profile, --system, or --image"
+ raise InfoException("must specify --profile, --system, or --image")
else:
if (self.profile is None and self.system is None and self.image is None):
self.system = self.autodetect_system(allow_interactive=self.live_cd)
@@ -330,13 +347,13 @@ class Koan:
if self.virt_type not in [ "qemu", "xenpv", "xenfv", "xen", "vmware", "vmwarew", "auto" ]:
if self.virt_type == "xen":
self.virt_type = "xenpv"
- raise InfoException, "--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto"
+ raise InfoException("--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto")
# if --qemu-disk-type was called without --virt-type=qemu, then fail
if (self.qemu_disk_type is not None):
self.qemu_disk_type = self.qemu_disk_type.lower()
if self.virt_type not in [ "qemu", "auto", "kvm" ]:
- raise InfoException, "--qemu-disk-type must use with --virt-type=qemu"
+ raise(InfoException, "--qemu-disk-type must use with --virt-type=qemu")
# if --qemu-net-type was called without --virt-type=qemu, then fail
if (self.qemu_net_type is not None):
@@ -346,7 +363,7 @@ class Koan:
# if --static-interface and --profile was called together, then fail
if self.static_interface is not None and self.profile is not None:
- raise InfoException, "--static-interface option is incompatible with --profile option use --system instead"
+ raise InfoException("--static-interface option is incompatible with --profile option use --system instead")
# perform one of three key operations
if self.is_virt:
@@ -372,7 +389,7 @@ class Koan:
try:
available_profiles = self.xmlrpc_server.get_profiles()
except:
- traceback.print(_exc())
+ traceback.print_exc()
self.connect_fail()
print("\n- which profile to install?\n")
@@ -423,12 +440,12 @@ class Koan:
detected_systems = utils.uniqify(detected_systems)
if len(detected_systems) > 1:
- raise InfoException, "Error: Multiple systems matched"
+ raise InfoException("Error: Multiple systems matched")
elif len(detected_systems) == 0:
if not allow_interactive:
mac_criteria = utils.uniqify(mac_criteria, purge="?")
ip_criteria = utils.uniqify(ip_criteria, purge="?")
- raise InfoException, "Error: Could not find a matching system with MACs: %s or IPs: %s" % (",".join(mac_criteria), ",".join(ip_criteria))
+ raise InfoException("Error: Could not find a matching system with MACs: %s or IPs: %s" % (",".join(mac_criteria), ",".join(ip_criteria)))
else:
return None
elif len(detected_systems) == 1:
@@ -523,7 +540,7 @@ class Koan:
self.virt_type = "qemu"
else:
# assume Xen, we'll check to see if virt-type is really usable later.
- raise InfoException, "Not running a Xen kernel and qemu is not installed"
+ raise InfoException("Not running a Xen kernel and qemu is not installed")
print("- no virt-type specified, auto-selecting %s" % self.virt_type)
@@ -766,12 +783,12 @@ class Koan:
# asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
- raise InfoException, "Kernel options are too long, 512 chars exceeded: %s" % k_args
+ raise InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args)
elif arch.startswith("s390"):
if len(k_args) > 895:
- raise InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args
+ raise(InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args)
elif len(k_args) > 2047:
- raise InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args
+ raise(InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args)
utils.subprocess_call([
'kexec',
@@ -800,19 +817,21 @@ class Koan:
"""
try:
shutil.rmtree("/var/spool/koan")
- except OSError, (err, msg):
+ except OSError as xxx_todo_changeme:
+ (err, msg) = xxx_todo_changeme.args
if err != errno.ENOENT:
raise
try:
os.makedirs("/var/spool/koan")
- except OSError, (err, msg):
+ except OSError as xxx_todo_changeme:
+ (err, msg) = xxx_todo_changeme.args
if err != errno.EEXIST:
raise
def after_download(self, profile_data):
if not os.path.exists("/sbin/grubby"):
- raise InfoException, "grubby is not installed"
+ raise InfoException("grubby is not installed")
k_args = self.calc_kernel_args(profile_data,replace_self=1)
kickstart = self.safe_load(profile_data,'kickstart')
@@ -844,12 +863,12 @@ class Koan:
# asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
- raise InfoException, "Kernel options are too long, 512 chars exceeded: %s" % k_args
+ raise InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args)
elif arch.startswith("s390"):
if len(k_args) > 895:
- raise InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args
+ raise(InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args)
elif len(k_args) > 2047:
- raise InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args
+ raise(InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args)
cmd = [ "/sbin/grubby",
"--add-kernel", self.safe_load(profile_data,'kernel_local'),
@@ -975,7 +994,7 @@ class Koan:
#---------------------------------------------------
def connect_fail(self):
- raise InfoException, "Could not communicate with %s:%s" % (self.server, self.port)
+ raise InfoException("Could not communicate with %s:%s" % (self.server, self.port))
#---------------------------------------------------
@@ -986,7 +1005,7 @@ class Koan:
else:
data = getattr(self.xmlrpc_server, "get_%s_for_koan" % what)(name)
except:
- traceback.print(_exc())
+ traceback.print_exc()
self.connect_fail()
if data == {}:
raise InfoException("No entry/entries found")
@@ -1057,8 +1076,8 @@ class Koan:
print("url=%s" % kernel)
utils.urlgrab(kernel,kernel_save)
except:
- traceback.print(_exc())
- raise InfoException, "error downloading files"
+ traceback.print_exc()
+ raise(InfoException, "error downloading files")
profile_data['kernel_local'] = kernel_save
profile_data['initrd_local'] = initrd_save
@@ -1238,7 +1257,7 @@ class Koan:
uuid = None
creator = vmwwcreate.start_install
else:
- raise InfoException, "Unspecified virt type: %s" % self.virt_type
+ raise InfoException("Unspecified virt type: %s" % self.virt_type)
return (uuid, creator, fullvirt, can_poll)
#---------------------------------------------------
@@ -1257,7 +1276,7 @@ class Koan:
if len(disks) == 0:
print("paths: ", paths)
print("sizes: ", sizes)
- raise InfoException, "Disk configuration not resolvable!"
+ raise InfoException("Disk configuration not resolvable!")
return disks
#---------------------------------------------------
@@ -1353,7 +1372,7 @@ class Koan:
try:
isize = int(size)
except:
- traceback.print(_exc())
+ traceback.print_exc()
return default_cpus
return isize
@@ -1460,13 +1479,13 @@ class Koan:
os.makedirs(os.path.dirname(location))
return location
else:
- raise InfoException, "invalid location: %s" % location
+ raise(InfoException, "invalid location: %s" % location)
elif location.startswith("/dev/"):
# partition
if os.path.exists(location):
return location
else:
- raise InfoException, "virt path is not a valid block device"
+ raise InfoException("virt path is not a valid block device")
else:
# it's a volume group, verify that it exists
args = "vgs -o vg_name"
@@ -1475,7 +1494,7 @@ class Koan:
print(vgnames)
if vgnames.find(location) == -1:
- raise InfoException, "The volume group [%s] does not exist." % location
+ raise InfoException("The volume group [%s] does not exist." % location)
# check free space
args = "LANG=C vgs --noheadings -o vg_free --units g %s" % location
@@ -1510,13 +1529,13 @@ class Koan:
print("%s" % args)
lv_create = sub_process.call(args, shell=True)
if lv_create != 0:
- raise InfoException, "LVM creation failed"
+ raise InfoException("LVM creation failed")
# return partition location
return "/dev/%s/%s" % (location,name)
else:
- raise InfoException, "volume group needs %s GB free space." % virt_size
+ raise InfoException("volume group needs %s GB free space." % virt_size)
def randomUUID(self):
diff --git a/koan/qcreate.py b/koan/qcreate.py
index 1db3d97..d0bafae 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -26,6 +26,7 @@ requires python-virtinst-0.200 (or virt-install in later distros).
from . import utils
from . import virtinstall
from xml.dom.minidom import parseString
+from . import app as koan
def start_install(*args, **kwargs):
# See http://post-office.corp.redhat.com/archives/satellite-dept-list/2013-December/msg00039.html for discussion on this hack.
diff --git a/koan/register.py b/koan/register.py
index 1157e5c..5d28acd 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -76,7 +76,7 @@ def main():
k.hostname = options.hostname
k.batch = options.batch
k.run()
- except Exception, e:
+ except Exception as e:
(xa, xb, tb) = sys.exc_info()
try:
getattr(e,"from_koan")
@@ -177,7 +177,7 @@ class Register:
self.conn.register_new_system(reg_info)
print("- registration successful, new system name: %s" % sysname)
except:
- traceback.print(_exc())
+ traceback.print_exc()
print("- registration failed, ignoring because of --batch")
return
diff --git a/koan/utils.py b/koan/utils.py
index 77d53b2..1aee405 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -92,7 +92,7 @@ def urlread(url):
"""
print("- reading URL: %s" % url)
if url is None or url == "":
- raise InfoException, "invalid URL: %s" % url
+ raise InfoException("invalid URL: %s" % url)
elif url[0:3] == "nfs":
try:
@@ -109,8 +109,8 @@ def urlread(url):
subprocess_call(cmd)
return data
except:
- traceback.print(_exc())
- raise InfoException, "Couldn't mount and read URL: %s" % url
+ traceback.print_exc()
+ raise(InfoException, "Couldn't mount and read URL: %s" % url)
elif url[0:4] == "http":
try:
@@ -119,8 +119,8 @@ def urlread(url):
fd.close()
return data
except:
- traceback.print(_exc())
- raise InfoException, "Couldn't download: %s" % url
+ traceback.print_exc()
+ raise(InfoException, "Couldn't download: %s" % url)
elif url[0:4] == "file":
try:
fd = open(url[5:])
@@ -128,10 +128,10 @@ def urlread(url):
fd.close()
return data
except:
- raise InfoException, "Couldn't read file from URL: %s" % url
+ raise InfoException("Couldn't read file from URL: %s" % url)
else:
- raise InfoException, "Unhandled URL protocol: %s" % url
+ raise InfoException("Unhandled URL protocol: %s" % url)
def urlgrab(url,saveto):
"""
@@ -150,7 +150,7 @@ def subprocess_call(cmd,ignore_rc=0):
print("- %s" % cmd)
rc = sub_process.call(cmd)
if rc != 0 and not ignore_rc:
- raise InfoException, "command failed (%s)" % rc
+ raise InfoException("command failed (%s)" % rc)
return rc
def subprocess_get_response(cmd, ignore_rc=False):
@@ -165,7 +165,7 @@ def subprocess_get_response(cmd, ignore_rc=False):
result = result.strip()
rc = p.poll()
if not ignore_rc and rc != 0:
- raise InfoException, "command failed (%s)" % rc
+ raise InfoException("command failed (%s)" % rc)
return rc, result
def input_string_or_hash(options,delim=None,allow_multiples=True):
@@ -333,9 +333,9 @@ def os_release():
for t in tokens:
try:
return (make,float(t))
- except ValueError, ve:
+ except ValueError:
pass
- raise CX("failed to detect local OS version from /etc/redhat-release")
+ raise koan.KX("failed to detect local OS version from /etc/redhat-release")
elif check_dist() == "debian":
fd = open("/etc/debian_version")
@@ -522,7 +522,7 @@ def __try_connect(url):
xmlrpc_server.ping()
return xmlrpc_server
except:
- traceback.print(_exc())
+ traceback.print_exc()
return None
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 97e0ba2..c77c018 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
import os
import random
+from . import app as koan
+
IMAGE_DIR = "/var/lib/vmware/images"
VMX_DIR = "/var/lib/vmware/vmx"
--
2.5.5

View File

@ -0,0 +1,25 @@
From 9a06847b9b9b8ff0b2da837a5123d1a1178336d7 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:28:43 +0100
Subject: [PATCH 06/17] octal number Python 3 fix
---
koan/vmwcreate.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index c77c018..82bfa4a 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -104,7 +104,7 @@ def register_vmx(vmx_file):
raise VirtCreateException("vmware registration failed")
def start_vm(vmx_file):
- os.chmod(vmx_file,0755)
+ os.chmod(vmx_file, 0o755)
cmd = "vmware-cmd %s start" % vmx_file
print("- %s" % cmd)
rc = os.system(cmd)
--
2.5.5

View File

@ -0,0 +1,111 @@
From 79136996ad2cf9d5ea51cc0a053cfe5815785c41 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:34:57 +0100
Subject: [PATCH 07/17] Python 3 compatible string operations
---
koan/app.py | 9 ++++-----
koan/register.py | 3 +--
koan/utils.py | 7 +++----
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index c1d79c2..e727932 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -40,7 +40,6 @@ try: #python2
import xmlrpclib
except ImportError: #python3
import xmlrpc.client as xmlrpclib
-import string
import re
from . import utils
@@ -880,7 +879,7 @@ class Koan:
cmd.append("--copy-default")
boot_probe_ret_code, probe_output = self.get_boot_loader_info()
- if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") >= 0:
+ if boot_probe_ret_code == 0 and probe_output.find("lilo") >= 0:
cmd.append("--lilo")
if self.add_reinstall_entry:
@@ -929,7 +928,7 @@ class Koan:
else:
# if grubby --bootloader-probe returns lilo,
# apply lilo changes
- if boot_probe_ret_code == 0 and string.find(probe_output, "lilo") != -1:
+ if boot_probe_ret_code == 0 and probe_output.find("lilo") != -1:
print("- applying lilo changes")
cmd = [ "/sbin/lilo" ]
utils.subprocess_call(cmd)
@@ -1132,10 +1131,10 @@ class Koan:
hash2 = utils.input_string_or_hash(self.kopts_override)
hashv.update(hash2)
options = utils.hash_to_string(hashv)
- options = string.replace(options, "lang ","lang= ")
+ options = options.replace("lang ","lang= ")
# if using ksdevice=bootif that only works for PXE so replace
# it with something that will work
- options = string.replace(options, "ksdevice=bootif","ksdevice=link")
+ options = options.replace("ksdevice=bootif","ksdevice=link")
return options
#---------------------------------------------------
diff --git a/koan/register.py b/koan/register.py
index 5d28acd..a69f2d1 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -31,7 +31,6 @@ except ImportError: #python3
import xmlrpc.client as xmlrpclib
import socket
from . import utils
-import string
# usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
@@ -84,7 +83,7 @@ def main():
except:
print(xa)
print(xb)
- print(string.join(traceback.format_list(traceback.extract_tb(tb))))
+ print("".join(traceback.format_list(traceback.extract_tb(tb))))
return 1
return 0
diff --git a/koan/utils.py b/koan/utils.py
index 1aee405..f2f2692 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -31,7 +31,6 @@ try: #python2
except ImportError: #python3
import urllib.request as urllib2
import xmlrpc.client as xmlrpclib
-import string
import shutil
import tempfile
import urlgrabber
@@ -181,9 +180,9 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
raise InfoException("No idea what to do with list: %s" % options)
elif type(options) == type(""):
new_dict = {}
- tokens = string.split(options, delim)
+ tokens = options.split(delim)
for t in tokens:
- tokens2 = string.split(t,"=",1)
+ tokens2 = t.split("=",1)
if len(tokens2) == 1:
# this is a singleton option, no value
key = tokens2[0]
@@ -246,7 +245,7 @@ def nfsmount(input_path):
# FIXME: move this function to util.py so other modules can use it
# we have to mount it first
filename = input_path.split("/")[-1]
- dirpath = string.join(input_path.split("/")[:-1],"/")
+ dirpath = "/".join(input_path.split("/")[:-1])
tempdir = tempfile.mkdtemp(suffix='.mnt', prefix='koan_', dir='/tmp')
mount_cmd = [
"/bin/mount", "-t", "nfs", "-o", "ro", dirpath, tempdir
--
2.5.5

View File

@ -0,0 +1,33 @@
From dc08d632d0f27e194da5cec05a1f367237ae4e2c Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:35:29 +0100
Subject: [PATCH 08/17] do not require urlgrabber
---
koan/utils.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/koan/utils.py b/koan/utils.py
index f2f2692..b24fa0f 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -33,7 +33,6 @@ except ImportError: #python3
import xmlrpc.client as xmlrpclib
import shutil
import tempfile
-import urlgrabber
VIRT_STATE_NAME_MAP = {
0 : "running",
@@ -493,7 +492,7 @@ def make_floppy(kickstart):
# download the kickstart file onto the mounted floppy
print("- downloading %s" % kickstart)
save_file = os.path.join(mount_path, "unattended.txt")
- urlgrabber.urlgrab(kickstart,filename=save_file)
+ urlgrab(kickstart,filename=save_file)
# umount
cmd = "umount %s" % mount_path
--
2.5.5

View File

@ -0,0 +1,25 @@
From a2dba086cd78ac54b0366d328a64b6e48e9dc422 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:35:59 +0100
Subject: [PATCH 09/17] replace iteritems with items
---
koan/app.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/koan/app.py b/koan/app.py
index e727932..ac6b0df 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -426,7 +426,7 @@ class Koan:
systems = self.get_data("systems")
for system in systems:
obj_name = system["name"]
- for (obj_iname, obj_interface) in system['interfaces'].iteritems():
+ for (obj_iname, obj_interface) in system['interfaces'].items():
mac = obj_interface["mac_address"].upper()
ip = obj_interface["ip_address"].upper()
for my_mac in mac_criteria:
--
2.5.5

View File

@ -0,0 +1,25 @@
From 41cc091c9680935c072b44b4aaa49261d66f6dc4 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:36:30 +0100
Subject: [PATCH 10/17] open target file in binary mode
---
koan/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/koan/utils.py b/koan/utils.py
index b24fa0f..28c8af1 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -137,7 +137,7 @@ def urlgrab(url,saveto):
see comments for urlread as to why it's this way.
"""
data = urlread(url)
- fd = open(saveto, "w+")
+ fd = open(saveto, "w+b")
fd.write(data)
fd.close()
--
2.5.5

View File

@ -0,0 +1,34 @@
From 31321dc6d1dd14166601ffc59b9e98c02aaf25f0 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:37:07 +0100
Subject: [PATCH 11/17] make sure it's a string
---
koan/app.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index ac6b0df..f251c77 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -805,7 +805,7 @@ class Koan:
def get_boot_loader_info(self):
cmd = [ "/sbin/grubby", "--bootloader-probe" ]
probe_process = sub_process.Popen(cmd, stdout=sub_process.PIPE)
- which_loader = probe_process.communicate()[0]
+ which_loader = probe_process.communicate()[0].decode()
return probe_process.returncode, which_loader
def replace(self):
@@ -851,7 +851,7 @@ class Koan:
)
arch_cmd = sub_process.Popen("/bin/uname -m", stdout=sub_process.PIPE, shell=True)
- arch = arch_cmd.communicate()[0]
+ arch = arch_cmd.communicate()[0].decode()
# Validate kernel argument length (limit depends on architecture --
# see asm-*/setup.h). For example:
--
2.5.5

View File

@ -0,0 +1,25 @@
From cd2fc155f84655ca689e33cc176fc2d9ab08c936 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:37:38 +0100
Subject: [PATCH 12/17] make sure list is returned
---
koan/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/koan/utils.py b/koan/utils.py
index 28c8af1..e202bd5 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -364,7 +364,7 @@ def uniqify(lst, purge=None):
if x != purge:
temp2[x] = 1
temp = temp2
- return temp.keys()
+ return list(temp.keys())
def get_network_info():
try:
--
2.5.5

View File

@ -0,0 +1,121 @@
From 4a23a3cc1b9d1ab1238aadbd7945aa93c21f7638 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:39:34 +0100
Subject: [PATCH 13/17] Python 3 ethtool and indentation fixes
---
koan/utils.py | 98 ++++++++++++++++++++++++++++++++---------------------------
1 file changed, 54 insertions(+), 44 deletions(-)
diff --git a/koan/utils.py b/koan/utils.py
index e202bd5..0cd48ea 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -367,50 +367,60 @@ def uniqify(lst, purge=None):
return list(temp.keys())
def get_network_info():
- try:
- import ethtool
- except:
- try:
- import rhpl.ethtool
- ethtool = rhpl.ethtool
- except:
- raise InfoException("the rhpl or ethtool module is required to use this feature (is your OS>=EL3?)")
-
- interfaces = {}
- # get names
- inames = ethtool.get_devices()
-
- for iname in inames:
- mac = ethtool.get_hwaddr(iname)
-
- if mac == "00:00:00:00:00:00":
- mac = "?"
-
- try:
- ip = ethtool.get_ipaddr(iname)
- if ip == "127.0.0.1":
- ip = "?"
- except:
- ip = "?"
-
- bridge = 0
- module = ""
-
- try:
- nm = ethtool.get_netmask(iname)
- except:
- nm = "?"
-
- interfaces[iname] = {
- "ip_address" : ip,
- "mac_address" : mac,
- "netmask" : nm,
- "bridge" : bridge,
- "module" : module
- }
-
- # print(interfaces)
- return interfaces
+ try: # python 2
+ import ethtool
+ ethtool_available = True
+ except ImportError: # python 3
+ import netifaces
+ ethtool_available = False
+
+ interfaces = {}
+ # get names
+ if ethtool_available:
+ inames = ethtool.get_devices()
+ else:
+ inames = netifaces.interfaces()
+
+ for iname in inames:
+ if ethtool_available:
+ mac = ethtool.get_hwaddr(iname)
+ else:
+ mac = netifaces.ifaddresses(iname)[netifaces.AF_LINK][0]['addr']
+
+ if mac == "00:00:00:00:00:00":
+ mac = "?"
+
+ try:
+ if ethtool_available:
+ ip = ethtool.get_ipaddr(iname)
+ else:
+ ip = netifaces.ifaddresses(iname)[netifaces.AF_INET][0]['addr']
+ if ip == "127.0.0.1":
+ ip = "?"
+ except:
+ ip = "?"
+
+ bridge = 0
+ module = ""
+
+ try:
+ if ethtool_available:
+ nm = ethtool.get_netmask(iname)
+ else:
+ nm = netifaces.ifaddresses(iname)[netifaces.AF_INET][0]['netmask']
+ except:
+ nm = "?"
+
+ interfaces[iname] = {
+ "ip_address" : ip,
+ "mac_address" : mac,
+ "netmask" : nm,
+ "bridge" : bridge,
+ "module" : module
+ }
+
+ # print(interfaces)
+ return interfaces
def connect_to_server(server=None,port=None):
--
2.5.5

View File

@ -0,0 +1,129 @@
From 769722facf088ea59ab010b363fc44d18b70d670 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:43:20 +0100
Subject: [PATCH 14/17] has_key is not in Python 3
---
koan/app.py | 14 +++++++-------
koan/utils.py | 2 +-
koan/virtinstall.py | 4 ++--
koan/vmwcreate.py | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index f251c77..4ae4c90 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -454,9 +454,9 @@ class Koan:
#---------------------------------------------------
def safe_load(self,hashv,primary_key,alternate_key=None,default=None):
- if hashv.has_key(primary_key):
+ if primary_key in hashv:
return hashv[primary_key]
- elif alternate_key is not None and hashv.has_key(alternate_key):
+ elif alternate_key is not None and alternate_key in hashv:
return hashv[alternate_key]
else:
return default
@@ -524,7 +524,7 @@ class Koan:
if profile_data.get("xml_file","") != "":
raise InfoException("xmlfile based installations are not supported")
- elif profile_data.has_key("file"):
+ elif "file" in profile_data:
print("- ISO or Image based installation, always uses --virt-type=qemu")
self.virt_type = "qemu"
@@ -661,7 +661,7 @@ class Koan:
raise InfoException("koan does not know how to list that")
data = self.get_data(what)
for x in data:
- if x.has_key("name"):
+ if "name" in x:
print(x["name"])
return True
@@ -670,7 +670,7 @@ class Koan:
def display(self):
def after_download(self, profile_data):
for x in DISPLAY_PARAMS:
- if profile_data.has_key(x):
+ if x in profile_data:
value = profile_data[x]
if x == 'kernel_options':
value = self.calc_kernel_args(profile_data)
@@ -732,7 +732,7 @@ class Koan:
print("- file: %s" % save_as)
pattern = "http://%s/cblr/svc/op/template/%s/%s/path/%s"
- if profile_data.has_key("interfaces"):
+ if "interfaces" in profile_data:
url = pattern % (profile_data["http_server"],"system",profile_data["name"],dest)
else:
url = pattern % (profile_data["http_server"],"profile",profile_data["name"],dest)
@@ -1284,7 +1284,7 @@ class Koan:
if self.virt_name is not None:
# explicit override
name = self.virt_name
- elif profile_data.has_key("interfaces"):
+ elif "interfaces" in profile_data:
# this is a system object, just use the name
name = profile_data["name"]
else:
diff --git a/koan/utils.py b/koan/utils.py
index 0cd48ea..12ec718 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -206,7 +206,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
new_dict[key] = value
# dict.pop is not avail in 2.2
- if new_dict.has_key(""):
+ if "" in new_dict:
del new_dict[""]
return new_dict
elif type(options) == type({}):
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index 2d1f3df..5359b2a 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -233,7 +233,7 @@ def build_commandline(uri,
raise koan.InfoException("Profile 'file' required for image "
"install")
- elif profile_data.has_key("file"):
+ elif "file" in profile_data:
if is_xen:
raise koan.InfoException("Xen does not work with --image yet")
@@ -255,7 +255,7 @@ def build_commandline(uri,
floppy = utils.make_floppy(kickstart)
elif is_qemu or is_xen:
# images don't need to source this
- if not profile_data.has_key("install_tree"):
+ if not "install_tree" in profile_data:
raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
if not profile_data["install_tree"].endswith("/"):
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 82bfa4a..33c5819 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -126,11 +126,11 @@ def start_install(name=None,
virt_type=None,
virt_auto_boot=False):
- if profile_data.has_key("file"):
+ if "file" in profile_data:
raise koan.InfoException("vmware does not work with --image yet")
mac = None
- if not profile_data.has_key("interfaces"):
+ if not "interfaces" in profile_data:
print("- vmware installation requires a system, not a profile")
return 1
for iname in profile_data["interfaces"]:
--
2.5.5

View File

@ -0,0 +1,394 @@
From f565382b5291409ac1ab4a96494c566cd9a4dfd4 Mon Sep 17 00:00:00 2001
From: Jan Dobes <jdobes@redhat.com>
Date: Wed, 18 Oct 2017 13:18:24 +0200
Subject: [PATCH 15/17] relative imports don't work on both Python 2 and 3
(cherry picked from commit a2339d3a544c0cfbec6cfc5437942a79abe4bd30)
Conflicts:
koan/app.py
koan/utils.py
koan/virtinstall.py
---
koan/app.py | 34 +++++++++-------------------------
koan/imagecreate.py | 7 ++++---
koan/qcreate.py | 11 ++++++-----
koan/register.py | 6 +++---
koan/utils.py | 6 ++++--
koan/virtinstall.py | 27 ++++++++++++++-------------
koan/vmwcreate.py | 4 ++--
koan/xencreate.py | 7 ++++---
scripts/cobbler-register | 2 +-
scripts/koan | 2 +-
10 files changed, 48 insertions(+), 58 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index 4ae4c90..f5af5e9 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -41,7 +41,7 @@ try: #python2
except ImportError: #python3
import xmlrpc.client as xmlrpclib
import re
-from . import utils
+from koan import utils
COBBLER_REQUIRED = 1.300
@@ -228,22 +228,6 @@ def main():
#=======================================================
-class KoanException(Exception):
-
- def __init__(self, value, *args):
- self.value = value % args
- # this is a hack to work around some odd exception handling
- # in older pythons
- self.from_koan = 1
-
- def __str__(self):
- return repr(self.value)
-
-
-class KX(KoanException):
- pass
-
-
class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
@@ -1145,9 +1129,9 @@ class Koan:
"""
pd = profile_data
# importing can't throw exceptions any more, don't put it in a sub-method
- from . import xencreate
- from . import qcreate
- from . import imagecreate
+ from koan import xencreate
+ from koan import qcreate
+ from koan import imagecreate
arch = self.safe_load(pd,'arch','x86')
kextra = self.calc_kernel_args(pd)
@@ -1232,11 +1216,11 @@ class Koan:
if (self.image is not None) and (pd["image_type"] == "virt-clone"):
fullvirt = True
uuid = None
- from . import imagecreate
+ from koan import imagecreate
creator = imagecreate.start_install
elif self.virt_type in [ "xenpv", "xenfv" ]:
uuid = self.get_uuid(self.calc_virt_uuid(pd))
- from . import xencreate
+ from koan import xencreate
creator = xencreate.start_install
if self.virt_type == "xenfv":
fullvirt = True
@@ -1244,15 +1228,15 @@ class Koan:
elif self.virt_type == "qemu":
fullvirt = True
uuid = None
- from . import qcreate
+ from koan import qcreate
creator = qcreate.start_install
can_poll = "qemu"
elif self.virt_type == "vmware":
- from . import vmwcreate
+ from koan import vmwcreate
uuid = None
creator = vmwcreate.start_install
elif self.virt_type == "vmwarew":
- from . import vmwwcreate
+ from koan import vmwwcreate
uuid = None
creator = vmwwcreate.start_install
else:
diff --git a/koan/imagecreate.py b/koan/imagecreate.py
index d70d519..9b98f74 100644
--- a/koan/imagecreate.py
+++ b/koan/imagecreate.py
@@ -23,9 +23,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
"""
-from . import utils
-from . import virtinstall
+from koan.utils import subprocess_call
+from koan import virtinstall
+
def start_install(*args, **kwargs):
cmd = virtinstall.build_commandline("import", *args, **kwargs)
- utils.subprocess_call(cmd)
+ subprocess_call(cmd)
diff --git a/koan/qcreate.py b/koan/qcreate.py
index d0bafae..73b6abb 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -23,10 +23,11 @@ module for creating fullvirt guests via KVM/kqemu/qemu
requires python-virtinst-0.200 (or virt-install in later distros).
"""
-from . import utils
-from . import virtinstall
from xml.dom.minidom import parseString
-from . import app as koan
+from koan.utils import subprocess_call
+from koan import virtinstall
+from koan import app
+
def start_install(*args, **kwargs):
# See http://post-office.corp.redhat.com/archives/satellite-dept-list/2013-December/msg00039.html for discussion on this hack.
@@ -37,7 +38,7 @@ def start_install(*args, **kwargs):
try:
import libvirt
except:
- raise koan.InfoException("package libvirt is required for installing virtual guests")
+ raise app.InfoException("package libvirt is required for installing virtual guests")
conn = libvirt.openReadOnly(None)
# See http://libvirt.org/formatcaps.html
capabilities = parseString(conn.getCapabilities())
@@ -49,4 +50,4 @@ def start_install(*args, **kwargs):
virtinstall.create_image_file(*args, **kwargs)
cmd = virtinstall.build_commandline("qemu:///system", *args, **kwargs)
- utils.subprocess_call(cmd)
+ subprocess_call(cmd)
diff --git a/koan/register.py b/koan/register.py
index a69f2d1..8ce7db3 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -30,7 +30,7 @@ try: #python2
except ImportError: #python3
import xmlrpc.client as xmlrpclib
import socket
-from . import utils
+from koan.utils import connect_to_server, get_network_info
# usage: cobbler-register [--server=server] [--hostname=hostname] --profile=foo
@@ -127,10 +127,10 @@ class Register:
raise InfoException("root access is required to register")
print("- preparing to koan home")
- self.conn = utils.connect_to_server(self.server, self.port)
+ self.conn = connect_to_server(self.server, self.port)
reg_info = {}
print("- gathering network info")
- netinfo = utils.get_network_info()
+ netinfo = get_network_info()
reg_info["interfaces"] = netinfo
print("- checking hostname")
sysname = ""
diff --git a/koan/utils.py b/koan/utils.py
index 12ec718..607db1f 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -44,6 +44,7 @@ VIRT_STATE_NAME_MAP = {
6 : "crashed"
}
+
class InfoException(Exception):
"""
Custom exception for tracking of fatal errors.
@@ -54,6 +55,7 @@ class InfoException(Exception):
def __str__(self):
return repr(self.value)
+
def setupLogging(appname):
"""
set up logging ... code borrowed/adapted from virt-manager
@@ -253,7 +255,7 @@ def nfsmount(input_path):
rc = sub_process.call(mount_cmd)
if not rc == 0:
shutil.rmtree(tempdir, ignore_errors=True)
- raise koan.InfoException("nfs mount failed: %s" % dirpath)
+ raise InfoException("nfs mount failed: %s" % dirpath)
# NOTE: option for a blocking install might be nice, so we could do this
# automatically, if supported by virt-install
print("after install completes, you may unmount and delete %s" % tempdir)
@@ -333,7 +335,7 @@ def os_release():
return (make,float(t))
except ValueError:
pass
- raise koan.KX("failed to detect local OS version from /etc/redhat-release")
+ raise InfoException("failed to detect local OS version from /etc/redhat-release")
elif check_dist() == "debian":
fd = open("/etc/debian_version")
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index 5359b2a..ce6c425 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -30,15 +30,15 @@ import os
import re
import shlex
-from . import app as koan
-from . import utils
+from koan import app
+from koan.utils import subprocess_get_response, nfsmount, make_floppy
# The virtinst module will no longer be availabe to import in some
# distros. We need to get all the info we need from the virt-install
# command line tool. This should work on both old and new variants,
# as the virt-install command line tool has always been provided by
# python-virtinst (and now the new virt-install rpm).
-rc, response = utils.subprocess_get_response(
+rc, response = subprocess_get_response(
shlex.split('virt-install --version'), True)
if rc == 0:
virtinst_version = response
@@ -63,7 +63,7 @@ try:
supported_variants.add(variant)
except:
try:
- rc, response = utils.subprocess_get_response(
+ rc, response = subprocess_get_response(
shlex.split('virt-install --os-variant list'))
variants = response.split('\n')
for variant in variants:
@@ -90,7 +90,7 @@ def _sanitize_disks(disks):
if d[1] != 0 or d[0].startswith("/dev"):
ret.append((d[0], d[1], driver_type))
else:
- raise koan.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
+ raise app.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
return ret
@@ -128,7 +128,7 @@ def _sanitize_nics(nics, bridge, profile_bridge, network_count):
intf_bridge = intf["virt_bridge"]
if intf_bridge == "":
if profile_bridge == "":
- raise koan.InfoException("virt-bridge setting is not defined in cobbler")
+ raise app.InfoException("virt-bridge setting is not defined in cobbler")
intf_bridge = profile_bridge
else:
@@ -151,7 +151,8 @@ def create_image_file(disks=None, **kwargs):
continue
if str(size) == "0":
continue
- utils.create_qemu_image_file(path, size, driver_type)
+ # This method doesn't exist and this functionality is probably broken
+ # create_qemu_image_file(path, size, driver_type)
def build_commandline(uri,
name=None,
@@ -230,12 +231,12 @@ def build_commandline(uri,
if is_import:
importpath = profile_data.get("file")
if not importpath:
- raise koan.InfoException("Profile 'file' required for image "
+ raise app.InfoException("Profile 'file' required for image "
"install")
elif "file" in profile_data:
if is_xen:
- raise koan.InfoException("Xen does not work with --image yet")
+ raise app.InfoException("Xen does not work with --image yet")
# this is an image based installation
input_path = profile_data["file"]
@@ -244,7 +245,7 @@ def build_commandline(uri,
# this is not an NFS path
cdrom = input_path
else:
- (tempdir, filename) = utils.nfsmount(input_path)
+ (tempdir, filename) = nfsmount(input_path)
cdrom = os.path.join(tempdir, filename)
kickstart = profile_data.get("kickstart","")
@@ -252,11 +253,11 @@ def build_commandline(uri,
# we have a (windows?) answer file we have to provide
# to the ISO.
print("I want to make a floppy for %s" % kickstart)
- floppy = utils.make_floppy(kickstart)
+ floppy = make_floppy(kickstart)
elif is_qemu or is_xen:
# images don't need to source this
if not "install_tree" in profile_data:
- raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
+ raise app.InfoException("Cannot find install source in kickstart file, aborting.")
if not profile_data["install_tree"].endswith("/"):
profile_data["install_tree"] = profile_data["install_tree"] + "/"
@@ -277,7 +278,7 @@ def build_commandline(uri,
bridge = profile_data["virt_bridge"]
if bridge == "":
- raise koan.InfoException("virt-bridge setting is not defined in cobbler")
+ raise app.InfoException("virt-bridge setting is not defined in cobbler")
nics = [(bridge, None)]
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 33c5819..1b90a27 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
import os
import random
-from . import app as koan
+from koan import app
IMAGE_DIR = "/var/lib/vmware/images"
VMX_DIR = "/var/lib/vmware/vmx"
@@ -127,7 +127,7 @@ def start_install(name=None,
virt_auto_boot=False):
if "file" in profile_data:
- raise koan.InfoException("vmware does not work with --image yet")
+ raise app.InfoException("vmware does not work with --image yet")
mac = None
if not "interfaces" in profile_data:
diff --git a/koan/xencreate.py b/koan/xencreate.py
index 7eda3e6..18b2969 100755
--- a/koan/xencreate.py
+++ b/koan/xencreate.py
@@ -26,9 +26,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
"""
-from . import utils
-from . import virtinstall
+from koan.utils import subprocess_call
+from koan import virtinstall
+
def start_install(*args, **kwargs):
cmd = virtinstall.build_commandline("xen:///", *args, **kwargs)
- utils.subprocess_call(cmd)
+ subprocess_call(cmd)
diff --git a/scripts/cobbler-register b/scripts/cobbler-register
index ed97cfc..3f2ffb1 100755
--- a/scripts/cobbler-register
+++ b/scripts/cobbler-register
@@ -15,5 +15,5 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import sys
-import koan.register as register
+from koan import register
sys.exit(register.main() or 0)
diff --git a/scripts/koan b/scripts/koan
index aeccb0e..9c3f445 100755
--- a/scripts/koan
+++ b/scripts/koan
@@ -15,5 +15,5 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
import sys
-import koan.app as app
+from koan import app
sys.exit(app.main() or 0)
--
2.5.5

View File

@ -0,0 +1,26 @@
From c1c3e1d9f42861a756f26706765cb51b409926c3 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 11:47:37 +0100
Subject: [PATCH 16/17] keys() and sort() doesn't work on Python 3
---
koan/virtinstall.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index ce6c425..de2a670 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -110,8 +110,7 @@ def _sanitize_nics(nics, bridge, profile_bridge, network_count):
if not nics:
return ret
- interfaces = nics.keys()
- interfaces.sort()
+ interfaces = sorted(nics)
counter = -1
vlanpattern = re.compile("[a-zA-Z0-9]+\.[0-9]+")
--
2.5.5

View File

@ -0,0 +1,671 @@
From 650f96a40ab858904ae4ea17481a59a75ade7def Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Mon, 5 Mar 2018 12:02:02 +0100
Subject: [PATCH 17/17] raise is a function call in python3
---
koan/app.py | 82 ++++++++++++++++++++++++++---------------------------
koan/qcreate.py | 2 +-
koan/register.py | 8 +++---
koan/utils.py | 42 +++++++++++++--------------
koan/virtinstall.py | 14 ++++-----
koan/vmwcreate.py | 10 +++----
6 files changed, 79 insertions(+), 79 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index f5af5e9..ed81fe4 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -283,7 +283,7 @@ class Koan:
# we can get the info we need from either the cobbler server
# or a kickstart file
if self.server is None:
- raise InfoException("no server specified")
+ raise(InfoException("no server specified"))
# check to see that exclusive arguments weren't used together
found = 0
@@ -291,13 +291,13 @@ class Koan:
if x:
found = found+1
if found != 1:
- raise InfoException("choose: --virt, --replace-self, --update-files, --list=what, or --display")
+ raise(InfoException("choose: --virt, --replace-self, --update-files, --list=what, or --display"))
# This set of options are only valid with --server
if not self.server or self.server == "":
if self.list_items or self.profile or self.system or self.port:
- raise InfoException("--server is required")
+ raise(InfoException("--server is required"))
self.xmlrpc_server = utils.connect_to_server(server=self.server, port=self.port)
@@ -315,7 +315,7 @@ class Koan:
# if both --profile and --system were ommitted, autodiscover
if self.is_virt:
if (self.profile is None and self.system is None and self.image is None):
- raise InfoException("must specify --profile, --system, or --image")
+ raise(InfoException("must specify --profile, --system, or --image"))
else:
if (self.profile is None and self.system is None and self.image is None):
self.system = self.autodetect_system(allow_interactive=self.live_cd)
@@ -330,23 +330,23 @@ class Koan:
if self.virt_type not in [ "qemu", "xenpv", "xenfv", "xen", "vmware", "vmwarew", "auto" ]:
if self.virt_type == "xen":
self.virt_type = "xenpv"
- raise InfoException("--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto")
+ raise(InfoException("--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto"))
# if --qemu-disk-type was called without --virt-type=qemu, then fail
if (self.qemu_disk_type is not None):
self.qemu_disk_type = self.qemu_disk_type.lower()
if self.virt_type not in [ "qemu", "auto", "kvm" ]:
- raise(InfoException, "--qemu-disk-type must use with --virt-type=qemu")
+ raise((InfoException, "--qemu-disk-type must use with --virt-type=qemu"))
# if --qemu-net-type was called without --virt-type=qemu, then fail
if (self.qemu_net_type is not None):
self.qemu_net_type = self.qemu_net_type.lower()
if self.virt_type not in [ "qemu", "auto", "kvm" ]:
- raise InfoException, "--qemu-net-type must use with --virt-type=qemu"
+ raise(InfoException, "--qemu-net-type must use with --virt-type=qemu")
# if --static-interface and --profile was called together, then fail
if self.static_interface is not None and self.profile is not None:
- raise InfoException("--static-interface option is incompatible with --profile option use --system instead")
+ raise(InfoException("--static-interface option is incompatible with --profile option use --system instead"))
# perform one of three key operations
if self.is_virt:
@@ -423,12 +423,12 @@ class Koan:
detected_systems = utils.uniqify(detected_systems)
if len(detected_systems) > 1:
- raise InfoException("Error: Multiple systems matched")
+ raise(InfoException("Error: Multiple systems matched"))
elif len(detected_systems) == 0:
if not allow_interactive:
mac_criteria = utils.uniqify(mac_criteria, purge="?")
ip_criteria = utils.uniqify(ip_criteria, purge="?")
- raise InfoException("Error: Could not find a matching system with MACs: %s or IPs: %s" % (",".join(mac_criteria), ",".join(ip_criteria)))
+ raise(InfoException("Error: Could not find a matching system with MACs: %s or IPs: %s" % (",".join(mac_criteria), ",".join(ip_criteria))))
else:
return None
elif len(detected_systems) == 1:
@@ -506,7 +506,7 @@ class Koan:
if self.virt_type == "auto":
if profile_data.get("xml_file","") != "":
- raise InfoException("xmlfile based installations are not supported")
+ raise(InfoException("xmlfile based installations are not supported"))
elif "file" in profile_data:
print("- ISO or Image based installation, always uses --virt-type=qemu")
@@ -523,7 +523,7 @@ class Koan:
self.virt_type = "qemu"
else:
# assume Xen, we'll check to see if virt-type is really usable later.
- raise InfoException("Not running a Xen kernel and qemu is not installed")
+ raise(InfoException("Not running a Xen kernel and qemu is not installed"))
print("- no virt-type specified, auto-selecting %s" % self.virt_type)
@@ -535,20 +535,20 @@ class Koan:
uname_str = cmd.communicate()[0]
# correct kernel on dom0?
if uname_str.find("xen") == -1:
- raise InfoException("kernel-xen needs to be in use")
+ raise(InfoException("kernel-xen needs to be in use"))
# xend installed?
if not os.path.exists("/usr/sbin/xend"):
- raise InfoException("xen package needs to be installed")
+ raise(InfoException("xen package needs to be installed"))
# xend running?
rc = sub_process.call("/usr/sbin/xend status", stderr=None, stdout=None, shell=True)
if rc != 0:
- raise InfoException("xend needs to be started")
+ raise(InfoException("xend needs to be started"))
# for qemu
if self.virt_type == "qemu":
# qemu package installed?
if not os.path.exists("/usr/bin/qemu-img"):
- raise InfoException("qemu package needs to be installed")
+ raise(InfoException("qemu package needs to be installed"))
# is libvirt new enough?
# Note: in some newer distros (like Fedora 19) the python-virtinst package has been
# subsumed into virt-install. If we don't have one check to see if we have the other.
@@ -556,7 +556,7 @@ class Koan:
if rc != 0:
rc, version_str = utils.subprocess_get_response(shlex.split('rpm -q python-virtinst'), True)
if rc != 0 or version_str.find("virtinst-0.1") != -1 or version_str.find("virtinst-0.0") != -1:
- raise InfoException("need python-virtinst >= 0.2 or virt-install package to do installs for qemu/kvm (depending on your OS)")
+ raise(InfoException("need python-virtinst >= 0.2 or virt-install package to do installs for qemu/kvm (depending on your OS)"))
# for vmware
if self.virt_type == "vmware" or self.virt_type == "vmwarew":
@@ -565,14 +565,14 @@ class Koan:
if self.virt_type == "virt-image":
if not os.path.exists("/usr/bin/virt-image"):
- raise InfoException("virt-image not present, downlevel virt-install package?")
+ raise(InfoException("virt-image not present, downlevel virt-install package?"))
# for both virt types
if os.path.exists("/etc/rc.d/init.d/libvirtd"):
rc = sub_process.call("/sbin/service libvirtd status", stdout=None, shell=True)
if rc != 0:
# libvirt running?
- raise InfoException("libvirtd needs to be running")
+ raise(InfoException("libvirtd needs to be running"))
if self.virt_type in [ "xenpv" ]:
@@ -642,7 +642,7 @@ class Koan:
def list(self,what):
if what not in [ "images", "profiles", "systems", "distros", "repos" ]:
- raise InfoException("koan does not know how to list that")
+ raise(InfoException("koan does not know how to list that"))
data = self.get_data(what)
for x in data:
if "name" in x:
@@ -766,12 +766,12 @@ class Koan:
# asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
- raise InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args)
+ raise(InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args))
elif arch.startswith("s390"):
if len(k_args) > 895:
- raise(InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args)
+ raise((InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args))
elif len(k_args) > 2047:
- raise(InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args)
+ raise((InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args))
utils.subprocess_call([
'kexec',
@@ -803,18 +803,18 @@ class Koan:
except OSError as xxx_todo_changeme:
(err, msg) = xxx_todo_changeme.args
if err != errno.ENOENT:
- raise
+ raise()
try:
os.makedirs("/var/spool/koan")
except OSError as xxx_todo_changeme:
(err, msg) = xxx_todo_changeme.args
if err != errno.EEXIST:
- raise
+ raise()
def after_download(self, profile_data):
if not os.path.exists("/sbin/grubby"):
- raise InfoException("grubby is not installed")
+ raise(InfoException("grubby is not installed"))
k_args = self.calc_kernel_args(profile_data,replace_self=1)
kickstart = self.safe_load(profile_data,'kickstart')
@@ -846,12 +846,12 @@ class Koan:
# asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
- raise InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args)
+ raise(InfoException("Kernel options are too long, 512 chars exceeded: %s" % k_args))
elif arch.startswith("s390"):
if len(k_args) > 895:
- raise(InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args)
+ raise((InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args))
elif len(k_args) > 2047:
- raise(InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args)
+ raise((InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args))
cmd = [ "/sbin/grubby",
"--add-kernel", self.safe_load(profile_data,'kernel_local'),
@@ -977,7 +977,7 @@ class Koan:
#---------------------------------------------------
def connect_fail(self):
- raise InfoException("Could not communicate with %s:%s" % (self.server, self.port))
+ raise(InfoException("Could not communicate with %s:%s" % (self.server, self.port)))
#---------------------------------------------------
@@ -991,7 +991,7 @@ class Koan:
traceback.print_exc()
self.connect_fail()
if data == {}:
- raise InfoException("No entry/entries found")
+ raise(InfoException("No entry/entries found"))
return data
#---------------------------------------------------
@@ -1060,7 +1060,7 @@ class Koan:
utils.urlgrab(kernel,kernel_save)
except:
traceback.print_exc()
- raise(InfoException, "error downloading files")
+ raise((InfoException, "error downloading files"))
profile_data['kernel_local'] = kernel_save
profile_data['initrd_local'] = initrd_save
@@ -1179,7 +1179,7 @@ class Koan:
elif can_poll == "qemu":
conn = libvirt.open("qemu:///system")
else:
- raise InfoException("Don't know how to poll this virt-type")
+ raise(InfoException("Don't know how to poll this virt-type"))
ct = 0
while True:
time.sleep(3)
@@ -1196,7 +1196,7 @@ class Koan:
utils.find_vm(conn, virtname).create()
return results
else:
- raise InfoException("internal error, bad virt state")
+ raise(InfoException("internal error, bad virt state"))
if virt_auto_boot:
if self.virt_type in [ "xenpv", "xenfv" ]:
@@ -1240,7 +1240,7 @@ class Koan:
uuid = None
creator = vmwwcreate.start_install
else:
- raise InfoException("Unspecified virt type: %s" % self.virt_type)
+ raise(InfoException("Unspecified virt type: %s" % self.virt_type))
return (uuid, creator, fullvirt, can_poll)
#---------------------------------------------------
@@ -1259,7 +1259,7 @@ class Koan:
if len(disks) == 0:
print("paths: ", paths)
print("sizes: ", sizes)
- raise InfoException("Disk configuration not resolvable!")
+ raise(InfoException("Disk configuration not resolvable!"))
return disks
#---------------------------------------------------
@@ -1462,13 +1462,13 @@ class Koan:
os.makedirs(os.path.dirname(location))
return location
else:
- raise(InfoException, "invalid location: %s" % location)
+ raise((InfoException, "invalid location: %s" % location))
elif location.startswith("/dev/"):
# partition
if os.path.exists(location):
return location
else:
- raise InfoException("virt path is not a valid block device")
+ raise(InfoException("virt path is not a valid block device"))
else:
# it's a volume group, verify that it exists
args = "vgs -o vg_name"
@@ -1477,7 +1477,7 @@ class Koan:
print(vgnames)
if vgnames.find(location) == -1:
- raise InfoException("The volume group [%s] does not exist." % location)
+ raise(InfoException("The volume group [%s] does not exist." % location))
# check free space
args = "LANG=C vgs --noheadings -o vg_free --units g %s" % location
@@ -1512,13 +1512,13 @@ class Koan:
print("%s" % args)
lv_create = sub_process.call(args, shell=True)
if lv_create != 0:
- raise InfoException("LVM creation failed")
+ raise(InfoException("LVM creation failed"))
# return partition location
return "/dev/%s/%s" % (location,name)
else:
- raise InfoException("volume group needs %s GB free space." % virt_size)
+ raise(InfoException("volume group needs %s GB free space." % virt_size))
def randomUUID(self):
diff --git a/koan/qcreate.py b/koan/qcreate.py
index 73b6abb..e41a532 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -38,7 +38,7 @@ def start_install(*args, **kwargs):
try:
import libvirt
except:
- raise app.InfoException("package libvirt is required for installing virtual guests")
+ raise(app.InfoException("package libvirt is required for installing virtual guests"))
conn = libvirt.openReadOnly(None)
# See http://libvirt.org/formatcaps.html
capabilities = parseString(conn.getCapabilities())
diff --git a/koan/register.py b/koan/register.py
index 8ce7db3..0a066f1 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -124,7 +124,7 @@ class Register:
# not really required, but probably best that ordinary users don't try
# to run this not knowing what it does.
if os.getuid() != 0:
- raise InfoException("root access is required to register")
+ raise(InfoException("root access is required to register"))
print("- preparing to koan home")
self.conn = connect_to_server(self.server, self.port)
@@ -144,12 +144,12 @@ class Register:
hostname = ""
sysname = str(time.time())
else:
- raise InfoException("must specify --fqdn, could not discover")
+ raise(InfoException("must specify --fqdn, could not discover"))
if sysname == "":
sysname = hostname
if self.profile == "":
- raise InfoException("must specify --profile")
+ raise(InfoException("must specify --profile"))
# we'll do a profile check here just to avoid some log noise on the remote end.
# network duplication checks and profile checks also happen on the remote end.
@@ -166,7 +166,7 @@ class Register:
reg_info['hostname'] = hostname
if not matched_profile:
- raise InfoException("no such remote profile, see 'koan --list-profiles'")
+ raise(InfoException("no such remote profile, see 'koan --list-profiles'") )
if not self.batch:
self.conn.register_new_system(reg_info)
diff --git a/koan/utils.py b/koan/utils.py
index 607db1f..b88ba94 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -92,7 +92,7 @@ def urlread(url):
"""
print("- reading URL: %s" % url)
if url is None or url == "":
- raise InfoException("invalid URL: %s" % url)
+ raise(InfoException("invalid URL: %s" % url))
elif url[0:3] == "nfs":
try:
@@ -110,7 +110,7 @@ def urlread(url):
return data
except:
traceback.print_exc()
- raise(InfoException, "Couldn't mount and read URL: %s" % url)
+ raise((InfoException, "Couldn't mount and read URL: %s" % url))
elif url[0:4] == "http":
try:
@@ -120,7 +120,7 @@ def urlread(url):
return data
except:
traceback.print_exc()
- raise(InfoException, "Couldn't download: %s" % url)
+ raise((InfoException, "Couldn't download: %s" % url))
elif url[0:4] == "file":
try:
fd = open(url[5:])
@@ -128,10 +128,10 @@ def urlread(url):
fd.close()
return data
except:
- raise InfoException("Couldn't read file from URL: %s" % url)
+ raise(InfoException("Couldn't read file from URL: %s" % url))
else:
- raise InfoException("Unhandled URL protocol: %s" % url)
+ raise(InfoException("Unhandled URL protocol: %s" % url))
def urlgrab(url,saveto):
"""
@@ -150,7 +150,7 @@ def subprocess_call(cmd,ignore_rc=0):
print("- %s" % cmd)
rc = sub_process.call(cmd)
if rc != 0 and not ignore_rc:
- raise InfoException("command failed (%s)" % rc)
+ raise(InfoException("command failed (%s)" % rc))
return rc
def subprocess_get_response(cmd, ignore_rc=False):
@@ -165,7 +165,7 @@ def subprocess_get_response(cmd, ignore_rc=False):
result = result.strip()
rc = p.poll()
if not ignore_rc and rc != 0:
- raise InfoException("command failed (%s)" % rc)
+ raise(InfoException("command failed (%s)" % rc))
return rc, result
def input_string_or_hash(options,delim=None,allow_multiples=True):
@@ -178,7 +178,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
if options is None:
return {}
elif type(options) == list:
- raise InfoException("No idea what to do with list: %s" % options)
+ raise(InfoException("No idea what to do with list: %s" % options))
elif type(options) == type(""):
new_dict = {}
tokens = options.split(delim)
@@ -215,7 +215,7 @@ def input_string_or_hash(options,delim=None,allow_multiples=True):
options.pop('',None)
return options
else:
- raise InfoException("invalid input type: %s" % type(options))
+ raise(InfoException("invalid input type: %s" % type(options)))
def hash_to_string(hash):
"""
@@ -255,7 +255,7 @@ def nfsmount(input_path):
rc = sub_process.call(mount_cmd)
if not rc == 0:
shutil.rmtree(tempdir, ignore_errors=True)
- raise InfoException("nfs mount failed: %s" % dirpath)
+ raise(InfoException("nfs mount failed: %s" % dirpath))
# NOTE: option for a blocking install might be nice, so we could do this
# automatically, if supported by virt-install
print("after install completes, you may unmount and delete %s" % tempdir)
@@ -290,7 +290,7 @@ def find_vm(conn, vmid):
if vm.name() == vmid:
return vm
- raise InfoException("koan could not find the VM to watch: %s" % vmid)
+ raise(InfoException("koan could not find the VM to watch: %s" % vmid))
def get_vm_state(conn, vmid):
"""
@@ -335,7 +335,7 @@ def os_release():
return (make,float(t))
except ValueError:
pass
- raise InfoException("failed to detect local OS version from /etc/redhat-release")
+ raise(InfoException("failed to detect local OS version from /etc/redhat-release"))
elif check_dist() == "debian":
fd = open("/etc/debian_version")
@@ -429,7 +429,7 @@ def connect_to_server(server=None,port=None):
if server is None:
server = os.environ.get("COBBLER_SERVER","")
if server == "":
- raise InfoException("--server must be specified")
+ raise(InfoException("--server must be specified"))
if port is None:
port = 25151
@@ -445,7 +445,7 @@ def connect_to_server(server=None,port=None):
server = __try_connect(url)
if server is not None:
return server
- raise InfoException ("Could not find Cobbler.")
+ raise(InfoException ("Could not find Cobbler."))
def create_xendomains_symlink(name):
"""
@@ -459,7 +459,7 @@ def create_xendomains_symlink(name):
if os.path.exists(src) and os.access(os.path.dirname(dst), os.W_OK):
os.symlink(src, dst)
else:
- raise InfoException("Could not create /etc/xen/auto/%s symlink. Please check write permissions and ownership" % name)
+ raise(InfoException("Could not create /etc/xen/auto/%s symlink. Please check write permissions and ownership" % name))
def libvirt_enable_autostart(domain_name):
import libvirt
@@ -469,10 +469,10 @@ def libvirt_enable_autostart(domain_name):
domain = conn.lookupByName(domain_name)
domain.setAutostart(1)
except:
- raise InfoException("libvirt could not find domain %s" % domain_name)
+ raise(InfoException("libvirt could not find domain %s" % domain_name))
if not domain.autostart:
- raise InfoException("Could not enable autostart on domain %s." % domain_name)
+ raise(InfoException("Could not enable autostart on domain %s." % domain_name))
def make_floppy(kickstart):
@@ -484,14 +484,14 @@ def make_floppy(kickstart):
print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
- raise InfoException("dd failed")
+ raise(InfoException("dd failed"))
# vfatify
cmd = "mkdosfs %s" % floppy_path
print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
- raise InfoException("mkdosfs failed")
+ raise(InfoException("mkdosfs failed"))
# mount the floppy
mount_path = tempfile.mkdtemp(suffix=".mnt", prefix='tmp', dir="/tmp")
@@ -499,7 +499,7 @@ def make_floppy(kickstart):
print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
- raise InfoException("mount failed")
+ raise(InfoException("mount failed"))
# download the kickstart file onto the mounted floppy
print("- downloading %s" % kickstart)
@@ -511,7 +511,7 @@ def make_floppy(kickstart):
print("- %s" % cmd)
rc = os.system(cmd)
if not rc == 0:
- raise InfoException("umount failed")
+ raise(InfoException("umount failed"))
# return the path to the completed disk image to pass to virt-install
return floppy_path
diff --git a/koan/virtinstall.py b/koan/virtinstall.py
index de2a670..fbafb43 100644
--- a/koan/virtinstall.py
+++ b/koan/virtinstall.py
@@ -90,7 +90,7 @@ def _sanitize_disks(disks):
if d[1] != 0 or d[0].startswith("/dev"):
ret.append((d[0], d[1], driver_type))
else:
- raise app.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
+ raise(app.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero"))
return ret
@@ -127,7 +127,7 @@ def _sanitize_nics(nics, bridge, profile_bridge, network_count):
intf_bridge = intf["virt_bridge"]
if intf_bridge == "":
if profile_bridge == "":
- raise app.InfoException("virt-bridge setting is not defined in cobbler")
+ raise(app.InfoException("virt-bridge setting is not defined in cobbler"))
intf_bridge = profile_bridge
else:
@@ -230,12 +230,12 @@ def build_commandline(uri,
if is_import:
importpath = profile_data.get("file")
if not importpath:
- raise app.InfoException("Profile 'file' required for image "
- "install")
+ raise(app.InfoException("Profile 'file' required for image "
+ "install"))
elif "file" in profile_data:
if is_xen:
- raise app.InfoException("Xen does not work with --image yet")
+ raise(app.InfoException("Xen does not work with --image yet"))
# this is an image based installation
input_path = profile_data["file"]
@@ -256,7 +256,7 @@ def build_commandline(uri,
elif is_qemu or is_xen:
# images don't need to source this
if not "install_tree" in profile_data:
- raise app.InfoException("Cannot find install source in kickstart file, aborting.")
+ raise(app.InfoException("Cannot find install source in kickstart file, aborting."))
if not profile_data["install_tree"].endswith("/"):
profile_data["install_tree"] = profile_data["install_tree"] + "/"
@@ -277,7 +277,7 @@ def build_commandline(uri,
bridge = profile_data["virt_bridge"]
if bridge == "":
- raise app.InfoException("virt-bridge setting is not defined in cobbler")
+ raise(app.InfoException("virt-bridge setting is not defined in cobbler"))
nics = [(bridge, None)]
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index 1b90a27..3e94e1c 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -82,7 +82,7 @@ def make_disk(disksize,image):
print("- %s" % cmd)
rc = os.system(cmd)
if rc != 0:
- raise VirtCreateException("command failed")
+ raise(VirtCreateException("command failed"))
def make_vmx(path,vmdk_image,image_name,mac_address,memory):
template_params = {
@@ -101,7 +101,7 @@ def register_vmx(vmx_file):
print("- %s" % cmd)
rc = os.system(cmd)
if rc!=0:
- raise VirtCreateException("vmware registration failed")
+ raise(VirtCreateException("vmware registration failed"))
def start_vm(vmx_file):
os.chmod(vmx_file, 0o755)
@@ -109,7 +109,7 @@ def start_vm(vmx_file):
print("- %s" % cmd)
rc = os.system(cmd)
if rc != 0:
- raise VirtCreateException("vm start failed")
+ raise(VirtCreateException("vm start failed"))
def start_install(name=None,
ram=None,
@@ -127,7 +127,7 @@ def start_install(name=None,
virt_auto_boot=False):
if "file" in profile_data:
- raise app.InfoException("vmware does not work with --image yet")
+ raise(app.InfoException("vmware does not work with --image yet"))
mac = None
if not "interfaces" in profile_data:
@@ -154,7 +154,7 @@ def start_install(name=None,
os.makedirs(VMX_DIR)
if len(disks) != 1:
- raise VirtCreateException("vmware support is limited to 1 virtual disk")
+ raise(VirtCreateException("vmware support is limited to 1 virtual disk"))
diskname = disks[0][0]
disksize = disks[0][1]
--
2.5.5

View File

@ -0,0 +1,518 @@
From 9d02d75f09b8e6612acb22eb0a9777df63397730 Mon Sep 17 00:00:00 2001
From: Jan Dobes <jdobes@redhat.com>
Date: Thu, 12 Oct 2017 10:20:54 +0200
Subject: [PATCH 18/18] adapt setup.py for both py2 and py3
(cherry picked from commit 84ef184850f29638f07d2540a9ec35b4fb6c5095)
Conflicts:
setup.py
---
setup.py | 376 ++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 203 insertions(+), 173 deletions(-)
diff --git a/setup.py b/setup.py
index 045abd7..38ee962 100644
--- a/setup.py
+++ b/setup.py
@@ -4,12 +4,13 @@ import sys
import os.path
from distutils.core import setup, Extension
import string
-import yaml # PyYAML
+if sys.version_info[0] == 2:
+ import yaml # PyYAML
+ import Cheetah.Template as Template
try:
import subprocess
except:
import cobbler.sub_process as subprocess
-import Cheetah.Template as Template
import time
VERSION = "2.0.7"
@@ -67,63 +68,64 @@ def gen_config():
templatify(MODULES_TEMPLATE, defaults, os.path.join(OUTPUT_DIR, "modules.conf"))
templatify(SETTINGS_TEMPLATE, defaults, os.path.join(OUTPUT_DIR, "settings"))
-if __name__ == "__main__":
+
+def py2_setup():
gen_build_version()
gen_config()
# etc configs
- etcpath = "/etc/cobbler"
- initpath = "/etc/init.d"
- rotpath = "/etc/logrotate.d"
- powerpath = etcpath + "/power"
- pxepath = etcpath + "/pxe"
- reppath = etcpath + "/reporting"
- zonepath = etcpath + "/zone_templates"
+ etcpath = "/etc/cobbler"
+ initpath = "/etc/init.d"
+ rotpath = "/etc/logrotate.d"
+ powerpath = etcpath + "/power"
+ pxepath = etcpath + "/pxe"
+ reppath = etcpath + "/reporting"
+ zonepath = etcpath + "/zone_templates"
# lib paths
- libpath = "/var/lib/cobbler"
- backpath = libpath + "/backup"
- trigpath = libpath + "/triggers"
+ libpath = "/var/lib/cobbler"
+ backpath = libpath + "/backup"
+ trigpath = libpath + "/triggers"
snippetpath = libpath + "/snippets"
- kickpath = libpath + "/kickstarts"
- dbpath = libpath + "/config"
- loadpath = libpath + "/loaders"
+ kickpath = libpath + "/kickstarts"
+ dbpath = libpath + "/config"
+ loadpath = libpath + "/loaders"
# share paths
- sharepath = "/usr/share/cobbler"
- itemplates = sharepath + "/installer_templates"
- wwwtmpl = sharepath + "/webui_templates"
- manpath = "share/man/man1"
- spool_koan = "/var/spool/koan"
+ sharepath = "/usr/share/cobbler"
+ itemplates = sharepath + "/installer_templates"
+ wwwtmpl = sharepath + "/webui_templates"
+ manpath = "share/man/man1"
+ spool_koan = "/var/spool/koan"
# www paths
- wwwpath = "/var/www/cobbler"
+ wwwpath = "/var/www/cobbler"
if os.path.exists("/etc/SuSE-release"):
- wwwconf = "/etc/apache2/conf.d"
+ wwwconf = "/etc/apache2/conf.d"
elif os.path.exists("/etc/debian_version"):
- wwwconf = "/etc/apache2/conf.d"
+ wwwconf = "/etc/apache2/conf.d"
else:
- wwwconf = "/etc/httpd/conf.d"
+ wwwconf = "/etc/httpd/conf.d"
- wwwcon = "/var/www/cobbler_webui_content"
+ wwwcon = "/var/www/cobbler_webui_content"
vw_localmirror = wwwpath + "/localmirror"
- vw_kickstarts = wwwpath + "/kickstarts"
- vw_kickstarts_sys = wwwpath + "/kickstarts_sys"
+ vw_kickstarts = wwwpath + "/kickstarts"
+ vw_kickstarts_sys = wwwpath + "/kickstarts_sys"
vw_repomirror = wwwpath + "/repo_mirror"
- vw_ksmirror = wwwpath + "/ks_mirror"
- vw_ksmirrorc = wwwpath + "/ks_mirror/config"
- vw_images = wwwpath + "/images"
- vw_distros = wwwpath + "/distros"
- vw_systems = wwwpath + "/systems"
- vw_profiles = wwwpath + "/profiles"
- vw_links = wwwpath + "/links"
- vw_aux = wwwpath + "/aux"
- modpython = wwwpath + "/web"
- modwsgisvc = wwwpath + "/svc"
- modpythonsvc = modwsgisvc
+ vw_ksmirror = wwwpath + "/ks_mirror"
+ vw_ksmirrorc = wwwpath + "/ks_mirror/config"
+ vw_images = wwwpath + "/images"
+ vw_distros = wwwpath + "/distros"
+ vw_systems = wwwpath + "/systems"
+ vw_profiles = wwwpath + "/profiles"
+ vw_links = wwwpath + "/links"
+ vw_aux = wwwpath + "/aux"
+ modpython = wwwpath + "/web"
+ modwsgisvc = wwwpath + "/svc"
+ modpythonsvc = modwsgisvc
# log paths
- logpath = "/var/log/cobbler"
+ logpath = "/var/log/cobbler"
logpath2 = logpath + "/kicklog"
logpath3 = logpath + "/syslog"
logpath4 = "/var/log/httpd/cobbler"
@@ -132,123 +134,123 @@ if __name__ == "__main__":
logpath7 = logpath + "/tasks"
# django content
- dj_config = "/etc/httpd/conf.d/"
+ dj_config = "/etc/httpd/conf.d/"
dj_templates = "/usr/share/cobbler/web/cobbler_web/templates"
- dj_webui = "/usr/share/cobbler/web/cobbler_web"
- dj_webui2 = "/usr/share/cobbler/web/cobbler_web/templatetags"
- dj_webui_proj= "/usr/share/cobbler/web"
- dj_sessions = "/var/lib/cobbler/webui_sessions"
- dj_js = "/var/www/cobbler_webui_content/"
+ dj_webui = "/usr/share/cobbler/web/cobbler_web"
+ dj_webui2 = "/usr/share/cobbler/web/cobbler_web/templatetags"
+ dj_webui_proj = "/usr/share/cobbler/web"
+ dj_sessions = "/var/lib/cobbler/webui_sessions"
+ dj_js = "/var/www/cobbler_webui_content/"
setup(
name="cobbler",
- version = VERSION,
- author = "Michael DeHaan",
- author_email = "mdehaan@redhat.com",
- url = "http://fedorahosted.org/cobbler/",
- license = "GPL",
- packages = [
+ version=VERSION,
+ author="Michael DeHaan",
+ author_email="mdehaan@redhat.com",
+ url="http://fedorahosted.org/cobbler/",
+ license="GPL",
+ packages= [
"cobbler",
"cobbler/modules",
"koan"
],
- scripts = [
+ scripts=[
"scripts/cobbler",
"scripts/cobblerd",
"scripts/cobbler-ext-nodes",
"scripts/koan",
"scripts/cobbler-register"
],
- data_files = [
+ data_files=[
(modpythonsvc, ['scripts/services.py']),
- (modwsgisvc, ['scripts/services.wsgi']),
+ (modwsgisvc, ['scripts/services.wsgi']),
# miscellaneous config files
- (rotpath, ['config/cobblerd_rotate']),
- (wwwconf, ['config/cobbler.conf']),
- (wwwconf, ['config/cobbler_wsgi.conf']),
- (libpath, ['config/cobbler_hosts']),
- (etcpath, ['config/modules.conf']),
- (etcpath, ['config/users.digest']),
- (etcpath, ['config/rsync.exclude']),
- (etcpath, ['config/users.conf']),
- (etcpath, ['config/cheetah_macros']),
+ (rotpath, ['config/cobblerd_rotate']),
+ (wwwconf, ['config/cobbler.conf']),
+ (wwwconf, ['config/cobbler_wsgi.conf']),
+ (libpath, ['config/cobbler_hosts']),
+ (etcpath, ['config/modules.conf']),
+ (etcpath, ['config/users.digest']),
+ (etcpath, ['config/rsync.exclude']),
+ (etcpath, ['config/users.conf']),
+ (etcpath, ['config/cheetah_macros']),
(initpath, ['config/cobblerd']),
- (etcpath, ['config/settings']),
+ (etcpath, ['config/settings']),
# django webui content
- (dj_config, [ 'config/cobbler_web.conf' ]),
- (dj_templates, [ 'web/cobbler_web/templates/blank.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/empty.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/enoaccess.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/error_page.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/header.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/index.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/item.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/ksfile_edit.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/ksfile_list.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/snippet_edit.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/snippet_list.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/master.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/message.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/paginate.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/settings.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/generic_edit.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/generic_list.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/generic_delete.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/generic_rename.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/events.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/eventlog.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/import.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/task_created.tmpl' ]),
- (dj_templates, [ 'web/cobbler_web/templates/check.tmpl' ]),
+ (dj_config, ['config/cobbler_web.conf']),
+ (dj_templates, ['web/cobbler_web/templates/blank.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/empty.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/enoaccess.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/error_page.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/header.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/index.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/item.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/ksfile_edit.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/ksfile_list.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/snippet_edit.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/snippet_list.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/master.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/message.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/paginate.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/settings.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/generic_edit.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/generic_list.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/generic_delete.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/generic_rename.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/events.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/eventlog.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/import.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/task_created.tmpl']),
+ (dj_templates, ['web/cobbler_web/templates/check.tmpl']),
# django code, private to cobbler-web application
- (dj_webui, [ 'web/cobbler_web/__init__.py' ]),
- (dj_webui_proj, [ 'web/__init__.py' ]),
- (dj_webui_proj, [ 'web/urls.py' ]),
- (dj_webui_proj, [ 'web/manage.py' ]),
- (dj_webui_proj, [ 'web/settings.py' ]),
- (dj_webui, [ 'web/cobbler_web/urls.py' ]),
- (dj_webui, [ 'web/cobbler_web/views.py' ]),
- (dj_webui2, [ 'web/cobbler_web/templatetags/site.py' ]),
- (dj_webui2, [ 'web/cobbler_web/templatetags/__init__.py' ]),
- (dj_sessions, []),
+ (dj_webui, ['web/cobbler_web/__init__.py']),
+ (dj_webui_proj, ['web/__init__.py']),
+ (dj_webui_proj, ['web/urls.py']),
+ (dj_webui_proj, ['web/manage.py']),
+ (dj_webui_proj, ['web/settings.py']),
+ (dj_webui, ['web/cobbler_web/urls.py']),
+ (dj_webui, ['web/cobbler_web/views.py']),
+ (dj_webui2, ['web/cobbler_web/templatetags/site.py']),
+ (dj_webui2, ['web/cobbler_web/templatetags/__init__.py']),
+ (dj_sessions, []),
# backups for upgrades
(backpath, []),
# for --version support across distros
- (libpath, ['config/version']),
+ (libpath, ['config/version']),
# bootloaders and syslinux support files
# we only package zpxe.rexx because it's source
# user supplies the others
- (loadpath, ['scripts/zpxe.rexx']),
+ (loadpath, ['scripts/zpxe.rexx']),
# database/serializer
- (dbpath + "/distros.d", []),
+ (dbpath + "/distros.d", []),
(dbpath + "/profiles.d", []),
- (dbpath + "/systems.d", []),
- (dbpath + "/repos.d", []),
- (dbpath + "/images.d", []),
+ (dbpath + "/systems.d", []),
+ (dbpath + "/repos.d", []),
+ (dbpath + "/images.d", []),
# sample kickstart files
- (kickpath, ['kickstarts/legacy.ks']),
- (kickpath, ['kickstarts/sample.ks']),
- (kickpath, ['kickstarts/sample_end.ks']),
- (kickpath, ['kickstarts/default.ks']),
- (kickpath, ['kickstarts/pxerescue.ks']),
+ (kickpath, ['kickstarts/legacy.ks']),
+ (kickpath, ['kickstarts/sample.ks']),
+ (kickpath, ['kickstarts/sample_end.ks']),
+ (kickpath, ['kickstarts/default.ks']),
+ (kickpath, ['kickstarts/pxerescue.ks']),
# seed files for debian
- (kickpath, ['kickstarts/sample.seed']),
+ (kickpath, ['kickstarts/sample.seed']),
# templates for DHCP, DNS, TFTP, RSYNC
- (etcpath, ['templates/dhcp.template']),
- (etcpath, ['templates/dnsmasq.template']),
- (etcpath, ['templates/named.template']),
- (etcpath, ['templates/zone.template']),
- (etcpath, ['templates/rsync.template']),
+ (etcpath, ['templates/dhcp.template']),
+ (etcpath, ['templates/dnsmasq.template']),
+ (etcpath, ['templates/named.template']),
+ (etcpath, ['templates/zone.template']),
+ (etcpath, ['templates/rsync.template']),
# templates for netboot configs
(pxepath, ['templates/pxedefault.template']),
@@ -283,7 +285,7 @@ if __name__ == "__main__":
(powerpath, ['templates/power_virsh.template']),
# templates for reporting
- (reppath, ['templates/build_report_email.template']),
+ (reppath, ['templates/build_report_email.template']),
# templates for setup
(itemplates, ['installer_templates/modules.conf.template']),
@@ -313,12 +315,12 @@ if __name__ == "__main__":
(snippetpath, ['snippets/log_ks_post']),
# documentation
- (manpath, ['docs/cobbler.1.gz']),
- (manpath, ['docs/koan.1.gz']),
- (manpath, ['docs/cobbler-register.1.gz']),
+ (manpath, ['docs/cobbler.1.gz']),
+ (manpath, ['docs/koan.1.gz']),
+ (manpath, ['docs/cobbler-register.1.gz']),
# logfiles
- (logpath, []),
+ (logpath, []),
(logpath2, []),
(logpath3, []),
(logpath4, []),
@@ -330,72 +332,100 @@ if __name__ == "__main__":
(spool_koan, []),
# web page directories that we own
- (vw_localmirror, []),
- (vw_kickstarts, []),
+ (vw_localmirror, []),
+ (vw_kickstarts, []),
(vw_kickstarts_sys, []),
- (vw_repomirror, []),
- (vw_ksmirror, []),
- (vw_ksmirrorc, []),
- (vw_distros, []),
- (vw_images, []),
- (vw_systems, []),
- (vw_profiles, []),
- (vw_links, []),
- (vw_aux, []),
+ (vw_repomirror, []),
+ (vw_ksmirror, []),
+ (vw_ksmirrorc, []),
+ (vw_distros, []),
+ (vw_images, []),
+ (vw_systems, []),
+ (vw_profiles, []),
+ (vw_links, []),
+ (vw_aux, []),
# zone-specific templates directory
- (zonepath, []),
+ (zonepath, []),
# Web UI templates for object viewing & modification
# FIXME: other templates to add as they are created.
# slurp in whole directory?
# Web UI support files
- (wwwcon, ['web/content/style.css']),
- (wwwcon, ['web/content/logo-cobbler.png']),
- (modpython, ['web/content/index.html']),
- (wwwpath + "/pub", []),
- (dj_js, ['web/content/cobbler.js']),
+ (wwwcon, ['web/content/style.css']),
+ (wwwcon, ['web/content/logo-cobbler.png']),
+ (modpython, ['web/content/index.html']),
+ (wwwpath + "/pub", []),
+ (dj_js, ['web/content/cobbler.js']),
# FIXME: someday Fedora/EPEL will package these and then we should not embed them then.
- (dj_js, ['web/content/jquery-1.3.2.js']),
- (dj_js, ['web/content/jquery-1.3.2.min.js']),
- (dj_js, ['web/content/jsGrowl_jquery.js']),
- (dj_js, ['web/content/jsGrowl.js']),
- (dj_js, ['web/content/jsgrowl_close.png']),
- (dj_js, ['web/content/jsgrowl_corners.png']),
- (dj_js, ['web/content/jsgrowl_middle_hover.png']),
- (dj_js, ['web/content/jsgrowl_corners_hover.png']),
- (dj_js, ['web/content/jsgrowl_side_hover.png']),
- (dj_js, ['web/content/jsGrowl.css']),
+ (dj_js, ['web/content/jquery-1.3.2.js']),
+ (dj_js, ['web/content/jquery-1.3.2.min.js']),
+ (dj_js, ['web/content/jsGrowl_jquery.js']),
+ (dj_js, ['web/content/jsGrowl.js']),
+ (dj_js, ['web/content/jsgrowl_close.png']),
+ (dj_js, ['web/content/jsgrowl_corners.png']),
+ (dj_js, ['web/content/jsgrowl_middle_hover.png']),
+ (dj_js, ['web/content/jsgrowl_corners_hover.png']),
+ (dj_js, ['web/content/jsgrowl_side_hover.png']),
+ (dj_js, ['web/content/jsGrowl.css']),
# Anamon script
- (vw_aux, ['aux/anamon', 'aux/anamon.init']),
+ (vw_aux, ['aux/anamon', 'aux/anamon.init']),
# Directories to hold cobbler triggers
- ("%s/add/distro/pre" % trigpath, []),
- ("%s/add/distro/post" % trigpath, []),
- ("%s/add/profile/pre" % trigpath, []),
- ("%s/add/profile/post" % trigpath, []),
- ("%s/add/system/pre" % trigpath, []),
- ("%s/add/system/post" % trigpath, []),
- ("%s/add/repo/pre" % trigpath, []),
- ("%s/add/repo/post" % trigpath, []),
- ("%s/delete/distro/pre" % trigpath, []),
- ("%s/delete/distro/post" % trigpath, []),
- ("%s/delete/profile/pre" % trigpath, []),
+ ("%s/add/distro/pre" % trigpath, []),
+ ("%s/add/distro/post" % trigpath, []),
+ ("%s/add/profile/pre" % trigpath, []),
+ ("%s/add/profile/post" % trigpath, []),
+ ("%s/add/system/pre" % trigpath, []),
+ ("%s/add/system/post" % trigpath, []),
+ ("%s/add/repo/pre" % trigpath, []),
+ ("%s/add/repo/post" % trigpath, []),
+ ("%s/delete/distro/pre" % trigpath, []),
+ ("%s/delete/distro/post" % trigpath, []),
+ ("%s/delete/profile/pre" % trigpath, []),
("%s/delete/profile/post" % trigpath, []),
- ("%s/delete/system/pre" % trigpath, []),
- ("%s/delete/system/post" % trigpath, []),
- ("%s/delete/repo/pre" % trigpath, []),
- ("%s/delete/repo/post" % trigpath, []),
- ("%s/delete/repo/post" % trigpath, []),
- ("%s/install/pre" % trigpath, []),
- ("%s/install/post" % trigpath, []),
- ("%s/sync/pre" % trigpath, []),
- ("%s/sync/post" % trigpath, []),
- ("%s/change" % trigpath, [])
+ ("%s/delete/system/pre" % trigpath, []),
+ ("%s/delete/system/post" % trigpath, []),
+ ("%s/delete/repo/pre" % trigpath, []),
+ ("%s/delete/repo/post" % trigpath, []),
+ ("%s/delete/repo/post" % trigpath, []),
+ ("%s/install/pre" % trigpath, []),
+ ("%s/install/post" % trigpath, []),
+ ("%s/sync/pre" % trigpath, []),
+ ("%s/sync/post" % trigpath, []),
+ ("%s/change" % trigpath, [])
],
- description = SHORT_DESC,
- long_description = LONG_DESC
+ description=SHORT_DESC,
+ long_description=LONG_DESC
)
+
+def py3_setup():
+ # Only koan is ready for Python 3
+ setup(
+ name='koan',
+ version=VERSION,
+ description=SHORT_DESC,
+ long_description=LONG_DESC,
+ author='Jan Dobes',
+ author_email='jdobes@redhat.com',
+ url='http://www.github.com/spacewalkproject',
+ packages=['koan'],
+ license='GPLv2',
+ scripts=[
+ "scripts/koan",
+ "scripts/cobbler-register"
+ ],
+ )
+
+if __name__ == "__main__":
+ if sys.version_info[0] == 3:
+ py3_setup()
+ else:
+ py2_setup()
+
+
+
+
--
2.5.5

View File

@ -0,0 +1,19 @@
diff -rupN cobbler-2.0.11.old/cobbler/action_buildiso.py cobbler-2.0.11/cobbler/action_buildiso.py
--- cobbler-2.0.11.old/cobbler/action_buildiso.py 2015-06-11 18:48:59.000000000 +0200
+++ cobbler-2.0.11/cobbler/action_buildiso.py.new 2015-06-17 13:33:13.392123548 +0200
@@ -253,7 +253,14 @@ class BuildIso:
append_line = append_line + " gateway=%s" % data["gateway"]
if not exclude_dns and data.has_key("name_servers") and data["name_servers"]:
- append_line = append_line + " dns=%s\n" % ",".join(data["name_servers"])
+ version = dist.os_version
+ if dist.breed == "redhat" and (
+ (version.startswith("rhel") and version >= "rhel7") or
+ (version.startswith("fedora") and version >= "fedora17")
+ ):
+ append_line = append_line + " nameserver=%s\n" % " nameserver=".join(data["name_servers"])
+ else:
+ append_line = append_line + " dns=%s\n" % ",".join(data["name_servers"])
length=len(append_line)
if length > 254:

View File

@ -0,0 +1,135 @@
diff -rupN cobbler-2.0.7-orig/cobbler/action_buildiso.py cobbler-2.0.7/cobbler/action_buildiso.py
--- cobbler-2.0.7-orig/cobbler/action_buildiso.py 2015-09-07 08:32:49.197852179 -0400
+++ cobbler-2.0.7/cobbler/action_buildiso.py 2015-09-07 08:33:42.301458113 -0400
@@ -45,6 +45,9 @@ TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local
+"""
+
+LOCAL_HDD_HEADER = HEADER + """
LABEL local
MENU LABEL (local)
MENU DEFAULT
@@ -86,7 +89,7 @@ class BuildIso:
return str(self.distctr)
- def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None,force_server=None):
+ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None,force_server=None,no_local_hdd=None):
self.logger.info("copying kernels and initrds for profiles")
# copy all images in included profiles to images dir
for profile in self.api.profiles():
@@ -131,7 +134,11 @@ class BuildIso:
self.logger.info("generating a isolinux.cfg")
isolinuxcfg = os.path.join(isolinuxdir, "isolinux.cfg")
cfg = open(isolinuxcfg, "w+")
- cfg.write(HEADER) # fixme, use template
+ header_written = True
+ if not no_local_hdd:
+ cfg.write(LOCAL_HDD_HEADER) # fixme, use template
+ else:
+ header_written = False
self.logger.info("generating profile list")
#sort the profiles
@@ -156,6 +163,10 @@ class BuildIso:
data["server"] = force_server
distname = self.make_shorter(dist.name)
+ if not header_written:
+ cfg.write(HEADER.replace('local', profile.name))
+ header_written = True
+
cfg.write("\n")
cfg.write("LABEL %s\n" % profile.name)
cfg.write(" MENU LABEL %s\n" % profile.name)
@@ -197,7 +197,8 @@ class BuildIso:
if systems is not None:
self.logger.info("generating system list")
- cfg.write("\nMENU SEPARATOR\n")
+ if header_written:
+ cfg.write("\nMENU SEPARATOR\n")
#sort the systems
system_list = [system for system in self.systems]
@@ -222,6 +223,10 @@ class BuildIso:
data["server"] = force_server
distname = self.make_shorter(dist.name)
+ if not header_written:
+ cfg.write(HEADER.replace('local', system.name))
+ header_written = True
+
cfg.write("\n")
cfg.write("LABEL %s\n" % system.name)
cfg.write(" MENU LABEL %s\n" % system.name)
@@ -295,6 +300,9 @@ class BuildIso:
cfg.write(append_line)
+ if not header_written:
+ cfg.write(HEADER)
+
self.logger.info("done writing config")
cfg.write("\n")
cfg.write("MENU END\n")
@@ -375,7 +386,7 @@ class BuildIso:
return
- def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None,force_server=None):
+ def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None,force_server=None,no_local_hdd=None):
# the distro option is for stand-alone builds only
if not standalone and distro is not None:
@@ -446,7 +457,7 @@ class BuildIso:
if standalone:
self.generate_standalone_iso(imagesdir,isolinuxdir,distro,source)
else:
- self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns,force_server)
+ self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns,force_server,no_local_hdd)
# removed --quiet
cmd = "mkisofs -o %s -r -b isolinux/isolinux.bin -c isolinux/boot.cat" % iso
diff -rupN cobbler-2.0.7-orig/cobbler/api.py cobbler-2.0.7/cobbler/api.py
--- cobbler-2.0.7-orig/cobbler/api.py 2015-09-07 08:32:49.197852179 -0400
+++ cobbler-2.0.7/cobbler/api.py 2015-09-07 08:34:50.453735488 -0400
@@ -748,10 +748,10 @@ class BootAPI:
# ==========================================================================
- def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None, force_server=None):
+ def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None, force_server=None, no_local_hdd=None):
builder = action_buildiso.BuildIso(self._config, logger=logger)
return builder.run(
- iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns, force_server=force_server
+ iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns, force_server=force_server,no_local_hdd=no_local_hdd
)
# ==========================================================================
diff -rupN cobbler-2.0.7-orig/cobbler/cli.py cobbler-2.0.7/cobbler/cli.py
--- cobbler-2.0.7-orig/cobbler/cli.py 2015-09-07 08:32:49.198852228 -0400
+++ cobbler-2.0.7/cobbler/cli.py 2015-09-07 08:35:19.491150220 -0400
@@ -323,6 +323,7 @@ class BootCLI:
self.parser.add_option("--source", dest="source", help="(OPTIONAL) used with --standalone to specify a source for the distribution files")
self.parser.add_option("--exclude-dns", dest="exclude_dns", action="store_true", help="(OPTIONAL) prevents addition of name server addresses to the kernel boot options")
self.parser.add_option("--force-server", dest="force_server", help="(OPTIONAL) when kickstarting get required files from the given server instead of the default (may be given as IP Address or FQDN of the server). Useful when kickstarting through a proxy.")
+ self.parser.add_option("--no-local-hdd", dest="no_local_hdd", action="store_true", help="(OPTIONAL) removes option to boot from local hdd, keeps only kickstart profiles in boot menu")
(options, args) = self.parser.parse_args()
task_id = self.start_task("buildiso",options)
diff -rupN cobbler-2.0.7-orig/cobbler/remote.py cobbler-2.0.7/cobbler/remote.py
--- cobbler-2.0.7-orig/cobbler/remote.py 2015-09-07 08:32:49.198852228 -0400
+++ cobbler-2.0.7/cobbler/remote.py 2015-09-07 08:35:49.765636882 -0400
@@ -153,7 +153,8 @@ class CobblerXMLRPCInterface:
self.options.get("source",None),
self.options.get("exclude_dns",False),
self.logger,
- self.options.get("force_server",None)
+ self.options.get("force_server",None),
+ self.options.get("no_local_hdd",False)
)
def on_done(self):
if self.options.get("iso","") == "/var/www/cobbler/pub/generated.iso":

View File

@ -0,0 +1,17 @@
--- ./snippets/post_install_network_config 2013-05-13 16:18:57.855827751 +0200
+++ ./snippets/post_install_network_config 2013-05-13 16:19:20.707940757 +0200
@@ -204,13 +204,8 @@ echo "IPV6_DEFAULTGW=$ipv6_default_gatew
#end if
#end if
#else
- #if $ip == ""
- ## this interface has no IPv4 address set
-echo "BOOTPROTO=none" >> $devfile
- #else
- ## this is a DHCP interface, much less work to do
+ ## this is a DHCP interface, much less work to do
echo "BOOTPROTO=dhcp" >> $devfile
- #end if
#end if
#if $mtu != ""
echo "MTU=$mtu" >> $devfile

View File

@ -0,0 +1,222 @@
diff -rupN cobbler-2.0.7-orig/cobbler/action_buildiso.py cobbler-2.0.7-new/cobbler/action_buildiso.py
--- cobbler-2.0.7-orig/cobbler/action_buildiso.py 2013-05-22 15:00:28.213867934 -0400
+++ cobbler-2.0.7-new/cobbler/action_buildiso.py 2013-07-11 15:35:59.637378396 -0400
@@ -86,7 +86,7 @@ class BuildIso:
return str(self.distctr)
- def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None):
+ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None,force_server=None):
self.logger.info("copying kernels and initrds for profiles")
# copy all images in included profiles to images dir
for profile in self.api.profiles():
@@ -152,6 +152,8 @@ class BuildIso:
if dist.name.find("-xen") != -1:
continue
data = utils.blender(self.api, True, profile)
+ if force_server:
+ data["server"] = force_server
distname = self.make_shorter(dist.name)
cfg.write("\n")
@@ -164,6 +166,12 @@ class BuildIso:
data["server"],
profile.name
)
+ else:
+ if force_server:
+ # replace configured hostname with the forced one
+ data["kickstart"] = re.sub(r'://.*?/',
+ '://' + data["server"] + '/',
+ data["kickstart"])
append_line = " append initrd=%s.img" % distname
append_line = append_line + " ks=%s " % data["kickstart"]
@@ -199,6 +207,8 @@ class BuildIso:
if dist.name.find("-xen") != -1:
continue
data = utils.blender(self.api, True, system)
+ if force_server:
+ data["server"] = force_server
distname = self.make_shorter(dist.name)
cfg.write("\n")
@@ -211,6 +221,12 @@ class BuildIso:
data["server"],
system.name
)
+ else:
+ if force_server:
+ # replace configured hostname with the forced one
+ data["kickstart"] = re.sub(r'://.*?/',
+ '://' + data["server"] + '/',
+ data["kickstart"])
append_line = " append initrd=%s.img" % distname
append_line = append_line + " ks=%s" % data["kickstart"]
@@ -352,7 +368,7 @@ class BuildIso:
return
- def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None):
+ def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None,force_server=None):
# the distro option is for stand-alone builds only
if not standalone and distro is not None:
@@ -372,7 +388,7 @@ class BuildIso:
iso = "kickstart.iso"
if tempdir is None:
- tempdir = os.path.join(os.getcwd(), "buildiso")
+ tempdir = self.config.settings().buildisodir
else:
if not os.path.isdir(tempdir):
utils.die(self.logger,"The --tempdir specified is not a directory")
@@ -415,14 +431,15 @@ class BuildIso:
files = [ isolinuxbin, menu, chain ]
for f in files:
if not os.path.exists(f):
- utils.die(self.logger,"Required file not found: %s" % f)
+ self.logger.error("Required file not found: %s. Try 'yum install cobbler-loaders'." % f)
+ return False
else:
utils.copyfile(f, os.path.join(isolinuxdir, os.path.basename(f)), self.api)
if standalone:
self.generate_standalone_iso(imagesdir,isolinuxdir,distro,source)
else:
- self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns)
+ self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns,force_server)
# removed --quiet
cmd = "mkisofs -o %s -r -b isolinux/isolinux.bin -c isolinux/boot.cat" % iso
diff -rupN cobbler-2.0.7-orig/cobbler/action_check.py cobbler-2.0.7-new/cobbler/action_check.py
--- cobbler-2.0.7-orig/cobbler/action_check.py 2013-05-22 15:00:28.210867913 -0400
+++ cobbler-2.0.7-new/cobbler/action_check.py 2013-07-11 14:41:26.976177891 -0400
@@ -325,7 +325,7 @@ class BootCheck:
missing = True
if missing:
- 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.")
+ status.append("some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'yum install cobbler-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 'yum install cobbler-loaders' command is the easiest way to resolve these requirements.")
def check_tftpd_bin(self,status):
"""
diff -rupN cobbler-2.0.7-orig/cobbler/action_dlcontent.py cobbler-2.0.7-new/cobbler/action_dlcontent.py
--- cobbler-2.0.7-orig/cobbler/action_dlcontent.py 2013-05-22 15:00:28.209867906 -0400
+++ cobbler-2.0.7-new/cobbler/action_dlcontent.py 2013-07-11 14:41:26.976177891 -0400
@@ -39,36 +39,11 @@ class ContentDownloader:
def run(self,force=False):
"""
- Download bootloader content for all of the latest bootloaders, since the user
- has chosen to not supply their own. You may ask "why not get this from yum", though
- Fedora has no IA64 repo, for instance, and we also want this to be able to work on Debian and
- further do not want folks to have to install a cross compiler. For those that don't like this approach
- they can still source their cross-arch bootloader content manually.
+ This action used to download the bootloaders from fedorapeople.org,
+ however these files are now available from yum in the cobbler-loaders
+ package so you should use that instead.
"""
- content_server = "http://mdehaan.fedorapeople.org/loaders"
- dest = "/var/lib/cobbler/loaders"
-
- files = (
- ( "%s/README" % content_server, "%s/README" % dest ),
- ( "%s/COPYING.elilo" % content_server, "%s/COPYING.elilo" % dest ),
- ( "%s/COPYING.yaboot" % content_server, "%s/COPYING.yaboot" % dest),
- ( "%s/COPYING.syslinux" % content_server, "%s/COPYING.syslinux" % dest),
- ( "%s/elilo-3.8-ia64.efi" % content_server, "%s/elilo-ia64.efi" % dest ),
- ( "%s/yaboot-1.3.14-12" % content_server, "%s/yaboot" % dest),
- ( "%s/pxelinux.0-3.61" % content_server, "%s/pxelinux.0" % dest),
- ( "%s/menu.c32-3.61" % content_server, "%s/menu.c32" % dest),
- )
-
- self.logger.info("downloading content required to netboot all arches")
- for f in files:
- src = f[0]
- dst = f[1]
- if os.path.exists(dst) and not force:
- self.logger.info("path %s already exists, not overwriting existing content, use --force if you wish to update" % dst)
- continue
- self.logger.info("downloading %s to %s" % (src,dst))
- urlgrabber.urlgrab(src,dst)
-
- return True
+ self.logger.info("The 'cobbler get-loaders' command has been obsoleted with 'yum install cobbler-loaders' in this version of cobbler. Please use 'yum install cobbler-loaders' instead.")
+ return False
diff -rupN cobbler-2.0.7-orig/cobbler/api.py cobbler-2.0.7-new/cobbler/api.py
--- cobbler-2.0.7-orig/cobbler/api.py 2013-05-22 15:00:28.214867942 -0400
+++ cobbler-2.0.7-new/cobbler/api.py 2013-07-11 14:41:26.977177897 -0400
@@ -750,10 +750,10 @@ class BootAPI:
# ==========================================================================
- def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None):
+ def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None, force_server=None):
builder = action_buildiso.BuildIso(self._config, logger=logger)
return builder.run(
- iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns
+ iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns, force_server=force_server
)
# ==========================================================================
diff -rupN cobbler-2.0.7-orig/cobbler/cli.py cobbler-2.0.7-new/cobbler/cli.py
--- cobbler-2.0.7-orig/cobbler/cli.py 2013-05-22 15:00:28.212867927 -0400
+++ cobbler-2.0.7-new/cobbler/cli.py 2013-07-12 15:18:14.024502192 -0400
@@ -29,6 +29,7 @@ import time
import os
import utils
+import config
import module_loader
import item_distro
import item_profile
@@ -311,16 +312,17 @@ class BootCLI:
task_id = -1 # if assigned, we must tail the logfile
if action_name == "buildiso":
-
- defaultiso = os.path.join(os.getcwd(), "generated.iso")
- self.parser.add_option("--iso", dest="iso", default=defaultiso, help="(OPTIONAL) output ISO to this path")
+ buildisodir = config.Config(self).settings().buildisodir
+ defaultiso = os.path.join(buildisodir, "generated.iso")
+ self.parser.add_option("--iso", dest="iso", default=defaultiso, help="(OPTIONAL) output ISO to this path (must be writable by cobblerd)")
self.parser.add_option("--profiles", dest="profiles", help="(OPTIONAL) use these profiles only")
self.parser.add_option("--systems", dest="systems", help="(OPTIONAL) use these systems only")
- self.parser.add_option("--tempdir", dest="tempdir", help="(OPTIONAL) working directory")
+ self.parser.add_option("--tempdir", dest="tempdir", help="(OPTIONAL) temporary working directory (must be writable by cobblerd)")
self.parser.add_option("--distro", dest="distro", help="(OPTIONAL) used with --standalone to create a distro-based ISO including all associated profiles/systems")
self.parser.add_option("--standalone", dest="standalone", action="store_true", help="(OPTIONAL) creates a standalone ISO with all required distro files on it")
self.parser.add_option("--source", dest="source", help="(OPTIONAL) used with --standalone to specify a source for the distribution files")
self.parser.add_option("--exclude-dns", dest="exclude_dns", action="store_true", help="(OPTIONAL) prevents addition of name server addresses to the kernel boot options")
+ self.parser.add_option("--force-server", dest="force_server", help="(OPTIONAL) when kickstarting get required files from the given server instead of the default (may be given as IP Address or FQDN of the server). Useful when kickstarting through a proxy.")
(options, args) = self.parser.parse_args()
task_id = self.start_task("buildiso",options)
diff -rupN cobbler-2.0.7-orig/cobbler/remote.py cobbler-2.0.7-new/cobbler/remote.py
--- cobbler-2.0.7-orig/cobbler/remote.py 2013-05-22 15:00:28.212867927 -0400
+++ cobbler-2.0.7-new/cobbler/remote.py 2013-07-11 14:41:26.978177903 -0400
@@ -152,7 +152,8 @@ class CobblerXMLRPCInterface:
self.options.get("standalone",False),
self.options.get("source",None),
self.options.get("exclude_dns",False),
- self.logger
+ self.logger,
+ self.options.get("force_server",None)
)
def on_done(self):
if self.options.get("iso","") == "/var/www/cobbler/pub/generated.iso":
diff -rupN cobbler-2.0.7-orig/cobbler/settings.py cobbler-2.0.7-new/cobbler/settings.py
--- cobbler-2.0.7-orig/cobbler/settings.py 2013-05-22 15:00:28.212867927 -0400
+++ cobbler-2.0.7-new/cobbler/settings.py 2013-07-11 16:31:33.375946740 -0400
@@ -96,6 +96,7 @@ DEFAULTS = {
"template_remote_kickstarts" : 0,
"virt_auto_boot" : 0,
"webdir" : "/var/www/cobbler",
+ "buildisodir" : "/tmp/cobbler/buildiso",
"xmlrpc_port" : 25151,
"yum_post_install_mirror" : 1,
"createrepo_flags" : "-c cache -s sha",

View File

@ -0,0 +1,92 @@
From 51f0baf6c7e6ef042ce6fa7543b37b0d2d723ae0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msuchy@redhat.com>
Date: Fri, 23 Sep 2011 13:56:07 +0200
Subject: [PATCH] if hostname is not resolvable do not fail and use that
hostname
in commit 588756aa7aefc122310847d007becf3112647944 cobbler start using IP address in kickstart path due s390x
but in BZ 253274 we have example where hostname is not resolvable from the location where cobbler run.
But it is resolvable from location where client runs.
So if cobbler is unable to resolve hostname, do not fail and revert to behaviour prior 588756aa7aefc122310847d007becf3112647944.
Addressing:
Fri Sep 23 04:51:12 2011 - INFO | Exception occured: <class 'socket.gaierror'>
Fri Sep 23 04:51:12 2011 - INFO | Exception value: [Errno -2] Name or service
not known
Fri Sep 23 04:51:12 2011 - INFO | Exception Info:
File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 1759, in
_dispatch
return method_handle(*params)
File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 874, in
save_system
return self.save_item("system",object_id,token,editmode=editmode)
File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 866, in
save_item
rc = self.api.add_item(what,obj)
File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 394, in
add_item
return
self.get_items(what).add(ref,check_for_duplicate_names=check_for_duplicate_names,save=save,logger=logger)
File "/usr/lib/python2.6/site-packages/cobbler/collection.py", line 284, in
add
self.lite_sync.add_single_system(ref.name)
File "/usr/lib/python2.6/site-packages/cobbler/action_litesync.py", line
142, in add_single_system
self.sync.pxegen.write_all_system_files(system)
File "/usr/lib/python2.6/site-packages/cobbler/pxegen.py", line 295, in
write_all_system_files
self.write_pxe_file(f2,system,profile,distro,working_arch)
File "/usr/lib/python2.6/site-packages/cobbler/pxegen.py", line 566, in
write_pxe_file
ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
---
cobbler/pxegen.py | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py
index 889f363..32c8f01 100644
--- a/cobbler/pxegen.py
+++ b/cobbler/pxegen.py
@@ -209,8 +209,11 @@ class PXEGen:
blended = utils.blender(self.api, True, system)
self.templar.render(template_cf, blended, cf)
# FIXME: profiles also need this data!
- # FIXME: the _conf and _parm files are limited to 80 characters in length
- ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ # FIXME: the _conf and _parm files are limited to 80 characters in length
+ try:
+ ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ except socket.gaierror:
+ ipaddress = blended["http_server"]
kickstart_path = "http://%s/cblr/svc/op/ks/system/%s" % (ipaddress, system.name)
# gather default kernel_options and default kernel_options_s390x
kopts = blended.get("kernel_options","")
@@ -321,8 +324,11 @@ class PXEGen:
blended = utils.blender(self.api, True, profile)
self.templar.render(template_cf, blended, cf)
# FIXME: profiles also need this data!
- # FIXME: the _conf and _parm files are limited to 80 characters in length
- ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ # FIXME: the _conf and _parm files are limited to 80 characters in length
+ try:
+ ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ except socket.gaierror:
+ ipaddress = blended["http_server"]
kickstart_path = "http://%s/cblr/svc/op/ks/profile/%s" % (ipaddress, profile.name)
# gather default kernel_options and default kernel_options_s390x
kopts = blended.get("kernel_options","")
@@ -666,7 +672,10 @@ class PXEGen:
# FIXME: need to make shorter rewrite rules for these URLs
- ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ try:
+ ipaddress = socket.gethostbyname_ex(blended["http_server"])[2][0]
+ except socket.gaierror:
+ ipaddress = blended["http_server"]
if system is not None and kickstart_path.startswith("/"):
kickstart_path = "http://%s/cblr/svc/op/ks/system/%s" % (ipaddress, system.name)
elif kickstart_path.startswith("/"):
--
1.7.6.2

View File

@ -0,0 +1,53 @@
diff -rupN cobbler-2.0.7.old/cobbler/api.py cobbler-2.0.7/cobbler/api.py
--- cobbler-2.0.7.old/cobbler/api.py 2015-05-06 14:47:57.860206615 -0400
+++ cobbler-2.0.7/cobbler/api.py 2015-05-06 15:09:40.455772584 -0400
@@ -179,11 +179,9 @@ class BootAPI:
API instance, regardless of the serializer type.
"""
if not os.path.exists("/var/lib/cobbler/.mtime"):
- old = os.umask(0x777)
- fd = open("/var/lib/cobbler/.mtime","w")
- fd.write("0")
- fd.close()
- os.umask(old)
+ fd = os.open("/var/lib/cobbler/.mtime", os.O_CREAT|os.O_RDWR, 0200)
+ os.write(fd, "0")
+ os.close(fd)
return 0
fd = open("/var/lib/cobbler/.mtime")
data = fd.read().strip()
diff -rupN cobbler-2.0.7.old/cobbler/cobblerd.py cobbler-2.0.7/cobbler/cobblerd.py
--- cobbler-2.0.7.old/cobbler/cobblerd.py 2015-05-06 14:47:57.856206586 -0400
+++ cobbler-2.0.7/cobbler/cobblerd.py 2015-05-06 15:23:17.605662935 -0400
@@ -58,10 +58,9 @@ def regen_ss_file():
fd = open("/dev/urandom")
data = fd.read(512)
fd.close()
- fd = open("/var/lib/cobbler/web.ss","w+")
- fd.write(binascii.hexlify(data))
- fd.close()
- utils.os_system("chmod 700 /var/lib/cobbler/web.ss")
+ fd = os.open("/var/lib/cobbler/web.ss", os.O_CREAT|os.O_RDWR, 0600)
+ os.write(fd, binascii.hexlify(data))
+ os.close(fd)
utils.os_system("chown apache /var/lib/cobbler/web.ss")
return 1
diff -rupN cobbler-2.0.7.old/cobbler/serializer.py cobbler-2.0.7/cobbler/serializer.py
--- cobbler-2.0.7.old/cobbler/serializer.py 2015-05-06 14:47:57.858206601 -0400
+++ cobbler-2.0.7/cobbler/serializer.py 2015-05-06 15:24:31.318192455 -0400
@@ -64,11 +64,9 @@ def __release_lock(with_changes=False):
# this file is used to know when the last config change
# was made -- allowing the API to work more smoothly without
# a lot of unneccessary reloads.
- old = os.umask(0x777)
- fd = open("/var/lib/cobbler/.mtime","w")
- fd.write("%f" % time.time())
- fd.close()
- os.umask(old)
+ fd = os.open("/var/lib/cobbler/.mtime", os.O_CREAT|os.O_RDWR, 0200)
+ os.write(fd, "%f" % time.time())
+ os.close(fd)
if LOCK_ENABLED:
LOCK_HANDLE = open("/var/lib/cobbler/lock","r")
fcntl.flock(LOCK_HANDLE.fileno(), fcntl.LOCK_UN)

View File

@ -0,0 +1,68 @@
diff -ur cobbler.orig/scripts/services.py cobbler/scripts/services.py
--- cobbler.orig/scripts/services.py 2012-11-09 17:31:33.000000000 +0100
+++ cobbler/scripts/services.py 2012-11-09 17:31:51.000000000 +0100
@@ -86,7 +86,12 @@
mode = form.get('op','index')
func = getattr( cw, mode )
- content = func( **form )
+ try:
+ content = func( **form )
+ except xmlrpclib.Fault, (err):
+ req.status = apache.HTTP_INTERNAL_SERVER_ERROR
+ req.write(err.faultString)
+ return apache.OK
# apache.log_error("%s:%s ... %s" % (my_user, my_uri, str(form)))
req.content_type = "text/plain;charset=utf-8"
diff -ur cobbler.orig/scripts/services.wsgi cobbler/scripts/services.wsgi
--- cobbler.orig/scripts/services.wsgi 2012-11-09 17:31:33.000000000 +0100
+++ cobbler/scripts/services.wsgi 2012-11-09 17:31:58.000000000 +0100
@@ -21,6 +21,7 @@
"""
import yaml
import os
+import xmlrpclib
from cobbler.services import CobblerSvc
import cobbler.utils as utils
@@ -75,22 +76,26 @@
# Execute corresponding operation on the CobblerSvc object:
func = getattr( cw, mode )
- content = func( **form )
+ try:
+ content = func( **form )
- content = unicode(content).encode('utf-8')
- status = '200 OK'
+ content = unicode(content).encode('utf-8')
+ status = '200 OK'
+
+ if content.find("# *** ERROR ***") != -1:
+ status = '500 SERVER ERROR'
+ print("possible cheetah template error")
- if content.find("# *** ERROR ***") != -1:
+ # TODO: Not sure these strings are the right ones to look for...
+ elif content.find("# profile not found") != -1 or \
+ content.find("# system not found") != -1 or \
+ content.find("# object not found") != -1:
+ print("content not found: %s" % my_uri)
+ status = "404 NOT FOUND"
+ except xmlrpclib.Fault, (err):
status = '500 SERVER ERROR'
- print("possible cheetah template error")
-
- # TODO: Not sure these strings are the right ones to look for...
- elif content.find("# profile not found") != -1 or \
- content.find("# system not found") != -1 or \
- content.find("# object not found") != -1:
- print("content not found: %s" % my_uri)
- status = "404 NOT FOUND"
-
+ content = err.faultString
+
# req.content_type = "text/plain;charset=utf-8"
response_headers = [('Content-type', 'text/plain;charset=utf-8'),
('Content-Length', str(len(content)))]

View File

@ -0,0 +1,141 @@
diff -rupN cobbler-2.0.7-orig/cobbler/collection_distros.py cobbler-2.0.7/cobbler/collection_distros.py
--- cobbler-2.0.7-orig/cobbler/collection_distros.py 2013-10-21 14:11:29.327459462 -0400
+++ cobbler-2.0.7/cobbler/collection_distros.py 2013-10-22 08:22:48.727270516 -0400
@@ -68,7 +68,11 @@ class Distros(collection.Collection):
if with_sync:
lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
lite_sync.remove_single_distro(name)
- del self.listing[name]
+ self.lock.acquire()
+ try:
+ del self.listing[name]
+ finally:
+ self.lock.release()
self.config.serialize_delete(self, obj)
diff -rupN cobbler-2.0.7-orig/cobbler/collection_images.py cobbler-2.0.7/cobbler/collection_images.py
--- cobbler-2.0.7-orig/cobbler/collection_images.py 2013-10-21 14:11:29.327459462 -0400
+++ cobbler-2.0.7/cobbler/collection_images.py 2013-10-22 08:23:16.008462783 -0400
@@ -65,7 +65,11 @@ class Images(collection.Collection):
lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
lite_sync.remove_single_image(name)
- del self.listing[name]
+ self.lock.acquire()
+ try:
+ del self.listing[name]
+ finally:
+ self.lock.release()
self.config.serialize_delete(self, obj)
if with_delete:
diff -rupN cobbler-2.0.7-orig/cobbler/collection_profiles.py cobbler-2.0.7/cobbler/collection_profiles.py
--- cobbler-2.0.7-orig/cobbler/collection_profiles.py 2013-10-21 14:11:29.326459455 -0400
+++ cobbler-2.0.7/cobbler/collection_profiles.py 2013-10-22 08:35:28.586626217 -0400
@@ -68,7 +68,11 @@ class Profiles(collection.Collection):
if with_delete:
if with_triggers:
utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/profile/pre/*", [], logger)
- del self.listing[name]
+ self.lock.acquire()
+ try:
+ del self.listing[name]
+ finally:
+ self.lock.release()
self.config.serialize_delete(self, obj)
if with_delete:
if with_triggers:
diff -rupN cobbler-2.0.7-orig/cobbler/collection.py cobbler-2.0.7/cobbler/collection.py
--- cobbler-2.0.7-orig/cobbler/collection.py 2013-10-21 14:11:29.331459490 -0400
+++ cobbler-2.0.7/cobbler/collection.py 2013-10-22 08:32:46.137481152 -0400
@@ -26,6 +26,7 @@ import utils
import glob
import time
import random
+from threading import Lock
import action_litesync
import item_system
@@ -45,6 +46,7 @@ class Collection:
self.clear()
self.api = self.config.api
self.lite_sync = None
+ self.lock = Lock()
def factory_produce(self,config,seed_data):
"""
@@ -89,9 +91,13 @@ class Collection:
if len(kargs) == 1 and kargs.has_key("name") and not return_list:
return self.listing.get(kargs["name"].lower(), None)
- for (name, obj) in self.listing.iteritems():
- if obj.find_match(kargs, no_errors=no_errors):
- matches.append(obj)
+ self.lock.acquire()
+ try:
+ for (name, obj) in self.listing.iteritems():
+ if obj.find_match(kargs, no_errors=no_errors):
+ matches.append(obj)
+ finally:
+ self.lock.release()
if not return_list:
if len(matches) == 0:
@@ -266,14 +272,22 @@ class Collection:
if not save:
# don't need to run triggers, so add it already ...
- self.listing[ref.name.lower()] = ref
+ self.lock.acquire()
+ try:
+ self.listing[ref.name.lower()] = ref
+ finally:
+ self.lock.release()
# perform filesystem operations
if save:
# failure of a pre trigger will prevent the object from being added
if with_triggers:
utils.run_triggers(self.api, ref,"/var/lib/cobbler/triggers/add/%s/pre/*" % self.collection_type(), [], logger)
- self.listing[ref.name.lower()] = ref
+ self.lock.acquire()
+ try:
+ self.listing[ref.name.lower()] = ref
+ finally:
+ self.lock.release()
# save just this item if possible, if not, save
# the whole collection
diff -rupN cobbler-2.0.7-orig/cobbler/collection_repos.py cobbler-2.0.7/cobbler/collection_repos.py
--- cobbler-2.0.7-orig/cobbler/collection_repos.py 2013-10-21 14:11:29.324459441 -0400
+++ cobbler-2.0.7/cobbler/collection_repos.py 2013-10-22 08:24:23.448938085 -0400
@@ -58,7 +58,11 @@ class Repos(collection.Collection):
if with_triggers:
utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/pre/*", [], logger)
- del self.listing[name]
+ self.lock.acquire()
+ try:
+ del self.listing[name]
+ finally:
+ self.lock.release()
self.config.serialize_delete(self, obj)
if with_delete:
diff -rupN cobbler-2.0.7-orig/cobbler/collection_systems.py cobbler-2.0.7/cobbler/collection_systems.py
--- cobbler-2.0.7-orig/cobbler/collection_systems.py 2013-10-21 14:11:29.324459441 -0400
+++ cobbler-2.0.7/cobbler/collection_systems.py 2013-10-22 08:24:36.502030081 -0400
@@ -56,7 +56,11 @@ class Systems(collection.Collection):
if with_sync:
lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
lite_sync.remove_single_system(name)
- del self.listing[name]
+ self.lock.acquire()
+ try:
+ del self.listing[name]
+ finally:
+ self.lock.release()
self.config.serialize_delete(self, obj)
if with_delete:
if with_triggers:

View File

@ -0,0 +1,17 @@
--- scripts/cobblerd.orig 2013-06-18 14:12:00.328726666 +0200
+++ scripts/cobblerd 2013-06-18 14:12:19.784627599 +0200
@@ -50,10 +50,10 @@
print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
- #dev_null = file('/dev/null','rw')
- #os.dup2(dev_null.fileno(), sys.stdin.fileno())
- #os.dup2(dev_null.fileno(), sys.stdout.fileno())
- #os.dup2(dev_null.fileno(), sys.stderr.fileno())
+ dev_null = file('/dev/null','rw')
+ os.dup2(dev_null.fileno(), sys.stdin.fileno())
+ os.dup2(dev_null.fileno(), sys.stdout.fileno())
+ os.dup2(dev_null.fileno(), sys.stderr.fileno())
def main():
op = optparse.OptionParser()

View File

@ -0,0 +1,12 @@
diff -up cobbler/action_check.py.orig cobbler-2.0.7/cobbler/action_check.py
--- cobbler/action_check.py 2010-07-28 17:48:48.000000000 +0200
+++ cobbler/action_check.py 2011-05-25 11:26:10.000000000 +0200
@@ -51,7 +51,7 @@ class BootCheck:
status = []
self.checked_dist = utils.check_dist()
self.check_name(status)
- self.check_selinux(status)
+ # self.check_selinux(status)
if self.settings.manage_dhcp:
mode = self.config.api.get_sync().dhcp.what()
if mode == "isc":

View File

@ -0,0 +1,26 @@
--- cobbler/utils.py 2010-10-07 20:12:03.000000000 +0200
+++ cobbler/utils.py 2011-05-25 15:53:03.000000000 +0200
@@ -996,21 +996,8 @@
return True
def is_safe_to_hardlink(src,dst,api):
- (dev1, path1) = get_file_device_path(src)
- (dev2, path2) = get_file_device_path(dst)
- if dev1 != dev2:
- return False
- if dev1.find(":") != -1:
- # is remoted
- return False
- # note: this is very cobbler implementation specific!
- if not api.is_selinux_enabled():
- return True
- if _re_initrd.match(os.path.basename(path1)):
- return True
- if _re_kernel.match(os.path.basename(path1)):
- return True
- # we're dealing with SELinux and files that are not safe to chcon
+ # 568801: hardlinks ruin SELinux contexts because multiple
+ # paths match, avoid hardlinks
return False
def hashfile(fn, lcache=None, logger=None):

View File

@ -0,0 +1,76 @@
diff -rupN cobbler-2.0.7.old/cobbler/services.py cobbler-2.0.7/cobbler/services.py
--- cobbler-2.0.7.old/cobbler/services.py 2014-09-11 11:51:46.494164060 -0400
+++ cobbler-2.0.7/cobbler/services.py 2014-09-11 11:52:33.163499576 -0400
@@ -217,25 +217,18 @@ class CobblerSvc(object):
def findks(self,system=None,profile=None,**rest):
self.__xmlrpc_setup()
- serverseg = self.server.replace("http://","")
- serverseg = self.server.replace("/cobbler_api","")
-
name = "?"
- type = "system"
if system is not None:
- url = "%s/cblr/svc/op/ks/system/%s" % (serverseg, name)
+ url = "/cblr/svc/op/ks/system/%s" % (system.name)
elif profile is not None:
- url = "%s/cblr/svc/op/ks/profile/%s" % (serverseg, name)
+ url = "/cblr/svc/op/ks/profile/%s" % (profile.name)
else:
name = self.autodetect(**rest)
if name.startswith("FAILED"):
return "# autodetection %s" % name
- url = "%s/cblr/svc/op/ks/system/%s" % (serverseg, name)
+ url = "/cblr/svc/op/ks/system/%s" % (name)
- try:
- return urlgrabber.urlread(url)
- except:
- return "# kickstart retrieval failed (%s)" % url
+ return url + "# redirect"
def puppet(self,hostname=None,**rest):
self.__xmlrpc_setup()
diff -rupN cobbler-2.0.7.old/scripts/services.wsgi cobbler-2.0.7/scripts/services.wsgi
--- cobbler-2.0.7.old/scripts/services.wsgi 2014-09-11 11:51:46.500164103 -0400
+++ cobbler-2.0.7/scripts/services.wsgi 2014-09-11 11:52:33.163499576 -0400
@@ -56,7 +56,11 @@ def application(environ, start_response)
# This MAC header is set by anaconda during a kickstart booted with the
# kssendmac kernel option. The field will appear here as something
# like: eth0 XX:XX:XX:XX:XX:XX
- form["REMOTE_MAC"] = form.get("HTTP_X_RHN_PROVISIONING_MAC_0", None)
+ form["REMOTE_MAC"] = environ.get("HTTP_X_RHN_PROVISIONING_MAC_0", None)
+
+ # REMOTE_ADDR isn't a required wsgi attribute so it may be naive to assume
+ # it's always present in this context.
+ form["REMOTE_ADDR"] = environ.get("REMOTE_ADDR", None)
# Save client remote address for ks/triggers
form["REMOTE_ADDR"] = environ['REMOTE_ADDR']
@@ -80,6 +84,7 @@ def application(environ, start_response)
# Execute corresponding operation on the CobblerSvc object:
func = getattr( cw, mode )
+ response_headers = [('Content-type', 'text/plain;charset=utf-8')]
try:
content = func( **form )
@@ -96,13 +101,16 @@ def application(environ, start_response)
content.find("# object not found") != -1:
print("content not found: %s" % my_uri)
status = "404 NOT FOUND"
+ elif content.find("# redirect") != -1:
+ status = "302 Found"
+ response_headers.append(('Location', content[:content.find("# redirect")]))
+ content = ""
except xmlrpclib.Fault, (err):
status = '500 SERVER ERROR'
content = err.faultString
# req.content_type = "text/plain;charset=utf-8"
- response_headers = [('Content-type', 'text/plain;charset=utf-8'),
- ('Content-Length', str(len(content)))]
+ response_headers.append(('Content-Length', str(len(content))))
start_response(status, response_headers)
return [content]

View File

@ -0,0 +1,392 @@
--- ./cobbler/field_info.py 2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/field_info.py 2012-01-26 13:43:04.000000000 +0100
@@ -58,6 +58,7 @@ USES_CHECKBOX = [
"*netboot_enabled",
"netboot_enabled",
"*static",
+ "ipv6_autoconfiguration",
"keep_updated",
"mirror_locally",
"virt_auto_boot"
@@ -101,6 +102,7 @@ BLOCK_MAPPINGS = {
"broadcast" : "Networking", # ..
"reserved" : "Networking", # ..
"*mac_address" : "Networking",
+ "*mtu" : "Networking",
"*ip_address" : "Networking",
"*dhcp_tag" : "Networking",
"*static" : "Networking",
@@ -110,17 +112,24 @@ BLOCK_MAPPINGS = {
"*dns_name" : "Networking",
"*static_routes" : "Networking",
"*subnet" : "Networking",
- "hostname" : "Networking (Global)",
- "gateway" : "Networking (Global)",
- "name_servers" : "Networking (Global)",
- "name_servers_search" : "Networking (Global)",
- "repos" : "General",
- "dhcp_tag" : "Advanced",
- "mgmt_classes" : "Management",
- "template_files" : "Management",
- "network_widget_a" : "Networking",
- "network_widget_b" : "Networking",
- "server" : "Advanced",
+ "*ipv6_address" : "Networking",
+ "*ipv6_secondaries" : "Networking",
+ "*ipv6_mtu" : "Networking",
+ "*ipv6_static_routes" : "Networking",
+ "*ipv6_default_gateway" : "Networking",
+ "hostname" : "Networking (Global)",
+ "gateway" : "Networking (Global)",
+ "name_servers" : "Networking (Global)",
+ "name_servers_search" : "Networking (Global)",
+ "ipv6_default_device" : "Networking (Global)",
+ "ipv6_autoconfiguration" : "Networking (Global)",
+ "repos" : "General",
+ "dhcp_tag" : "Advanced",
+ "mgmt_classes" : "Management",
+ "template_files" : "Management",
+ "network_widget_a" : "Networking",
+ "network_widget_b" : "Networking",
+ "server" : "Advanced",
"redhat_management_key" : "Management",
"redhat_management_server" : "Management",
"createrepo_flags" : "Advanced",
--- ./cobbler/item_system.py 2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/item_system.py 2012-01-26 13:43:04.000000000 +0100
@@ -59,9 +59,12 @@ FIELDS = [
["gateway","",0,"Gateway",True,"",0,"str"],
["name_servers",[],0,"Name Servers",True,"space delimited",0,"list"],
["name_servers_search",[],0,"Name Servers Search Path",True,"space delimited",0,"list"],
+ ["ipv6_default_device","",0,"IPv6 Default Device",True,"",0,"str"],
+ ["ipv6_autoconfiguration",False,0,"IPv6 Autoconfiguration",True,"",0,"bool"],
["network_widget_a","",0,"Add Interface",True,"",0,"str"], # not a real field, a marker for the web app
["network_widget_b","",0,"Edit Interface",True,"",0,"str"], # not a real field, a marker for the web app
["*mac_address","",0,"MAC Address",True,"(Place \"random\" in this field for a random MAC Address.)",0,"str"],
+ ["*mtu","",0,"MTU",True,"",0,"str"],
["*ip_address","",0,"IP Address",True,"",0,"str"],
["*bonding","na",0,"Bonding Mode",True,"",["na","master","slave"],"str"],
["*bonding_master","",0,"Bonding Master",True,"",0,"str"],
@@ -72,6 +75,11 @@ FIELDS = [
["*dns_name","",0,"DNS Name",True,"",0,"str"],
["*static_routes",[],0,"Static Routes",True,"",0,"list"],
["*virt_bridge","",0,"Virt Bridge",True,"",0,"str"],
+ ["*ipv6_address","",0,"IPv6 Address",True,"",0,"str"],
+ ["*ipv6_secondaries",[],0,"IPv6 Secondaries",True,"space delimited",0,"list"],
+ ["*ipv6_mtu","",0,"IPv6 MTU",True,"",0,"str"],
+ ["*ipv6_static_routes",[],0,"IPv6 Static Routes",True,"",0,"list"],
+ ["*ipv6_default_gateway","",0,"IPv6 Default Gateway",True,"",0,"str"],
["mgmt_classes",[],0,"Management Classes",True,"For external config management",0,"list"],
["template_files",{},0,"Template Files",True,"File mappings for built-in configuration management",0,"dict"],
["redhat_management_key","<<inherit>>",0,"Red Hat Management Key",True,"Registration key for RHN, Satellite, or Spacewalk",0,"str"],
@@ -114,6 +122,7 @@ class System(item.Item):
if not self.interfaces.has_key(name):
self.interfaces[name] = {
"mac_address" : "",
+ "mtu" : "",
"ip_address" : "",
"dhcp_tag" : "",
"subnet" : "",
@@ -124,6 +133,11 @@ class System(item.Item):
"bonding_opts" : "",
"dns_name" : "",
"static_routes" : [],
+ "ipv6_address" : "",
+ "ipv6_secondaries" : [],
+ "ipv6_mtu" : "",
+ "ipv6_static_routes" : [],
+ "ipv6_default_gateway" : "",
}
return self.interfaces[name]
@@ -364,6 +378,65 @@ class System(item.Item):
intf["bonding_opts"] = bonding_opts
return True
+ def set_ipv6_autoconfiguration(self,truthiness):
+ self.ipv6_autoconfiguration = utils.input_boolean(truthiness)
+ return True
+
+ def set_ipv6_default_device(self,interface_name):
+ if interface_name is None:
+ interface_name = ""
+ self.ipv6_default_device = interface_name
+ return True
+
+ def set_ipv6_address(self,address,interface):
+ """
+ Assign a IP or hostname in DHCP when this MAC boots.
+ Only works if manage_dhcp is set in /etc/cobbler/settings
+ """
+ intf = self.__get_interface(interface)
+ if address == "" or utils.is_ip(address):
+ intf["ipv6_address"] = address.strip()
+ return True
+ raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+ def set_ipv6_secondaries(self,addresses,interface):
+ intf = self.__get_interface(interface)
+ data = utils.input_string_or_list(addresses)
+ secondaries = []
+ for address in data:
+ if address == "" or utils.is_ip(address):
+ secondaries.append(address)
+ else:
+ raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+ intf["ipv6_secondaries"] = secondaries
+ return True
+
+ def set_ipv6_default_gateway(self,address,interface):
+ intf = self.__get_interface(interface)
+ if address == "" or utils.is_ip(address):
+ intf["ipv6_default_gateway"] = address.strip()
+ return True
+ raise CX(_("invalid format for IPv6 IP address (%s)") % address)
+
+ def set_ipv6_static_routes(self,routes,interface):
+ intf = self.__get_interface(interface)
+ data = utils.input_string_or_list(routes)
+ intf["ipv6_static_routes"] = data
+ return True
+
+ def set_ipv6_mtu(self,mtu,interface):
+ intf = self.__get_interface(interface)
+ intf["ipv6_mtu"] = mtu
+ return True
+
+ def set_mtu(self,mtu,interface):
+ intf = self.__get_interface(interface)
+ intf["mtu"] = mtu
+ return True
+
+
+
def set_profile(self,profile_name):
"""
Set the system to use a certain named profile. The profile
@@ -503,17 +576,23 @@ class System(item.Item):
for (key,value) in hash.iteritems():
(field,interface) = key.split("-")
field = field.replace("_","").replace("-","")
- if field == "macaddress" : self.set_mac_address(value, interface)
- if field == "ipaddress" : self.set_ip_address(value, interface)
- if field == "dnsname" : self.set_dns_name(value, interface)
- if field == "static" : self.set_static(value, interface)
- if field == "dhcptag" : self.set_dhcp_tag(value, interface)
- if field == "subnet" : self.set_subnet(value, interface)
- if field == "virtbridge" : self.set_virt_bridge(value, interface)
- if field == "bonding" : self.set_bonding(value, interface)
- if field == "bondingmaster" : self.set_bonding_master(value, interface)
- if field == "bondingopts" : self.set_bonding_opts(value, interface)
- if field == "staticroutes" : self.set_static_routes(value, interface)
+ if field == "macaddress" : self.set_mac_address(value, interface)
+ if field == "mtu" : self.set_mtu(value, interface)
+ if field == "ipaddress" : self.set_ip_address(value, interface)
+ if field == "dnsname" : self.set_dns_name(value, interface)
+ if field == "static" : self.set_static(value, interface)
+ if field == "dhcptag" : self.set_dhcp_tag(value, interface)
+ if field == "subnet" : self.set_subnet(value, interface)
+ if field == "virtbridge" : self.set_virt_bridge(value, interface)
+ if field == "bonding" : self.set_bonding(value, interface)
+ if field == "bondingmaster" : self.set_bonding_master(value, interface)
+ if field == "bondingopts" : self.set_bonding_opts(value, interface)
+ if field == "staticroutes" : self.set_static_routes(value, interface)
+ if field == "ipv6address" : self.set_ipv6_address(value, interface)
+ if field == "ipv6secondaries" : self.set_ipv6_secondaries(value, interface)
+ if field == "ipv6mtu" : self.set_ipv6_mtu(value, interface)
+ if field == "ipv6staticroutes" : self.set_ipv6_static_routes(value, interface)
+ if field == "ipv6defaultgateway" : self.set_ipv6_default_gateway(value, interface)
return True
def check_if_valid(self):
--- ./snippets/post_install_network_config 2010-07-28 17:48:48.000000000 +0200
+++ ./snippets/post_install_network_config 2012-01-26 15:53:46.000000000 +0100
@@ -14,6 +14,7 @@
#
#set $configbymac = True
#set $numbondingdevs = 0
+ #set $enableipv6 = False
## =============================================================================
#for $iname in $ikeys
## look at the interface hash data for the specific interface
@@ -29,6 +30,12 @@
#if $idata["bonding"].lower() == "master"
#set $numbondingdevs += 1
#end if
+
+ ## enable IPv6 networking if we set an ipv6 address or turn on autoconfiguration
+ #if $idata["ipv6_address"] != "" or $ipv6_autoconfiguration == True
+ #set $enableipv6 = True
+ #end if
+
#end for
## end looping through the interfaces to see which ones we need to configure.
## =============================================================================
@@ -64,22 +71,56 @@ mv /etc/sysconfig/network.cobbler /etc/s
# connecting to Puppet before a reboot).
/bin/hostname $hostname
#end if
+
+ #if $enableipv6 == True
+grep -v NETWORKING_IPV6 /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network.cobbler
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+
+ #if $ipv6_autoconfiguration != ""
+grep -v IPV6_AUTOCONF /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+ #if $ipv6_autoconfiguration == True
+echo "IPV6_AUTOCONF=yes" >> /etc/sysconfig/network.cobbler
+ #else
+echo "IPV6_AUTOCONF=no" >> /etc/sysconfig/network.cobbler
+ #end if
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+ #end if
+
+ #if $ipv6_default_device != ""
+grep -v IPV6_DEFAULTDEV /etc/sysconfig/network > /etc/sysconfig/network.cobbler
+echo "IPV6_DEFAULTDEV=$ipv6_default_device" >> /etc/sysconfig/network.cobbler
+rm -f /etc/sysconfig/network
+mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
+ #end if
+
+ #end if
+
## =============================================================================
## now create the config file for each interface
#for $iname in $ikeys
# Start configuration for $iname
## create lots of variables to use later
- #set $idata = $interfaces[$iname]
- #set $mac = $idata["mac_address"].upper()
- #set $static = $idata["static"]
- #set $ip = $idata["ip_address"]
- #set $netmask = $idata["subnet"]
- #set $static_routes = $idata["static_routes"]
- #set $bonding = $idata["bonding"]
- #set $bonding_master = $idata["bonding_master"]
- #set $bonding_opts = $idata["bonding_opts"]
- #set $devfile = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
- #set $routesfile = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
+ #set $idata = $interfaces[$iname]
+ #set $mac = $idata["mac_address"].upper()
+ #set $mtu = $idata["mtu"]
+ #set $static = $idata["static"]
+ #set $ip = $idata["ip_address"]
+ #set $netmask = $idata["subnet"]
+ #set $static_routes = $idata["static_routes"]
+ #set $bonding = $idata["bonding"]
+ #set $bonding_master = $idata["bonding_master"]
+ #set $bonding_opts = $idata["bonding_opts"]
+ #set $ipv6_address = $idata["ipv6_address"]
+ #set $ipv6_secondaries = $idata["ipv6_secondaries"]
+ #set $ipv6_mtu = $idata["ipv6_mtu"]
+ #set $ipv6_default_gateway = $idata["ipv6_default_gateway"]
+ #set $ipv6_static_routes = $idata["ipv6_static_routes"]
+ #set $devfile = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
+ #set $routesfile = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
+ #set $ipv6_routesfile = "/etc/sysconfig/network-scripts/cobbler/route6-" + $iname
## determine if this interface is for a VLAN
#if $vlanpattern.match($iname)
## If this is a VLAN interface, skip it, anaconda doesn't know
@@ -140,9 +181,37 @@ echo "NETMASK=$netmask" >> $devfile
## we don't have enough info for static configuration
echo "BOOTPROTO=none" >> $devfile
#end if
+ #if $enableipv6 == True and $ipv6_address == "" and $ipv6_secondaries == ""
+echo "IPV6INIT=no" >> $devfile
+ #end if
+ #if $enableipv6 == True and $ipv6_autoconfiguration == False
+ #if $ipv6_address != ""
+echo "IPV6INIT=yes" >> $devfile
+echo "IPV6ADDR=$ipv6_address" >> $devfile
+ #end if
+ #if $ipv6_secondaries != ""
+ #set ipv6_secondaries = ' '.join(ipv6_secondaries)
+ ## The quotes around the ipv6 ip's need to be here
+echo 'IPV6ADDR_SECONDARIES="$ipv6_secondaries"' >> $devfile
+ #end if
+ #if $ipv6_mtu != ""
+echo "IPV6MTU=$ipv6_mtu" >> $devfile
+ #end if
+ #if $ipv6_default_gateway != ""
+echo "IPV6_DEFAULTGW=$ipv6_default_gateway" >> $devfile
+ #end if
+ #end if
#else
+ #if $ip == ""
+ ## this interface has no IPv4 address set
+echo "BOOTPROTO=none" >> $devfile
+ #else
## this is a DHCP interface, much less work to do
echo "BOOTPROTO=dhcp" >> $devfile
+ #end if
+ #end if
+ #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
#end if
#else if $is_vlan == "true" or $bonding.lower() == "master"
## Handle non-physical interfaces with special care. :)
@@ -178,6 +247,9 @@ echo "BOOTPROTO=none" >> $devfile
#else
echo "BOOTPROTO=dhcp" >> $devfile
#end if
+ #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
+ #end if
#else if $configbymac == False
## We'll end up here when not all physical interfaces present for
## this system have MAC-addresses configured for them. We don't
@@ -214,6 +286,9 @@ echo "BOOTPROTO=none" >> $devfile
## this is a DHCP interface, much less work to do
echo "BOOTPROTO=dhcp" >> $devfile
#end if
+ #if $mtu != ""
+echo "MTU=$mtu" >> $devfile
+ #end if
#else
# If you end up here, please mail the list... This shouldn't
# happen. ;-) -- jcapel
@@ -225,19 +300,32 @@ echo "BOOTPROTO=dhcp" >> $devfile
#set $nct = $nct + 1
echo "DNS$nct=$nameserver" >> $devfile
#end for
- #end if
- #for $route in $static_routes
- #set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
- #if $routepattern.match($route)
- #set $routebits = $route.split(":")
- #set [$network, $router] = $route.split(":")
+ #end if
+ #for $route in $static_routes
+ #set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
+ #if $routepattern.match($route)
+ #set $routebits = $route.split(":")
+ #set [$network, $router] = $route.split(":")
echo "$network via $router" >> $routesfile
- #else
+ #else
+ # Warning: invalid route "$route"
+ #end if
+ #end for
+ #if $enableipv6 == True
+ #for $route in $ipv6_static_routes
+ #set routepattern = $re.compile("[0-9a-fA-F:/]+,[0-9a-fA-F:]+")
+ #if $routepattern.match($route)
+ #set $routebits = $route.split(",")
+ #set [$network, $router] = $route.split(",")
+echo "$network via $router dev $iname" >> $ipv6_routesfile
+ #else
# Warning: invalid route "$route"
#end if
#end for
+ #end if
#set $i = $i + 1
# End configuration for $iname
+
#end for
## =============================================================================
## Configure name server search path in /etc/resolv.conf

View File

@ -0,0 +1,134 @@
--- ./cobbler/cobblerd.py 2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/cobblerd.py 2012-01-26 11:26:05.000000000 +0100
@@ -25,6 +25,7 @@ import socket
import time
import os
import SimpleXMLRPCServer
+import SocketServer
import glob
from utils import _
import xmlrpclib
@@ -104,7 +105,27 @@ def log(logger,msg):
def do_xmlrpc_rw(bootapi,settings,port):
xinterface = remote.ProxiedXMLRPCInterface(bootapi,remote.CobblerXMLRPCInterface)
- server = remote.CobblerXMLRPCServer(('127.0.0.1', port))
+
+ bound = False
+ for res in socket.getaddrinfo('localhost', port, socket.AF_UNSPEC,
+ socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
+ (af, sa) = (res[0], res[4])
+ try:
+ SocketServer.TCPServer.address_family = af
+ server = remote.CobblerXMLRPCServer((sa[0], sa[1]))
+ except Exception, msg:
+ if af == socket.AF_INET:
+ message = "Could not bind to %s:%s: %s" % (sa[0], sa[1], msg)
+ elif af == socket.AF_INET6:
+ message = "Could not bind to [%s]:%s: %s" % (sa[0], sa[1], msg)
+ xinterface.logger.debug(message)
+ else:
+ bound = True
+ break
+
+ if not bound:
+ raise socket.error("Could not bind to localhost")
+
server.logRequests = 0 # don't print stuff
xinterface.logger.debug("XMLRPC running on %s" % port)
server.register_instance(xinterface)
--- ./cobbler/modules/authn_spacewalk.py 2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/modules/authn_spacewalk.py 2012-01-26 11:26:05.000000000 +0100
@@ -77,7 +77,7 @@ def authenticate(api_handle,username,pas
if server == "xmlrpc.rhn.redhat.com":
return False # emergency fail, don't bother RHN!
- spacewalk_url = "https://%s/rpc/api" % server
+ spacewalk_url = "http://%s/rpc/api" % server
client = xmlrpclib.Server(spacewalk_url, verbose=0)
--- ./cobbler/utils.py 2012-01-26 11:26:05.000000000 +0100
+++ ./cobbler/utils.py 2012-01-26 11:28:22.000000000 +0100
@@ -1862,6 +1862,30 @@ def get_shared_secret():
return -1
return str(data).strip()
+def get_localhost_addr(port):
+ (sock, sa, af) = (None, None, None)
+ for res in socket.getaddrinfo('localhost', port, socket.AF_UNSPEC, socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ try:
+ sock = socket.socket(af, socktype, proto)
+ except socket.error:
+ sock = None
+ continue
+
+ try:
+ sock.connect((sa[0], sa[1]))
+ except socket.error:
+ sock.close()
+ sock = None
+ continue
+ break
+
+ if sock is None:
+ return (None, None)
+
+ sock.close()
+ return (sa[0], af)
+
def local_get_cobbler_api_url():
# Load server and http port
try:
@@ -1882,7 +1906,18 @@ def local_get_cobbler_xmlrpc_url():
except:
traceback.print_exc()
raise CX("/etc/cobbler/settings is not a valid YAML file")
- return "http://%s:%s" % ("127.0.0.1",data.get("xmlrpc_port","25151"))
+ port = data.get("xmlrpc_port","25151")
+ addr = get_localhost_addr(port)
+
+ if addr[1] == socket.AF_INET:
+ return "http://%s:%s" % (addr[0], port)
+ if addr[1] == socket.AF_INET6:
+ return "http://[%s]:%s" % (addr[0], port)
+
+ if os.path.exists('/proc/net/if_inet6'):
+ return "http://[::1]:%s" % port
+ else:
+ return "http://127.0.0.1:%s" % port
def strip_none(data, omit_none=False):
"""
--- ./scripts/services.py 2010-07-28 17:48:48.000000000 +0200
+++ ./scripts/services.py 2012-01-26 11:26:05.000000000 +0100
@@ -78,7 +78,7 @@ def handler(req):
# instantiate a CobblerWeb object
cw = CobblerSvc(
apache = apache,
- server = "http://127.0.0.1:%s" % remote_port
+ server = utils.local_get_cobbler_xmlrpc_url()
)
# check for a valid path/mode
--- ./scripts/services.wsgi 2010-10-07 20:12:03.000000000 +0200
+++ ./scripts/services.wsgi 2012-01-26 11:26:05.000000000 +0100
@@ -23,6 +23,7 @@ import yaml
import os
from cobbler.services import CobblerSvc
+import cobbler.utils as utils
def application(environ, start_response):
@@ -64,7 +65,7 @@ def application(environ, start_response)
remote_port = ydata.get("xmlrpc_port",25151)
# instantiate a CobblerWeb object
- cw = CobblerSvc(server = "http://127.0.0.1:%s" % remote_port)
+ cw = CobblerSvc(server = utils.local_get_cobbler_xmlrpc_url())
# check for a valid path/mode
# handle invalid paths gracefully

View File

@ -0,0 +1,14 @@
--- ./snippets/keep_ssh_host_keys 2010-07-28 17:48:48.000000000 +0200
+++ ./snippets/keep_ssh_host_keys 2011-08-18 13:56:47.083867519 +0200
@@ -89,10 +89,9 @@ if [ "$keys_found" = "yes" ]; then
sleep 10
if [ -d /mnt/sysimage$SEARCHDIR ] ; then
cp -af /tmp/$TEMPDIR/${PATTERN}* /mnt/sysimage$SEARCHDIR
- logger "keys copied to newly installed system"
break
fi
- done &
+ done >/dev/null 2>/dev/null &
fi
#end raw

View File

@ -0,0 +1,56 @@
--- ./koan/app.py 2010-10-18 15:40:34.000000000 +0200
+++ ./koan/app.py 2011-01-07 11:47:23.173337611 +0100
@@ -382,10 +382,6 @@ class Koan:
Determine the name of the cobbler system record that
matches this MAC address.
"""
- try:
- import rhpl
- except:
- raise CX("the rhpl module is required to autodetect a system. Your OS does not have this, please manually specify --profile or --system")
systems = self.get_data("systems")
my_netinfo = utils.get_network_info()
my_interfaces = my_netinfo.keys()
--- ./koan/utils.py 2010-10-18 15:40:34.000000000 +0200
+++ ./koan/utils.py 2011-01-07 11:47:23.173337611 +0100
@@ -383,22 +383,26 @@ def uniqify(lst, purge=None):
def get_network_info():
try:
- import rhpl.ethtool
+ import ethtool
except:
- raise InfoException("the rhpl module is required to use this feature (is your OS>=EL3?)")
+ try:
+ import rhpl.ethtool
+ ethtool = rhpl.ethtool
+ except:
+ raise InfoException("the rhpl or ethtool module is required to use this feature (is your OS>=EL3?)")
interfaces = {}
# get names
- inames = rhpl.ethtool.get_devices()
+ inames = ethtool.get_devices()
for iname in inames:
- mac = rhpl.ethtool.get_hwaddr(iname)
+ mac = ethtool.get_hwaddr(iname)
if mac == "00:00:00:00:00:00":
mac = "?"
try:
- ip = rhpl.ethtool.get_ipaddr(iname)
+ ip = ethtool.get_ipaddr(iname)
if ip == "127.0.0.1":
ip = "?"
except:
@@ -408,7 +412,7 @@ def get_network_info():
module = ""
try:
- nm = rhpl.ethtool.get_netmask(iname)
+ nm = ethtool.get_netmask(iname)
except:
nm = "?"

View File

@ -0,0 +1,11 @@
--- ./koan/app.py 2011-08-23 17:47:53.135881905 +0200
+++ ./koan/app.py 2011-08-23 17:48:18.715879926 +0200
@@ -1460,7 +1460,7 @@ class Koan:
cmd = sub_process.Popen(args, stdout=sub_process.PIPE, shell=True)
freespace_str = cmd.communicate()[0]
freespace_str = freespace_str.split("\n")[0].strip()
- freespace_str = freespace_str.replace("G","") # remove gigabytes
+ freespace_str = freespace_str.lower().replace("g","") # remove gigabytes
print "(%s)" % freespace_str
freespace = int(float(freespace_str))

View File

@ -0,0 +1,12 @@
diff -ur cobbler-2.0.7.old/koan/app.py cobbler-2.0.7.new/koan/app.py
--- cobbler-2.0.7.old/koan/app.py 2013-03-27 14:24:46.002915215 -0400
+++ cobbler-2.0.7.new/koan/app.py 2013-03-27 15:32:44.987651207 -0400
@@ -1492,7 +1492,7 @@
raise InfoException, "LVM creation failed"
# partition location
- partition_location = "/dev/mapper/%s-%s" % (location,name.replace('-','--'))
+ partition_location = "/dev/%s/%s" % (location,name)
# check whether we have SELinux enabled system
args = "/usr/sbin/selinuxenabled"

View File

@ -0,0 +1,67 @@
--- a/snippets/post_install_network_config 2013-11-11 10:46:45.464341394 +0100
+++ b/snippets/post_install_network_config 2013-11-12 12:13:34.578812084 +0100
@@ -43,9 +43,13 @@
## setup bonding if we have to
## if using bonding, must have an /ect/modpobe.conf file
#if $numbondingdevs > 0
-touch "/etc/modprobe.conf"
-if [ -f "/etc/modprobe.conf" ]; then
- echo "options bonding max_bonds=$numbondingdevs" >> /etc/modprobe.conf
+MODPROBE_CONF="/etc/modprobe.conf"
+if [ -d "/etc/modprobe.d" ]; then
+ MODPROBE_CONF="/etc/modprobe.d/post_install_network_config.conf"
+fi
+touch "\$MODPROBE_CONF"
+if [ -f "\$MODPROBE_CONF" ]; then
+ echo "options bonding max_bonds=$numbondingdevs" >> \$MODPROBE_CONF
fi
#end if
## =============================================================================
@@ -134,13 +138,13 @@
## if this is a bonded interface, configure it in modprobe.conf
#if $bonding.lower() == "master"
#if $osversion == "rhel4"
-if [ -f "/etc/modprobe.conf" ]; then
- echo "install $iname /sbin/modprobe bonding -o $iname $bonding_opts" >> /etc/modprobe.conf.cobbler
+if [ -f "\$MODPROBE_CONF" ]; then
+ echo "install $iname /sbin/modprobe bonding -o $iname $bonding_opts" >> \$MODPROBE_CONF.cobbler
fi
#else
## Add required entry to modprobe.conf
-if [ -f "/etc/modprobe.conf" ]; then
- echo "alias $iname bonding" >> /etc/modprobe.conf.cobbler
+if [ -f "\$MODPROBE_CONF" ]; then
+ echo "alias $iname bonding" >> \$MODPROBE_CONF.cobbler
fi
#end if
#end if
@@ -150,11 +154,11 @@
IFNAME=\$(ip -o link | grep -i '$mac' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
## Rename this interface in modprobe.conf
## FIXME: if both interfaces startwith eth this is wrong
-if [ -f "/etc/modprobe.conf" ] && [ \$IFNAME ]; then
- grep \$IFNAME /etc/modprobe.conf | sed "s/\$IFNAME/$iname/" >> /etc/modprobe.conf.cobbler
- grep -v \$IFNAME /etc/modprobe.conf >> /etc/modprobe.conf.new
- rm -f /etc/modprobe.conf
- mv /etc/modprobe.conf.new /etc/modprobe.conf
+if [ -f "\$MODPROBE_CONF" ] && [ \$IFNAME ]; then
+ grep \$IFNAME \$MODPROBE_CONF | sed "s/\$IFNAME/$iname/" >> \$MODPROBE_CONF.cobbler
+ grep -v \$IFNAME \$MODPROBE_CONF >> \$MODPROBE_CONF.new
+ rm -f \$MODPROBE_CONF
+ mv \$MODPROBE_CONF.new \$MODPROBE_CONF
fi
echo "DEVICE=$iname" > $devfile
echo "HWADDR=$mac" >> $devfile
@@ -348,9 +352,9 @@
rm -f /etc/sysconfig/network-scripts/ifcfg-*
mv /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/
rm -r /etc/sysconfig/network-scripts/cobbler
-if [ -f "/etc/modprobe.conf" ]; then
-cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
-rm -f /etc/modprobe.conf.cobbler
+if [ -f "\$MODPROBE_CONF" ]; then
+cat \$MODPROBE_CONF.cobbler >> \$MODPROBE_CONF
+rm -f \$MODPROBE_CONF.cobbler
fi
#end if
# End post_install_network_config generated code

View File

@ -0,0 +1,23 @@
--- ./cobbler/utils.py 2011-08-23 17:19:24.442680062 +0200
+++ ./cobbler/utils.py 2011-08-23 17:19:37.466012392 +0200
@@ -186,8 +186,9 @@ def get_host_ip(ip, shorten=True):
ip = netaddr.IP(ip)
cidr = ip.cidr()
else:
- ip = netaddr.ip.IPAddress(ip)
- cidr = netaddr.ip.IPNetwork(ip)
+ ipnet = netaddr.IPNetwork(ip)
+ ip = ipnet.ip
+ cidr = ipnet.cidr
if len(cidr) == 1: # Just an IP, e.g. a /32
return pretty_hex(ip)
@@ -210,7 +211,7 @@ def _IP(ip):
if NETADDR_PRE_0_7:
ip_class = netaddr.IP
else:
- ip_class = netaddr.ip.IPAddress
+ ip_class = netaddr.ip.IPNetwork
if isinstance(ip, ip_class) or ip == "":
return ip
else:

View File

@ -0,0 +1,12 @@
--- ./cobbler/item_system.py 2012-02-02 11:47:38.977405017 +0100
+++ ./cobbler/item_system.py 2012-02-09 17:21:33.318228733 +0100
@@ -574,7 +574,7 @@ class System(item.Item):
Used by the WUI to modify an interface more-efficiently
"""
for (key,value) in hash.iteritems():
- (field,interface) = key.split("-")
+ (field,interface) = key.split("-", 1)
field = field.replace("_","").replace("-","")
if field == "macaddress" : self.set_mac_address(value, interface)
if field == "mtu" : self.set_mtu(value, interface)

View File

@ -0,0 +1,11 @@
--- cobbler/action_sync.py 2011-05-27 16:05:40.000000000 +0200
+++ cobbler/action_sync.py 2011-05-27 16:05:53.000000000 +0200
@@ -182,7 +182,7 @@
if not x.endswith(".py"):
utils.rmfile(path,logger=self.logger)
if os.path.isdir(path):
- if not x in ["aux", "web", "webui", "localmirror","repo_mirror","ks_mirror","images","links","repo_profile","repo_system","svc","rendered",".link_cache"] :
+ if not x in ["aux", "web", "webui", "localmirror","repo_mirror","ks_mirror","images","links","repo_profile","repo_system","svc","rendered",".link_cache", "pub"] :
# delete directories that shouldn't exist
utils.rmtree(path,logger=self.logger)
if x in ["kickstarts","kickstarts_sys","images","systems","distros","profiles","repo_profile","repo_system","rendered"]:

View File

@ -0,0 +1,59 @@
--- cobbler-2.0.7/snippets/post_install_network_config.org 2017-10-31 11:57:38.783714163 +0100
+++ cobbler-2.0.7/snippets/post_install_network_config 2017-10-31 12:11:05.663448156 +0100
@@ -21,18 +21,18 @@
#set $idata = $interfaces[$iname]
## do not configure by mac address if we don't have one AND it's not for bonding/vlans
## as opposed to a "real" physical interface
- #if $idata["mac_address"] == "" and not $vlanpattern.match($iname) and not $idata["bonding"].lower() == "master":
+ #if $idata.get("mac_address", "") == "" and not $vlanpattern.match($iname) and not $idata.get("bonding", "").lower() == "master":
## we have to globally turn off the config by mac feature as we can't
## use it now
#set $configbymac = False
#end if
## count the number of bonding devices we have.
- #if $idata["bonding"].lower() == "master"
+ #if $idata.get("bonding", "").lower() == "master"
#set $numbondingdevs += 1
#end if
## enable IPv6 networking if we set an ipv6 address or turn on autoconfiguration
- #if $idata["ipv6_address"] != "" or $ipv6_autoconfiguration == True
+ #if $idata.get("ipv6_address", "") != "" or $ipv6_autoconfiguration == True
#set $enableipv6 = True
#end if
@@ -110,20 +110,20 @@ mv /etc/sysconfig/network.cobbler /etc/s
# Start configuration for $iname
## create lots of variables to use later
#set $idata = $interfaces[$iname]
- #set $mac = $idata["mac_address"].upper()
- #set $mtu = $idata["mtu"]
- #set $static = $idata["static"]
- #set $ip = $idata["ip_address"]
- #set $netmask = $idata["subnet"]
- #set $static_routes = $idata["static_routes"]
- #set $bonding = $idata["bonding"]
- #set $bonding_master = $idata["bonding_master"]
- #set $bonding_opts = $idata["bonding_opts"]
- #set $ipv6_address = $idata["ipv6_address"]
- #set $ipv6_secondaries = $idata["ipv6_secondaries"]
- #set $ipv6_mtu = $idata["ipv6_mtu"]
- #set $ipv6_default_gateway = $idata["ipv6_default_gateway"]
- #set $ipv6_static_routes = $idata["ipv6_static_routes"]
+ #set $mac = $idata.get("mac_address", "").upper()
+ #set $mtu = $idata.get("mtu", "")
+ #set $static = $idata.get("static", "")
+ #set $ip = $idata.get("ip_address", "")
+ #set $netmask = $idata.get("subnet", "")
+ #set $static_routes = $idata.get("static_routes", "")
+ #set $bonding = $idata.get("bonding", "")
+ #set $bonding_master = $idata.get("bonding_master", "")
+ #set $bonding_opts = $idata.get("bonding_opts", "")
+ #set $ipv6_address = $idata.get("ipv6_address", "")
+ #set $ipv6_secondaries = $idata.get("ipv6_secondaries", "")
+ #set $ipv6_mtu = $idata.get("ipv6_mtu", "")
+ #set $ipv6_default_gateway = $idata.get("ipv6_default_gateway", "")
+ #set $ipv6_static_routes = $idata.get("ipv6_static_routes", "")
#set $devfile = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
#set $routesfile = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
#set $ipv6_routesfile = "/etc/sysconfig/network-scripts/cobbler/route6-" + $iname

View File

@ -0,0 +1,108 @@
diff -rupN cobbler-2.0.7.old/cobbler/action_power.py cobbler-2.0.7/cobbler/action_power.py
--- cobbler-2.0.7.old/cobbler/action_power.py 2014-11-10 15:07:00.578732736 -0500
+++ cobbler-2.0.7/cobbler/action_power.py 2014-11-10 15:11:19.692536590 -0500
@@ -30,6 +30,7 @@ import os
import os.path
import traceback
import time
+import re
import utils
import func_utils
@@ -102,8 +103,22 @@ class PowerTool:
# Try the power command 5 times before giving up.
# Some power switches are flakey
for x in range(0,5):
- rc = utils.subprocess_call(self.logger, template_command, shell=False)
+ output, rc = utils.subprocess_sp(self.logger, template_command, shell=False)
if rc == 0:
+ # If the desired state is actually a query for the status
+ # return different information than command return code
+ if desired_state == 'status':
+ match = re.match('(^Status:\s)(ON|OFF)', output)
+ if not match:
+ match = re.match('(.*Chassis power\s*(=|is)\s*)(On|Off).*', output, re.IGNORECASE)
+ if match:
+ power_status = match.groups()[2]
+ if power_status.upper() == 'ON':
+ return True
+ else:
+ return False
+ utils.die(self.logger,"command succeeded (rc=%s), but output ('%s') was not understood" % (rc, output))
+ return None
break
else:
time.sleep(2)
diff -rupN cobbler-2.0.7.old/cobbler/api.py cobbler-2.0.7/cobbler/api.py
--- cobbler-2.0.7.old/cobbler/api.py 2014-11-10 15:07:00.577732729 -0500
+++ cobbler-2.0.7/cobbler/api.py 2014-11-10 15:07:27.941923229 -0500
@@ -818,6 +818,15 @@ class BootAPI:
time.sleep(5)
return self.power_on(system, user, password, logger=logger)
+ def power_status(self, system, user=None, password=None, logger=None):
+ """
+ Returns the power status for a system that has power management configured.
+
+ @return: 0 the system is powered on, False if it's not or None on error
+ """
+ return action_power.PowerTool(self._config, system, self, user, password, logger = logger).power("status")
+
+
# ==========================================================================
def clear_logs(self, system, logger=None):
diff -rupN cobbler-2.0.7.old/cobbler/cli.py cobbler-2.0.7/cobbler/cli.py
--- cobbler-2.0.7.old/cobbler/cli.py 2014-11-10 15:07:00.575732715 -0500
+++ cobbler-2.0.7/cobbler/cli.py 2014-11-10 15:07:27.941923229 -0500
@@ -40,7 +40,7 @@ import item_image
OBJECT_ACTIONS = {
"distro" : "add copy edit find list remove rename report".split(" "),
"profile" : "add copy dumpvars edit find getks list remove rename report".split(" "),
- "system" : "add copy dumpvars edit find getks list remove rename report poweron poweroff reboot".split(" "),
+ "system" : "add copy dumpvars edit find getks list remove rename report poweron poweroff powerstatus reboot".split(" "),
"image" : "add copy edit find list remove rename report".split(" "),
"repo" : "add copy edit find list remove rename report".split(" ")
}
@@ -278,7 +278,7 @@ class BootCLI:
keys.sort()
for x in keys:
print "%s : %s" % (x, data[x])
- elif object_action in [ "poweron", "poweroff", "reboot" ]:
+ elif object_action in [ "poweron", "poweroff", "powerstatus", "reboot" ]:
power={}
power["power"] = object_action.replace("power","")
power["systems"] = [options.name]
diff -rupN cobbler-2.0.7.old/cobbler/remote.py cobbler-2.0.7/cobbler/remote.py
--- cobbler-2.0.7.old/cobbler/remote.py 2014-11-10 15:07:00.575732715 -0500
+++ cobbler-2.0.7/cobbler/remote.py 2014-11-10 15:07:27.942923236 -0500
@@ -1706,7 +1706,7 @@ class CobblerXMLRPCInterface:
"""
Internal implementation used by background_power, do not call
directly if possible.
- Allows poweron/poweroff/reboot of a system specified by object_id.
+ Allows poweron/poweroff/powerstatus/reboot of a system specified by object_id.
"""
obj = self.__get_object(object_id)
self.check_access(token, "power_system", obj)
@@ -1714,10 +1714,12 @@ class CobblerXMLRPCInterface:
rc=self.api.power_on(obj, user=None, password=None, logger=logger)
elif power=="off":
rc=self.api.power_off(obj, user=None, password=None, logger=logger)
+ elif power=="status":
+ rc=self.api.power_status(obj, user=None, password=None, logger=logger)
elif power=="reboot":
rc=self.api.reboot(obj, user=None, password=None, logger=logger)
else:
- utils.die(self.logger, "invalid power mode '%s', expected on/off/reboot" % power)
+ utils.die(self.logger, "invalid power mode '%s', expected on/off/status/reboot" % power)
return rc
def clear_system_logs(self, object_id, token=None, logger=None):
diff -rupN cobbler-2.0.7.old/templates/power_ipmilan.template cobbler-2.0.7/templates/power_ipmilan.template
--- cobbler-2.0.7.old/templates/power_ipmilan.template 2014-11-10 15:07:00.581732757 -0500
+++ cobbler-2.0.7/templates/power_ipmilan.template 2014-11-10 15:07:27.943923243 -0500
@@ -1,2 +1 @@
-#use power_id to pass in additional options like -P, Use Lanplus
-fence_ipmilan -i "$power_address" $power_id -l "$power_user" -p "$power_pass" -o "$power_mode"
+fence_ipmilan -a "$power_address" $power_id -l "$power_user" -p "$power_pass" -o "$power_mode"

View File

@ -0,0 +1,127 @@
diff -ru cobbler-2.0.7/cobbler/action_power.py cobbler-2.0.7-new/cobbler/action_power.py
--- cobbler-2.0.7/cobbler/action_power.py 2010-07-28 17:48:48.000000000 +0200
+++ cobbler-2.0.7-new/cobbler/action_power.py 2012-06-11 11:16:06.409111259 +0200
@@ -36,6 +36,7 @@
from cexceptions import *
import templar
import clogger
+import shlex
class PowerTool:
"""
@@ -68,8 +69,9 @@
interested in maximum security should take that route.
"""
- template = self.get_command_template()
- template_file = open(template, "r")
+ power_command = utils.get_power(self.system.power_type)
+ if not power_command:
+ utils.die(self.logger,"no power type set for system")
meta = utils.blender(self.api, False, self.system)
meta["power_mode"] = desired_state
@@ -80,35 +82,27 @@
if self.force_pass is not None:
meta["power_pass"] = self.force_pass
- tmp = templar.Templar(self.api._config)
- cmd = tmp.render(template_file, meta, None, self.system)
- template_file.close()
-
- cmd = cmd.strip()
-
self.logger.info("cobbler power configuration is:")
-
self.logger.info(" type : %s" % self.system.power_type)
self.logger.info(" address: %s" % self.system.power_address)
self.logger.info(" user : %s" % self.system.power_user)
self.logger.info(" id : %s" % self.system.power_id)
# if no username/password data, check the environment
-
if meta.get("power_user","") == "":
meta["power_user"] = os.environ.get("COBBLER_POWER_USER","")
if meta.get("power_pass","") == "":
meta["power_pass"] = os.environ.get("COBBLER_POWER_PASS","")
- self.logger.info("- %s" % cmd)
-
- # use shell so we can have mutliple power commands chained together
- cmd = ['/bin/sh','-c', cmd]
+ template = utils.get_power_template(self.system.power_type)
+ tmp = templar.Templar(self.api._config)
+ template_data = tmp.render(template, meta, None, self.system)
+ template_command = shlex.split(str(template_data))
# Try the power command 5 times before giving up.
# Some power switches are flakey
for x in range(0,5):
- rc = utils.subprocess_call(self.logger, cmd, shell=False)
+ rc = utils.subprocess_call(self.logger, template_command, shell=False)
if rc == 0:
break
else:
@@ -119,19 +113,3 @@
return rc
- def get_command_template(self):
-
- """
- In case the user wants to customize the power management commands,
- we source the code for each command from /etc/cobbler and run
- them through Cheetah.
- """
-
- if self.system.power_type in [ "", "none" ]:
- utils.die(self.logger,"Power management is not enabled for this system")
-
- result = utils.get_power(self.system.power_type)
- if not result:
- utils.die(self.logger, "Invalid power management type for this system (%s, %s)" % (self.system.power_type, self.system.name))
- return result
-
diff -ru cobbler-2.0.7/cobbler/item_system.py cobbler-2.0.7-new/cobbler/item_system.py
--- cobbler-2.0.7/cobbler/item_system.py 2010-07-28 17:48:48.000000000 +0200
+++ cobbler-2.0.7-new/cobbler/item_system.py 2012-06-11 11:16:06.410111268 +0200
@@ -50,11 +50,11 @@
["virt_auto_boot","<<inherit>>",0,"Virt Auto Boot",True,"Auto boot this VM?",0,"bool"],
["ctime",0,0,"",False,"",0,"float"],
["mtime",0,0,"",False,"",0,"float"],
- ["power_type","SETTINGS:power_management_default_type",0,"Power Management Type",True,"",utils.get_power_types(),"str"],
+ ["power_type","SETTINGS:power_management_default_type",0,"Power Management Type",True,"Power management script to use",utils.get_power_types(),"str"],
["power_address","",0,"Power Management Address",True,"Ex: power-device.example.org",0,"str"],
- ["power_user","",0,"Power Username ",True,"",0,"str"],
- ["power_pass","",0,"Power Password",True,"",0,"str"],
- ["power_id","",0,"Power ID",True,"Usually a plug number or blade name, if power type requires it",0,"str"],
+ ["power_user","",0,"Power Management Username ",True,"",0,"str"],
+ ["power_pass","",0,"Power Management Password",True,"",0,"str"],
+ ["power_id","",0,"Power Management ID",True,"Usually a plug number or blade name, if power type requires it",0,"str"],
["hostname","",0,"Hostname",True,"",0,"str"],
["gateway","",0,"Gateway",True,"",0,"str"],
["name_servers",[],0,"Name Servers",True,"space delimited",0,"list"],
diff -ru cobbler-2.0.7/cobbler/utils.py cobbler-2.0.7-new/cobbler/utils.py
--- cobbler-2.0.7/cobbler/utils.py 2012-06-11 11:19:10.469232289 +0200
+++ cobbler-2.0.7-new/cobbler/utils.py 2012-06-11 11:18:39.660541633 +0200
@@ -1846,6 +1846,20 @@
return powerpath
return None
+def get_power_template(powertype=None):
+ """
+ Return power template for type
+ """
+ if powertype:
+ powertemplate = "/etc/cobbler/power/power_%s.template" % powertype
+ if os.path.isfile(powertemplate):
+ f = open(powertemplate)
+ template = f.read()
+ f.close()
+ return template
+ # return a generic template if a specific one wasn't found
+ return "action=$power_mode\nlogin=$power_user\npasswd=$power_pass\nipaddr=$power_address\nport=$power_id"
+
def get_shared_secret():
"""
The 'web.ss' file is regenerated each time cobblerd restarts and is

View File

@ -0,0 +1,14 @@
--- ./cobbler/pxegen.py.orig 2010-07-28 17:48:48.000000000 +0200
+++ ./cobbler/pxegen.py 2010-11-24 10:48:30.000000000 +0100
@@ -91,8 +91,9 @@
utils.copyfile_pattern('/usr/share/syslinux/menu.c32', dst, api=self.api, logger=self.logger)
except:
- utils.copyfile_pattern('/usr/lib/syslinux/pxelinux.0', dst, api=self.api, logger=self.logger)
- utils.copyfile_pattern('/usr/lib/syslinux/menu.c32', dst, api=self.api, logger=self.logger)
+ if os.path.exists('/usr/lib/syslinux'):
+ utils.copyfile_pattern('/usr/lib/syslinux/pxelinux.0', dst, api=self.api, logger=self.logger)
+ utils.copyfile_pattern('/usr/lib/syslinux/menu.c32', dst, api=self.api, logger=self.logger)
# copy memtest only if we find it
utils.copyfile_pattern('/boot/memtest*', dst, require_match=False, api=self.api, logger=self.logger)

View File

@ -0,0 +1,13 @@
diff -rupN cobbler-2.0.7-old/scripts/services.wsgi cobbler-2.0.7/scripts/services.wsgi
--- cobbler-2.0.7-old/scripts/services.wsgi 2014-06-02 10:33:45.037218183 -0400
+++ cobbler-2.0.7/scripts/services.wsgi 2014-06-02 10:17:09.122312563 -0400
@@ -58,6 +58,9 @@ def application(environ, start_response)
# like: eth0 XX:XX:XX:XX:XX:XX
form["REMOTE_MAC"] = form.get("HTTP_X_RHN_PROVISIONING_MAC_0", None)
+ # Save client remote address for ks/triggers
+ form["REMOTE_ADDR"] = environ['REMOTE_ADDR']
+
# Read config for the XMLRPC port to connect to:
fd = open("/etc/cobbler/settings")
data = fd.read()

View File

@ -0,0 +1,13 @@
diff -rupN cobbler-old/snippets/post_install_network_config cobbler-new/snippets/post_install_network_config
--- cobbler-old/snippets/post_install_network_config 2012-08-24 15:20:57.543943513 -0400
+++ cobbler-new/snippets/post_install_network_config 2012-08-24 15:28:14.298918151 -0400
@@ -41,7 +41,9 @@
## =============================================================================
#set $i = 0
## setup bonding if we have to
+ ## if using bonding, must have an /ect/modpobe.conf file
#if $numbondingdevs > 0
+touch "/etc/modprobe.conf"
if [ -f "/etc/modprobe.conf" ]; then
echo "options bonding max_bonds=$numbondingdevs" >> /etc/modprobe.conf
fi

View File

@ -0,0 +1,12 @@
diff -rupN cobbler-2.0.7-old/cobbler/codes.py cobbler-2.0.7-new/cobbler/codes.py
--- cobbler-2.0.7-old/cobbler/codes.py 2014-04-09 15:09:16.712074725 -0400
+++ cobbler-2.0.7-new/cobbler/codes.py 2014-04-09 15:20:32.775951259 -0400
@@ -41,7 +41,7 @@ VALID_OS_BREEDS = [
]
VALID_OS_VERSIONS = {
- "redhat" : [ "rhel2.1", "rhel3", "rhel4", "rhel5", "rhel6", "fedora5", "fedora6", "fedora7", "fedora8", "fedora9", "fedora10", "fedora11", "fedora12", "fedora13", "fedora14", "fedora15", "generic24", "generic26", "virtio26", "other" ],
+ "redhat" : [ "rhel2.1", "rhel3", "rhel4", "rhel5", "rhel5.4", "rhel6", "rhel7", "fedora5", "fedora6", "fedora7", "fedora8", "fedora9", "fedora10", "fedora11", "fedora12", "fedora13", "fedora14", "fedora15", "fedora16", "fedora17", "fedora18", "fedora19", "fedora20", "generic24", "generic26", "virtio26", "other" ],
"suse" : [ "sles10", "generic24", "generic26", "virtio26", "other" ],
"debian" : [ "etch", "lenny", "generic24", "generic26", "other" ],
"ubuntu" : [ "dapper", "hardy", "intrepid", "jaunty" ],

View File

@ -0,0 +1,54 @@
--- a/snippets/post_install_network_config
+++ a/snippets/post_install_network_config
@@ -147,7 +147,7 @@ fi
#if $configbymac and $is_vlan == "false" and $bonding.lower() != "master"
## This is the code path physical interfaces will follow.
## Get the current interface name
-IFNAME=\$(ifconfig -a | grep -i '$mac' | cut -d ' ' -f 1)
+IFNAME=\$(ip -o link | grep -i '$mac' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
## Rename this interface in modprobe.conf
## FIXME: if both interfaces startwith eth this is wrong
if [ -f "/etc/modprobe.conf" ] && [ \$IFNAME ]; then
--- a/snippets/pre_install_network_config
+++ a/snippets/pre_install_network_config
@@ -1,5 +1,27 @@
#if $getVar("system_name","") != ""
# Start pre_install_network_config generated code
+#raw
+# generic functions to be used later for discovering NICs
+mac_exists() {
+ if which ip &> /dev/null; then
+ ip -o link | grep -i "$1" &> /dev/null
+ return $?
+ else
+ ifconfig -a | grep -i "$1" &> /dev/null
+ return $?
+ fi
+}
+get_ifname() {
+ if which ip &> /dev/null; then
+ IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
+ else
+ IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
+ if [ -z $IFNAME ]; then
+ IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
+ fi
+ fi
+}
+#end raw
#set ikeys = $interfaces.keys()
#import re
#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
@@ -75,9 +97,9 @@
#set $netinfo = "%s --hostname=%s" % ($netinfo, $hostname)
#end if
# Configuring $iname ($mac)
-if ifconfig -a | grep -i $mac
+if mac_exists $mac
then
- IFNAME=\$(ifconfig -a | grep -i '$mac' | cut -d " " -f 1)
+ get_ifname $mac
echo "network --device=\$IFNAME $netinfo" >> /tmp/pre_install_network_config
fi
#else

View File

@ -0,0 +1,21 @@
diff -rupN cobbler-2.0.11.old/cobbler/utils.py cobbler-2.0.11/cobbler/utils.py
--- cobbler-2.0.11.old/cobbler/utils.py.org
+++ cobbler-2.0.11/cobbler/utils.py
@@ -615,9 +615,16 @@ def blender(api_handle,remove_hashes, ro
# hack -- s390 nodes get additional default kernel options
arch = results.get("arch","?")
if arch.startswith("s390"):
+ blacklist_options = []
+ version = results.get("os_version")
+ if ((version.startswith("rhel") and version >= "rhel7") or
+ (version.startswith("fedora") and version >= "fedora17")):
+ # these options were removed from default kernel options
+ blacklist_options.append("ip")
+ blacklist_options.append("root")
keyz = settings.kernel_options_s390x.keys()
for k in keyz:
- if not results.has_key(k):
+ if not results.has_key(k) and k not in blacklist_options:
results["kernel_options"][k] = settings.kernel_options_s390x[k]
# Get topmost object to determine which breed we're dealing with

View File

@ -0,0 +1,25 @@
diff -up ./cobbler/remote.py.org ./cobbler/remote.py
--- ./cobbler/remote.py 2010-10-07 20:12:03.000000000 +0200
+++ ./cobbler/remote.py 2011-12-08 16:18:15.984887836 +0100
@@ -1501,7 +1501,7 @@ class CobblerXMLRPCInterface:
return True
else:
self._log("invalid token",token=token)
- raise CX("invalid token: %s" % token)
+ return False
def __name_to_object(self,resource,name):
if resource.find("distro") != -1:
@@ -1587,10 +1587,9 @@ class CobblerXMLRPCInterface:
def token_check(self,token):
"""
- This is a demo function that does not return anything useful.
+ Checks to make sure a token is valid or not
"""
- self.__validate_token(token)
- return True
+ return self.__validate_token(token)
def sync(self,token):
"""

View File

@ -0,0 +1,23 @@
diff -rupN cobbler-2.0.7-orig/cobbler/utils.py cobbler-2.0.7/cobbler/utils.py
--- cobbler-2.0.7-orig/cobbler/utils.py 2013-07-17 14:28:09.987051106 -0400
+++ cobbler-2.0.7/cobbler/utils.py 2013-07-17 14:31:38.577514157 -0400
@@ -854,7 +854,8 @@ def run_triggers(api,ref,globber,additio
if ref:
arglist.append(ref.name)
for x in additional:
- arglist.append(x)
+ if x:
+ arglist.append(x)
if logger is not None:
logger.debug("running python trigger %s" % m.__name__)
rc = m.run(api, arglist, logger)
@@ -878,7 +879,8 @@ def run_triggers(api,ref,globber,additio
if ref:
arglist.append(ref.name)
for x in additional:
- arglist.append(x)
+ if x:
+ arglist.append(x)
if logger is not None:
logger.debug("running shell trigger %s" % file)
rc = subprocess_call(logger, arglist, shell=False) # close_fds=True)

View File

@ -0,0 +1,29 @@
diff -rupN cobbler-2.0.7.old/cobbler/templar.py cobbler-2.0.7/cobbler/templar.py
--- cobbler-2.0.7.old/cobbler/templar.py 2015-05-06 14:47:57.858206601 -0400
+++ cobbler-2.0.7/cobbler/templar.py 2015-05-06 14:54:56.002214099 -0400
@@ -108,6 +108,9 @@ class Templar:
# tell Cheetah not to blow up if it can't find a symbol for something
raw_data = "#errorCatcher ListErrors\n" + raw_data
+ # specify unicode encoding for Cheetah Compiler
+ raw_data = "#unicode UTF-8\n" + raw_data
+
table_copy = search_table.copy()
# for various reasons we may want to call a module inside a template and pass
diff -rupN cobbler-2.0.7.old/cobbler/template_api.py cobbler-2.0.7/cobbler/template_api.py
--- cobbler-2.0.7.old/cobbler/template_api.py 2015-05-06 14:47:57.860206615 -0400
+++ cobbler-2.0.7/cobbler/template_api.py 2015-05-06 14:59:50.250384146 -0400
@@ -311,8 +311,9 @@ class Template(BuiltinTemplate, MacrosTe
pass
try:
- return utils.read_file_contents('%s/%s' % (self.getVar('snippetsdir'),
- file), fetch_if_remote=True)
+ return "#unicode UTF-8\n" + utils.read_file_contents(
+ '%s/%s' % (self.getVar('snippetsdir'), file),
+ fetch_if_remote=True)
except FileNotFoundException:
return None

View File

@ -0,0 +1,27 @@
From 33b5fbd7ac2071aa5108c31b468504d8c9916ef8 Mon Sep 17 00:00:00 2001
From: Tomas Kasparek <tkasparek@redhat.com>
Date: Tue, 31 Oct 2017 11:07:14 +0100
Subject: [PATCH] 1314379 - updating logrotate config to cobbler 2.8 state
---
config/cobblerd_rotate | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/config/cobblerd_rotate b/config/cobblerd_rotate
index 1a1fb2f..b529355 100644
--- a/config/cobblerd_rotate
+++ b/config/cobblerd_rotate
@@ -4,9 +4,7 @@
rotate 4
weekly
postrotate
- if [ -f /var/lock/subsys/cobblerd ]; then
- /etc/init.d/cobblerd condrestart > /dev/null
- fi
+ /sbin/service cobblerd condrestart > /dev/null 2>&1
endscript
}
--
2.5.5

View File

@ -0,0 +1,39 @@
diff -rupN cobbler-2.0.7.old/scripts/services.py cobbler-2.0.7/scripts/services.py
--- cobbler-2.0.7.old/scripts/services.py 2015-07-29 10:26:04.312785484 -0400
+++ cobbler-2.0.7/scripts/services.py 2015-07-29 08:41:25.904423573 -0400
@@ -22,6 +22,7 @@ import os
from cobbler.services import CobblerSvc
import yaml # PyYAML version
import cobbler.utils as utils
+import urllib
#=======================================
@@ -34,7 +35,7 @@ def handler(req):
but we still need to use the token for all remote requests.
"""
- my_uri = req.uri
+ my_uri = urllib.unquote(req.uri)
req.add_common_vars()
diff -rupN cobbler-2.0.7.old/scripts/services.wsgi cobbler-2.0.7/scripts/services.wsgi
--- cobbler-2.0.7.old/scripts/services.wsgi 2015-07-29 10:26:04.312785484 -0400
+++ cobbler-2.0.7/scripts/services.wsgi 2015-07-29 10:14:41.360193691 -0400
@@ -22,13 +22,14 @@ Foundation, Inc., 51 Franklin Street, Fi
import yaml
import os
import xmlrpclib
+import urllib
from cobbler.services import CobblerSvc
import cobbler.utils as utils
def application(environ, start_response):
- my_uri = environ['REQUEST_URI']
+ my_uri = urllib.unquote(environ['REQUEST_URI'])
form = {}

View File

@ -0,0 +1,50 @@
--- ./koan/xencreate.py 2010-07-28 17:48:48.000000000 +0200
+++ ./koan/xencreate.py 2011-01-06 23:04:33.000000000 +0100
@@ -36,11 +36,16 @@ import virtinst
import app as koan
try:
- import virtinst.DistroManager as DistroManager
-except:
- # older virtinst, this is probably ok
- # but we know we can't do Xen fullvirt installs
- pass
+ from virtinst.DistroManager import PXEInstaller
+ pxe_installer = PXEInstaller()
+except ImportError:
+ try:
+ from virtinst import PXEInstaller
+ pxe_installer = PXEInstaller(os_type='hvm')
+ except:
+ # older virtinst, this is probably ok
+ # but we know we can't do Xen fullvirt installs
+ pass
import traceback
def random_mac():
@@ -77,7 +82,7 @@ def start_install(name=None,
if fullvirt:
# FIXME: add error handling here to explain when it's not supported
- guest = virtinst.FullVirtGuest(installer=DistroManager.PXEInstaller())
+ guest = virtinst.FullVirtGuest(installer=pxe_installer)
else:
guest = virtinst.ParaVirtGuest()
@@ -123,7 +128,15 @@ def start_install(name=None,
for d in disks:
if d[1] != 0 or d[0].startswith("/dev"):
- guest.disks.append(virtinst.XenDisk(d[0], size=d[1]))
+ virtdisk = virtinst.XenDisk(d[0], size=d[1])
+
+ # Set driver_name to tap for Xen PV guests
+ if guest.installer and guest.installer.os_type in ('xen', 'linux'):
+ if virtdisk.type == virtinst.XenDisk.TYPE_FILE and \
+ virtinst._util.is_blktap_capable():
+ virtdisk.driver_name = virtinst.XenDisk.DRIVER_TAP
+
+ guest.disks.append(virtdisk)
else:
raise koan.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")

View File

@ -0,0 +1,51 @@
--- ./koan/app.py 2011-08-24 11:54:37.985552147 +0200
+++ ./koan/app.py 2011-08-24 11:55:39.448880750 +0200
@@ -742,19 +742,19 @@ class Koan:
# Validate kernel argument length (limit depends on architecture --
# see asm-*/setup.h). For example:
- # asm-i386/setup.h:#define COMMAND_LINE_SIZE 256
+ # asm-i386/setup.h:#define COMMAND_LINE_SIZE 2048
# asm-ia64/setup.h:#define COMMAND_LINE_SIZE 512
# asm-powerpc/setup.h:#define COMMAND_LINE_SIZE 512
# asm-s390/setup.h:#define COMMAND_LINE_SIZE 896
- # asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 256
+ # asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
raise InfoException, "Kernel options are too long, 512 chars exceeded: %s" % k_args
elif arch.startswith("s390"):
if len(k_args) > 895:
raise InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args
- elif len(k_args) > 255:
- raise InfoException, "Kernel options are too long, 255 chars exceeded: %s" % k_args
+ elif len(k_args) > 2047:
+ raise InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args
utils.subprocess_call([
'kexec',
@@ -829,11 +829,11 @@ class Koan:
# Validate kernel argument length (limit depends on architecture --
# see asm-*/setup.h). For example:
- # asm-i386/setup.h:#define COMMAND_LINE_SIZE 256
+ # asm-i386/setup.h:#define COMMAND_LINE_SIZE 2048
# asm-ia64/setup.h:#define COMMAND_LINE_SIZE 512
# asm-powerpc/setup.h:#define COMMAND_LINE_SIZE 512
# asm-s390/setup.h:#define COMMAND_LINE_SIZE 896
- # asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 256
+ # asm-x86_64/setup.h:#define COMMAND_LINE_SIZE 2048
if not ANCIENT_PYTHON:
if arch.startswith("ppc") or arch.startswith("ia64"):
if len(k_args) > 511:
@@ -841,8 +841,8 @@ class Koan:
elif arch.startswith("s390"):
if len(k_args) > 895:
raise InfoException, "Kernel options are too long, 896 chars exceeded: %s" % k_args
- elif len(k_args) > 255:
- raise InfoException, "Kernel options are too long, 255 chars exceeded: %s" % k_args
+ elif len(k_args) > 2047:
+ raise InfoException, "Kernel options are too long, 2047 chars exceeded: %s" % k_args
cmd = [ "/sbin/grubby",
"--add-kernel", self.safe_load(profile_data,'kernel_local'),

View File

@ -0,0 +1,11 @@
--- ./koan/app.py 2011-03-31 20:47:55.360598401 +0200
+++ ./koan/app.py 2011-03-31 20:48:01.308598402 +0200
@@ -808,7 +808,7 @@ class Koan:
(make, version) = utils.os_release()
- if (make == "centos" and version < 6) or (make == "redhat" and version < 6) or (make == "fedora" and version < 10):
+ if (make == "centos" and version < 6) or (make == "redhat" and version < 7) or (make == "fedora" and version < 10):
# embed the initrd in the kickstart file because of libdhcp and/or pump
# needing the help due to some DHCP timeout potential in some certain

View File

@ -0,0 +1,31 @@
--- a/koan/app.py 2018-11-12 05:28:52.566167929 -0500
+++ b/koan/app.py 2018-11-12 05:32:12.017191022 -0500
@@ -614,7 +614,7 @@ class Koan:
nfs_parser.add_option("--server", dest="server")
for line in lines:
- match = method_re.match(line)
+ match = method_re.match(line.decode('utf-8'))
if match:
cmd = match.group("urlcmd")
if cmd:
--- a/koan/virtinstall.py 2018-11-12 05:32:23.803251480 -0500
+++ b/koan/virtinstall.py 2018-11-12 05:32:54.193407368 -0500
@@ -65,7 +65,7 @@ except:
try:
rc, response = subprocess_get_response(
shlex.split('virt-install --os-variant list'))
- variants = response.split('\n')
+ variants = response.decode('utf-8').split('\n')
for variant in variants:
supported_variants.add(variant.split()[0])
except:
@@ -73,7 +73,7 @@ except:
# maybe on newer os using osinfo-query?
rc, response = utils.subprocess_get_response(
shlex.split('osinfo-query os'))
- variants = response.split('\n')
+ variants = response.decode('utf-8').split('\n')
for variant in variants:
supported_variants.add(variant.split()[0])
except:

View File

@ -0,0 +1,11 @@
--- ./koan/app.py.orig 2018-10-18 09:57:07.010606609 -0400
+++ ./koan/app.py 2018-10-18 09:57:52.062860372 -0400
@@ -856,7 +856,7 @@
cmd = [ "/sbin/grubby",
"--add-kernel", self.safe_load(profile_data,'kernel_local'),
"--initrd", self.safe_load(profile_data,'initrd_local'),
- "--args", "\"%s\"" % k_args
+ "--args", k_args
]
if self.grubby_copy_default:

View File

@ -0,0 +1,19 @@
diff -rupN cobbler-2.0.7.old/koan/utils.py cobbler-2.0.7/koan/utils.py
--- cobbler-2.0.7.old/koan/utils.py 2015-01-12 13:33:54.809244930 -0500
+++ cobbler-2.0.7/koan/utils.py 2015-01-12 14:00:17.264594111 -0500
@@ -186,11 +186,10 @@ def subprocess_get_response(cmd, ignore_
rc = 0
result = ""
if not ANCIENT_PYTHON:
- try:
- result = sub_process.check_output(cmd).strip()
- except sub_process.CalledProcessError, e:
- rc = e.returncode
- result = e.output
+ p = sub_process.Popen(cmd, stdout=sub_process.PIPE, stderr=sub_process.STDOUT)
+ result, stderr = p.communicate()
+ result = result.strip()
+ rc = p.poll()
else:
cmd = string.join(cmd, " ")
print "cmdstr=(%s)" % cmd

View File

@ -0,0 +1,21 @@
diff -rupN cobbler-2.0.7.old/koan/app.py cobbler-2.0.7/koan/app.py
--- cobbler-2.0.7.old/koan/app.py.org 2016-03-15 12:58:22.739224509 -0400
+++ cobbler-2.0.7/koan/app.py 2016-03-15 12:58:49.898224509 -0400
@@ -922,6 +922,17 @@ class Koan:
utils.subprocess_call(cmd)
+ # Need to remove the root= argument to prevent booting the current OS
+ cmd = [
+ "/sbin/grubby",
+ "--update-kernel",
+ self.safe_load(
+ profile_data,
+ 'kernel_local'),
+ "--remove-args=root"]
+
+ utils.subprocess_call(cmd)
+
# Any post-grubby processing required (e.g. ybin, zipl, lilo)?
if not ANCIENT_PYTHON and arch.startswith("ppc") and "grub2" not in probe_output:
# FIXME - CHRP hardware uses a 'PPC PReP Boot' partition and doesn't require running ybin

View File

@ -0,0 +1,21 @@
--- a/koan/app.py
+++ b/koan/app.py
@@ -727,7 +727,7 @@ class Koan:
(make, version) = utils.os_release()
- if (make == "centos" and version < 6) or (make == "redhat" and version < 6) or (make == "fedora" and version < 10):
+ if (make == "centos" and version < 8) or (make == "redhat" and version < 8) or (make == "fedora" and version < 10):
# embed the initrd in the kickstart file because of libdhcp and/or pump
# needing the help due to some DHCP timeout potential in some certain
@@ -808,7 +808,7 @@ class Koan:
(make, version) = utils.os_release()
- if (make == "centos" and version < 6) or (make == "redhat" and version < 7) or (make == "fedora" and version < 10):
+ if (make == "centos" and version < 8) or (make == "redhat" and version < 8) or (make == "fedora" and version < 10):
# embed the initrd in the kickstart file because of libdhcp and/or pump
# needing the help due to some DHCP timeout potential in some certain

View File

@ -0,0 +1,23 @@
diff -rupN cobbler-2.0.7-old/koan/app.py cobbler-2.0.7-new/koan/app.py
--- cobbler-2.0.7-old/koan/app.py 2014-03-18 13:53:31.916116417 -0400
+++ cobbler-2.0.7-new/koan/app.py 2014-03-18 13:56:36.590423095 -0400
@@ -875,14 +875,17 @@ class Koan:
# Are we running on ppc?
if not ANCIENT_PYTHON:
if arch.startswith("ppc"):
- cmd.append("--yaboot")
+ if "grub2" in probe_output:
+ cmd.append("--grub2")
+ else:
+ cmd.append("--yaboot")
elif arch.startswith("s390"):
cmd.append("--zipl")
utils.subprocess_call(cmd)
# Any post-grubby processing required (e.g. ybin, zipl, lilo)?
- if not ANCIENT_PYTHON and arch.startswith("ppc"):
+ if not ANCIENT_PYTHON and arch.startswith("ppc") and "grub2" not in probe_output:
# FIXME - CHRP hardware uses a 'PPC PReP Boot' partition and doesn't require running ybin
print "- applying ybin changes"
cmd = [ "/sbin/ybin" ]

File diff suppressed because it is too large Load Diff

34
SOURCES/koan-rhel71.patch Normal file
View File

@ -0,0 +1,34 @@
diff -rupN cobbler-2.0.7.old/koan/virtinstall.py cobbler-2.0.7/koan/virtinstall.py
--- cobbler-2.0.7.old/koan/virtinstall.py 2015-01-22 11:11:27.917649507 -0500
+++ cobbler-2.0.7/koan/virtinstall.py 2015-01-22 11:30:07.849523465 -0500
@@ -69,7 +69,16 @@ except:
for variant in variants:
supported_variants.add(variant.split()[0])
except:
- pass # No problem, we'll just use generic
+ try:
+ # maybe on newer os using osinfo-query?
+ rc, response = utils.subprocess_get_response(
+ shlex.split('osinfo-query os'))
+ variants = response.split('\n')
+ for variant in variants:
+ supported_variants.add(variant.split()[0])
+ except:
+ # okay, probably on old os and we'll just use generic26
+ pass
def _sanitize_disks(disks):
ret = []
@@ -362,6 +371,12 @@ def build_commandline(uri,
found = False
if os_version in supported_variants:
cmd += "--os-variant %s " % os_version
+ elif os_version + ".0" in supported_variants:
+ # osinfo based virt-install only knows about major.minor
+ # variants, not just major variants like it used to. Default
+ # to major.0 variant in that case. Lack of backwards
+ # compatibility in virt-install grumble grumble.
+ cmd += "--os-variant %s" % os_version + ".0 "
else:
print ("- warning: virt-install doesn't know this os_version, defaulting to generic26")
cmd += "--os-variant generic26 "

View File

@ -0,0 +1,12 @@
diff -rupN cobbler-2.0.7.org/koan/utils.py cobbler-2.0.7/koan/utils.py
--- cobbler-2.0.7.org/koan/utils.py 2015-10-09 08:27:48.306630477 -0400
+++ cobbler-2.0.7/koan/utils.py 2015-10-09 08:27:11.026630477 -0400
@@ -213,7 +213,7 @@ def input_string_or_hash(options,delim=N
new_dict = {}
tokens = string.split(options, delim)
for t in tokens:
- tokens2 = string.split(t,"=")
+ tokens2 = string.split(t,"=",1)
if len(tokens2) == 1:
# this is a singleton option, no value
key = tokens2[0]

View File

@ -0,0 +1,66 @@
From 53b4932a705653c45228db287fc933a1288b5108 Mon Sep 17 00:00:00 2001
From: Jan Dobes <jdobes@redhat.com>
Date: Tue, 17 Oct 2017 11:58:51 +0200
Subject: [PATCH] support kvm type
copy from Cobbler 2.8
---
koan/app.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/koan/app.py b/koan/app.py
index bacc135..b7dabb1 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -327,10 +327,10 @@
# if --virt-type was specified and invalid, then fail
if self.virt_type is not None:
self.virt_type = self.virt_type.lower()
- if self.virt_type not in [ "qemu", "xenpv", "xenfv", "xen", "vmware", "vmwarew", "auto" ]:
+ if self.virt_type not in [ "qemu", "xenpv", "xenfv", "xen", "vmware", "vmwarew", "auto", "kvm" ]:
if self.virt_type == "xen":
self.virt_type = "xenpv"
- raise(InfoException("--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto"))
+ raise(InfoException("--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, kvm or auto"))
# if --qemu-disk-type was called without --virt-type=qemu, then fail
if (self.qemu_disk_type is not None):
@@ -545,7 +545,7 @@
raise(InfoException("xend needs to be started"))
# for qemu
- if self.virt_type == "qemu":
+ if self.virt_type in [ "qemu", "kvm" ]:
# qemu package installed?
if not os.path.exists("/usr/bin/qemu-img"):
raise(InfoException("qemu package needs to be installed"))
@@ -1201,7 +1201,7 @@
if virt_auto_boot:
if self.virt_type in [ "xenpv", "xenfv" ]:
utils.create_xendomains_symlink(virtname)
- elif self.virt_type == "qemu":
+ elif self.virt_type in [ "qemu", "kvm" ]:
utils.libvirt_enable_autostart(virtname)
else:
print("- warning: don't know how to autoboot this virt type yet")
@@ -1225,7 +1225,7 @@
if self.virt_type == "xenfv":
fullvirt = True
can_poll = "xen"
- elif self.virt_type == "qemu":
+ elif self.virt_type in [ "qemu", "kvm" ]:
fullvirt = True
uuid = None
from koan import qcreate
@@ -1410,7 +1410,7 @@
# not set in cobbler either? then assume reasonable defaults
if self.virt_type in [ "xenpv", "xenfv" ]:
prefix = "/var/lib/xen/images/"
- elif self.virt_type == "qemu":
+ elif self.virt_type in [ "qemu", "kvm" ]:
prefix = "/var/lib/libvirt/images/"
elif self.virt_type == "vmwarew":
prefix = "/var/lib/vmware/%s/" % name
--
1.8.3.1

View File

@ -0,0 +1,51 @@
--- a/koan/virtinstall.py 2018-11-12 05:32:23.803251480 -0500
+++ b/koan/virtinstall.py 2018-11-12 06:40:17.454546012 -0500
@@ -70,12 +70,13 @@ except:
supported_variants.add(variant.split()[0])
except:
try:
- # maybe on newer os using osinfo-query?
- rc, response = utils.subprocess_get_response(
- shlex.split('osinfo-query os'))
+ rc, response = subprocess_get_response(
+ shlex.split('osinfo-query -f short-id os'))
variants = response.decode('utf-8').split('\n')
for variant in variants:
- supported_variants.add(variant.split()[0])
+ supported_variants.add(variant.strip())
+ # osinfo-query does not list virtio26, add it here for fallback
+ supported_variants.add('virtio26')
except:
# okay, probably on old os and we'll just use generic26
pass
@@ -367,19 +368,24 @@ def build_commandline(uri,
if suse_version_re.match(os_version):
os_version = suse_version_re.match(os_version).groups()[0]
# make sure virt-install knows about our os_version,
- # otherwise default it to generic26
- found = False
+ # otherwise default it to virtio26 or generic26
+ # found = False
if os_version in supported_variants:
- cmd += "--os-variant %s " % os_version
+ pass # os_version is correct
elif os_version + ".0" in supported_variants:
# osinfo based virt-install only knows about major.minor
# variants, not just major variants like it used to. Default
# to major.0 variant in that case. Lack of backwards
# compatibility in virt-install grumble grumble.
- cmd += "--os-variant %s" % os_version + ".0 "
+ os_version = os_version + ".0"
else:
- print(("- warning: virt-install doesn't know this os_version, defaulting to generic26"))
- cmd += "--os-variant generic26 "
+ if "virtio26" in supported_variants:
+ os_version = "virtio26"
+ else:
+ os_version = "generic26"
+ print("- warning: virt-install doesn't know this os_version, "
+ "defaulting to %s" % os_version)
+ cmd += "--os-variant %s " % os_version
else:
distro = "unix"
if breed in [ "debian", "suse", "redhat" ]:

View File

@ -0,0 +1,103 @@
diff -rupN cobbler-2.0.7.old/koan/app.py cobbler-2.0.7.new/koan/app.py
--- cobbler-2.0.7.old/koan/app.py 2014-11-06 15:02:37.476914876 -0500
+++ cobbler-2.0.7.new/koan/app.py 2014-11-06 15:14:29.830881393 -0500
@@ -182,6 +182,22 @@ def main():
dest="embed_kickstart",
action="store_true",
help="When used with --replace-self, embed the kickstart in the initrd to overcome potential DHCP timeout issues. (seldom needed)")
+ p.add_option("", "--qemu-disk-type",
+ dest="qemu_disk_type",
+ help="when used with --virt_type=qemu, add select of disk driver types: ide,scsi,virtio")
+ p.add_option("", "--qemu-net-type",
+ dest="qemu_net_type",
+ help="when used with --virt_type=qemu, select type of network device to use: e1000, ne2k_pci, pcnet, rtl8139, virtio")
+ p.add_option("", "--wait",
+ dest="wait", type='int', default=0, # default to 0 for koan backwards compatibility
+ help="pass the --wait=<INT> argument to virt-install")
+ p.add_option("", "--cpu",
+ dest="cpu",
+ help="pass the --cpu argument to virt-install")
+ p.add_option("", "--noreboot",
+ dest="noreboot", default=False, # default to False for koan backwards compatibility
+ action="store_true",
+ help="pass the --noreboot argument to virt-install")
(options, args) = p.parse_args()
@@ -209,6 +225,11 @@ def main():
k.should_poll = options.should_poll
k.embed_kickstart = options.embed_kickstart
k.virt_auto_boot = options.virt_auto_boot
+ k.qemu_disk_type = options.qemu_disk_type
+ k.qemu_net_type = options.qemu_net_type
+ k.virtinstall_cpu = options.cpu
+ k.virtinstall_wait = options.wait
+ k.virtinstall_noreboot= options.noreboot
if options.virt_name is not None:
k.virt_name = options.virt_name
@@ -264,6 +285,11 @@ class Koan:
self.virt_path = None
self.qemu_disk_type = None
self.virt_auto_boot = None
+ self.qemu_disk_type = None
+ self.qemu_net_type = None
+ self.virtinstall_cpu = None
+ self.virtinstall_wait = None
+ self.virtinstall_noreboot = None
# This option adds the --copy-default argument to /sbin/grubby
# which uses the default boot entry in the grub.conf
@@ -330,6 +356,18 @@ class Koan:
self.virt_type = "xenpv"
raise InfoException, "--virt-type should be qemu, xenpv, xenfv, vmware, vmwarew, or auto"
+ # if --qemu-disk-type was called without --virt-type=qemu, then fail
+ if (self.qemu_disk_type is not None):
+ self.qemu_disk_type = self.qemu_disk_type.lower()
+ if self.virt_type not in [ "qemu", "auto", "kvm" ]:
+ raise InfoException, "--qemu-disk-type must use with --virt-type=qemu"
+
+ # if --qemu-net-type was called without --virt-type=qemu, then fail
+ if (self.qemu_net_type is not None):
+ self.qemu_net_type = self.qemu_net_type.lower()
+ if self.virt_type not in [ "qemu", "auto", "kvm" ]:
+ raise InfoException, "--qemu-net-type must use with --virt-type=qemu"
+
# if --static-interface and --profile was called together, then fail
if self.static_interface is not None and self.profile is not None:
raise InfoException, "--static-interface option is incompatible with --profile option use --system instead"
@@ -1145,7 +1183,12 @@ class Koan:
fullvirt = fullvirt,
bridge = self.virt_bridge,
virt_type = self.virt_type,
- virt_auto_boot = virt_auto_boot
+ virt_auto_boot = virt_auto_boot,
+ qemu_driver_type = self.qemu_disk_type,
+ qemu_net_type = self.qemu_net_type,
+ cpu = self.virtinstall_cpu,
+ wait = self.virtinstall_wait,
+ noreboot = self.virtinstall_noreboot,
)
print results
diff -rupN cobbler-2.0.7.old/koan/virtinstall.py cobbler-2.0.7.new/koan/virtinstall.py
--- cobbler-2.0.7.old/koan/virtinstall.py 2014-11-06 15:02:37.476914876 -0500
+++ cobbler-2.0.7.new/koan/virtinstall.py 2014-11-06 15:11:11.564499529 -0500
@@ -162,6 +162,7 @@ def build_commandline(uri,
qemu_driver_type=None,
qemu_net_type=None,
qemu_machine_type=None,
+ cpu=None,
wait=0,
noreboot=False,
osimport=False):
@@ -404,6 +405,8 @@ def build_commandline(uri,
cmd += " "
cmd += "--wait %d " % int(wait)
+ if cpu:
+ cmd += "--cpu %s " % cpu
if noreboot:
cmd += "--noreboot "
if osimport and not(import_exists):

View File

@ -0,0 +1,23 @@
--- ./koan/app.py 2012-06-21 13:38:43.303738934 +0200
+++ ./koan/app.py 2012-06-21 13:40:26.704251677 +0200
@@ -912,7 +912,9 @@ class Koan:
return r"""
cd /var/spool/koan
mkdir initrd
- gzip -dc %s > initrd.tmp
+ if ! gzip -dc %s > initrd.tmp 2> /dev/null; then
+ xz -dc %s > initrd.tmp
+ fi
if mount -o loop -t ext2 initrd.tmp initrd >&/dev/null ; then
cp ks.cfg initrd/
ln initrd/ks.cfg initrd/tmp/ks.cfg
@@ -927,7 +929,7 @@ class Koan:
find . | cpio -o -H newc | gzip -9 > ../initrd_final
echo "...done"
fi
- """ % initrd
+ """ % (initrd, initrd)
#---------------------------------------------------

View File

@ -0,0 +1,37 @@
diff -ru cobbler-2.0.7.orig/koan/app.py cobbler-2.0.7/koan/app.py
--- cobbler-2.0.7.orig/koan/app.py 2013-04-10 10:51:54.775900810 +0200
+++ cobbler-2.0.7/koan/app.py 2013-04-10 10:52:36.816981814 +0200
@@ -1491,32 +1491,8 @@
if lv_create != 0:
raise InfoException, "LVM creation failed"
- # partition location
- partition_location = "/dev/%s/%s" % (location,name)
-
- # check whether we have SELinux enabled system
- args = "/usr/sbin/selinuxenabled"
- selinuxenabled = sub_process.call(args)
- if selinuxenabled == 0:
- # required context type
- context_type = "virt_image_t"
-
- # change security context type to required one
- args = "/usr/bin/chcon -t %s %s" % (context_type, partition_location)
- print "%s" % args
- change_context = sub_process.call(args, close_fds=True, shell=True)
-
- # modify SELinux policy in order to preserve security context
- # between reboots
- args = "/usr/sbin/semanage fcontext -a -t %s %s" % (context_type, partition_location)
- print "%s" % args
- change_context |= sub_process.call(args, close_fds=True, shell=True)
-
- if change_context != 0:
- raise InfoException, "SELinux security context setting to LVM partition failed"
-
# return partition location
- return partition_location
+ return "/dev/%s/%s" % (location,name)
else:
raise InfoException, "volume group needs %s GB free space." % virt_size

678
SPECS/cobbler.spec Normal file
View File

@ -0,0 +1,678 @@
%if 0%{?fedora} || 0%{?rhel} >= 8
%global build_py3 1
%global default_py3 1
%{!?python3_sitelib: %global python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif
%define pythonX %{?default_py3: python3}%{!?default_py3: python2}
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%define _binaries_in_noarch_packages_terminate_build 0
%global debug_package %{nil}
Summary: Boot server configurator
Name: cobbler
License: GPLv2+
AutoReq: no
Version: 2.0.7.1
Release: 5%{?dist}
Source0: cobbler-%{version}.tar.gz
Patch0: cobbler-pxelinux-s390x-bz580072.patch
Patch1: cobbler-xenpv-tap-driver.patch
Patch2: cobbler-koan-rhpl.patch
Patch3: koan-el6-ks-embed.patch
Patch4: cobbler-disable-check-selinux-bz706857.patch
Patch5: cobbler-disable-hardlinks-bz568801.patch
Patch6: cobbler-no-remove-pub-bz707215.patch
Patch7: cobbler-keep-ssh-snippet.patch
Patch8: cobbler-netaddr.patch
Patch9: cobbler-lvm-installation.patch
Patch10: koan-cmdline-length.patch
Patch11: cobbler-bz-253274.patch
Patch12: cobbler-token-validation.patch
Patch13: cobbler-ipv6-xmlrpc.patch
Patch14: cobbler-ipv6-snippet.patch
Patch15: koan-xz-initrd.patch
Patch16: cobbler-nic-dash.patch
Patch17: cobbler-power-vulnerability.patch
Patch18: cobbler-rhel6-bonding.patch
Patch19: cobbler-catch-cheetah-exception.patch
Patch20: cobbler-lvm-selinux.patch
Patch21: koan_no_selinux_set.patch
Patch22: cobbler-buildiso.patch
Patch23: cobbler-daemon.patch
Patch24: cobbler-rhel7-snippets.patch
Patch25: koan-rhel7-initramfs-embedding.patch
Patch26: cobbler-bootproto-post-install.patch
Patch27: cobbler-triggers.patch
Patch28: cobbler-concurrency.patch
Patch29: koan-rhel7-virtinst.patch
Patch30: koan-rhel7-ppc.patch
Patch31: cobbler-rhel7-distros.patch
Patch32: cobbler-remote-addr.patch
Patch34: cobbler-modprobe-d.patch
Patch35: cobbler-findks.patch
Patch36: koan-virt-install-options.patch
Patch37: cobbler-power-status.patch
Patch38: koan-no-check_output.patch
Patch39: koan-rhel71.patch
Patch40: cobbler-unicode-scripts.patch
Patch41: cobbler-bz1052857.patch
Patch42: buildiso-boot-options.patch
Patch43: cobbler-uudecode.patch
Patch44: buildiso-no-local-hdd.patch
Patch45: cobbler-s390-kernel-options.patch
Patch46: koan-s390-kernel-options-parse.patch
Patch47: koan-remove-root-argument.patch
Patch48: cobbler-updating-logrotate-config.patch
Patch49: cobbler-post-install-network-defaults.patch
Patch50: 0001-exceptions-module-doesn-t-have-to-be-imported.patch
Patch51: 0002-cleanup-ANCIENT_PYTHON-stuff-and-unused-imports.patch
Patch52: 0003-fixing-xmlrpclib-urllib2-and-local-imports-in-Python.patch
Patch53: 0004-Python-3-compatible-prints.patch
Patch54: 0005-Python-3-compatible-exceptions.patch
Patch55: 0006-octal-number-Python-3-fix.patch
Patch56: 0007-Python-3-compatible-string-operations.patch
Patch57: 0008-do-not-require-urlgrabber.patch
Patch58: 0009-replace-iteritems-with-items.patch
Patch59: 0010-open-target-file-in-binary-mode.patch
Patch60: 0011-make-sure-it-s-a-string.patch
Patch61: 0012-make-sure-list-is-returned.patch
Patch62: 0013-Python-3-ethtool-and-indentation-fixes.patch
Patch63: 0014-has_key-is-not-in-Python-3.patch
Patch64: 0015-relative-imports-don-t-work-on-both-Python-2-and-3.patch
Patch65: 0016-keys-and-sort-doesn-t-work-on-Python-3.patch
Patch66: 0017-raise-is-a-function-call-in-python3.patch
Patch67: 0018-adapt-setup.py-for-both-py2-and-py3.patch
Patch68: koan-grubby480.patch
Patch69: koan-fix-TypeError.patch
Patch70: koan-support-osinfo-query.patch
Patch71: koan-support-kvm-type.patch
Group: Applications/System
%if 0%{?default_py3}
%if 0%{?fedora} && 0%{?fedora} < 21
BuildRequires: python3-setuptools-devel
%else
BuildRequires: python3-setuptools
%endif
%if 0%{?suse_version} < 0
BuildRequires: redhat-rpm-config
%endif
BuildRequires: python3-PyYAML
%endif
Requires: python >= 2.3
Provides: cobbler2 = %{version}-%{release}
%if 0%{?suse_version} >= 1000
Requires: apache2
Requires: apache2-mod_python
Requires: tftp
%else
Requires: httpd
Requires: tftp-server
%endif
%if 0%{?rhel} >= 6
Requires: mod_wsgi
Requires: ipmitool
%else
Requires: mod_python
%endif
Requires: createrepo
%if 0%{?fedora} >= 11 || 0%{?rhel} >= 6
Requires: genisoimage
%else
Requires: mkisofs
%endif
Requires: libyaml
Requires: python-cheetah
Requires: python-devel
Requires: python-netaddr
Requires: python-simplejson
Requires: python-urlgrabber
Requires: PyYAML
Requires: rsync
%if 0%{?fedora} >= 6 || 0%{?rhel} >= 5
Requires: yum-utils
%endif
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
%if 0%{?fedora} >= 11 || 0%{?rhel} >= 6
%{!?pyver: %define pyver %(%{__python} -c "import sys ; print sys.version[:3]" || echo 0)}
Requires: python(abi) >= %{pyver}
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url: http://fedorahosted.org/cobbler
%description
Cobbler is a network install server. Cobbler
supports PXE, virtualized installs, and
reinstalling existing Linux machines. The last two
modes use a helper tool, 'koan', that
integrates with cobbler. There is also a web interface
'cobbler-web'. Cobbler's advanced features
include importing distributions from DVDs and rsync
mirrors, kickstart templating, integrated yum
mirroring, and built-in DHCP/DNS Management. Cobbler has
a XMLRPC API for integration with other applications.
%prep
%setup -q
%patch0 -p0
%patch1 -p0
%patch2 -p0
%patch3 -p0
%patch4 -p0
%patch5 -p0
%patch6 -p0
%patch7 -p0
%patch8 -p0
%patch9 -p0
%patch10 -p0
%patch11 -p1
%patch12 -p0
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p0
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch55 -p1
%patch56 -p1
%patch57 -p1
%patch58 -p1
%patch59 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%build
%{pythonX} setup.py build
%install
test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%if 0%{?suse_version} >= 1000
PREFIX="--prefix=/usr"
%endif
%if 0%{?build_py3}
sed -i 's|#!/usr/bin/python|#!/usr/bin/python3|' {scripts/koan,scripts/cobbler-register}
%endif
%{pythonX} setup.py install --optimize=1 --root=$RPM_BUILD_ROOT $PREFIX
mkdir -p $RPM_BUILD_ROOT/var/log/koan
mkdir -p $RPM_BUILD_ROOT/var/spool/koan
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1/
cp docs/cobbler-register.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1/
cp docs/koan.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1/
cp koan/*py $RPM_BUILD_ROOT/%{python3_sitelib}/koan/
%post
if [ "$1" = "1" ];
then
# This happens upon initial install. Upgrades will follow the next else
/sbin/chkconfig --add cobblerd
elif [ "$1" -ge "2" ];
then
# backup config
if [ -e /var/lib/cobbler/distros ]; then
cp /var/lib/cobbler/distros* /var/lib/cobbler/backup 2>/dev/null
cp /var/lib/cobbler/profiles* /var/lib/cobbler/backup 2>/dev/null
cp /var/lib/cobbler/systems* /var/lib/cobbler/backup 2>/dev/null
cp /var/lib/cobbler/repos* /var/lib/cobbler/backup 2>/dev/null
cp /var/lib/cobbler/networks* /var/lib/cobbler/backup 2>/dev/null
fi
if [ -e /var/lib/cobbler/config ]; then
cp -a /var/lib/cobbler/config /var/lib/cobbler/backup 2>/dev/null
fi
# upgrade older installs
# move power and pxe-templates from /etc/cobbler, backup new templates to *.rpmnew
for n in power pxe; do
rm -f /etc/cobbler/$n*.rpmnew
find /etc/cobbler -maxdepth 1 -name "$n*" -type f | while read f; do
newf=/etc/cobbler/$n/`basename $f`
[ -e $newf ] && mv $newf $newf.rpmnew
mv $f $newf
done
done
# upgrade older installs
# copy kickstarts from /etc/cobbler to /var/lib/cobbler/kickstarts
rm -f /etc/cobbler/*.ks.rpmnew
find /etc/cobbler -maxdepth 1 -name "*.ks" -type f | while read f; do
newf=/var/lib/cobbler/kickstarts/`basename $f`
[ -e $newf ] && mv $newf $newf.rpmnew
cp $f $newf
done
# reserialize and restart
# FIXIT: ?????
#/usr/bin/cobbler reserialize
/sbin/service cobblerd condrestart
fi
%preun
if [ $1 = 0 ]; then
/sbin/service cobblerd stop >/dev/null 2>&1 || :
chkconfig --del cobblerd || :
fi
%postun
if [ "$1" -ge "1" ]; then
/sbin/service cobblerd condrestart >/dev/null 2>&1 || :
/sbin/service httpd condrestart >/dev/null 2>&1 || :
fi
%clean
test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%package -n koan
Summary: Helper tool that performs cobbler orders on remote machines.
Group: Applications/System
%if 0%{?build_py3}
Requires: python3-koan
%else
Requires: python2-koan
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url: http://fedorahosted.org/cobbler/
%description -n koan
Koan stands for kickstart-over-a-network and allows for both
network installation of new virtualized guests and reinstallation
of an existing system. For use with a boot-server configured with Cobbler
%files -n koan
%defattr(644,root,root,755)
# FIXME: need to generate in setup.py
%dir /var/spool/koan
%{_mandir}/man1/koan.1.gz
%{_mandir}/man1/cobbler-register.1.gz
%dir /var/log/koan
%doc AUTHORS COPYING CHANGELOG README
%if 0%{?build_py3}
%package -n python3-koan
Summary: Helper tool that performs cobbler orders on remote machines.
Group: Applications/System
%{?__python3:Requires: %{__python3}}
BuildRequires: python3-devel
%if 0%{?fedora} >= 11 || 0%{?rhel} >= 6
%{!?pyver: %define pyver %(%{__python} -c "import sys ; print sys.version[:3]")}
Requires: python(abi) >= %{pyver}
%endif
%if 0%{?fedora} && 0%{?fedora} < 21
BuildRequires: python3-setuptools-devel
%else
BuildRequires: python3-setuptools
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url: http://fedorahosted.org/cobbler/
%description -n python3-koan
Koan stands for kickstart-over-a-network and allows for both
network installation of new virtualized guests and reinstallation
of an existing system. For use with a boot-server configured with Cobbler
%files -n python3-koan
%{_bindir}/koan
%{_bindir}/cobbler-register
%{python3_sitelib}/koan/
%{python3_sitelib}/koan-*.egg-info
%endif
%changelog
* Thu Mar 21 2019 Michael Mraka <michael.mraka@redhat.com> 2.0.7.1-5
- 1686794 - backported koan kvm support patch
* Wed Mar 06 2019 Michael Mraka <michael.mraka@redhat.com> 2.0.7.1-4
- removed patches which break RHEL8
* Tue Mar 05 2019 Michael Mraka <michael.mraka@redhat.com> 2.0.7.1-3
- remove broken unused dependency
* Mon Nov 12 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7.1-2
- 1647351 - fix provisioning of RHEL8 virtual guests (tkasparek@redhat.com)
* Wed Nov 07 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7.1-1
- Resolves: rhbz#1647355 - RHEL8 version should be higher than RHEL7
* Fri Oct 19 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-6
- 1633713 - Require the Python interpreter directly instead of using the
package name (tkasparek@redhat.com)
* Thu Oct 18 2018 Michael Mraka <michael.mraka@redhat.com> 2.0.7-5
- 1640635 - don't quote kernel args (michael.mraka@redhat.com)
- use python3 dependencies (tkasparek@redhat.com)
* Tue Jul 24 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-4
- require python3 packages in buildtime (tkasparek@redhat.com)
* Tue Jul 24 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-3
- fix bogus changelog date (nils@redhat.com)
- remove subpackages we don't ship (nils@redhat.com)
- deactivate main package BRs if we don't build it (nils@redhat.com)
- concentrate main package BRs in one place (nils@redhat.com)
- add tito.props for cobbler (tkasparek@redhat.com)
* Thu Mar 08 2018 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-2
- reset package release (tkasparek@redhat.com)
- package koan properly (tkasparek@redhat.com)
- python-urlgrabber is no longer needed in koan (tkasparek@redhat.com)
- don't build cobbler subpackage at all (tkasparek@redhat.com)
- build python3 version of koan (tkasparek@redhat.com)
- add python3 patches (tkasparek@redhat.com)
- resue cobbler from Satellite git (tkasparek@redhat.com)
* Tue Oct 31 2017 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-69
- 1178515 - use empty string when key is not defined in
post_install_network_config snippet
- 1314379 - updating logrotate config to cobbler 2.8 state
* Mon Apr 25 2016 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-68
- 1208253 - remove the root= argument to prevent booting the current OS
* Wed Jan 13 2016 Grant Gainey 2.0.7-67
- 1279986 - Updated version for PPC64LE release
* Wed Dec 09 2015 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-66
- add system support to --no-local-hdd option without need of profiles
* Thu Oct 29 2015 Jan Dobes 2.0.7-65
- 1270676 - split only once for creating key-value pairs
* Mon Oct 05 2015 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-64
- 1078820 - timeout to 1st available profile with --no-local-hdd instead of
local hdd
* Wed Sep 09 2015 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-63
- 1199214 - removing kernel options for s390 systems
- add option to skip local harddrive as buildiso entry
* Wed Jul 29 2015 Grant Gainey 2.0.7-62
- 1245769 - Apply fix to remaining codepath
* Tue Jul 28 2015 Grant Gainey 2.0.7-61
- Having a patch isn't enough, the spec has to actually *apply* it
* Wed Jul 22 2015 Grant Gainey 2.0.7-60
- Let cobbler handle urlencoded URLs (see upstream commit
c9a51eec74a66d5034c47f08212177884642d70e for full explanation)
* Mon Jun 29 2015 Jan Dobes 2.0.7-59
- Revert "fix adding netmask kernel parameter into isolinux.cfg"
* Thu Jun 25 2015 Tomas Kasparek <tkasparek@redhat.com> 2.0.7-58
- 1095198 - fixing multiple nameserver boot options on rhel7 and fedora
- fix adding netmask kernel parameter into isolinux.cfg
* Tue Jun 02 2015 Jan Dobes 2.0.7-57
- 1227340 - fixing order of cheetah keywords
* Wed May 20 2015 Grant Gainey 2.0.7-56
- 1052857 - fix typo in patch
* Wed May 06 2015 Stephen Herr <sherr@redhat.com> 2.0.7-55
- 1052857 - remove python timing window for incorrect file permissions
- 1096263 - set Cheetah templates to use UTF-8
* Thu Jan 22 2015 Stephen Herr <sherr@redhat.com> 2.0.7-54
- 1184595 - update koan to be compatible with rhel 7.1 virt-install
* Mon Jan 12 2015 Stephen Herr <sherr@redhat.com> 2.0.7-53
- 1181286 - check_output is only available on RHEL 7
* Fri Dec 05 2014 Tomas Lestach <tlestach@redhat.com> 2.0.7-52
- 1169741 - accept more power status messages
* Mon Dec 01 2014 Stephen Herr <sherr@redhat.com> 2.0.7-51
- 1162311 - remove comment from power template
* Mon Nov 10 2014 Stephen Herr <sherr@redhat.com> 2.0.7-50
- 1162337 - install ipmitool by default so that power management will work
- 1162311 - add status power command support to cobbler
* Thu Nov 06 2014 Stephen Herr <sherr@redhat.com> 2.0.7-49
- 1002467 - add optional virt-install options to koan
- cobbler (koan) is in RHN Tools which we build on all RHEL 5/6/7
* Fri Sep 26 2014 Stephen Herr <sherr@redhat.com> 2.0.7-48
- 1138710 - fixing arm-arch patch, cobbler-2.0.7 does not have cache arg
* Thu Sep 11 2014 Stephen Herr <sherr@redhat.com> 2.0.7-47
- 979966 - auto-trialing-whitespace trim broke patch file
- 905129 - add support for cobbler findks operation
* Thu Sep 11 2014 Michael Mraka <michael.mraka@redhat.com> 2.0.7-46
- 979966 - support modprobe.d on RHEL6
* Fri Sep 05 2014 Stephen Herr <sherr@redhat.com> 2.0.7-45
- 1138710 - cobbler should support provisioning aarch64 systems
* Mon Jun 02 2014 Stephen Herr <sherr@redhat.com> 2.0.7-44
- 1057785 - set REMOTE_ADDR for cobbler triggers
* Wed Apr 09 2014 Stephen Herr <sherr@redhat.com> 2.0.7-43
- 1051160 - update available distros to include rhel7
* Tue Mar 25 2014 Stephen Herr <sherr@redhat.com> 2.0.7-42
- 1073822 - koan needs to be grub2 aware for ppc
* Thu Dec 05 2013 Stephen Herr <sherr@redhat.com> 2.0.7-41
- 1029493 - fixing koan guest arch and kvm acceleration issue
* Fri Nov 22 2013 Stephen Herr <sherr@redhat.com> 2.0.7-40
- 1029493 - provisioning virtual guests on rhel 7 fails
* Thu Oct 24 2013 Stephen Herr <sherr@redhat.com> 2.0.7-39
- 1008967 - adding finally blocks to lock releases - cobbler concurrency
* Mon Oct 21 2013 Stephen Herr <sherr@redhat.com> 2.0.7-38
- 1008967 - better concurrency in cobbler
* Wed Jul 17 2013 Stephen Herr <sherr@redhat.com> 2.0.7-37
- 856944 - make cobbler triggers work
* Fri Jul 12 2013 Stephen Herr <sherr@redhat.com> 2.0.7-36
- 506485 - spaces in the source file mean you have to keep spaces in the patch
* Fri Jul 12 2013 Stephen Herr <sherr@redhat.com> 2.0.7-35
- 506485 - cobbler buildiso documentation updates
* Fri Jul 12 2013 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-34
- 895096 - correctly setup dhcp networking for new systems
- 886609 - Support for ks.cfg initramfs embedding on RHEL-7
- 883885 - pre/post install_network_config: RHEL-7 support
* Thu Jul 11 2013 Stephen Herr <sherr@redhat.com> 2.0.7-33
- 978601 - fixing cobbler buildiso selinux issue
* Tue Jun 18 2013 Michael Mraka <michael.mraka@redhat.com> 2.0.7-32
- 718238 - detach daemon from terminal
* Wed May 22 2013 Stephen Herr <sherr@redhat.com> 2.0.7-29
- 506485 - Cobbler buildiso changes
- update dist-git branches for cobbler
* Wed Apr 10 2013 Tomas Lestach <tlestach@redhat.com> 2.0.7-28
- 768451 - do not set selinux context for patition locations
* Wed Mar 27 2013 Stephen Herr <sherr@redhat.com> 2.0.7-27
- 768451 - bumping build number so the tag won't interfere with SATELLITE-5.5
- 768451 - actually adding the patch is a good thing
- 768451 - /dev/mapper doesn't work with lvm if selinux is on
* Tue Mar 19 2013 Michael Mraka <michael.mraka@redhat.com> 2.0.7-24
- provide cobbler2 to satisfy deps in spacewalk 1.8+ packages
* Tue Nov 20 2012 Tomas Lestach <tlestach@redhat.com> 2.0.7-23
- fix patch to match --fuzz=0 option on rhel6
* Tue Nov 20 2012 Tomas Lestach <tlestach@redhat.com> 2.0.7-22
- 866326 - catch cheetah exception in mod_pythod/mod_wsgi and forward it as 500
SERVER ERROR
* Thu Sep 06 2012 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-21
- 784049 - support XZ packes ramdisk: correct bash syntax
* Fri Aug 24 2012 Stephen Herr <sherr@redhat.com> 2.0.7-20
- 589318 - make sure modprobe.conf exists if we need to create a bond
- updating tito configs to move from Satellite-5.x* to Satellite-5.5* branches
* Tue Jul 03 2012 Stephen Herr <sherr@redhat.com> 2.0.7-19
- 836545 - have to convert from unicode to string on RHEL 6
* Fri Jun 29 2012 Stephen Herr <sherr@redhat.com> 2.0.7-18
- 830662 - fixing power vulnerability patch so that templated commands will run
properly
- 830662 - fixing 'no power type set for system' errors
* Thu Jun 21 2012 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-17
- 784049 - correct support for xz packed ramdisk
* Mon Jun 11 2012 Jan Pazdziora 2.0.7-16
- CVE-2012-2395 - power vulnerability patch. (sherr@redhat.com)
- update build settings for cobbler (mzazrivec@redhat.com)
* Wed Mar 14 2012 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-15
- 789037 - handle nic with a dash correctly (mzazrivec@redhat.com)
- 784049 - support for XZ packed ramdisk (mzazrivec@redhat.com)
- 784912 - post_install_network snippet: IPv6 support (mzazrivec@redhat.com)
- 717884 - make cobblerd work in IPv6 environment (mzazrivec@redhat.com)
* Thu Dec 08 2011 Tomas Lestach <tlestach@redhat.com> 2.0.7-14
- 723060 - fix token validation (tlestach@redhat.com)
* Fri Sep 23 2011 Miroslav Suchý 2.0.7-13
- 253274 - if resolving to ip address fail, use hostname
* Wed Aug 24 2011 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-12
- 728268 - update allowed kernel command line parameter length
- 708347 - fix koan error when provisioning VM to use a logical volume
- 717344 - fix problem with CIDR network notation in RHEL-6
- 723898 - fix keep_ssh_host_keys snippet
* Fri May 27 2011 Jan Pazdziora 2.0.7-11
- 707215 - cobbler should not remove pub during sync as the cobbler rpm owns
that directory.
* Wed May 25 2011 Jan Pazdziora 2.0.7-10
- 568801 - hardlinks ruin SELinux contexts because multiple paths match, avoid
hardlinks.
* Wed May 25 2011 Jan Pazdziora 2.0.7-9
- 706857 - disable the SELinux part of cobbler check.
* Thu Mar 31 2011 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-8
- 673388 - embed kickstart file into ramdisk for RHEL-6 and static networking
* Mon Mar 28 2011 Tomas Lestach <tlestach@redhat.com> 2.0.7-7
- remove fence-agents Require from cobbler (tlestach@redhat.com)
- We need to be building cobbler / koan for RHEL-4 as well
(mzazrivec@redhat.com)
* Mon Jan 10 2011 Milan Zazrivec <mzazrivec@redhat.com> 2.0.7-6
- 660673 - RHEL-6: replace rhpl with ethtool
- 610174 - use tap driver for Xen PV disks
* Thu Dec 02 2010 Jan Pazdziora 2.0.7-5
- 580072 - avoid copying pxelinux.0 on arches where it is not present (s390x).
* Tue Oct 26 2010 Justin Sherrill <jsherril@redhat.com> 2.0.7-4
- fixing previous dep for koan to not appear within an if statement
(jsherril@redhat.com)
* Mon Oct 25 2010 Justin Sherrill <jsherril@redhat.com> 2.0.7-3
- adding missing python-urlgrabber dep for koan (jsherril@redhat.com)
* Mon Oct 18 2010 Shannon Hughes <shughes@redhat.com> 2.0.7-2
- combine patches into new version build (shughes@redhat.com)
- build.py.props for cobbler (mzazrivec@redhat.com)
* Mon Oct 18 2010 Scott Henson <shenson@redhat.com> - 2.0.7-1
- Bug fix relase, see Changelog for details
* Tue Jul 13 2010 Scott Henson <shenson@redhat.com> - 2.0.5-1
- Bug fix release, see Changelog for details
* Tue Apr 27 2010 Scott Henson <shenson@redhat.com> - 2.0.4-1
- Bug fix release, see Changelog for details
* Mon Mar 1 2010 Scott Henson <shenson@redhat.com> - 2.0.3.1-3
- Bump release because I forgot cobbler-web
* Mon Mar 1 2010 Scott Henson <shenson@redhat.com> - 2.0.3.1-2
- Remove requires on mkinitrd as it is not used
* Mon Feb 15 2010 Scott Henson <shenson@redhat.com> - 2.0.3.1-1
- Upstream Brown Paper Bag Release (see CHANGELOG)
* Thu Feb 11 2010 Scott Henson <shenson@redhat.com> - 2.0.3-1
- Upstream changes (see CHANGELOG)
* Mon Nov 23 2009 John Eckersberg <jeckersb@redhat.com> - 2.0.2-1
- Upstream changes (see CHANGELOG)
* Tue Sep 15 2009 Michael DeHaan <mdehaan@redhat.com> - 2.0.0-1
- First release with unified spec files