summaryrefslogtreecommitdiffstats
path: root/contrib/ruby/examples/check_version.rb
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ruby/examples/check_version.rb')
-rwxr-xr-xcontrib/ruby/examples/check_version.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/contrib/ruby/examples/check_version.rb b/contrib/ruby/examples/check_version.rb
new file mode 100755
index 00000000..1d5653e5
--- /dev/null
+++ b/contrib/ruby/examples/check_version.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/ruby -w
+#
+# create_system.rb - example of using rubygem-cobbler to create a system.
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce@redhat.com>
+#
+# This file is part of rubygem-cobbler.
+#
+# rubygem-cobbleris free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# rubygem-cobbler 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 rubygem-cobbler. If not, see <http://www.gnu.org/licenses/>.
+#
+
+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 ],
+ ['--help', '-h', GetoptLong::NO_ARGUMENT])
+
+hostname = nil
+
+def usage
+ puts "Usage: #{$0} --hostname hostname\n"
+ exit
+end
+
+opts.each do |opt, arg|
+ case opt
+ when '--hostname' then hostname = arg
+ when '--help' then usage
+ end
+end
+
+if hostname
+ Base.hostname = hostname
+ version = Base.remote_version
+ if version
+ puts "Remote version: #{version}"
+ else
+ puts "Unable to determine version."
+ end
+else
+ usage
+end