mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1112: Update onevnet command
This commit is contained in:
parent
5c9dcf9033
commit
9ae062e39e
@ -3,11 +3,6 @@
|
||||
:desc: ONE identifier for Virtual Network
|
||||
:size: 4
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Network
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Virtual Network owner
|
||||
:size: 8
|
||||
@ -18,6 +13,16 @@
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Network
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:CLUSTER:
|
||||
:desc: Name of the Cluster
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:TYPE:
|
||||
:desc: Type of Virtual Network
|
||||
:size: 6
|
||||
@ -39,6 +44,7 @@
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
- :CLUSTER
|
||||
- :TYPE
|
||||
- :BRIDGE
|
||||
- :LEASES
|
||||
|
@ -39,11 +39,6 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Virtual Network", :left,
|
||||
:size=>15 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Virtual Network owner", :left,
|
||||
:size=>8 do |d|
|
||||
helper.user_name(d, options)
|
||||
@ -54,11 +49,24 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Virtual Network", :left,
|
||||
:size=>15 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
|
||||
if d["CLUSTER"] == "none"
|
||||
"-"
|
||||
else
|
||||
d["CLUSTER"]
|
||||
end
|
||||
end
|
||||
|
||||
column :TYPE, "Type of Virtual Network", :size=>6 do |d|
|
||||
OneVNetHelper.type_to_str(d["TYPE"])
|
||||
end
|
||||
|
||||
column :SIZE, "Size of the Virtual Network", :size=>6 do |d|
|
||||
column :SIZE, "Size of the Virtual Network", :size=>5 do |d|
|
||||
d["SIZE"]
|
||||
end
|
||||
|
||||
@ -68,7 +76,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :LEASES, "Number of this Virtual Network's given leases",
|
||||
:size=>7 do |d|
|
||||
:size=>6 do |d|
|
||||
d["TOTAL_LEASES"]
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/onevnet_helper'
|
||||
require 'one_helper/onecluster_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onevnet` <command> [<args>] [<options>]"
|
||||
@ -41,6 +42,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
########################################################################
|
||||
set :option, CommandParser::OPTIONS
|
||||
|
||||
CREATE_OPTIONS = [OneClusterHelper::CLUSTER]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
@ -52,10 +55,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
OpenNebulaHelper.rname_to_id(arg, "USER")
|
||||
end
|
||||
|
||||
set :format, :clusterid, OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg|
|
||||
OpenNebulaHelper.rname_to_id(arg, "CLUSTER")
|
||||
end
|
||||
|
||||
set :format, :vnetid, OneVNetHelper.to_id_desc do |arg|
|
||||
helper.to_id(arg)
|
||||
end
|
||||
@ -76,14 +75,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Virtual Network from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file, [:clusterid, nil] do
|
||||
helper.create_resource(options) do |vn|
|
||||
template=File.read(args[0])
|
||||
command :create, create_desc, :file, options=>CREATE_OPTIONS do
|
||||
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
||||
|
||||
if args.size == 1
|
||||
vn.allocate(template)
|
||||
else
|
||||
vn.allocate(template, args[1].to_i)
|
||||
helper.create_resource(options) do |vn|
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
vn.allocate(template, cid)
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user