opennebula-cli 5.7.85.pre → 5.7.90.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 608bcd9d04a44a0a66aafc66cfbc5a301a68c183
4
- data.tar.gz: 55407832344ac01ed0d331ce5c47e61667c9d260
3
+ metadata.gz: 140ee7b9d1fe1f1f0398855476b9725fa3504d83
4
+ data.tar.gz: f8e03bfed912972e084abcc72d133474b8aedc52
5
5
  SHA512:
6
- metadata.gz: e27b7f253050290ab01cb292c9d88e5aa1bc1c611bb0637feea8254af643df71c465d57b620bc9ba6828dc334293a4604fb753952497a628d773c94bb71e87ec
7
- data.tar.gz: 47be3aceb3b467b79aaa4ed6e89a36e94856597965b7ed08a15f88939515559b7c570f5d4c1b16a69b3ec2b7bcc0d0869450f7966061b2eef084ca7df89d4652
6
+ metadata.gz: b838c7dbba2a7edc7277630fa870ab72fc9fa140b8e6378cb62afe6c4a1984f95f0679d7560c961216e24b274f6ebb6323c84e79bc5b7862b093055a7467a36e
7
+ data.tar.gz: c81ef184f9e28f34f1c1e86dfb621edcbfa41d6e2d3044759cdbac5f5c08b38feacd91a202a58a4b453c111da966b10868a8422ef19a3aae0f33c22645b8a251
@@ -88,8 +88,8 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
88
88
  end
89
89
 
90
90
  column :TYPE, "Datastore type", :left, :size=>4 do |d|
91
- type = Datastore::DATASTORE_TYPES[d["TYPE"].to_i]
92
- Datastore::SHORT_DATASTORE_TYPES[type]
91
+ type = OpenNebula::Datastore::DATASTORE_TYPES[d["TYPE"].to_i]
92
+ OpenNebula::Datastore::SHORT_DATASTORE_TYPES[type]
93
93
  end
94
94
 
95
95
  column :DS, "Datastore driver", :left, :size=>7 do |d|
@@ -101,8 +101,8 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
101
101
  end
102
102
 
103
103
  column :STAT, "State of the Datastore", :left, :size=>3 do |d|
104
- state = Datastore::DATASTORE_STATES[d["STATE"].to_i]
105
- Datastore::SHORT_DATASTORE_STATES[state]
104
+ state = OpenNebula::Datastore::DATASTORE_STATES[d["STATE"].to_i]
105
+ OpenNebula::Datastore::SHORT_DATASTORE_STATES[state]
106
106
  end
107
107
 
108
108
  default :ID, :USER, :GROUP, :NAME, :SIZE, :AVAIL, :CLUSTERS, :IMAGES,
@@ -24,7 +24,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
24
24
  TEMPLATE_XPATH = '//HOST/TEMPLATE'
