Reminder: you must be subscribed to the list to post
by Michael DeHaan
I'm not approving off-list posting each time I get one, so if you are
not seeing your emails go through, please sign up for the mailing list
(digest mode is ok) for the address you are posting from.
--Michael
15 years, 8 months
[BUG] SystemExit error and trace from --help
by Dave Hatton
Hi Michael,
Hopefully, I have dealt with this correctly?
Dave
>From 31811b7beebfec2907ec97a81141b870bb35590b Mon Sep 17 00:00:00 2001
From: root <root(a)cobbler.starground.co.uk>
Date: Thu, 14 Aug 2008 17:04:52 +0100
Subject: [PATCH] resolved SystemExit error
---
cobbler/cobbler.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index d729523..0fa6e73 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -82,8 +82,11 @@ def main():
return 1
return rc
except Exception, exc:
- utils.print_exc(exc,full=True)
- return 1
+ if sys.exc_type==SystemExit:
+ return 0
+ else:
+ utils.print_exc(exc,full=True)
+ return 1
if __name__ == "__main__":
sys.exit(main())
--
1.5.5.1
15 years, 8 months
[PATCH] The auth_token is now cached as Cobbler::Base@@auth_token.
by Darryl L. Pierce
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
contrib/ruby/TODO | 2 +
contrib/ruby/examples/list_systems.rb | 2 +-
contrib/ruby/lib/cobbler/base.rb | 71 +++++++++++++++++--------
contrib/ruby/lib/cobbler/distro.rb | 2 +-
contrib/ruby/lib/cobbler/network_interface.rb | 2 +-
contrib/ruby/lib/cobbler/profile.rb | 2 +-
contrib/ruby/lib/cobbler/system.rb | 6 +-
contrib/ruby/test/test_system.rb | 6 +-
8 files changed, 61 insertions(+), 32 deletions(-)
diff --git a/contrib/ruby/TODO b/contrib/ruby/TODO
index 02bea04..f865e8d 100644
--- a/contrib/ruby/TODO
+++ b/contrib/ruby/TODO
@@ -1,3 +1,5 @@
This is a list of features to be developed in future.
* Cache auth tokens to avoid unnecessary logins.
+* Add hierarchical relationships, so that a Profile will load it's
+ Distro, a System will load it's Profile, etc.
\ No newline at end of file
diff --git a/contrib/ruby/examples/list_systems.rb b/contrib/ruby/examples/list_systems.rb
index fbee42c..ad277f8 100755
--- a/contrib/ruby/examples/list_systems.rb
+++ b/contrib/ruby/examples/list_systems.rb
@@ -57,7 +57,7 @@ System.find do |system|
if details
puts "\tOwner: #{system.owners}"
- system.interfaces.each { |nic| puts "\tNIC: #{nic.mac_address}"}
+ system.interfaces.each_pair { |id,nic| puts "\tNIC[#{id}]: #{nic.mac_address}"}
end
end
\ No newline at end of file
diff --git a/contrib/ruby/lib/cobbler/base.rb b/contrib/ruby/lib/cobbler/base.rb
index ea75ef3..52bf8d7 100644
--- a/contrib/ruby/lib/cobbler/base.rb
+++ b/contrib/ruby/lib/cobbler/base.rb
@@ -33,26 +33,40 @@ module Cobbler
# class System < Base
# cobbler_lifecycle :find_all => 'get_systems'
# cobbler_field :name
- # cobbler_field :owner, :array => 'String'
+ # cobbler_collection :owners, :type => 'String', :packing => :hash
# end
#
- # declares a class named Farkle that contains two fields. The first, "name",
- # will be one that is searchable on Cobbler; i.e., a method named "find_by_name"
- # will be generated and will use the "get_farkle" remote method to retrieve
- # that instance from Cobbler.
+ # declares a class named System that contains two fields and a class-level
+ # method.
#
- # The second field, "owner", will simply be a field named Farkle.owner that
- # returns a character string.
- #
- # +Base+ provides some common functionality for all child classes:
- #
+ # The first field, "name", is a simple property. It will be retrieved from
+ # the value "name" in the remote definition for a system, identifyed by the
+ # +:owner+ argument.
+ #
+ # The second field, "owners", is similarly retrieved from a property also
+ # named "owners" in the remote definition. However, this property is a
+ # collection: in this case, it is an array of definitions itself. The
+ # +:type+ argument identifies what the +local+ class type is that will be
+ # used to represent each element in the collection.
+ #
+ # A +cobbler_collection+ is packed in one of two ways: either as an array
+ # of values or as a hash of keys and associated values. These are defined by
+ # the +:packing+ argument with the values +Array+ and +Hash+, respectively.
+ #
+ # The +cobbler_lifecycle+ method allows for declaring different methods for
+ # retrieving remote instances of the class. These methods are:
+ #
+ # +find_one+ - the remote method to find a single instance,
+ # +find_all+ - the remote method to find all instances,
+ # +remove+ - the remote method to remote an instance
#
class Base
@@hostname = nil
@@connection = nil
+ @@auth_token = nil
- @defintions = nil
+ @definitions = nil
def initialize(definitions)
@definitions = definitions
@@ -60,8 +74,8 @@ module Cobbler
# Sets the connection. This method is only needed during unit testing.
#
- def self.connection=(mock)
- @@connection = mock
+ def self.connection=(connection)
+ @@connection = connection
end
# Returns or creates a new connection.
@@ -91,7 +105,7 @@ module Cobbler
# Logs into the Cobbler server.
#
def self.login
- make_call('login', @@username, @@password)
+ (@@auth_token || make_call('login', @@username, @@password))
end
# Makes a remote call.
@@ -122,7 +136,7 @@ module Cobbler
def self.hostname=(hostname)
@@hostname = hostname
end
-
+
class << self
# Creates a complete finder method
#
@@ -234,24 +248,37 @@ module Cobbler
#
def cobbler_collection(field, *args) # :nodoc:
classname = 'String'
- packing = :array
+ packing = 'Array'
# process collection definition
args.each do |arg|
classname = arg[:type] if arg[:type]
- packing = arg[:packing] if arg[:packing]
+ if arg[:packing]
+ case arg[:packing]
+ when :hash then packing = 'Hash'
+ when :array then packing = 'Array'
+ end
+ end
end
module_eval <<-"end;"
def #{field.to_s}(&block)
unless @#{field.to_s}
- @#{field.to_s} = Array.new
+ @#{field.to_s} = #{packing}.new
- definition('#{field.to_s}').each do |value|
- if value
- @#{field.to_s} << #{classname}.new(value)
- end
+ values = definition('#{field.to_s}')
+
+ case "#{packing}"
+ when "Array" then
+ values.each do |value|
+ @#{field.to_s} << #{classname}.new(value)
+ end
+
+ when "Hash" then
+ values.keys.each do |key|
+ @#{field.to_s}[key] = #{classname}.new(values[key])
+ end
end
end
diff --git a/contrib/ruby/lib/cobbler/distro.rb b/contrib/ruby/lib/cobbler/distro.rb
index c66d29d..b0e36fe 100644
--- a/contrib/ruby/lib/cobbler/distro.rb
+++ b/contrib/ruby/lib/cobbler/distro.rb
@@ -28,7 +28,7 @@ module Cobbler
:remove => 'remove_distro'
cobbler_field :name
- cobbler_field :owners
+ cobbler_collection :owners, :packing => :array
cobbler_field :kernel
cobbler_field :breed
cobbler_field :depth
diff --git a/contrib/ruby/lib/cobbler/network_interface.rb b/contrib/ruby/lib/cobbler/network_interface.rb
index 3437714..3308249 100644
--- a/contrib/ruby/lib/cobbler/network_interface.rb
+++ b/contrib/ruby/lib/cobbler/network_interface.rb
@@ -31,7 +31,7 @@ module Cobbler
cobbler_field :ip_address
def initialize(args)
- @definitions = args[1]
+ @definitions = args
end
# A hack for getting the NIC's details over the wire.
diff --git a/contrib/ruby/lib/cobbler/profile.rb b/contrib/ruby/lib/cobbler/profile.rb
index c8df8a3..d6338d7 100644
--- a/contrib/ruby/lib/cobbler/profile.rb
+++ b/contrib/ruby/lib/cobbler/profile.rb
@@ -31,7 +31,7 @@ module Cobbler
cobbler_field :name, :findable => 'get_profile'
cobbler_field :parent
- cobbler_field :owners
+ cobbler_collection :owners, :packing => :array
cobbler_field :dhcp_tag
cobbler_field :depth
cobbler_field :virt_file_size
diff --git a/contrib/ruby/lib/cobbler/system.rb b/contrib/ruby/lib/cobbler/system.rb
index c15d225..255391c 100644
--- a/contrib/ruby/lib/cobbler/system.rb
+++ b/contrib/ruby/lib/cobbler/system.rb
@@ -32,19 +32,19 @@ module Cobbler
cobbler_field :parent
cobbler_field :profile
cobbler_field :depth
- cobbler_field :kernel_options
+ cobbler_collection :kernel_options, :packing => :hash
cobbler_field :kickstart
- cobbler_field :ks_meta
+ cobbler_collection :ks_meta, :packing => :hash
cobbler_field :netboot_enabled
cobbler_collection :owners
cobbler_field :server
+ cobbler_collection :interfaces, :type => 'NetworkInterface', :packing => :hash
cobbler_field :virt_cpus
cobbler_field :virt_file_size
cobbler_field :virt_path
cobbler_field :virt_ram
cobbler_field :virt_type
cobbler_field :virt_bridge
- cobbler_collection :interfaces, :type => 'NetworkInterface', :packing => :hash
def initialize(definitions)
super(definitions)
diff --git a/contrib/ruby/test/test_system.rb b/contrib/ruby/test/test_system.rb
index cc64e84..e28da8b 100644
--- a/contrib/ruby/test/test_system.rb
+++ b/contrib/ruby/test/test_system.rb
@@ -44,7 +44,7 @@ module Cobbler
@profile = 'profile1'
@nics = Array.new
@nic_details = {'mac_address' => '00:11:22:33:44:55:66:77'}
- @nic = NetworkInterface.new(['intf0',@nic_details])
+ @nic = NetworkInterface.new(@nic_details)
@nics << @nic
@systems = Array.new
@@ -103,11 +103,11 @@ module Cobbler
@connection.should_receive(:call).with('get_systems').once.returns(@systems)
result = System.find
-
+
assert result, 'Expected a result set.'
assert_equal 2, result.size, 'Did not receive the right number of results.'
assert_equal 2, result[0].interfaces.size, 'Did not parse the NICs correctly.'
- result[0].interfaces.collect do |nic| assert_equal "00:11:22:33:44:55", nic.mac_address end
+ result[0].interfaces.keys.each { |intf| assert_equal "00:11:22:33:44:55", result[0].interfaces[intf].mac_address }
assert_equal 3, result[0].owners.size, 'Did not parse the owners correctly.'
end
--
1.5.5.1
15 years, 8 months
Looking for something to do with Cobbler?
by Michael DeHaan
If you're interested in contributing to Cobbler, I've gone through the
RFE list and assigned components, so you can easily sort the TODO list
by the things you might be interested in. There are a lot of good
ideas here:
https://fedorahosted.org/cobbler/report/1?sort=component&asc=1
Features are not closed in the order they are submitted, I try to work
on the ones that I think most folks can take advantage of, in addition
to incorporating things that come in on the list. So, if your idea is
still sitting in the queue for several months and you want it
implemented, this may be a good time to send in a patch for it.
Generally I tend to tackle the "big ticket" items so a lot of the
features in there are pretty easy additions. As I mentioned, mostly
I'll be concentrating on WebUI issues/features for 1.3.
The main remaining feature for 1.2 is making sure koan is happy on EL 2/3.
--Michael
15 years, 8 months
[New Feature] cobbler system getks
by Dave Hatton
The attached patch adds a "getks" option to "cobbler system".
This renders the finished kickstart file for a specified system on the
console or terminal winder using the elinks ascii browser.
eg: cobbler system getks --name teapot
I find this very useful for checking the kickstart genrerated by cobbler
in an environment where I can't use http.
I hope others find this useful and it can be added to the base cobbler
system.
Regards
Dave Hatton
>From d1f278517ae9042ee2d941bc5bb3d7008ac4068a Mon Sep 17 00:00:00 2001
From: root <root(a)cobbler.starground.co.uk>
Date: Mon, 11 Aug 2008 18:49:53 +0100
Subject: [PATCH] added getks option to cobbler system
---
cobbler/action_check.py | 4 ++++
cobbler/commands.py | 7 +++++++
cobbler/modules/cli_misc.py | 32 +++++++++++++++++++++++++++++++-
cobbler/modules/cli_system.py | 14 +++++++-------
4 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index a85344d..fe0d322 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -69,6 +69,7 @@ class BootCheck:
self.check_for_unreferenced_repos(status)
self.check_for_unsynced_repos(status)
self.check_vsftpd_bin(status)
+ self.check_elinks(status)
return status
@@ -302,4 +303,7 @@ class BootCheck:
else:
status.append(_("missing file: %(file)s") % { "file" : self.settings.dhcpd_conf })
+ def check_elinks(self,status):
+ if not os.path.exists("/usr/bin/elinks"):
+ status.append(_("elinks package is not installed, needed for cobbler system render, yum install elinks?"))
diff --git a/cobbler/commands.py b/cobbler/commands.py
index cbd7cdd..1507abe 100644
--- a/cobbler/commands.py
+++ b/cobbler/commands.py
@@ -16,6 +16,7 @@ import optparse
from cexceptions import *
from utils import _
import sys
+import os
HELP_FORMAT = "%-20s%s"
@@ -253,6 +254,12 @@ class CobblerFunction:
self.reporting_list_names2(collect_fn(),self.options.name)
return None
+ if "getks" in self.args:
+ if self.options.name:
+ os.system("/usr/bin/elinks --localhost 1 http://localhost/cblr/svc/op/ks/system/" + self.options.name)
+ else:
+ raise CX(_("Please specify a system name using --name"))
+
if not self.options.name:
raise CX(_("name is required"))
diff --git a/cobbler/modules/cli_misc.py b/cobbler/modules/cli_misc.py
index f92094a..ec9948f 100644
--- a/cobbler/modules/cli_misc.py
+++ b/cobbler/modules/cli_misc.py
@@ -14,6 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import distutils.sysconfig
import sys
+import os
plib = distutils.sysconfig.get_python_lib()
mod_path="%s/cobbler" % plib
@@ -198,6 +199,34 @@ class ReportFunction(commands.CobblerFunction):
########################################################
+class GetksFunction(commands.CobblerFunction):
+
+ def help_me(self):
+ return HELP_FORMAT % ("cobbler getks","[ARGS|--help]")
+
+ def command_name(self):
+ return "getks"
+
+ def add_options(self, p, args):
+ p.add_option("--what", dest="what", default="all", help="systems")
+ p.add_option("--name", dest="name", help="report on just this object")
+
+ def run(self):
+ if self.options.what not in [ "all", "systems" ]:
+ raise CX(_("Invalid value for --what"))
+
+ if self.options.what in [ "all", "systems" ]:
+ if self.options.name:
+ os.system("/usr/bin/elinks --localhost 1 http://localhost/cblr/svc/op/ks/system/" + self.options.name)
+ else:
+ raise CX(_("Please specify a system name using --name"))
+
+ return True
+
+
+
+########################################################
+
class StatusFunction(commands.CobblerFunction):
def help_me(self):
@@ -345,7 +374,8 @@ def cli_functions(api):
CheckFunction(api), ImportFunction(api), ReserializeFunction(api),
ListFunction(api), ReportFunction(api), StatusFunction(api),
SyncFunction(api), RepoSyncFunction(api), ValidateKsFunction(api),
- ReplicateFunction(api), AclFunction(api)
+ ReplicateFunction(api), AclFunction(api),
+ GetksFunction(api)
]
return []
diff --git a/cobbler/modules/cli_system.py b/cobbler/modules/cli_system.py
index fbf40cb..62a0c5b 100644
--- a/cobbler/modules/cli_system.py
+++ b/cobbler/modules/cli_system.py
@@ -27,20 +27,20 @@ import cexceptions
class SystemFunction(commands.CobblerFunction):
def help_me(self):
- return commands.HELP_FORMAT % ("cobbler system","<add|copy|edit|find|list|rename|remove|report> [ARGS|--help]")
+ return commands.HELP_FORMAT % ("cobbler system","<add|copy|edit|find|list|rename|remove|report|getks> [ARGS|--help]")
def command_name(self):
return "system"
def subcommands(self):
- return [ "add", "copy", "dumpvars", "edit", "find", "list", "remove", "rename", "report" ]
+ return [ "add", "copy", "dumpvars", "edit", "find", "list", "remove", "rename", "report", "getks"]
def add_options(self, p, args):
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"]):
+ if not self.matches_args(args,["dumpvars","remove","report","getks","list"]):
p.add_option("--dhcp-tag", dest="dhcp_tag", help="for use in advanced DHCP configurations")
p.add_option("--gateway", dest="gateway", help="for static IP / templating usage")
p.add_option("--hostname", dest="hostname", help="ex: server.example.org")
@@ -58,19 +58,19 @@ class SystemFunction(commands.CobblerFunction):
p.add_option("--name", dest="name", help="a name for the system (REQUIRED)")
- if not self.matches_args(args,["dumpvars","remove","report","list"]):
+ if not self.matches_args(args,["dumpvars","remove","report","getks","list"]):
p.add_option("--netboot-enabled", dest="netboot_enabled", help="PXE on (1) or off (0)")
if self.matches_args(args,["copy","rename"]):
p.add_option("--newname", dest="newname", help="for use with copy/edit")
- if not self.matches_args(args,["dumpvars","find","remove","report","list"]):
+ if not self.matches_args(args,["dumpvars","find","remove","report","getks","list"]):
p.add_option("--no-sync", action="store_true", dest="nosync", help="suppress sync for speed")
- if not self.matches_args(args,["dumpvars","find","report","list"]):
+ if not self.matches_args(args,["dumpvars","find","report","getks","list"]):
p.add_option("--no-triggers", action="store_true", dest="notriggers", help="suppress trigger execution")
- if not self.matches_args(args,["dumpvars","remove","report","list"]):
+ if not self.matches_args(args,["dumpvars","remove","report","getks","list"]):
p.add_option("--owners", dest="owners", help="specify owners for authz_ownership module")
p.add_option("--profile", dest="profile", help="name of cobbler profile (REQUIRED)")
p.add_option("--server-override", dest="server_override", help="overrides server value in settings file")
--
1.5.5.1
15 years, 8 months
FYI: license headers updated to include GPLv2 license headers
by Michael DeHaan
Cobbler and koan have always been GPL v2+.
This hasn't changed, but I have updated the python source files in git
to all have the appropriate headers. If reading just the headers, and
not the file named COPYING, it might have given the impression they were
GPL v1.
Just wanted to post that in case anyone wasn't aware and was curious
about the git logs. This is /not/ about relicensing cobbler or koan,
but about avoiding future license confusion.
Everybody's copyright lines at the tops of the files and so forth are
preserved.
--Michael
15 years, 8 months
Kickstart logs
by drew einhorn
Is there a way to capture the kickstart logs that appear under ctrl-alt-f3
ctrl-alt-f4 and ctrl-alt-f5?
When debugging it would be nice to see the stuff that has already scrolled
off the top of the console.
--
Drew Einhorn
15 years, 8 months
Other virtualization support for koan?
by Michael DeHaan
While I'm not sure it makes sense, I figured I would ask.
Is anyone interested in seeing koan assist with other types of
virtualized installs?
lguest? virtual box? others?
I won't do it if no one is interested, but keeping koan comprehensive
seems to be goodness. We are already supporting more than just what
libvirt supports (i.e. VMware) so I don't see why we can't add more if
people want them, and it probably helps cobbler/koan adoption.
Let me know your thoughts.
--Michael
15 years, 8 months
Things to help test in 1.1.X if you are interested.
by Michael DeHaan
For those wanting to help test out the 1.1.X testing release I posted
about recently:
http://people.fedoraproject.org/~mdehaan/files/test_releases/
A few good things to test if you have an interest in them might be:
-- VMware workstation (and regular VMware Server) if you have it
-- General purpose virt testing, & does koan still work as you expect
-- "cobbler image add" and associated features
-- snippets, as we've overhauled these some lately (and more so in devel
branch)
-- cobbler buildiso, do all of the flags work as you expect?
-- cobbler replicate, does it replicate data between cobbler servers as
expected
-- serializer_catalog, in general, as posted to the list a while back
(back up /var/lib/cobbler first)
If you are already using the devel branch in git, building there will
get you even more current code.
Help is /very/ much appreciated, couldn't do it it without you.
If you hit any problems or have questions, stopping by #cobbler on
irc.freenode.net would be great.
Thanks!
--Michael
15 years, 8 months