Changes for --breed, --os-version for 1.2
by Michael DeHaan
As Dave Hatton's patch alluded to, there are going to be some new fields
coming in for 1.2, that are strictly optional.
The reason for this is we need them to properly install some older
virtual machines for both distributions and images.
Before we had "--breed" which controls PXE behavior:
cobbler distro add --name=rhel4 --breed=redhat ...
Now we also have an "--os-version" that (for now) is basically a
comment, unless you are using it for virtualization. For instance if
you want RHEL2.1 to work in KVM, it won't work without
"--os-version=rhel2.1".
Both of these commands will only accept certain values and they will
tell you which ones they are.
I haven't quite implemented the backing bits for koan yet (should be
tomorrow or at least soon), nor the magic in import that tries to
auto-assign these, though I wanted to explain what they did. The idea
is for any new imports to automatically assign these fields, and for any
old ones, you can do "cobbler edit" commands on them.
(I also realized that "cobbler image" records don't have a page in the
WebUI yet. I'll add those pages for 1.3/1.4)
--Michael
15 years, 8 months
[PATCH] code to add --os-version
by Dave Hatton
Hi Michael,
Here is the code you asked for adding --os-version..
I didn't get around to adding the initial setup during an import yet.
(I also see I got a little carried away fixing up some whitespace)
Regards
Dave Hatton
>From 97f17ed35b7235c2da2161efe8eef447a12ad22f Mon Sep 17 00:00:00 2001
From: Dave Hatton <dave(a)starground.it>
Date: Mon, 25 Aug 2008 17:53:07 +0100
Subject: [PATCH] os-version code
---
cobbler/action_validate.py | 10 +++++--
cobbler/item_distro.py | 56 ++++++++++++++++++++++++-----------------
cobbler/modules/cli_distro.py | 3 ++
3 files changed, 43 insertions(+), 26 deletions(-)
diff --git a/cobbler/action_validate.py b/cobbler/action_validate.py
index f9645f3..2229e09 100644
--- a/cobbler/action_validate.py
+++ b/cobbler/action_validate.py
@@ -63,14 +63,18 @@ class Validate:
def checkfile(self,obj,is_profile):
blended = utils.blender(self.config.api, False, obj)
+
+ os_version = blended["os_version"]
+
ks = blended["kickstart"]
+ if ks is None or ks == "":
+ print "%s has no kickstart, skipping" % obj.name
+ return True
+
breed = blended["breed"]
if breed != "redhat":
print "%s has a breed of %s, skipping" % (obj.name, breed)
return True
- if ks is None or ks == "":
- print "%s has no kickstart, skipping" % obj.name
- return True
server = blended["server"]
if not ks.startswith("/"):
diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py
index abdd85b..d11b6ae 100644
--- a/cobbler/item_distro.py
+++ b/cobbler/item_distro.py
@@ -46,8 +46,9 @@ class Distro(item.Item):
self.kernel_options = ({}, '<<inherit>>')[is_subobject]
self.kernel_options_post = ({}, '<<inherit>>')[is_subobject]
self.ks_meta = ({}, '<<inherit>>')[is_subobject]
- self.arch = ('i386', '<<inherit>>')[is_subobject]
+ self.arch = ('i386', '<<inherit>>')[is_subobject]
self.breed = ('redhat', '<<inherit>>')[is_subobject]
+ self.os_version = ('', '<<inherit>>')[is_subobject]
self.source_repos = ([], '<<inherit>>')[is_subobject]
self.depth = 0
@@ -78,6 +79,7 @@ class Distro(item.Item):
self.ks_meta = self.load_item(seed_data,'ks_meta')
self.arch = self.load_item(seed_data,'arch','i386')
self.breed = self.load_item(seed_data,'breed','redhat')
+ self.os_version = self.load_item(seed_data,'os_version','')
self.source_repos = self.load_item(seed_data,'source_repos',[])
self.depth = self.load_item(seed_data,'depth',0)
@@ -113,6 +115,12 @@ class Distro(item.Item):
return True
raise CX(_("invalid value for --breed, see manpage"))
+ def set_os_version(self, os_version):
+ if os_version is not None:
+ self.os_version = os_version.lower()
+ return True
+ raise CX(_("invalid value for --os-version, see manpage"))
+
def set_initrd(self,initrd):
"""
Specifies an initrd image. Path search works as in set_kernel.
@@ -172,18 +180,19 @@ class Distro(item.Item):
Return a serializable datastructure representation of this object.
"""
return {
- 'name' : self.name,
- 'kernel' : self.kernel,
- 'initrd' : self.initrd,
- 'kernel_options' : self.kernel_options,
- 'kernel_options_post' : self.kernel_options_post,
- 'ks_meta' : self.ks_meta,
- 'arch' : self.arch,
- 'breed' : self.breed,
- 'source_repos' : self.source_repos,
- 'parent' : self.parent,
- 'depth' : self.depth,
- 'owners' : self.owners
+ 'name' : self.name,
+ 'kernel' : self.kernel,
+ 'initrd' : self.initrd,
+ 'kernel_options' : self.kernel_options,
+ 'kernel_options_post' : self.kernel_options_post,
+ 'ks_meta' : self.ks_meta,
+ 'arch' : self.arch,
+ 'breed' : self.breed,
+ 'os_version' : self.os_version,
+ 'source_repos' : self.source_repos,
+ 'parent' : self.parent,
+ 'depth' : self.depth,
+ 'owners' : self.owners
}
def printable(self):
@@ -194,6 +203,7 @@ class Distro(item.Item):
istr = utils.find_initrd(self.initrd)
buf = _("distro : %s\n") % self.name
buf = buf + _("breed : %s\n") % self.breed
+ buf = buf + _("os_version : %s\n") % self.os_version
buf = buf + _("architecture : %s\n") % self.arch
buf = buf + _("initrd : %s\n") % istr
buf = buf + _("kernel : %s\n") % kstr
@@ -205,15 +215,15 @@ class Distro(item.Item):
def remote_methods(self):
return {
- 'name' : self.set_name,
- 'kernel' : self.set_kernel,
- 'initrd' : self.set_initrd,
- 'kopts' : self.set_kernel_options,
- 'kopts_post' : self.set_kernel_options_post,
- 'arch' : self.set_arch,
- 'ksmeta' : self.set_ksmeta,
- 'breed' : self.set_breed,
- 'owners' : self.set_owners
+ 'name' : self.set_name,
+ 'kernel' : self.set_kernel,
+ 'initrd' : self.set_initrd,
+ 'kopts' : self.set_kernel_options,
+ 'kopts_post' : self.set_kernel_options_post,
+ 'arch' : self.set_arch,
+ 'ksmeta' : self.set_ksmeta,
+ 'breed' : self.set_breed,
+ 'os_version' : self.set_os_version,
+ 'owners' : self.set_owners
}
-
diff --git a/cobbler/modules/cli_distro.py b/cobbler/modules/cli_distro.py
index e541c6f..d647294 100644
--- a/cobbler/modules/cli_distro.py
+++ b/cobbler/modules/cli_distro.py
@@ -48,6 +48,7 @@ class DistroFunction(commands.CobblerFunction):
if not self.matches_args(args,["dumpvars","remove","report","list"]):
p.add_option("--arch", dest="arch", help="ex: x86, x86_64, ia64")
p.add_option("--breed", dest="breed", help="ex: redhat, debian, suse")
+ p.add_option("--os-version", dest="os_version", help="ex: free format os version string")
if self.matches_args(args,["add"]):
p.add_option("--clobber", dest="clobber", help="allow add to overwrite existing objects", action="store_true")
if not self.matches_args(args,["dumpvars","remove","report","list"]):
@@ -100,6 +101,8 @@ class DistroFunction(commands.CobblerFunction):
obj.set_ksmeta(self.options.ksmeta,self.options.inplace)
if self.options.breed:
obj.set_breed(self.options.breed)
+ if self.options.os_version:
+ obj.set_os_version(self.options.os_version)
if self.options.owners:
obj.set_owners(self.options.owners)
--
1.5.4.1
15 years, 8 months
Support for PXE'ing KVM guests in koan as alternate install mechanism
by Michael DeHaan
I'm thinking of adding support for PXE'ing KVM guests in koan.
Currently we support qemu/KVM through kernel+initrd+tree means, which
works for more environments that don't do PXE -- we'll be keeping this.
The additional idea is that if you know you have VT hardware and a
Cobbler managed PXE environment, you can use cobbler to /change/ what
profiles given virtual systems are going to boot to next time they start up.
Given, you won't be able to change their RAM and other parameters, but I
still think that's pretty interesting, particularly if you want to
change what your compute farm is doing very quickly.
You could just install the VMs with koan, change the assignments in
cobbler, and then power cycle selected ones using something like func
(http://fedorahosted.org/func).
--Michael
15 years, 8 months
Cobbler 1.3/1.4 -- ACLs and a simpler CobblerWeb
by Michael DeHaan
One of the features I want to address for the next major version of
cobbler is this:
I want to present a simple control panel that allows users who own
systems (when using the ownership module) to access to only what they
control. This means rather than an admin to manipulate Cobbler, we can
let the users do what they want to do directly -- the ownership module
does this /almost/ but it's still not quite there.
Lots of folks have asked for similar things (and some are building
similar things of their own, using the Cobbler XMLRPC interface, which
is great), so I wanted to talk about them here to make sure I'm building
what everyone can use.
See https://fedorahosted.org/cobbler/wiki/CustomizableAuthorization for
background info.
With this module, a user who is not in the admin group can only
manipulate objects that they "own". Any object in cobbler can be
tagged with ownership requirements with "--owner", and an object can
have multiple users/groups being able to edit it.
I think to do this right, we need a third module in modules.conf, that
extends authorization, for handling of where ACL data comes from.
Since each user must already be in a group, all we have to do is define
the ACLs for the group. Tentatively this would be
/etc/cobbler/acls.conf and would look something like:
- whitelist:
- admin:
- "*"
- users:
- "*/*"
- blacklist:
- users
- "distro/set_distro"
- "system/set_mac_address"
- "system/set_ip_address"
- "system/set_hostname"
That's just a simple list of what they are allowed to do, blacklists
executed first.
With wildcards to define what users could and could not access. The
stock cobbler ACL's file would be generous and allow full access with
any ownership module. In addition, whether ACLs were enabled or not
would be a setting in /etc/cobbler/settings and the source for the ACL
data would be in /etc/cobbler/modules.conf, the default would be
"acl_configfile", though it would allow for someone to source ACL's from
other sources by writing their own module.
How does this sound?
Once all of this is done, we would then have a Cobbler webapp that knew,
if ACL's were enabled, only to present objects to the user that they
could edit. Depending on how ACLs were configured, this may allow for
creation of new objects of certain types, or it might not. When
visiting the web page for certain objects, certain fields would then
become not editable, depending on whether the user had rights to edit
those fields, and we'd do something like a "show all fields" button to
hide most of the fields the user could/couldn't edit.
I suspect the percentage of users that would enable this would be small,
but that a lot of the people that do enable this are some of the larger
cobbler installs, so it seems to make sense.
(I also should acknowledge that the security section of the Wiki is
definitely do for some reorganization -- each of the modules should be
indexed seperately so they are easy to find, and right now authn/authz
is a bit mixed up, so I'd imagine plenty of folks aren't aware of what
all the capabilities are. I'll sort this out).
Thoughts?
--Michael
15 years, 8 months
[PATCH] Added an update call prior to saving or updating a system.
by Darryl L. Pierce
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
contrib/ruby/ChangeLog | 16 ++++++++++++++--
contrib/ruby/README | 15 +++++++++------
contrib/ruby/Rakefile | 2 +-
contrib/ruby/TODO | 3 ++-
contrib/ruby/lib/cobbler/system.rb | 7 +++++--
contrib/ruby/rubygem-cobbler.spec | 8 ++++++--
contrib/ruby/test/test_system.rb | 13 +++++++++++++
7 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/contrib/ruby/ChangeLog b/contrib/ruby/ChangeLog
index 81b0104..8b41d45 100644
--- a/contrib/ruby/ChangeLog
+++ b/contrib/ruby/ChangeLog
@@ -1,6 +1,18 @@
-* Wed Aug 13 2008 Darryl Pierce <dpierce(a)redhat.com>
+* Thu Aug 21 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.2-1
+- Added a call to update prior to saving or updating a system. If the update
+ fails, then an Exception is raised.
+
+* Wed Aug 13 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.1-3
- Added caching for the auth_token to prevent extraneous calls to login.
- Reworked and refined how cobbler_collection fields are processed, adding
support for both array and has properties.
- Rewrote the documentation for Cobbler::Base to make it easier to understand
- how to extend it to support other Cobbler types.
\ No newline at end of file
+ how to extend it to support other Cobbler types.
+- Refactored the examples to clean up the code.
+
+* Wed Aug 13 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.1-2
+- Removed markup of cobbler.yml and a config file. Fixed a few small bugs
+ in the code for using it as a gem.
+
+* Mon Aug 04 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.1-1
+- Initial package
diff --git a/contrib/ruby/README b/contrib/ruby/README
index 0fda7e2..a91b20c 100644
--- a/contrib/ruby/README
+++ b/contrib/ruby/README
@@ -7,8 +7,8 @@ Ruby bindings for interacting with Cobbler.
USAGE
-----
-To include the code, you must install the ruby gem named "cobbler" and then
-require 'cobbler' in your application.
+To use the code, you must install the ruby gem named "cobbler" and then
+require 'cobbler' in your application.
Minimally you need to provide a server name for your Cobbler machine using:
@@ -23,7 +23,10 @@ Cobbler::Base.password = password
CONFIGURATION
-------------
-By default, Cobbler::Base will load the file config/cobbler.yml, if it exists,
-and use that information for talking to Cobbler. To override where this file
-lives, set the COBBLER_ENV environment variable *before* requiring the 'cobbler'
-file.
\ No newline at end of file
+By default, Cobbler::Base will load the file $SEARCHPATH/config/cobbler.yml,
+if it exists, and use that information for talking to Cobbler. To override
+where this file lives, set the COBBLER_ENV environment variable *before*
+requiring the 'cobbler' file.
+
+However, these values can be overridden afterward by changing the fields in
+Cobbler::Base directly.
\ No newline at end of file
diff --git a/contrib/ruby/Rakefile b/contrib/ruby/Rakefile
index f4d88fe..5970cc3 100644
--- a/contrib/ruby/Rakefile
+++ b/contrib/ruby/Rakefile
@@ -22,7 +22,7 @@ require 'rake/testtask'
require 'rake/gempackagetask'
PKG_NAME='rubygem-cobbler'
-PKG_VERSION='0.0.1'
+PKG_VERSION='0.0.2'
PKG_FILES=FileList[
'Rakefile', 'README', 'ChangeLog', 'COPYING', 'NEWS', 'TODO',
'lib/**/*.rb',
diff --git a/contrib/ruby/TODO b/contrib/ruby/TODO
index e5eddbe..2c74dd7 100644
--- a/contrib/ruby/TODO
+++ b/contrib/ruby/TODO
@@ -1,8 +1,9 @@
This is a list of features to be developed in future.
-* Attempt to detech when a R/W call fails due to expired auth token and
+* Attempt to detect when a R/W call fails due to expired auth token and
retry the previous login.
* Rework the "find_one" method to be "find_by_[field]" instead.
* Add hierarchical relationships, so that a Profile will load it's
Distro, a System will load it's Profile, etc.
+* Perform an update check before saving or updating a system. [DONE: 21 Aug 2008]
* Cache auth tokens to avoid unnecessary logins. [DONE: 13 Aug 2008]
diff --git a/contrib/ruby/lib/cobbler/system.rb b/contrib/ruby/lib/cobbler/system.rb
index 255391c..849ab5d 100644
--- a/contrib/ruby/lib/cobbler/system.rb
+++ b/contrib/ruby/lib/cobbler/system.rb
@@ -55,7 +55,10 @@ module Cobbler
def save
Base.begin_transaction(true)
- token = Base.login
+ token = Base.login
+
+ raise Exception.new('Update failed prior to saving') unless Base.make_call('update')
+
sysid = Base.make_call('new_system',token)
Base.make_call('modify_system',sysid,'name',self.name,token)
@@ -76,7 +79,7 @@ module Cobbler
end
Base.make_call('save_system',sysid,token)
-
+
Base.end_transaction
end
diff --git a/contrib/ruby/rubygem-cobbler.spec b/contrib/ruby/rubygem-cobbler.spec
index 3843327..51dcd80 100644
--- a/contrib/ruby/rubygem-cobbler.spec
+++ b/contrib/ruby/rubygem-cobbler.spec
@@ -7,8 +7,8 @@
Summary: An interface for interacting with a Cobbler server
Name: rubygem-%{gemname}
-Version: 0.0.1
-Release: 3%{?dist}
+Version: 0.0.2
+Release: 1%{?dist}
Group: Development/Languages
License: LGPLv2+
URL: http://cobbler.et.redhat.com/
@@ -63,6 +63,10 @@ rm -rf %{buildroot}
%changelog
+* Thu Aug 21 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.2-1
+- Added a call to update prior to saving or updating a system. If the update
+ fails, then an Exception is raised.
+
* Wed Aug 13 2008 Darryl Pierce <dpierce(a)redhat.com> - 0.0.1-3
- Added caching for the auth_token to prevent extraneous calls to login.
- Reworked and refined how cobbler_collection fields are processed, adding
diff --git a/contrib/ruby/test/test_system.rb b/contrib/ruby/test/test_system.rb
index e28da8b..53c979b 100644
--- a/contrib/ruby/test/test_system.rb
+++ b/contrib/ruby/test/test_system.rb
@@ -111,10 +111,22 @@ module Cobbler
assert_equal 3, result[0].owners.size, 'Did not parse the owners correctly.'
end
+ # Ensures that saving stops when an update fails.
+ #
+ def test_save_and_update_fails
+ @connection.should_receive(:call).with('login',@username,@password).once.returns((a)auth_token)
+ @connection.should_receive(:call).with('update').once.returns{ false }
+
+ system = System.new(:name => @system_name, :profile => @profile_name)
+
+ assert_raise(Exception) {system.save}
+ end
+
# Ensures that saving a system works as expected.
#
def test_save
@connection.should_receive(:call).with('login',@username,@password).once.returns((a)auth_token)
+ @connection.should_receive(:call).with('update').once.returns { true }
@connection.should_receive(:call).with('new_system',@auth_token).once.returns((a)system_id)
@connection.should_receive(:call).with('modify_system',@system_id,'name',@system_name,(a)auth_token).once.returns(true)
@connection.should_receive(:call).with('modify_system',@system_id,'profile',@profile_name,(a)auth_token).once.returns(true)
@@ -130,6 +142,7 @@ module Cobbler
#
def test_save_with_new_nics
@connection.should_receive(:call).with('login',@username,@password).once.returns((a)auth_token)
+ @connection.should_receive(:call).with('update').once.returns { true }
@connection.should_receive(:call).with('new_system',@auth_token).once.returns((a)system_id)
@connection.should_receive(:call).with('modify_system',@system_id,'name',@system_name,(a)auth_token).once.returns(true)
@connection.should_receive(:call).with('modify_system',@system_id,'profile',@profile_name,(a)auth_token).once.returns(true)
--
1.5.5.1
15 years, 8 months
[ANNOUNCE] Cobbler and Koan 1.1.1-1, test2 release for 1.2
by Michael DeHaan
Cobbler changelog:
- ??? - 1.1.1
- (FEAT) make template replacement use regex module
- (BUGF) remove bootloader check in settings as that code doesn't need it
- (BUGF) refinements to image handling
- (FEAT) getks command added to command line
- (BUGF) don't print traceback during certain SystemExits
- (BUGF) --help now works more intuitively on odd command line usage
- (BUGF) use pxesystem for systems, not pxeprofile
- (FEAT) make Cheetah formatting errors contain help text for users
- (FEAT) --kopts-post can configure post-install kernel options
Koan changelog:
- Tue Aug 19 2008 Michael DeHaan <mdehaan(a)redhat.com> - 1.1.1-1
- (FEAT) update livecd builder to use F9 as src, reinstate livecd code.
- (BUGF) get --replace-self working on EL3 again
- (FEAT) make koan --replace-self work for reinstalls to (not from) SuSE
- (BUGF) remove debug print during --display
If nothing major is found in testing, these will become Cobbler/Koan 1.2
in a few weeks, and we'll continue to maintain stable branches of those
while starting a new devel branch.
We've incorporated a few new features between 1.1.0 and 1.1.1 that can
use testing.
Namely, the aforementioned --kopts-post feature is very new so it would
be nice to know if that works as intended for everyone across their distros.
Also, we've added the "getks" command to profiles and systems which can
show the kickstart without having to visit hte Web URL. In addition,
I've improved the error message you get when you have templating
problems to better explain what is going on and how users can fix this.
The intent here is to reduce the amount of templating questions that
posted to IRC, and so they don't just appear as normal scary tracebacks
:) So, testing of templating is welcome. Note that
$unreferenced_variables that were left silently before are now no longer
left silently as Cheetah mentions the "errorCatcher" we were using
before was for debug only. So this should make things faster, and it's
neccessary for the way the snippet code has been upgraded (to allow for
nesting of snippets, etc).
We still have a unresolved bugzilla open on grubby and one of the
options it uses, so the koan live CD is not happy when built against
F9. Cobbler buildiso will work in those cases though, so I'm still
tracking that one.
If anybody else has any other questions, please ask, and as always,
thanks very much for testing. The templating code got a lot of testing
in the last week or so and I think it will make for a much better
release because of it.
Thanks!
Files here:
http://people.fedoraproject.org/~mdehaan/files/test_releases/
--Michael
15 years, 8 months
cobbler import destroys profile kickstart settings
by Dustin Black
I've imported a slew of operating system shares into cobbler as so:
# cobbler import --mirror=/install_images/mnt --name=CBLR
--available-as=http://10.0.0.1/install_images/mnt
I've then created some custom profiles using the imported distros and
pointing to a specific new kickstart file.
Later, I've added some other OS shares to /install_images/mnt, and
performed the cobbler import command again to add the new distros to
cobbler. When I run this second import, the kickstarts for the custom
profiles are reset back to the sample.ks or sample_end.ks files.
Is this expected behavior, and if so, what should I be doing
differently?
Regards,
Dustin L. Black, RHCE
15 years, 8 months
Patch for --kopts-post feature applied
by Michael DeHaan
I've recently applied this with a few tweaks:
https://fedorahosted.org/pipermail/cobbler/2008-August/000514.html
This allows for the following:
cobbler distro edit --name=foo --kopts-post="noapic asdf=jkl"
In the above example all distros will have the default kernel options on
the installed OS include noapic and asdf-jkl. By contrast, "--kopts"
in cobbler only covers the kernel options of the system as it is
installing.
--kopts-post works on distros, profiles, and systems, in the same syntax
and way that --kopts works.
For users upgrading to 1.1 and later, this value will default to no
kernel options.
This is implemented by SNIPPET::post_install_kernel_options, which will
be included in all of the stock cobbler templates. This snippet is an
example of how we'll be including more and more snippets with cobbler
over time to make the kickstart templating in Cobbler more powerful and
flexible. For upgrading users, you won't have this snippet in your
kickstart files, so add it anywhere in %post if you want to take
advantage of this new feature.
--Michael
15 years, 8 months