opennebula-cli 3.8.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/oneacct +113 -0
- data/bin/oneacl +97 -0
- data/bin/onecluster +189 -0
- data/bin/onedatastore +165 -0
- data/bin/onegroup +137 -0
- data/bin/onehost +205 -0
- data/bin/oneimage +311 -0
- data/bin/onetemplate +277 -0
- data/bin/oneuser +404 -0
- data/bin/onevm +532 -0
- data/bin/onevnet +227 -0
- data/lib/cli_helper.rb +294 -0
- data/lib/command_parser.rb +719 -0
- data/lib/one_helper/oneacct_helper.rb +179 -0
- data/lib/one_helper/oneacl_helper.rb +130 -0
- data/lib/one_helper/onecluster_helper.rb +129 -0
- data/lib/one_helper/onedatastore_helper.rb +131 -0
- data/lib/one_helper/onegroup_helper.rb +134 -0
- data/lib/one_helper/onehost_helper.rb +196 -0
- data/lib/one_helper/oneimage_helper.rb +327 -0
- data/lib/one_helper/onequota_helper.rb +256 -0
- data/lib/one_helper/onetemplate_helper.rb +123 -0
- data/lib/one_helper/oneuser_helper.rb +242 -0
- data/lib/one_helper/onevm_helper.rb +266 -0
- data/lib/one_helper/onevnet_helper.rb +156 -0
- data/lib/one_helper.rb +609 -0
- metadata +93 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'one_helper'
|
18
|
+
|
19
|
+
class AcctHelper < OpenNebulaHelper::OneHelper
|
20
|
+
START_TIME = {
|
21
|
+
:name => "start_time",
|
22
|
+
:short => "-s TIME",
|
23
|
+
:large => "--start TIME" ,
|
24
|
+
:description => "Start date and time to take into account",
|
25
|
+
:format => String # TODO Time
|
26
|
+
}
|
27
|
+
|
28
|
+
END_TIME = {
|
29
|
+
:name => "end_time",
|
30
|
+
:short => "-e TIME",
|
31
|
+
:large => "--end TIME" ,
|
32
|
+
:description => "End date and time",
|
33
|
+
:format => String # TODO Time
|
34
|
+
}
|
35
|
+
|
36
|
+
USER = {
|
37
|
+
:name => "user",
|
38
|
+
:short => "-u user",
|
39
|
+
:large => "--user user" ,
|
40
|
+
:description => "User name or id to filter the results",
|
41
|
+
:format => String,
|
42
|
+
:proc => lambda { |o, options|
|
43
|
+
OpenNebulaHelper.rname_to_id(o, "USER")
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
GROUP = {
|
48
|
+
:name => "group",
|
49
|
+
:short => "-g group",
|
50
|
+
:large => "--group group" ,
|
51
|
+
:description => "Group name or id to filter the results",
|
52
|
+
:format => String,
|
53
|
+
:proc => lambda { |o, options|
|
54
|
+
puts o
|
55
|
+
OpenNebulaHelper.rname_to_id(o, "GROUP")
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
HOST = {
|
60
|
+
:name => "host",
|
61
|
+
:short => "-H HOST",
|
62
|
+
:large => "--host HOST" ,
|
63
|
+
:description => "Host name or id to filter the results",
|
64
|
+
:format => String,
|
65
|
+
:proc => lambda { |o, options|
|
66
|
+
OpenNebulaHelper.rname_to_id(o, "HOST")
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
XPATH = {
|
71
|
+
:name => "xpath",
|
72
|
+
:large => "--xpath XPATH_EXPRESSION" ,
|
73
|
+
:description => "Xpath expression to filter the results. \
|
74
|
+
For example: oneacct --xpath 'HISTORY[ETIME>0]'",
|
75
|
+
:format => String
|
76
|
+
}
|
77
|
+
|
78
|
+
XML = {
|
79
|
+
:name => "xml",
|
80
|
+
:short => "-x",
|
81
|
+
:large => "--xml",
|
82
|
+
:description => "Show the resource in xml format"
|
83
|
+
}
|
84
|
+
|
85
|
+
JSON = {
|
86
|
+
:name => "json",
|
87
|
+
:short => "-j",
|
88
|
+
:large => "--json",
|
89
|
+
:description => "Show the resource in xml format"
|
90
|
+
}
|
91
|
+
|
92
|
+
SPLIT={
|
93
|
+
:name => "split",
|
94
|
+
:large => "--split",
|
95
|
+
:description => "Split the output in a table for each VM"
|
96
|
+
}
|
97
|
+
|
98
|
+
ACCT_OPTIONS = [START_TIME, END_TIME, USER, GROUP, HOST, XPATH, XML, JSON, SPLIT]
|
99
|
+
|
100
|
+
|
101
|
+
ACCT_TABLE = CLIHelper::ShowTable.new("oneacct.yaml", nil) do
|
102
|
+
column :VID, "Virtual Machine ID", :size=>4 do |d|
|
103
|
+
d["OID"]
|
104
|
+
end
|
105
|
+
|
106
|
+
column :SEQ, "History record sequence number", :size=>3 do |d|
|
107
|
+
d["SEQ"]
|
108
|
+
end
|
109
|
+
|
110
|
+
column :HOSTNAME, "Host name", :left, :size=>15 do |d|
|
111
|
+
d["HOSTNAME"]
|
112
|
+
end
|
113
|
+
|
114
|
+
column :REASON, "VM state change reason", :left, :size=>4 do |d|
|
115
|
+
VirtualMachine.get_reason d["REASON"]
|
116
|
+
end
|
117
|
+
|
118
|
+
column :START_TIME, "Start time", :size=>14 do |d|
|
119
|
+
OpenNebulaHelper.time_to_str(d['STIME'])
|
120
|
+
end
|
121
|
+
|
122
|
+
column :END_TIME, "End time", :size=>14 do |d|
|
123
|
+
OpenNebulaHelper.time_to_str(d['ETIME'])
|
124
|
+
end
|
125
|
+
|
126
|
+
column :MEMORY, "Assigned memory", :size=>6 do |d|
|
127
|
+
OpenNebulaHelper.unit_to_str(d["VM"]["TEMPLATE"]["MEMORY"].to_i, {}, 'M')
|
128
|
+
end
|
129
|
+
|
130
|
+
column :CPU, "Number of CPUs", :size=>3 do |d|
|
131
|
+
d["VM"]["TEMPLATE"]["CPU"]
|
132
|
+
end
|
133
|
+
|
134
|
+
column :NET_RX, "Data received from the network", :size=>6 do |d|
|
135
|
+
# NET is measured in bytes, unit_to_str expects KBytes
|
136
|
+
OpenNebulaHelper.unit_to_str(d["VM"]["NET_RX"].to_i / 1024.0, {})
|
137
|
+
end
|
138
|
+
|
139
|
+
column :NET_TX, "Data sent to the network", :size=>6 do |d|
|
140
|
+
# NET is measured in bytes, unit_to_str expects KBytes
|
141
|
+
OpenNebulaHelper.unit_to_str(d["VM"]["NET_TX"].to_i / 1024.0, {})
|
142
|
+
end
|
143
|
+
|
144
|
+
default :VID, :HOSTNAME, :REASON, :START_TIME, :END_TIME, :MEMORY, :CPU, :NET_RX, :NET_TX
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.print_start_enc_time_header(start_time, end_time)
|
148
|
+
print "Showing active history records from "
|
149
|
+
|
150
|
+
CLIHelper.scr_bold
|
151
|
+
if ( start_time != -1 )
|
152
|
+
print Time.at(start_time).to_s
|
153
|
+
else
|
154
|
+
print "-"
|
155
|
+
end
|
156
|
+
|
157
|
+
CLIHelper.scr_restore
|
158
|
+
print " to "
|
159
|
+
|
160
|
+
CLIHelper.scr_bold
|
161
|
+
if ( end_time != -1 )
|
162
|
+
print Time.at(end_time).to_s
|
163
|
+
else
|
164
|
+
print "-"
|
165
|
+
end
|
166
|
+
|
167
|
+
CLIHelper.scr_restore
|
168
|
+
puts
|
169
|
+
puts
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.print_user_header(user_id)
|
173
|
+
CLIHelper.scr_bold
|
174
|
+
CLIHelper.scr_underline
|
175
|
+
puts "# User #{user_id}".ljust(80)
|
176
|
+
CLIHelper.scr_restore
|
177
|
+
puts
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'one_helper'
|
18
|
+
|
19
|
+
class OneAclHelper < OpenNebulaHelper::OneHelper
|
20
|
+
def self.rname
|
21
|
+
"ACL"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.conf_file
|
25
|
+
"oneacl.yaml"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def factory(id = nil)
|
31
|
+
if id
|
32
|
+
OpenNebula::Acl.new_with_id(id, @client)
|
33
|
+
else
|
34
|
+
xml = OpenNebula::Acl.build_xml
|
35
|
+
OpenNebula::Acl.new(xml, @client)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def factory_pool(filter)
|
40
|
+
OpenNebula::AclPool.new(@client)
|
41
|
+
end
|
42
|
+
|
43
|
+
# TODO check that @content[:resources_str] is valid
|
44
|
+
def self.resource_mask(str)
|
45
|
+
resource_type=str.split("/")[0]
|
46
|
+
|
47
|
+
mask = "----------"
|
48
|
+
|
49
|
+
resource_type.split("+").each{|type|
|
50
|
+
case type
|
51
|
+
when "VM"
|
52
|
+
mask[0] = "V"
|
53
|
+
when "HOST"
|
54
|
+
mask[1] = "H"
|
55
|
+
when "NET"
|
56
|
+
mask[2] = "N"
|
57
|
+
when "IMAGE"
|
58
|
+
mask[3] = "I"
|
59
|
+
when "USER"
|
60
|
+
mask[4] = "U"
|
61
|
+
when "TEMPLATE"
|
62
|
+
mask[5] = "T"
|
63
|
+
when "GROUP"
|
64
|
+
mask[6] = "G"
|
65
|
+
when "DATASTORE"
|
66
|
+
mask[7] = "D"
|
67
|
+
when "CLUSTER"
|
68
|
+
mask[8] = "C"
|
69
|
+
when "DOCUMENT"
|
70
|
+
mask[9] = "O"
|
71
|
+
end
|
72
|
+
}
|
73
|
+
mask
|
74
|
+
end
|
75
|
+
|
76
|
+
# TODO check that @content[:resources_str] is valid
|
77
|
+
def self.right_mask(str)
|
78
|
+
mask = "----"
|
79
|
+
|
80
|
+
str.split("+").each{|type|
|
81
|
+
case type
|
82
|
+
when "USE"
|
83
|
+
mask[0] = "u"
|
84
|
+
when "MANAGE"
|
85
|
+
mask[1] = "m"
|
86
|
+
when "ADMIN"
|
87
|
+
mask[2] = "a"
|
88
|
+
when "CREATE"
|
89
|
+
mask[3] = "c"
|
90
|
+
end
|
91
|
+
}
|
92
|
+
|
93
|
+
mask
|
94
|
+
end
|
95
|
+
|
96
|
+
def format_pool(options)
|
97
|
+
config_file = self.class.table_conf
|
98
|
+
|
99
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
100
|
+
column :ID, "Rule Identifier",
|
101
|
+
:size=>5 do |d|
|
102
|
+
d['ID']
|
103
|
+
end
|
104
|
+
|
105
|
+
column :USER, "To which resource owner the rule applies to",
|
106
|
+
:size=>8 do |d|
|
107
|
+
d['STRING'].split(" ")[0]
|
108
|
+
end
|
109
|
+
|
110
|
+
column :RES_VHNIUTGDCO, "Resource to which the rule applies",
|
111
|
+
:size => 14 do |d|
|
112
|
+
OneAclHelper::resource_mask d['STRING'].split(" ")[1]
|
113
|
+
end
|
114
|
+
|
115
|
+
column :RID, "Resource ID", :right, :size=>5 do |d|
|
116
|
+
d['STRING'].split(" ")[1].split("/")[1]
|
117
|
+
end
|
118
|
+
|
119
|
+
column :OPE_UMAC,
|
120
|
+
"Operation to which the rule applies", :size =>8 do |d|
|
121
|
+
OneAclHelper::right_mask d['STRING'].split(" ")[2]
|
122
|
+
end
|
123
|
+
|
124
|
+
default :ID, :USER, :RES_VHNIUTGDCO, :RID, :OPE_UMAC
|
125
|
+
end
|
126
|
+
|
127
|
+
table
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'one_helper'
|
18
|
+
|
19
|
+
class OneClusterHelper < OpenNebulaHelper::OneHelper
|
20
|
+
|
21
|
+
CLUSTER = {
|
22
|
+
:name => "cluster",
|
23
|
+
:short => "-c id|name",
|
24
|
+
:large => "--cluster id|name" ,
|
25
|
+
:description => "Selects the cluster",
|
26
|
+
:format => String,
|
27
|
+
:proc => lambda { |o, options|
|
28
|
+
OpenNebulaHelper.rname_to_id(o, "CLUSTER")
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
def self.rname
|
33
|
+
"CLUSTER"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.conf_file
|
37
|
+
"onecluster.yaml"
|
38
|
+
end
|
39
|
+
|
40
|
+
def element_size(ehash, ename)
|
41
|
+
ids = ehash[ename]["ID"]
|
42
|
+
|
43
|
+
if ids.nil?
|
44
|
+
return 0
|
45
|
+
elsif ids.class == String
|
46
|
+
return 1
|
47
|
+
else
|
48
|
+
return ids.size
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def format_pool(options)
|
54
|
+
config_file = self.class.table_conf
|
55
|
+
|
56
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
57
|
+
column :ID, "ONE identifier for the Cluster", :size=>5 do |d|
|
58
|
+
d["ID"]
|
59
|
+
end
|
60
|
+
|
61
|
+
column :NAME, "Name of the Cluster", :left, :size=>25 do |d|
|
62
|
+
d["NAME"]
|
63
|
+
end
|
64
|
+
|
65
|
+
column :HOSTS, "Number of Hosts", :size=>5 do |d|
|
66
|
+
@ext.element_size(d,"HOSTS")
|
67
|
+
end
|
68
|
+
|
69
|
+
column :VNETS, "Number of Networks", :size=>5 do |d|
|
70
|
+
@ext.element_size(d,"VNETS")
|
71
|
+
end
|
72
|
+
|
73
|
+
column :DATASTORES, "Number of Datastores", :size=>10 do |d|
|
74
|
+
@ext.element_size(d,"DATASTORES")
|
75
|
+
end
|
76
|
+
|
77
|
+
default :ID, :NAME, :HOSTS, :VNETS, :DATASTORES
|
78
|
+
end
|
79
|
+
|
80
|
+
table
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def factory(id=nil)
|
86
|
+
if id
|
87
|
+
OpenNebula::Cluster.new_with_id(id, @client)
|
88
|
+
else
|
89
|
+
xml=OpenNebula::Cluster.build_xml
|
90
|
+
OpenNebula::Cluster.new(xml, @client)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def factory_pool(user_flag=-2)
|
95
|
+
OpenNebula::ClusterPool.new(@client)
|
96
|
+
end
|
97
|
+
|
98
|
+
def format_resource(cluster)
|
99
|
+
str="%-15s: %-20s"
|
100
|
+
str_h1="%-80s"
|
101
|
+
|
102
|
+
CLIHelper.print_header(str_h1 % "CLUSTER #{cluster['ID']} INFORMATION")
|
103
|
+
puts str % ["ID", cluster.id.to_s]
|
104
|
+
puts str % ["NAME", cluster.name]
|
105
|
+
puts
|
106
|
+
|
107
|
+
CLIHelper.print_header(str_h1 % "CLUSTER TEMPLATE", false)
|
108
|
+
puts cluster.template_str
|
109
|
+
|
110
|
+
puts
|
111
|
+
|
112
|
+
CLIHelper.print_header("%-15s" % ["HOSTS"])
|
113
|
+
cluster.host_ids.each do |id|
|
114
|
+
puts "%-15s" % [id]
|
115
|
+
end
|
116
|
+
|
117
|
+
puts
|
118
|
+
CLIHelper.print_header("%-15s" % ["VNETS"])
|
119
|
+
cluster.vnet_ids.each do |id|
|
120
|
+
puts "%-15s" % [id]
|
121
|
+
end
|
122
|
+
|
123
|
+
puts
|
124
|
+
CLIHelper.print_header("%-15s" % ["DATASTORES"])
|
125
|
+
cluster.datastore_ids.each do |id|
|
126
|
+
puts "%-15s" % [id]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'one_helper'
|
18
|
+
|
19
|
+
class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
20
|
+
DATASTORE = {
|
21
|
+
:name => "datastore",
|
22
|
+
:short => "-d id|name",
|
23
|
+
:large => "--datastore id|name" ,
|
24
|
+
:description => "Selects the datastore",
|
25
|
+
:format => String,
|
26
|
+
:proc => lambda { |o, options|
|
27
|
+
OpenNebulaHelper.rname_to_id(o, "DATASTORE")
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
def self.rname
|
32
|
+
"DATASTORE"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.conf_file
|
36
|
+
"onedatastore.yaml"
|
37
|
+
end
|
38
|
+
|
39
|
+
def format_pool(options)
|
40
|
+
config_file = self.class.table_conf
|
41
|
+
|
42
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
43
|
+
column :ID, "ONE identifier for the Datastore", :size=>4 do |d|
|
44
|
+
d["ID"]
|
45
|
+
end
|
46
|
+
|
47
|
+
column :NAME, "Name of the Datastore", :left, :size=>25 do |d|
|
48
|
+
d["NAME"]
|
49
|
+
end
|
50
|
+
|
51
|
+
column :CLUSTER, "Name of the Cluster", :left, :size=>15 do |d|
|
52
|
+
OpenNebulaHelper.cluster_str(d["CLUSTER"])
|
53
|
+
end
|
54
|
+
|
55
|
+
column :IMAGES, "Number of Images", :size=>6 do |d|
|
56
|
+
if d["IMAGES"]["ID"].nil?
|
57
|
+
"0"
|
58
|
+
else
|
59
|
+
d["IMAGES"]["ID"].size
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
column :TYPE, "Datastore driver", :left, :size=>8 do |d|
|
64
|
+
d["DS_MAD"]
|
65
|
+
end
|
66
|
+
|
67
|
+
column :TM, "Transfer driver", :left, :size=>8 do |d|
|
68
|
+
d["TM_MAD"]
|
69
|
+
end
|
70
|
+
|
71
|
+
default :ID, :NAME, :CLUSTER, :IMAGES, :TYPE, :TM
|
72
|
+
end
|
73
|
+
|
74
|
+
table
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def factory(id=nil)
|
80
|
+
if id
|
81
|
+
OpenNebula::Datastore.new_with_id(id, @client)
|
82
|
+
else
|
83
|
+
xml=OpenNebula::Datastore.build_xml
|
84
|
+
OpenNebula::Datastore.new(xml, @client)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def factory_pool(user_flag=-2)
|
89
|
+
#TBD OpenNebula::UserPool.new(@client, user_flag)
|
90
|
+
OpenNebula::DatastorePool.new(@client)
|
91
|
+
end
|
92
|
+
|
93
|
+
def format_resource(datastore)
|
94
|
+
str="%-15s: %-20s"
|
95
|
+
str_h1="%-80s"
|
96
|
+
|
97
|
+
CLIHelper.print_header(str_h1 % "DATASTORE #{datastore['ID']} INFORMATION")
|
98
|
+
puts str % ["ID", datastore.id.to_s]
|
99
|
+
puts str % ["NAME", datastore.name]
|
100
|
+
puts str % ["USER", datastore['UNAME']]
|
101
|
+
puts str % ["GROUP", datastore['GNAME']]
|
102
|
+
puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(datastore['CLUSTER'])]
|
103
|
+
|
104
|
+
puts str % ["DS_MAD", datastore['DS_MAD']]
|
105
|
+
puts str % ["TM_MAD", datastore['TM_MAD']]
|
106
|
+
puts str % ["BASE PATH",datastore['BASE_PATH']]
|
107
|
+
puts
|
108
|
+
|
109
|
+
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
110
|
+
|
111
|
+
["OWNER", "GROUP", "OTHER"].each { |e|
|
112
|
+
mask = "---"
|
113
|
+
mask[0] = "u" if datastore["PERMISSIONS/#{e}_U"] == "1"
|
114
|
+
mask[1] = "m" if datastore["PERMISSIONS/#{e}_M"] == "1"
|
115
|
+
mask[2] = "a" if datastore["PERMISSIONS/#{e}_A"] == "1"
|
116
|
+
|
117
|
+
puts str % [e, mask]
|
118
|
+
}
|
119
|
+
puts
|
120
|
+
|
121
|
+
CLIHelper.print_header(str_h1 % "DATASTORE TEMPLATE", false)
|
122
|
+
puts datastore.template_str
|
123
|
+
|
124
|
+
puts
|
125
|
+
|
126
|
+
CLIHelper.print_header("%-15s" % "IMAGES")
|
127
|
+
datastore.img_ids.each do |id|
|
128
|
+
puts "%-15s" % [id]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|