[PATCH] Fixed tests for image handling.
by Darryl L. Pierce
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
cobbler/item_image.py | 21 ++++++++++++++-------
cobbler/test_basic.py | 11 +++++++++--
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/cobbler/item_image.py b/cobbler/item_image.py
index b11dc9c..5a4123b 100644
--- a/cobbler/item_image.py
+++ b/cobbler/item_image.py
@@ -119,26 +119,33 @@ class Image(item.Item):
* hostname:/path/to/the/filename.ext
* /path/to/the/filename.ext
"""
- print "STARTING WITH FILENAME: %s" % filename
uri = ""
- auth = hostname = path = ""
+ scheme = auth = hostname = path = ""
# we'll discard the protocol if it's supplied, for legacy support
if filename.find("://") != -1:
- ignored, uri = filename.split("://")
+ scheme, uri = filename.split("://")
filename = uri
else:
uri = filename
if filename.find("@") != -1:
auth, filename = filename.split("@")
+ # extract the hostname
+ # 1. if we have a colon, then everything before it is a hostname
+ # 2. if we don't have a colon, then check if we had a scheme; if
+ # we did, then grab all before the first forward slash as the
+ # hostname; otherwise, we've got a bad file
if filename.find(":") != -1:
hostname, filename = filename.split(":")
elif filename[0] != '/':
- index = filename.find("/")
- hostname = filename[:index]
- filename = filename[index:]
+ if len(scheme) > 0:
+ index = filename.find("/")
+ hostname = filename[:index]
+ filename = filename[index:]
+ else:
+ raise CX(_("invalid file: %s" % filename))
# raise an exception if we don't have a valid path
- if filename[0] != '/':
+ if len(filename) > 0 and filename[0] != '/':
raise CX(_("file contains an invalid path: %s" % filename))
if filename.find("/") != -1:
path, filename = filename.rsplit("/", 1)
diff --git a/cobbler/test_basic.py b/cobbler/test_basic.py
index 7f6a062..27ecabe 100644
--- a/cobbler/test_basic.py
+++ b/cobbler/test_basic.py
@@ -873,8 +873,15 @@ class TestImage(BootTest):
# ensure that only valid names are accepted and invalid ones are rejected
image = self.api.new_image()
self.assertTrue(image.set_file("nfs://hostname/path/to/filename.iso"))
- self.assertTrue(image.set_file("/mcpierce@hostname:/path/to/filename.iso"))
- self.assertTrue(image.set_file("path/to/filename.iso"))
+ self.assertTrue(image.set_file("nfs://mcpierce@hostname:/path/to/filename.iso"))
+ self.assertTrue(image.set_file("nfs://hostname:/path/to/filename.iso"))
+ self.assertTrue(image.set_file("nfs://hostname/filename.iso"))
+ self.assertTrue(image.set_file("hostname:/path/to/the/filename.iso"))
+ self.failUnlessRaises(CX, image.set_file, "hostname:filename.iso")
+ self.failUnlessRaises(CX, image.set_file, "path/to/filename.iso")
+ self.failUnlessRaises(CX, image.set_file, "hostname:")
+ # port is not allowed
+ self.failUnlessRaises(CX, image.set_file, "nfs://hostname:1234/path/to/the/filename.iso")
#class TestCLIBasic(BootTest):
#
--
1.6.0.6
15 years, 4 months
Using cobbler with vnc
by Jared Hodge
All,
So I'm still new to cobbler, but so far I'm very pleased with it. I
was considering rolling my own tool to do a lot of this, but I'm happy
not to. One thing that I was doing before I found cobbler and many
people may find useful is using the anaconda vnc remote install option.
It's very useful to be able to watch the progress of the anaconda
installer or even manually run it from the cobbler server. It would be
nice if there was a snippet to help with setting this up, and also a
trigger could help with opening the vnc listening viewer and closing it
after the install is complete. I'm still becoming familiar with the
cobbler architecture, so I won't try to bite this off myself yet, but
this should be trivial for someone familiar with cobbler.
-Jared
15 years, 4 months
Cobbler LiveCD question
by Flink, Timothy
I'm new to cobbler and I am trying to get the LiveCD working as I am not able to change the dhcp server. I apologize if there are docs about this, but I wasn't able to find them.
What is procedure for starting an install using the LiveCD?
I have been able to build the iso and when I try booting from the iso in vmware, I get a login prompt for FC9. From there, I can log in as root/cobbler but have no idea what to do after that.
Thanks,
Tim
15 years, 4 months
[patch] download comps.xml by 'cobbler reposync'
by Shuichi Ihara
Hi,
I've created a patch for 'cobbler reposync' to get comps.xml, if the file is
existing on repository.
The main problem is that old 'reposync' command ignores comps.xml.
Newer reposync command (in yum-utils-1.1.15 or later) has "-m" option to download
comps.xml, but yum-utils-1.1.10-xx is installed in rhel5.x/centos5.x by default.
So, this patch for OS has old yum-utils ( < 1.1.15).
Thanks
-Ihara
diff -Nurp cobbler-1.4.0.orig/cobbler/action_reposync.py cobbler-1.4.0/cobbler/action_reposync.py
--- cobbler-1.4.0.orig/cobbler/action_reposync.py 2008-12-19 08:17:36.000000000 -0800
+++ cobbler-1.4.0/cobbler/action_reposync.py 2008-12-27 00:35:08.000000000 -0800
@@ -345,6 +345,24 @@ class RepoSync:
if rc !=0:
raise CX(_("cobbler reposync failed"))
+ repodata_path = os.path.join(dest_path, "repodata")
+
+ if not os.path.exists("/usr/bin/wget"):
+ raise CX(_("no /usr/bin/wget found, please install wget"))
+
+ cmd2 = "/usr/bin/wget -q %s/repodata/comps.xml -O /dev/null" % (repo_mirror)
+ rc = sub_process.call(cmd2, shell=True, close_fds=True)
+ if rc == 0:
+ if not os.path.isdir(repodata_path):
+ os.makedirs(repodata_path)
+
+ cmd2 = "/usr/bin/wget -q %s/repodata/comps.xml -O %s/comps.xml" % (repo_mirror, repodata_path)
+ print _("- %s") % cmd2
+
+ rc = sub_process.call(cmd2, shell=True, close_fds=True)
+ if rc !=0:
+ raise CX(_("wget failed"))
+
# now run createrepo to rebuild the index
if repo.mirror_locally:
15 years, 4 months
unable to koan cobbler system entries
by Ronald J. Yacketta
Just updated to 1.4.1 this morning and added a new system. When I
attempt to koan the newly added system I get the following:
# koan --server=cobbler-server --list=systems
bs2-2-A
helios2
# koan --virt --server=cobbler-server --system=helios2
No entry/entries found
Here is the system config in cobbler:
system : helios2
profile : f10-i386
comment :
created : Mon Jan 12 09:55:54 2009
gateway : x.x.x.x
hostname : helios2
image :
kernel options : {}
kernel options post : {}
kickstart : <<inherit>>
ks metadata : {}
mgmt classes : []
modified : Mon Jan 12 09:55:54 2009
name servers : ['<<inherit>>']
netboot enabled? : True
owners : ['admin']
server : <<inherit>>
template files : {}
virt cpus : 1
virt file size : 30
virt path : /mnt/os1
virt ram : 1024
virt type : qemu
power type : apc_snmp
power address :
power user :
power password :
power id :
interface : eth0
mac address : 00:16:3e:21:21:07
bonding :
bonding_master :
bonding_opts :
is static? : False
ip address : x.x.x.x
subnet :
static routes : []
dns name : helios2
dhcp tag :
virt bridge : br9
I am able to koan against the f10-i386 profile without issues
-Ron
15 years, 4 months
[PATCH] Provides validation for the image file argument.
by Darryl L. Pierce
A file must have minimally a path and filename.
If a file contains authentication information then it must also have a
hostname.
Paths must be absolute.
If the file includes a protocol then that is dropped.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
cobbler/item_image.py | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/cobbler/item_image.py b/cobbler/item_image.py
index 98e0255..481951d 100644
--- a/cobbler/item_image.py
+++ b/cobbler/item_image.py
@@ -113,11 +113,32 @@ class Image(item.Item):
def set_file(self,filename):
"""
Stores the image location. This should be accessible on all nodes
- that need to access it. Format: either /mnt/commonpath/foo.iso or
- nfs://host/path/foo.iso
+ that need to access it. Format: can be one of the following:
+ * username:password@hostname:/path/to/the/filename.ext
+ * username@hostname:/path/to/the/filename.ext
+ * hostname:/path/to/the/filename.ext
+ * /path/to/the/filename.ext
"""
- # FIXME: this should accept NFS paths or filesystem paths
- self.file = filename
+ uri = ""
+ auth = hostname = path = ""
+ # we'll discard the protocol if it's supplied, for legacy support
+ if filename.find("://") != -1:
+ ignored, uri = filename.split("://")
+ filename = uri
+ else:
+ uri = filename
+
+ if filename.find("@") != -1: auth, filename = filename.split("@")
+ if filename.find(":") != -1: hostname, filename = filename.split(":")
+ # raise an exception if we don't have a valid path
+ if filename[0] != '/': raise CX(_("file contains an invalid path"))
+ if filename.find("/") != -1: path, filename = filename.rsplit("/", 1)
+
+ if len(filename) == 0: raise CX(_("missing filename"))
+ if len(auth) > 0 and len(hostname) == 0:
+ raise CX(_("a hostname must be specified with authentication details"))
+
+ self.file = uri
return True
def set_os_version(self,os_version):
--
1.6.0.6
15 years, 4 months
need error handling?
by Shuichi Ihara
Hi,
I'm using cobbler-1.4.0 on rhel5.2, but we see some unwanted messages, when we have
invalid option (by mis-operation) that is like "no" add/edit/remove/... option for
distro/profile/system/...
I have never seen these messages on cobbler-1.0.3 even if we did same mis-operations.
The "usage" was only showed up.
Here is an example on 1.4.0.
# cobbler distro --name
usage:
======
cobbler distro add [ARGS]
cobbler distro copy [ARGS]
cobbler distro dumpvars [ARGS]
cobbler distro edit [ARGS]
cobbler distro find [ARGS]
cobbler distro list [ARGS]
cobbler distro remove [ARGS]
cobbler distro rename [ARGS]
cobbler distro report [ARGS]
DistroFunction instance has no attribute 'options'
File "/usr/lib/python2.4/site-packages/cobbler/cobbler.py", line 83, in main
rc = BootCLI().run(sys.argv)
File "/usr/lib/python2.4/site-packages/cobbler/cobbler.py", line 61, in run
return self.loader.run(args)
File "/usr/lib/python2.4/site-packages/cobbler/commands.py", line 122, in run
return fn.run()
File "/usr/lib/python2.4/site-packages/cobbler/modules/cli_distro.py", line 90, in run
obj = self.object_manipulator_start(self.api.new_distro,self.api.distros)
File "/usr/lib/python2.4/site-packages/cobbler/commands.py", line 335, in object_manipulator_start
if not self.options
15 years, 4 months