summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorDarryl L. Pierce <dpierce@redhat.com>2008-08-14 08:30:56 -0400
committerDarryl L. Pierce <dpierce@redhat.com>2008-08-14 08:38:18 -0400
commit0560d8af4bc8aee0a9c32693ccdf7ea30906b726 (patch)
tree105a1229878ce5b5c6da7a5f63da3ba6f97d119f /contrib
parentd4c06553d573d8f34ff54e4af64c759a6c4c3d0a (diff)
downloadcobbler-0560d8af4bc8aee0a9c32693ccdf7ea30906b726.tar.gz
cobbler-0560d8af4bc8aee0a9c32693ccdf7ea30906b726.tar.xz
cobbler-0560d8af4bc8aee0a9c32693ccdf7ea30906b726.zip
Fixed the release number in the spec and a few typos and a missed file.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/ruby/examples/remove_distro.rb12
-rw-r--r--contrib/ruby/examples/remove_profile.rb72
-rw-r--r--contrib/ruby/rubygem-cobbler.spec4
3 files changed, 81 insertions, 7 deletions
diff --git a/contrib/ruby/examples/remove_distro.rb b/contrib/ruby/examples/remove_distro.rb
index c704ad49..2707057f 100755
--- a/contrib/ruby/examples/remove_distro.rb
+++ b/contrib/ruby/examples/remove_distro.rb
@@ -1,6 +1,6 @@
#!/usr/bin/ruby
#
-# remove_system.rb - example of using rubygem-cobbler to remove a system.
+# remove_distro.rb - example of using rubygem-cobbler to remove a distro.
#
# Copyright (C) 2008 Red Hat, Inc.
# Written by Darryl L. Pierce <dpierceredhat.com>
@@ -31,11 +31,11 @@ require 'cobbler'
include Cobbler
opts = GetoptLong.new(
- ["--hostname", "-s", GetoptLong::REQUIRED_ARGUMENT ],
- ["--name", "-d", GetoptLong::REQUIRED_ARGUMENT ],
- ["--username", "-u", GetoptLong::REQUIRED_ARGUMENT ],
- ["--password", "-p", GetoptLong::REQUIRED_ARGUMENT ],
- ["--help", "-h", GetoptLong::NO_ARGUMENT]
+ ['--hostname', '-s', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--name', '-d', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--username', '-u', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--password', '-p', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--help', '-h', GetoptLong::NO_ARGUMENT]
)
hostname = name = username = password = nil
diff --git a/contrib/ruby/examples/remove_profile.rb b/contrib/ruby/examples/remove_profile.rb
new file mode 100644
index 00000000..4c456274
--- /dev/null
+++ b/contrib/ruby/examples/remove_profile.rb
@@ -0,0 +1,72 @@
+#!/usr/bin/ruby
+#
+# remove_profile.rb - example of using rubygem-cobbler to remove a profile.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierceredhat.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 'getoptlong'
+
+require 'cobbler'
+
+include Cobbler
+
+opts = GetoptLong.new(
+ ['--hostname', '-s', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--name', '-d', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--username', '-u', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--password', '-p', GetoptLong::REQUIRED_ARGUMENT ],
+ ['--help', '-h', GetoptLong::NO_ARGUMENT]
+)
+
+hostname = name = username = password = nil
+
+def usage
+ puts "Usage: #{$0} --name profile-name [--hostname hostname] [--username username] [--password password]\n"
+ exit
+end
+
+opts.each do |opt, arg|
+ case opt
+ when '--hostname' then hostname = arg
+ when '--name' then name = arg
+ when '--username' then username = arg
+ when '--password' then password = arg
+ when '--help' then usage
+ end
+end
+
+if name
+ Base.hostname = hostname if hostname
+ Base.username = username if username
+ Base.password = password if password
+
+ puts "Removing the profile named \"#{name}\"..."
+
+ begin
+ puts "Deleted." if Profile.remove(name)
+ rescue Exception => e
+ puts "Error: #{e.message}"
+ end
+else
+ usage
+end \ No newline at end of file
diff --git a/contrib/ruby/rubygem-cobbler.spec b/contrib/ruby/rubygem-cobbler.spec
index 93523204..38433271 100644
--- a/contrib/ruby/rubygem-cobbler.spec
+++ b/contrib/ruby/rubygem-cobbler.spec
@@ -8,7 +8,7 @@
Summary: An interface for interacting with a Cobbler server
Name: rubygem-%{gemname}
Version: 0.0.1
-Release: 2%{?dist}
+Release: 3%{?dist}
Group: Development/Languages
License: LGPLv2+
URL: http://cobbler.et.redhat.com/
@@ -44,6 +44,7 @@ chmod +x %{installroot}/examples/list_systems.rb
chmod +x %{installroot}/examples/remove_distro.rb
chmod +x %{installroot}/examples/remove_image.rb
chmod +x %{installroot}/examples/remove_profile.rb
+chmod +x %{installroot}/examples/remove_system.rb
%clean
rm -rf %{buildroot}
@@ -68,6 +69,7 @@ rm -rf %{buildroot}
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.
+- 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