[Ovirt-devel] [PATCH client 09/11] Command line driver
David Lutterkort
lutter at redhat.com
Mon Jan 26 21:20:39 UTC 2009
---
bin/ovirt | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
create mode 100755 bin/ovirt
diff --git a/bin/ovirt b/bin/ovirt
new file mode 100755
index 0000000..42b7871
--- /dev/null
+++ b/bin/ovirt
@@ -0,0 +1,84 @@
+#! /usr/bin/ruby
+
+# FIXME: Remove this, only to ease testing
+$:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
+
+# The main oVirt command line client.
+
+require 'rubygems'
+require 'ovirt'
+require 'main'
+
+require 'ruby-debug'
+
+# This is not really how we want the command line, but a temporary
+# approximation
+
+Main {
+ mixin :command do
+ include OVirt::Command::Base
+
+ def run
+ OVirt::Base::site = params["server"].value
+ OVirt::Base::login
+
+ hash = params.to_options
+ ["server", "help"].each { |k| hash.delete(k) }
+ begin
+ execute(hash)
+ rescue ActiveResource::TimeoutError
+ puts_error "request timed out"
+ rescue ActiveResource::ServerError => e
+ puts_error "server error: #{e}"
+ rescue Errno::ECONNREFUSED => e
+ puts_error "connection refused"
+ end
+ end
+ end
+
+ mixin :pool_argument do
+ argument("pool") {
+ description "the pool on which to perform the operation"
+ required
+ }
+ end
+
+ description "Control an oVirt server from a distance"
+
+ option("server=[SERVER]") {
+ validate { |val| ! val.nil? }
+ default ENV["OVIRT_SERVER"]
+ description <<DESCR
+URL of the oVirt server, in the form http://USER:PASSWORD@SERVER/ovirt
+DESCR
+ }
+
+ mode 'node' do
+
+ mixin :pool_argument
+
+ mode 'list' do
+ option("verbose", "v")
+ include OVirt::Command::Node::List
+ mixin :command
+ end
+ end
+
+ mode 'storage' do
+
+ mixin :pool_argument
+
+ mode 'list' do
+ option("verbose", "v")
+ include OVirt::Command::Storage::List
+ mixin :command
+ end
+ end
+
+ def run
+ $stderr.puts usage.to_s
+ end
+}
+# Want:
+# ovirt node /root/hardware/default mv host.example.com /root/hardware/default/subpool
+# ovirt storage /root/hardware/default create-pool --type=nfs --ip=... --path=..
--
1.6.0.6
More information about the ovirt-devel
mailing list