mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1112: Image command includes datastore information
This commit is contained in:
parent
9ae062e39e
commit
fbbf10950a
@ -3,11 +3,6 @@
|
||||
:desc: ONE identifier for the Image
|
||||
:size: 4
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Image
|
||||
:size: 12
|
||||
:left: true
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Virtual Machine owner
|
||||
:size: 8
|
||||
@ -18,6 +13,16 @@
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Image
|
||||
:size: 12
|
||||
:left: true
|
||||
|
||||
:DATASTORE:
|
||||
:desc: Name of the Datastore
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:SIZE:
|
||||
:desc: Size of the Image
|
||||
:size: 7
|
||||
@ -47,9 +52,9 @@
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
- :DATASTORE
|
||||
- :SIZE
|
||||
- :TYPE
|
||||
- :REGTIME
|
||||
- :PERSISTENT
|
||||
- :STAT
|
||||
- :RVMS
|
||||
|
@ -59,7 +59,11 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :IMAGES, "Number of Images", :left, :size=>6 do |d|
|
||||
d["IMAGES"].size
|
||||
if d["IMAGES"]["ID"].nil?
|
||||
"0"
|
||||
else
|
||||
d["IMAGES"]["ID"].size
|
||||
end
|
||||
end
|
||||
|
||||
column :TYPE, "Datastore driver", :left, :size=>6 do |d|
|
||||
|
@ -45,10 +45,6 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Image", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Virtual Machine owner", :left,
|
||||
:size=>8 do |d|
|
||||
helper.user_name(d, options)
|
||||
@ -59,13 +55,16 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :TYPE, "Type of the Image", :size=>4 do |d,e|
|
||||
OneImageHelper.type_to_str(d["TYPE"])
|
||||
column :NAME, "Name of the Image", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :REGTIME, "Registration time of the Image",
|
||||
:size=>20 do |d|
|
||||
OpenNebulaHelper.time_to_str(d["REGTIME"])
|
||||
column :DATASTORE, "Name of the Image", :left, :size=>10 do |d|
|
||||
d["DATASTORE"]
|
||||
end
|
||||
|
||||
column :TYPE, "Type of the Image", :size=>4 do |d,e|
|
||||
OneImageHelper.type_to_str(d["TYPE"])
|
||||
end
|
||||
|
||||
column :PERSISTENT, "Whether the Image is persistent or not",
|
||||
@ -87,7 +86,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,options,"M")
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :SIZE, :TYPE, :REGTIME,
|
||||
default :ID, :USER, :GROUP, :NAME, :DATASTORE, :SIZE, :TYPE,
|
||||
:PERSISTENT , :STAT, :RVMS
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/oneimage_helper'
|
||||
require 'one_helper/onedatastore_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`oneimage` <command> [<args>] [<options>]"
|
||||
@ -45,6 +46,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
list_options << OpenNebulaHelper::XML
|
||||
list_options << OpenNebulaHelper::NUMERIC
|
||||
|
||||
CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
@ -56,10 +59,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
OpenNebulaHelper.rname_to_id(arg, "USER")
|
||||
end
|
||||
|
||||
set :format, :datastoreid, OpenNebulaHelper.rname_to_id_desc("DATASTORE") do |arg|
|
||||
OpenNebulaHelper.rname_to_id(arg, "DATASTORE")
|
||||
end
|
||||
|
||||
set :format, :imageid, OneImageHelper.to_id_desc do |arg|
|
||||
helper.to_id(arg)
|
||||
end
|
||||
@ -80,10 +79,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Image from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file, :datastoreid do
|
||||
command :create, create_desc, :file, :options=>CREATE_OPTIONS do
|
||||
if options[:datastore].nil?
|
||||
STDERR.puts "Datastore to save the image is mandatory: "
|
||||
STDERR.puts "\t -d datastore_id"
|
||||
exit -1
|
||||
end
|
||||
helper.create_resource(options) do |image|
|
||||
template=File.read(args[0])
|
||||
image.allocate(template, args[1])
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
image.allocate(template, options[:datastore] )
|
||||
rescue => e
|
||||
STDERR.puts e.messsage
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user