25
25
  HYBRID = {
26
26
  :ec2 => {
27
- :help => <<-EOT.unindent,
27
+ :help => <<-EOT.unindent
28
28
  #-----------------------------------------------------------------------
29
29
  # Supported EC2 AUTH ATTRIBUTTES:
30
30
  #
@@ -46,7 +46,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
46
46
  EOT
47
47
  },
48
48
  :az => {
49
- :help => <<-EOT.unindent,
49
+ :help => <<-EOT.unindent
50
50
  #-----------------------------------------------------------------------
51
51
  # Supported AZURE AUTH ATTRIBUTTES:
52
52
  #
@@ -212,6 +212,10 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
212
212
  end
213
213
  end
214
214
 
215
+ column :PROVIDER, 'Host provider', :left, :size => 6 do |d|
216
+ d['TEMPLATE']['PM_MAD'].nil? ? '-' : d['TEMPLATE']['PM_MAD']
217
+ end
218
+
215
219
  column :STAT, 'Host status', :left, :size => 6 do |d|
216
220
  OneHostHelper.state_to_str(d['STATE'])
217
221
  end
@@ -0,0 +1,258 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
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 'securerandom'
18
+
19
+ # OneProvision Helper
20
+ class OneProvisionHelper < OpenNebulaHelper::OneHelper
21
+
22
+ def self.rname
23
+ 'PROVISION'
24
+ end
25
+
26
+ def self.conf_file
27
+ 'oneprovision.yaml'
28
+ end
29
+
30
+ def parse_options(options)
31
+ OneProvision::OneProvisionLogger.get_logger(options)
32
+ OneProvision::Mode.get_run_mode(options)
33
+ OneProvision::Options.get_run_options(options)
34
+ end
35
+
36
+ def format_pool
37
+ config_file = self.class.table_conf
38
+
39
+ table = CLIHelper::ShowTable.new(config_file, self) do
40
+ column :ID, 'Identifier for the Provision', :size => 36 do |p|
41
+ p['ID']
42
+ end
43
+
44
+ column :NAME, 'Name of the Provision', :left, :size => 25 do |p|
45
+ p['NAME']
46
+ end
47
+
48
+ column :CLUSTERS, 'Number of Clusters', :size => 8 do |p|
49
+ p['CLUSTERS']['ID'].size
50
+ end
51
+
52
+ column :HOSTS, 'Number of Hosts', :size => 5 do |p|
53
+ p['HOSTS']['ID'].size
54
+ end
55
+
56
+ column :VNETS, 'Number of Networks', :size => 5 do |p|
57
+ p['VNETS']['ID'].size
58
+ end
59
+
60
+ column :DATASTORES, 'Number of Datastores', :size => 10 do |p|
61
+ p['DATASTORES']['ID'].size
62
+ end
63
+
64
+ column :STAT, 'Status of the Provision', :left, :size => 15 do |p|
65
+ p['STATUS']
66
+ end
67
+
68
+ default :ID, :NAME, :CLUSTERS, :HOSTS, :VNETS, :DATASTORES, :STAT
69
+ end
70
+
71
+ table
72
+ end
73
+
74
+ #######################################################################
75
+ # Helper provision functions
76
+ #######################################################################
77
+
78
+ def create(config)
79
+ msg = 'OpenNebula is not running'
80
+
81
+ OneProvision::Utils.fail(msg) if OneProvision::Utils.one_running?
82
+
83
+ provision = OneProvision::Provision.new(SecureRandom.uuid)
84
+
85
+ provision.create(config)
86
+ end
87
+
88
+ def configure(provision_id, options)
89
+ provision = OneProvision::Provision.new(provision_id)
90
+
91
+ provision.refresh
92
+
93
+ provision.configure((options.key? :force))
94
+ end
95
+
96
+ def delete(provision_id)
97
+ provision = OneProvision::Provision.new(provision_id)
98
+
99
+ provision.refresh
100
+
101
+ provision.delete
102
+ end
103
+
104
+ #######################################################################
105
+ # Helper host functions
106
+ #######################################################################
107
+
108
+ def hosts_operation(hosts, operation, options)
109
+ parse_options(options)
110
+
111
+ host_helper = OneHostHelper.new
112
+ host_helper.set_client(options)
113
+ host_helper.perform_actions(hosts,
114
+ options,
115
+ operation[:message]) do |host|
116
+ host = OneProvision::Host.new(host['ID'])
117
+
118
+ case operation[:operation]
119
+ when 'resume'
120
+ host.resume
121
+ when 'poweroff'
122
+ host.poweroff
123
+ when 'reboot'
124
+ host.reboot((options.key? :hard))
125
+ when 'delete'
126
+ host.delete
127
+ when 'configure'
128
+ host.configure((options.key? :force))
129
+ end
130
+ end
131
+ end
132
+
133
+ #######################################################################
134
+ # Utils functions
135
+ #######################################################################
136
+
137
+ def provision_ids
138
+ clusters = OneProvision::Cluster.new.pool
139
+ rc = clusters.info
140
+
141
+ if OpenNebula.is_error?(rc)
142
+ OneProvision::Utils.fail(rc.message)
143
+ end
144
+
145
+ clusters = clusters.reject do |x|
146
+ x['TEMPLATE/PROVISION/PROVISION_ID'].nil?
147
+ end
148
+
149
+ clusters = clusters.uniq do |x|
150
+ x['TEMPLATE/PROVISION/PROVISION_ID']
151
+ end
152
+
153
+ ids = []
154
+
155
+ clusters.each {|c| ids << c['TEMPLATE/PROVISION/PROVISION_ID'] }
156
+
157
+ ids
158
+ end
159
+
160
+ def get_list(columns, provision_list)
161
+ ret = []
162
+ ids = provision_ids
163
+
164
+ ids.each do |i|
165
+ provision = OneProvision::Provision.new(i)
166
+ provision.refresh
167
+
168
+ element = {}
169
+
170
+ element['ID'] = i if provision_list
171
+ element['ID'] = provision.clusters[0]['ID'] unless provision_list
172
+
173
+ element['NAME'] = provision.name
174
+ element['STATUS'] = provision.status
175
+
176
+ columns.each do |c|
177
+ element[c.to_s.upcase] = { 'ID' => [] }
178
+
179
+ provision.instance_variable_get("@#{c}").each do |v|
180
+ element[c.to_s.upcase]['ID'] << v['ID']
181
+ end
182
+ end
183
+
184
+ ret << element
185
+ end
186
+
187
+ ret
188
+ end
189
+
190
+ def list(options)
191
+ columns = %w[clusters hosts vnets datastores]
192
+
193
+ format_pool.show(get_list(columns, true), options)
194
+
195
+ 0
196
+ end
197
+
198
+ def show(provision_id)
199
+ provision = OneProvision::Provision.new(provision_id)
200
+
201
+ provision.refresh
202
+
203
+ OneProvision::Utils.fail('Provision not found.') unless provision.exists
204
+
205
+ ret = {}
206
+ ret['id'] = provision_id
207
+ ret['name'] = provision.name
208
+ ret['status'] = provision.status
209
+
210
+ %w[clusters datastores hosts vnets].each do |r|
211
+ ret["@#{r}_ids"] = []
212
+
213
+ provision.instance_variable_get("@#{r}").each do |x|
214
+ ret["@#{r}_ids"] << (x['ID'])
215
+ end
216
+ end
217
+
218
+ format_resource(ret)
219
+
220
+ 0
221
+ end
222
+
223
+ def format_resource(provision)
224
+ str_h1 = '%-80s'
225
+ status = provision['status']
226
+ id = provision['id']
227
+
228
+ CLIHelper.print_header(str_h1 % "PROVISION #{id} INFORMATION")
229
+ puts format('ID : %<s>s', :s => id)
230
+ puts format('NAME : %<s>s', :s => provision['name'])
231
+ puts format('STATUS : %<s>s', :s => CLIHelper.color_state(status))
232
+
233
+ puts
234
+ CLIHelper.print_header(format('%<s>s', :s => 'CLUSTERS'))
235
+ provision['@clusters_ids'].each do |i|
236
+ puts format('%<s>s', :s => i)
237
+ end
238
+
239
+ puts
240
+ CLIHelper.print_header(format('%<s>s', :s => 'HOSTS'))
241
+ provision['@hosts_ids'].each do |i|
242
+ puts format('%<s>s', :s => i)
243
+ end
244
+
245
+ puts
246
+ CLIHelper.print_header(format('%<s>s', :s => 'VNETS'))
247
+ provision['@vnets_ids'].each do |i|
248
+ puts format('%<s>s', :s => i)
249
+ end
250
+
251
+ puts
252
+ CLIHelper.print_header(format('%<s>s', :s => 'DATASTORES'))
253
+ provision['@datastores_ids'].each do |i|
254
+ puts format('%<s>s', :s => i)
255
+ end
256
+ end
257
+
258
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.7.85.pre
4
+ version: 5.7.90.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opennebula
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.7.85.pre
19
+ version: 5.7.90.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.7.85.pre
26
+ version: 5.7.90.pre
27
27
  description: Commands used to talk to OpenNebula
28
28
  email: contact@opennebula.org
29
29
  executables:
@@ -88,6 +88,7 @@ files:
88
88
  - lib/one_helper/oneimage_helper.rb
89
89
  - lib/one_helper/onemarket_helper.rb
90
90
  - lib/one_helper/onemarketapp_helper.rb
91
+ - lib/one_helper/oneprovision_helper.rb
91
92
  - lib/one_helper/onequota_helper.rb
92
93
  - lib/one_helper/onesecgroup_helper.rb
93
94
  - lib/one_helper/onetemplate_helper.rb