summaryrefslogtreecommitdiffstats
path: root/contrib/ruby
diff options
context:
space:
mode:
authorDarryl L. Pierce <dpierce@redhat.com>2008-08-21 13:26:30 -0400
committerDarryl L. Pierce <dpierce@redhat.com>2008-08-21 15:41:22 -0400
commit7e3f4a7860d774f769e634ce47b67c3b47ecf2dd (patch)
tree91f397ce2aa70cc01a526aba5889d4ba47bc6751 /contrib/ruby
parent09ce74a9c91db0cb497223d62465150842cdf9c0 (diff)
downloadcobbler-7e3f4a7860d774f769e634ce47b67c3b47ecf2dd.tar.gz
cobbler-7e3f4a7860d774f769e634ce47b67c3b47ecf2dd.tar.xz
cobbler-7e3f4a7860d774f769e634ce47b67c3b47ecf2dd.zip
Added an update call prior to saving or updating a system.
Diffstat (limited to 'contrib/ruby')
-rw-r--r--contrib/ruby/ChangeLog16
-rw-r--r--contrib/ruby/README15
-rw-r--r--contrib/ruby/Rakefile2
-rw-r--r--contrib/ruby/TODO3
-rw-r--r--contrib/ruby/lib/cobbler/system.rb7
-rw-r--r--contrib/ruby/rubygem-cobbler.spec8
-rw-r--r--contrib/ruby/test/test_system.rb13
7 files changed, 50 insertions, 14 deletions
diff --git a/contrib/ruby/ChangeLog b/contrib/ruby/ChangeLog
index 81b0104d..8b41d45a 100644
--- a/contrib/ruby/ChangeLog
+++ b/contrib/ruby/ChangeLog
@@ -1,6 +1,18 @@
-* Wed Aug 13 2008 Darryl Pierce <dpierce@redhat.com>
+* Thu Aug 21 2008 Darryl Pierce <dpierce@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@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@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@redhat.com> - 0.0.1-1
+- Initial package
diff --git a/contrib/ruby/README b/contrib/ruby/README
index 0fda7e22..a91b20cf 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 f4d88fe4..5970cc33 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 e5eddbe9..2c74dd77 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 255391c7..849ab5d7 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 38433271..51dcd800 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@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@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 e28da8bf..53c979ba 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(@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(@auth_token)
+ @connection.should_receive(:call).with('update').once.returns { true }
@connection.should_receive(:call).with('new_system',@auth_token).once.returns(@system_id)
@connection.should_receive(:call).with('modify_system',@system_id,'name',@system_name,@auth_token).once.returns(true)
@connection.should_receive(:call).with('modify_system',@system_id,'profile',@profile_name,@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(@auth_token)
+ @connection.should_receive(:call).with('update').once.returns { true }
@connection.should_receive(:call).with('new_system',@auth_token).once.returns(@system_id)
@connection.should_receive(:call).with('modify_system',@system_id,'name',@system_name,@auth_token).once.returns(true)
@connection.should_receive(:call).with('modify_system',@system_id,'profile',@profile_name,@auth_token).once.returns(true)