mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1112: Datastore Command
This commit is contained in:
parent
6861fa660e
commit
0e8ecf97f7
@ -8,7 +8,31 @@
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:CLUSTER:
|
||||
:desc: Name of the Cluster
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:IMAGES:
|
||||
:desc: Number of Images
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:TYPE:
|
||||
:desc: Datastore driver
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:TM:
|
||||
:desc: Transfer driver
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :NAME
|
||||
- :CLUSTER
|
||||
- :IMAGES
|
||||
- :TYPE
|
||||
- :TM
|
||||
|
||||
|
@ -29,7 +29,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
dsid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def self.rname
|
||||
"DATASTORE"
|
||||
end
|
||||
@ -46,11 +46,31 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Datastore", :left, :size=>15 do |d|
|
||||
column :NAME, "Name of the Datastore", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
default :ID, :NAME
|
||||
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
|
||||
if d["CLUSTER"] == "none"
|
||||
"-"
|
||||
else
|
||||
d["CLUSTER"]
|
||||
end
|
||||
end
|
||||
|
||||
column :IMAGES, "Number of Images", :left, :size=>6 do |d|
|
||||
d["IMAGES"].size
|
||||
end
|
||||
|
||||
column :TYPE, "Datastore driver", :left, :size=>6 do |d|
|
||||
d["DS_MAD"]
|
||||
end
|
||||
|
||||
column :TM, "Transfer driver", :left, :size=>6 do |d|
|
||||
d["TM_MAD"]
|
||||
end
|
||||
|
||||
default :ID, :CLUSTER, :NAME, :IMAGES, :TYPE, :TM_MAD
|
||||
end
|
||||
|
||||
table
|
||||
@ -82,6 +102,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["USER", datastore['UNAME']]
|
||||
puts str % ["GROUP", datastore['GNAME']]
|
||||
puts str % ["CLUSTER", datastore['CLUSTER']]
|
||||
puts str % ["CLUSTER_ID", datastore['CLUSTER_ID']]
|
||||
|
||||
puts str % ["DS_MAD", datastore['DS_MAD']]
|
||||
puts str % ["TM_MAD", datastore['TM_MAD']]
|
||||
@ -100,14 +121,14 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
}
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "IMAGES", false)
|
||||
CLIHelper.print_header("%-15s" % ["ID"])
|
||||
CLIHelper.print_header(str_h1 % "DATASTORE TEMPLATE",false)
|
||||
puts datastore.template_str
|
||||
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "REGISTERED IMAGES", false)
|
||||
datastore.img_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "DATASTORE TEMPLATE",false)
|
||||
puts datastore.template_str
|
||||
end
|
||||
end
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/onedatastore_helper'
|
||||
require 'one_helper/onecluster_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onedatastore` <command> [<args>] [<options>]"
|
||||
@ -76,14 +77,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Datastore from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file, [:clusterid, nil] do
|
||||
helper.create_resource(options) do |datastore|
|
||||
template=File.read(args[0])
|
||||
command :create, create_desc, :file, :options=>[OneClusterHelper::CLUSTER] do
|
||||
|
||||
if args.size == 1
|
||||
datastore.allocate(template)
|
||||
else
|
||||
datastore.allocate(template, args[1].to_i)
|
||||
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
||||
|
||||
helper.create_resource(options) do |datastore|
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
datastore.allocate(template, cid)
|
||||
rescue =>e
|
||||
STDERR.puts e.message
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user