Client can't get static IP from cobbler server
by jun fan
Cobbler Server: cobbler-1.0.2-1.el5 on RHEL5
I ran the following commands to produce boot CD :
cobbler distro add --arch=x86 --breed=redhat --initrd=/misc/mrepo/mrepo/rhel-server-5-i386/disc1/images/pxeboot/initrd.img --kernel=/misc/mrepo/mrepo/rhel-server-5-i386/disc1/images/pxeboot/vmlinuz --name=rhel-server-5-i386
cobbler profile add --distro=rhel-server-5-i386 --kickstart=http://192.168.0.1/kickstart/rhel5es_small_testbuild.cfg --kopts='ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:testbuild::' --name=testbuild
cobbler buildiso
Then client boot off the CD
The error message on alt+f3 console is :
ERROR: no DNS servers, can't look up hostname
ERROR: failed to retrieve http://192.168.0.1///kickstart/rhel5es_small_testbuild.cfg
There is no 404 error in apache log on cobbler server.
I think the client can't get static IP 192.168.0.2 from cobbler server.
Maybe there is something wrong with --kopts='ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:testbuild::' ?
Client can boot off the CD and complete installation successfully when I use --kopts='ip=dhcp:testbuild:: to produce profile.
I would like to know how to grant static IP to client. Any suggestion would be highly appreciated.
Healthy
---------------------------------
雅虎邮箱,您的终生邮箱!
---------------------------------
雅虎邮箱,您的终生邮箱!
15 years, 9 months
best practice for avoiding a boot loop
by Josh Miller
What is the recommended solution for avoiding a boot loop when using
cobbler with PXE/DHCP? I'd like to leave the primary boot interface as
PXE and have the flexibility to control when a system is rebuilt using
cobbler.
TIA,
--
Josh Miller, RHCE/VCP
Seattle, WA
Linux Solutions Provider
http://itsecureadmin.com/
15 years, 9 months
[PATCH] Ruby interface for Cobbler XML-RPC APIs.
by Darryl L. Pierce
The interface is stored in a module named Cobbler.
Examples for using the interface are stored in ./examples.
With this I'm looking for feedback on the general direction of
the code. I plan to change the list and get methods to eventually
work like ActiveRecord::Base and treat hashes as fields.
Signed-off-by: Darryl L. Pierce <dpierce(a)redhat.com>
---
ruby/rubygem-cobbler/examples/create_system.rb | 51 +++++++
ruby/rubygem-cobbler/examples/has_profile.rb | 41 +++++
ruby/rubygem-cobbler/examples/has_system.rb | 39 +++++
ruby/rubygem-cobbler/examples/list_distros.rb | 48 ++++++
ruby/rubygem-cobbler/examples/list_profiles.rb | 49 ++++++
ruby/rubygem-cobbler/examples/list_systems.rb | 49 ++++++
ruby/rubygem-cobbler/examples/remove_system.rb | 43 ++++++
ruby/rubygem-cobbler/lib/cobbler.rb | 25 +++
ruby/rubygem-cobbler/lib/cobbler/system.rb | 131 ++++++++++++++++
.../nbproject/private/private.properties | 3 +
ruby/rubygem-cobbler/nbproject/project.properties | 10 ++
ruby/rubygem-cobbler/nbproject/project.xml | 16 ++
ruby/rubygem-cobbler/test/test_system.rb | 159 ++++++++++++++++++++
13 files changed, 664 insertions(+), 0 deletions(-)
create mode 100755 ruby/rubygem-cobbler/examples/create_system.rb
create mode 100755 ruby/rubygem-cobbler/examples/has_profile.rb
create mode 100755 ruby/rubygem-cobbler/examples/has_system.rb
create mode 100755 ruby/rubygem-cobbler/examples/list_distros.rb
create mode 100755 ruby/rubygem-cobbler/examples/list_profiles.rb
create mode 100755 ruby/rubygem-cobbler/examples/list_systems.rb
create mode 100755 ruby/rubygem-cobbler/examples/remove_system.rb
create mode 100644 ruby/rubygem-cobbler/lib/cobbler.rb
create mode 100644 ruby/rubygem-cobbler/lib/cobbler/system.rb
create mode 100644 ruby/rubygem-cobbler/nbproject/private/private.properties
create mode 100644 ruby/rubygem-cobbler/nbproject/project.properties
create mode 100644 ruby/rubygem-cobbler/nbproject/project.xml
create mode 100755 ruby/rubygem-cobbler/test/test_system.rb
diff --git a/ruby/rubygem-cobbler/examples/create_system.rb b/ruby/rubygem-cobbler/examples/create_system.rb
new file mode 100755
index 0000000..93e86e9
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/create_system.rb
@@ -0,0 +1,51 @@
+#!/usr/bin/ruby -W0
+#
+# create_system.rb - example of using rubygem-cobbler to create a system.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty? || ARGV.size < 5
+ puts "Usage: #{$0} hostname system-name profile-name username password"
+ exit 1
+end
+
+hostname = ARGV[0]
+system_name = ARGV[1]
+profile_name = ARGV[2]
+username = ARGV[3]
+password = ARGV[4]
+
+puts "Attempting to create a new system named #{system_name} based on profile #{profile_name}"
+
+system = Cobbler::System.new(hostname)
+system.username = username
+system.password = password
+
+unless system.has_profile?(profile_name)
+ puts "No such profile: #{profile_name}"
+ exit 1
+end
+
+system.create_system(system_name,profile_name,'00:11:22:33:44:55:66:77')
diff --git a/ruby/rubygem-cobbler/examples/has_profile.rb b/ruby/rubygem-cobbler/examples/has_profile.rb
new file mode 100755
index 0000000..80a3054
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/has_profile.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/ruby -W0
+#
+# has_profile.rb - example of using rubygem-cobbler to chekc if a profile exists.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty? || ARGV.size < 2
+ puts "Usage: #{$0} hostname profile-name"
+ exit 1
+end
+
+hostname = ARGV[0]
+profile_name = ARGV[1]
+
+puts "Connecting to #{hostname}"
+
+system = Cobbler::System.new(hostname)
+
+puts "Does #{profile_name} exist? #{system.has_profile?(profile_name)}"
\ No newline at end of file
diff --git a/ruby/rubygem-cobbler/examples/has_system.rb b/ruby/rubygem-cobbler/examples/has_system.rb
new file mode 100755
index 0000000..ae62255
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/has_system.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/ruby -W0
+#
+# has_system.rb - example of using rubygem-cobbler to check if a system exists.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty? || ARGV.size < 2
+ puts "Usage: #{$0} hostname system-name"
+ exit 1
+end
+
+hostname = ARGV[0]
+system_name = ARGV[1]
+
+system = Cobbler::System.new(hostname)
+
+puts "Does #{system_name} exist? #{system.has_system?(system_name)}"
\ No newline at end of file
diff --git a/ruby/rubygem-cobbler/examples/list_distros.rb b/ruby/rubygem-cobbler/examples/list_distros.rb
new file mode 100755
index 0000000..be99ef8
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/list_distros.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/ruby -W0
+# list_distros.rb - example of using rubygem-cobbler to list distros.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty?
+ puts "Usage: #{$0} hostname"
+ exit 1
+end
+
+hostname = ARGV[0]
+
+puts "Connecting to #{hostname}"
+
+system = Cobbler::System.new(hostname)
+
+system.distros.each do |distro|
+ puts "[Distro: #{distro['name']}]"
+
+ distro.keys.each do |key|
+ puts "#{key}: #{distro[key]}" unless key == 'name'
+ end
+
+ puts "\n"
+end
+
diff --git a/ruby/rubygem-cobbler/examples/list_profiles.rb b/ruby/rubygem-cobbler/examples/list_profiles.rb
new file mode 100755
index 0000000..18c2783
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/list_profiles.rb
@@ -0,0 +1,49 @@
+#!/usr/bin/ruby -W0
+#
+# list_profiles.rb - example of using rubygem-cobbler to list profiles.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty?
+ puts "Usage: #{$0} hostname"
+ exit 1
+end
+
+hostname = ARGV[0]
+
+puts "Connecting to #{hostname}"
+
+system = Cobbler::System.new(hostname)
+
+system.profiles.each do |profile|
+ puts "[Profile: #{profile['name']}]"
+
+ profile.keys.each do |key|
+ puts "#{key}: #{profile[key]}" unless key == 'name'
+ end
+
+ puts "\n"
+end
+
diff --git a/ruby/rubygem-cobbler/examples/list_systems.rb b/ruby/rubygem-cobbler/examples/list_systems.rb
new file mode 100755
index 0000000..f82913e
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/list_systems.rb
@@ -0,0 +1,49 @@
+#!/usr/bin/ruby -W0
+#
+# list_systems.rb - example of using rubygem-cobbler to list systems.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty?
+ puts "Usage: #{$0} hostname"
+ exit 1
+end
+
+hostname = ARGV[0]
+
+puts "Connecting to #{hostname}"
+
+system = Cobbler::System.new(hostname)
+
+system.systems.each do |system|
+ puts "[System: #{system['name']}]"
+
+ system.keys.each do |key|
+ puts "#{key}: #{system[key]}" unless key == 'name'
+ end
+
+ puts "\n"
+end
+
diff --git a/ruby/rubygem-cobbler/examples/remove_system.rb b/ruby/rubygem-cobbler/examples/remove_system.rb
new file mode 100755
index 0000000..21e77bf
--- /dev/null
+++ b/ruby/rubygem-cobbler/examples/remove_system.rb
@@ -0,0 +1,43 @@
+#!/usr/bin/ruby -W0
+#
+# remove_system.rb - example of using rubygem-cobbler to remove a system.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+$LOAD_PATH << File.join(base, "lib")
+$LOAD_PATH << File.join(base, "examples")
+
+require 'cobbler'
+
+if ARGV.empty? || ARGV.size < 4
+ puts "Usage: #{$0} hostname system-name username password"
+ exit 1
+end
+
+hostname = ARGV[0]
+system_name = ARGV[1]
+username = ARGV[2]
+password = ARGV[3]
+
+system = Cobbler::System.new(hostname)
+system.username = username
+system.password = password
+
+system.remove_system(system_name)
\ No newline at end of file
diff --git a/ruby/rubygem-cobbler/lib/cobbler.rb b/ruby/rubygem-cobbler/lib/cobbler.rb
new file mode 100644
index 0000000..df78813
--- /dev/null
+++ b/ruby/rubygem-cobbler/lib/cobbler.rb
@@ -0,0 +1,25 @@
+# cobbler.rb - Cobbler module declaration.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+require 'cobbler/system'
+
+module Cobbler
+
+end
diff --git a/ruby/rubygem-cobbler/lib/cobbler/system.rb b/ruby/rubygem-cobbler/lib/cobbler/system.rb
new file mode 100644
index 0000000..2792be5
--- /dev/null
+++ b/ruby/rubygem-cobbler/lib/cobbler/system.rb
@@ -0,0 +1,131 @@
+# system.rb - Allows a remote client to interact with a Cobbler server.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+require 'xmlrpc/client'
+require 'pp'
+
+module Cobbler
+ include XMLRPC
+
+ # +System+ represents a remote Cobbler server.
+ #
+ class System
+
+ attr_accessor :hostname
+ attr_accessor :username, :password
+ attr_writer :connection
+
+ def initialize(hostname)
+ @hostname = hostname
+
+ @writing = false
+ end
+
+ # Returns the list of distros in Cobbler.
+ #
+ def distros
+ @writing = false
+ connect.call('get_distros')
+ end
+
+ # Returns the list of profiles in Cobbler.
+ #
+ def profiles
+ @writing = false
+ connect.call('get_profiles')
+ end
+
+ # Returns whether a profile exists in Cobbler.
+ #
+ def has_profile?(name)
+ raise Exception.new("No profile name specified") if name == nil or name.empty?
+
+ @writing = false
+
+ profiles.each do |profile|
+ return true if profile['name'] == name
+ end
+
+ return false
+ end
+
+ # Returns the list of systems in Cobbler.
+ #
+ def systems
+ @writing = false
+ connect.call('get_systems')
+ end
+
+ # Returns whether the given system exists.
+ #
+ def has_system?(name)
+ @writing = false
+
+ raise Exception.new('Expected a system name') if (name == nil) || name.empty?
+ systems.each do |system|
+ return true if system['name'] == name
+ end
+
+ return false
+ end
+
+ # Creates a new system record in Cobbler.
+ #
+ def create_system(name, profile, mac)
+ @writing = true
+
+ raise Exception.new("System already exists: #{name}") if has_system? name
+
+ token = login
+ system_id = connect.call('new_system',token)
+
+ connect.call('modify_system',system_id,'name',name,token)
+ connect.call('modify_system',system_id,'profile',profile,token)
+ #connect.call('modify_system',system_id,'mac',mac,token)
+ connect.call('save_system',system_id,token)
+
+ return system_id
+ end
+
+ # Removes the system with the given name.
+ #
+ def remove_system(name)
+ raise Exception.new('System name expected') if (name == nil) || name.empty?
+ raise Exception.new("No such system: #{name}") if !has_system? name
+
+ token = login
+
+ @writing = true
+
+ connect.call('remove_system',name,token)
+ end
+
+ private
+
+ def login
+ @writing = true
+ connect.call('login',@username, @password)
+ end
+
+ def connect(use_ssl = false)
+ (@connection || XMLRPC::Client.new2("#{@use_ssl ? 'https' : 'http'}://#{hostname}/cobbler_#{@writing ? 'api_rw' : 'api'}"))
+ end
+ end
+end
diff --git a/ruby/rubygem-cobbler/nbproject/private/private.properties b/ruby/rubygem-cobbler/nbproject/private/private.properties
new file mode 100644
index 0000000..33ea747
--- /dev/null
+++ b/ruby/rubygem-cobbler/nbproject/private/private.properties
@@ -0,0 +1,3 @@
+file.reference.rubygem-cobbler-lib=/home/mcpierce/Programming/cobbler/ruby/rubygem-cobbler/lib
+file.reference.rubygem-cobbler-test=/home/mcpierce/Programming/cobbler/ruby/rubygem-cobbler/test
+platform.active=Ruby
diff --git a/ruby/rubygem-cobbler/nbproject/project.properties b/ruby/rubygem-cobbler/nbproject/project.properties
new file mode 100644
index 0000000..b30fbd8
--- /dev/null
+++ b/ruby/rubygem-cobbler/nbproject/project.properties
@@ -0,0 +1,10 @@
+file.reference.rubygem-cobbler-lib=lib
+file.reference.rubygem-cobbler-test=test
+javac.classpath=
+main.file=
+platform.active=Ruby
+ruby.includejava=false
+source.encoding=UTF-8
+src.dir=${file.reference.rubygem-cobbler-lib}
+src.examples.dir=examples
+test.src.dir=${file.reference.rubygem-cobbler-test}
diff --git a/ruby/rubygem-cobbler/nbproject/project.xml b/ruby/rubygem-cobbler/nbproject/project.xml
new file mode 100644
index 0000000..3ea391e
--- /dev/null
+++ b/ruby/rubygem-cobbler/nbproject/project.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.ruby.rubyproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
+ <name>rubygem-cobbler</name>
+ <source-roots>
+ <root id="src.examples.dir"/>
+ <root id="src.dir"/>
+ </source-roots>
+ <test-roots>
+ <root id="test.src.dir"/>
+ </test-roots>
+ </data>
+ </configuration>
+</project>
diff --git a/ruby/rubygem-cobbler/test/test_system.rb b/ruby/rubygem-cobbler/test/test_system.rb
new file mode 100755
index 0000000..2eec238
--- /dev/null
+++ b/ruby/rubygem-cobbler/test/test_system.rb
@@ -0,0 +1,159 @@
+# test_system.rb - Unit tests.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
+
+require 'test/unit'
+require 'flexmock/test_unit'
+require 'cobbler/system'
+
+module Cobbler
+ class TestSystem < Test::Unit::TestCase
+ def setup
+ @system = System.new('cobbler.server')
+ @system.username = 'testuser'
+ @system.password = 'testpassword'
+
+ # create a mock connection so we can control it during testing
+ @connection = flexmock('connection')
+ @system.connection = @connection
+
+ # test results from API calls
+ @distros = ['distro1', 'distro2']
+
+ @profiles = Array.new
+ @profiles[0] = Hash.new
+ @profiles[0]['name'] = 'profile1'
+ @profiles[1] = Hash.new
+ @profiles[1]['name'] = 'profile2'
+
+ @systems = Array.new
+ @systems[0] = Hash.new
+ @systems[0]['name'] = 'system1'
+ @systems[1] = Hash.new
+ @systems[1]['name'] = 'system2'
+
+ @auth_token = 'authtoken'
+ @system_id = 717
+ end
+
+ # Ensures that the call to get distributions works as expected.
+ #
+ def test_distros
+ @connection.should_receive(:call).with('get_distros').once.returns(@distros)
+
+ result = @system.distros
+
+ assert result, 'Missing result.'
+ assert_same @distros, result, 'Did not get the correct result.'
+ end
+
+ # Ensures that the call to get profiles works as expected.
+ #
+ def test_profiles
+ @connection.should_receive(:call).with('get_profiles').once.returns(@profiles)
+
+ result = @system.profiles
+
+ assert result, 'Missing result.'
+ assert_same @profiles, result, 'Did not get the correct result.'
+ end
+
+ # Ensures that the call to check if a profile exists works as expected.
+ #
+ def test_has_profile
+ @connection.should_receive(:call).with('get_profiles').once.returns(@profiles)
+
+ assert @system.has_profile?(@profiles[0]['name']),'Got a false negative'
+
+ @connection.should_receive(:call).with('get_profiles').once.returns(@profiles)
+
+ assert @system.has_profile?('farkle') == false, 'Got a false positive'
+ end
+
+ # Ensures that the call to get systems works as expected.
+ #
+ def test_systems
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ result = @system.systems
+
+ assert result, 'Missing result.'
+ assert_same @systems, result, 'Did not get the correct result.'
+ end
+
+ # Ensures that the call to check if a system exists works as expected.
+ #
+ def test_has_system
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ assert @system.has_system?(@systems[0]['name']), 'Got a false negative.'
+
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ assert @system.has_system?('farkle') == false, 'Got a false positive.'
+ end
+
+ # Ensures that trying to create a system with an existing name raises an exception.
+ #
+ def test_create_with_used_name
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ assert_raise(Exception) {@system.create_system((a)systems[0]['name'],'profile1','00:11:22:33:44:55:66:77')}
+ end
+
+ # Ensures that creating a new system record works as expected.
+ #
+ def test_create_system
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+ @connection.should_receive(:call).with('login','testuser','testpassword').once.returns(@auth_token)
+ @connection.should_receive(:call).with('new_system',@auth_token).once.returns((a)system_id)
+ @connection.should_receive(:call).with('modify_system',@system_id,'name','testsystem',@auth_token)
+ @connection.should_receive(:call).with('modify_system',@system_id,'profile','profile1',@auth_token)
+ @connection.should_receive(:call).with('modify_system',@system_id,'mac','00:01:02:03:04:05:06:07',@auth_token)
+ @connection.should_receive(:call).with('save_system',@system_id,@auth_token)
+
+ result = @system.create_system('testsystem', 'profile1','00:01:02:03:04:05:06:07')
+
+ assert_equal @system_id, result, 'Did not receive the system id'
+ end
+
+ # Ensures that deleting a system which doesn't exist raises an exception
+ #
+ def test_remove_system_with_invalid_name
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ assert_raises(Exception) { @system.remove_system('farkle')}
+ end
+
+ # Ensures that deleting a system works as expected.
+ #
+ def test_remove_system
+ @connection.should_receive(:call).with('get_systems').once.returns(@systems)
+
+ @connection.should_receive(:call).with('login','testuser','testpassword').once.returns(@auth_token)
+ @connection.should_receive(:call).with('remove_system',@systems[0]['name'],(a)auth_token).once
+
+ result = @system.remove_system(@systems[0]['name'])
+
+ end
+ end
+end
--
1.5.5.1
15 years, 9 months
Some kickstart snippet cleanup (1.1)
by Michael DeHaan
Many folks have rightfully complained that "partition_select" (which is
there to automate the setup of the part of the kickstart that sets up a
good deafult disk configuration) is a bit sneaky because it includes a
"%pre" that is not readily obvious.
While I am going to continue to ship the old snippet, new versions of
cobbler will do this:
# Magically figure out how to partition this thing
SNIPPET::main_partition_select
%pre
SNIPPET::pre_partition_select
$kickstart_start
%end
%packages
%end
The difference is that the one snippet is now two, so the %pre isn't
embedded. This makes a lot more sense.
For F9-and-before distros, it will be the same as the above with no "%end".
I've also make some edits to make sure "$kickstart_start" (which is
needed for "cobbler status" to work effectively) is included in all of
the base kickstarts.
When making your own kickstart files, look at these for reference of how
to templatize a basic kickstart so it automates better with Cobbler.
And again, as we will continue to ship the old snipppet, your existing
kickstart files will not break if you decide to not update them to the
.rpmnew versions.
--Michael
15 years, 9 months
Windows Image Deployments & Cobbler
by Daniel Hawker
Hi All,
Our Windows team predominantly use Ghost to deploy default desktop images. They have been toying with migrating across and using PING (http://ping.windowsdream.com/) instead for a variety of reasons, mostly to do with the general nastiness of getting newer hardware to play with the DOS based Ghost environment.
After having a quick look at PING (not used it myself as of yet), I was wondering if I could re-purpose parts of the Cobbler infrastructure (PXE management, etc), so that it can use PING as a means of creating a Windows provisioning framework for our default images.
Obviously this isn't quite the same as kickstart and cobbler, (due to the need to image a golden-image system first), but I presume it'll work OK (with the caveats of using images). After reviewing the System Retirement with PXE and DBAN article on the wiki, it should be doable???
Does this all sound sensible??? I think so, but as I haven't done much Windows deployments for a few years, its all a bit hazy in my mind.
Last but not least, has anyone done this before and if so any tips/tricks to getting it going or was it all straight forward enough??? Otherwise I'll make a stab at it, see what happens and document any success.
Thanks
Dan
--
Dan Hawker
d.hawker(a)kew.org
UNIX & Comms
Royal Botanic Gardens - Kew
--
"I love deadlines. I like the whooshing sound they make as they fly by" - Douglas Adams
--
15 years, 9 months
Using a MAC address for the ksdevice.
by Joseph Boyer Jr.
Is there a way in cobbler today that automates using the MAC address for eth0 as the parameter place on the kernel line for the ksdevice, i.e. ksdevice=00:2c:3e:23:4d:1e instead of the default using ksdevice=eth0 or whichever device you specify in the /etc/cobbler/settings file.
I know that passing ksdevice = {My MAC} on the kernel options line in system settings works, but I am looking for something that requires no user intervention. That is I want to use the interface's MAC address as my default.
This is because of NIC enumeration issue on HP Blade Centers.
Thanks
joe
Joseph Boyer Jr
Enterprise Technology Services
Liquidnet Holdings, Inc.
Joseph.Boyer(a)liquidnet.com<mailto:aengelhardtsen@liquidnet.com>
T +1 646.660.8352
C +1 646.284.8394
15 years, 9 months
Thoughts on Windows deployment continued
by Michael DeHaan
Perry mentioned this
http://www.microsoft.com/downloads/details.aspx?FamilyID=3bd8561f-77ac-44...
as a way to "kickstart" Windows guests that works better across
different releases of Windows than the unattended.txt files.
Would someone mind taking a look at this and seeing what the reality of
installation is to modify an ISO image to make it "fully automatically
installable"? If it is possible for a user to generate an ISO and we
have instructions for using it with "cobbler image add" I think this
feature is set.
However, if this requires a extra server or something, we have more work
to do -- such as figuring out how to talk to it over the network. In
that scenario, looking at more direct integration with the
unattended.net stuff may be a better route. I'm willing to do this but
would prefer if we can just treat it as any other OS image. That may
not be the case.
--Michael
15 years, 9 months
Thoughts on the free Cobbler deployment guide "book". What do you want to see?
by Michael DeHaan
One of the things I've talked about previously is writing a much
involved "Best Practices" deployment guide for Cobbler. I think
Cobbler's far enough now that it would be a good time to do this, as the
core of things should not be changing so significantly that it will not
rapidly become out of date.
The focus would be on large scale and complex deployments, and would
roll up and incorporate all the content on the Wiki with various things
I hear from users about how they manage their deployments. This is
very much going to be a "book" in terms of length. How short or long
I'm not sure, but it will exceed the manpage and Wiki in scope.
I'm going to start working on that soon, so I am wondering if there is
anything specific you folks would like to see covered or included?
As with Cobbler, this is intended to be collaboratively developed, so
the document sources will be kept in git.
My main concern at this point is if the deployment guide would become
out of sync with the Wiki and/or manpage, so I'm tempted to just write
the deployment guide on the Wiki. However this is less than ideal for
printing reasons. Alternatively, we can look to hosting all
documentation in DocBook, though this makes the Wiki less Wiki like.
Publican seems to be a popular option for document publishing.
(https://fedorahosted.org/publican/wiki/UsersGuide). It has the
disadvantage of being XML, though I think this still may be a bit better
for getting contributions than something like LaTEX.
--Michael
15 years, 9 months
Snippet with generalized functions
by Dan G
Attached is a snippet that makes use of cheetah methods. These are similar to some of the functionality that the Solaris SST offers. They basically encapsulate many (usually obscure) sed commands into handy functions.
$set_config_value('/etc/login.defs', 'LOGIN_RETRIES', 3)
is more readable than:
perl -npe 's/^([ \t]*$LOGIN_RETRIES[ \t]+)[\x21-\x7E]*([ \t]*(#.*)?)$/\${1}3\${2}/' -i '/etc/login.defs'
and the perl (sed) command doesn't take into account the possibility that LOGIN_RETRIES may not already be present in the file. The use of a function makes kickstart templates more readable and helps avoid errors.
Because of the utility of these functions, I would suggest they be distributed with cobbler, possibly as 'built-in' methods.
Development note: although I have tested that these functions do not cause any Cheetah errors, I have not tested the resulting kickstarts in an actual provision. They may still cause errors on the client side :( .
~
Dan
_________________________________________________________________
With Windows Live for mobile, your contacts travel with you.
http://www.windowslive.com/mobile/overview.html?ocid=TXT_TAGLM_WL_mobile_...
15 years, 9 months