opennebula-cli 5.12.5 → 5.13.85.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oneacct +9 -4
- data/bin/oneacl +8 -5
- data/bin/onecluster +10 -7
- data/bin/onedatastore +10 -7
- data/bin/oneflow +85 -13
- data/bin/oneflow-template +45 -8
- data/bin/onegroup +10 -7
- data/bin/onehook +10 -7
- data/bin/onehost +10 -7
- data/bin/oneimage +100 -9
- data/bin/onemarket +10 -7
- data/bin/onemarketapp +118 -11
- data/bin/onesecgroup +13 -7
- data/bin/oneshowback +23 -10
- data/bin/onetemplate +16 -9
- data/bin/oneuser +30 -7
- data/bin/onevcenter +7 -4
- data/bin/onevdc +10 -7
- data/bin/onevm +147 -12
- data/bin/onevmgroup +13 -7
- data/bin/onevnet +8 -5
- data/bin/onevntemplate +11 -7
- data/bin/onevrouter +10 -7
- data/bin/onezone +10 -7
- data/lib/cli_helper.rb +6 -8
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper.rb +414 -46
- data/lib/one_helper/oneacct_helper.rb +8 -17
- data/lib/one_helper/oneacl_helper.rb +1 -1
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +11 -1
- data/lib/one_helper/oneflow_helper.rb +20 -5
- data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehook_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +1 -5
- data/lib/one_helper/oneimage_helper.rb +7 -7
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +500 -96
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +16 -4
- data/lib/one_helper/oneuser_helper.rb +11 -3
- data/lib/one_helper/onevcenter_helper.rb +176 -146
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +4 -3
- data/lib/one_helper/onevmgroup_helper.rb +1 -1
- data/lib/one_helper/onevnet_helper.rb +1 -1
- data/lib/one_helper/onevntemplate_helper.rb +1 -1
- data/lib/one_helper/onevrouter_helper.rb +1 -20
- data/lib/one_helper/onezone_helper.rb +13 -6
- data/share/schemas/xsd/acct.xsd +179 -0
- data/share/schemas/xsd/acl_pool.xsd +22 -0
- data/share/schemas/xsd/api_info.xsd +43 -0
- data/share/schemas/xsd/cluster.xsd +34 -0
- data/share/schemas/xsd/cluster_pool.xsd +12 -0
- data/share/schemas/xsd/datastore.xsd +67 -0
- data/share/schemas/xsd/datastore_pool.xsd +12 -0
- data/share/schemas/xsd/document.xsd +42 -0
- data/share/schemas/xsd/document_pool.xsd +12 -0
- data/share/schemas/xsd/group.xsd +179 -0
- data/share/schemas/xsd/group_pool.xsd +194 -0
- data/share/schemas/xsd/hook.xsd +59 -0
- data/share/schemas/xsd/hook_message_api.xsd +14 -0
- data/share/schemas/xsd/hook_message_retry.xsd +12 -0
- data/share/schemas/xsd/hook_message_state.xsd +25 -0
- data/share/schemas/xsd/hook_pool.xsd +12 -0
- data/share/schemas/xsd/host.xsd +164 -0
- data/share/schemas/xsd/host_pool.xsd +12 -0
- data/share/schemas/xsd/image.xsd +123 -0
- data/share/schemas/xsd/image_pool.xsd +12 -0
- data/share/schemas/xsd/index.xsd +49 -0
- data/share/schemas/xsd/marketplace.xsd +44 -0
- data/share/schemas/xsd/marketplace_pool.xsd +12 -0
- data/share/schemas/xsd/marketplaceapp.xsd +56 -0
- data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
- data/share/schemas/xsd/raftstatus.xsd +18 -0
- data/share/schemas/xsd/security_group.xsd +74 -0
- data/share/schemas/xsd/security_group_pool.xsd +12 -0
- data/share/schemas/xsd/showback.xsd +29 -0
- data/share/schemas/xsd/user.xsd +186 -0
- data/share/schemas/xsd/user_pool.xsd +201 -0
- data/share/schemas/xsd/vdc.xsd +76 -0
- data/share/schemas/xsd/vdc_pool.xsd +12 -0
- data/share/schemas/xsd/vm.xsd +251 -0
- data/share/schemas/xsd/vm_group.xsd +59 -0
- data/share/schemas/xsd/vm_group_pool.xsd +12 -0
- data/share/schemas/xsd/vm_pool.xsd +114 -0
- data/share/schemas/xsd/vmtemplate.xsd +52 -0
- data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vnet.xsd +137 -0
- data/share/schemas/xsd/vnet_pool.xsd +85 -0
- data/share/schemas/xsd/vntemplate.xsd +50 -0
- data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vrouter.xsd +49 -0
- data/share/schemas/xsd/vrouter_pool.xsd +12 -0
- data/share/schemas/xsd/zone.xsd +40 -0
- data/share/schemas/xsd/zone_pool.xsd +36 -0
- metadata +79 -18
- data/lib/one_helper/oneprovision_helper.rb +0 -362
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
3
|
+
targetNamespace="http://opennebula.org/XMLSchema" xmlns="http://opennebula.org/XMLSchema">
|
4
|
+
<xs:element name="ZONE_POOL">
|
5
|
+
<xs:element name="ZONE">
|
6
|
+
<xs:complexType>
|
7
|
+
<xs:sequence>
|
8
|
+
<xs:element name="ID" type="xs:integer"/>
|
9
|
+
<xs:element name="NAME" type="xs:string"/>
|
10
|
+
<xs:element name="TEMPLATE">
|
11
|
+
<xs:complexType>
|
12
|
+
<xs:sequence>
|
13
|
+
<xs:element name="ENDPOINT" type="xs:string"/>
|
14
|
+
</xs:sequence>
|
15
|
+
</xs:complexType>
|
16
|
+
</xs:element>
|
17
|
+
<xs:element name="SERVER_POOL">
|
18
|
+
<xs:complexType>
|
19
|
+
<xs:sequence>
|
20
|
+
<xs:element name="SERVER" minOccurs="0" maxOccurs="unbounded">
|
21
|
+
<xs:complexType>
|
22
|
+
<xs:sequence>
|
23
|
+
<xs:element name="ENDPOINT" type="xs:string"/>
|
24
|
+
<xs:element name="ID" type="xs:integer"/>
|
25
|
+
<xs:element name="NAME" type="xs:string"/>
|
26
|
+
</xs:sequence>
|
27
|
+
</xs:complexType>
|
28
|
+
</xs:element>
|
29
|
+
</xs:sequence>
|
30
|
+
</xs:complexType>
|
31
|
+
</xs:element>
|
32
|
+
</xs:sequence>
|
33
|
+
</xs:complexType>
|
34
|
+
</xs:element>
|
35
|
+
</xs:element>
|
36
|
+
</xs:schema>
|
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.
|
4
|
+
version: 5.13.85.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenNebula
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opennebula
|
@@ -16,19 +16,32 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.13.85.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.
|
26
|
+
version: 5.13.85.pre
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Commands used to talk to OpenNebula
|
28
42
|
email: contact@opennebula.io
|
29
43
|
executables:
|
30
44
|
- oneacct
|
31
|
-
- onevcenter
|
32
45
|
- oneacl
|
33
46
|
- onecluster
|
34
47
|
- onedatastore
|
@@ -44,6 +57,7 @@ executables:
|
|
44
57
|
- oneshowback
|
45
58
|
- onetemplate
|
46
59
|
- oneuser
|
60
|
+
- onevcenter
|
47
61
|
- onevdc
|
48
62
|
- onevm
|
49
63
|
- onevmgroup
|
@@ -54,8 +68,55 @@ executables:
|
|
54
68
|
extensions: []
|
55
69
|
extra_rdoc_files: []
|
56
70
|
files:
|
71
|
+
- share/schemas/xsd/acct.xsd
|
72
|
+
- share/schemas/xsd/acl_pool.xsd
|
73
|
+
- share/schemas/xsd/api_info.xsd
|
74
|
+
- share/schemas/xsd/cluster.xsd
|
75
|
+
- share/schemas/xsd/cluster_pool.xsd
|
76
|
+
- share/schemas/xsd/datastore.xsd
|
77
|
+
- share/schemas/xsd/datastore_pool.xsd
|
78
|
+
- share/schemas/xsd/document.xsd
|
79
|
+
- share/schemas/xsd/document_pool.xsd
|
80
|
+
- share/schemas/xsd/group.xsd
|
81
|
+
- share/schemas/xsd/group_pool.xsd
|
82
|
+
- share/schemas/xsd/hook.xsd
|
83
|
+
- share/schemas/xsd/hook_message_api.xsd
|
84
|
+
- share/schemas/xsd/hook_message_retry.xsd
|
85
|
+
- share/schemas/xsd/hook_message_state.xsd
|
86
|
+
- share/schemas/xsd/hook_pool.xsd
|
87
|
+
- share/schemas/xsd/host.xsd
|
88
|
+
- share/schemas/xsd/host_pool.xsd
|
89
|
+
- share/schemas/xsd/image.xsd
|
90
|
+
- share/schemas/xsd/image_pool.xsd
|
91
|
+
- share/schemas/xsd/index.xsd
|
92
|
+
- share/schemas/xsd/marketplace.xsd
|
93
|
+
- share/schemas/xsd/marketplace_pool.xsd
|
94
|
+
- share/schemas/xsd/marketplaceapp.xsd
|
95
|
+
- share/schemas/xsd/marketplaceapp_pool.xsd
|
96
|
+
- share/schemas/xsd/opennebula_configuration.xsd
|
97
|
+
- share/schemas/xsd/raftstatus.xsd
|
98
|
+
- share/schemas/xsd/security_group.xsd
|
99
|
+
- share/schemas/xsd/security_group_pool.xsd
|
100
|
+
- share/schemas/xsd/showback.xsd
|
101
|
+
- share/schemas/xsd/user.xsd
|
102
|
+
- share/schemas/xsd/user_pool.xsd
|
103
|
+
- share/schemas/xsd/vdc.xsd
|
104
|
+
- share/schemas/xsd/vdc_pool.xsd
|
105
|
+
- share/schemas/xsd/vm.xsd
|
106
|
+
- share/schemas/xsd/vm_group.xsd
|
107
|
+
- share/schemas/xsd/vm_group_pool.xsd
|
108
|
+
- share/schemas/xsd/vm_pool.xsd
|
109
|
+
- share/schemas/xsd/vmtemplate.xsd
|
110
|
+
- share/schemas/xsd/vmtemplate_pool.xsd
|
111
|
+
- share/schemas/xsd/vnet.xsd
|
112
|
+
- share/schemas/xsd/vnet_pool.xsd
|
113
|
+
- share/schemas/xsd/vntemplate.xsd
|
114
|
+
- share/schemas/xsd/vntemplate_pool.xsd
|
115
|
+
- share/schemas/xsd/vrouter.xsd
|
116
|
+
- share/schemas/xsd/vrouter_pool.xsd
|
117
|
+
- share/schemas/xsd/zone.xsd
|
118
|
+
- share/schemas/xsd/zone_pool.xsd
|
57
119
|
- bin/oneacct
|
58
|
-
- bin/onevcenter
|
59
120
|
- bin/oneacl
|
60
121
|
- bin/onecluster
|
61
122
|
- bin/onedatastore
|
@@ -71,6 +132,7 @@ files:
|
|
71
132
|
- bin/oneshowback
|
72
133
|
- bin/onetemplate
|
73
134
|
- bin/oneuser
|
135
|
+
- bin/onevcenter
|
74
136
|
- bin/onevdc
|
75
137
|
- bin/onevm
|
76
138
|
- bin/onevmgroup
|
@@ -78,16 +140,24 @@ files:
|
|
78
140
|
- bin/onevntemplate
|
79
141
|
- bin/onevrouter
|
80
142
|
- bin/onezone
|
81
|
-
- lib/command_parser.rb
|
82
143
|
- lib/cli_helper.rb
|
144
|
+
- lib/command_parser.rb
|
83
145
|
- lib/one_helper.rb
|
146
|
+
- lib/one_helper/oneacct_helper.rb
|
84
147
|
- lib/one_helper/oneacl_helper.rb
|
85
148
|
- lib/one_helper/onecluster_helper.rb
|
149
|
+
- lib/one_helper/onedatastore_helper.rb
|
150
|
+
- lib/one_helper/oneflow_helper.rb
|
151
|
+
- lib/one_helper/oneflowtemplate_helper.rb
|
86
152
|
- lib/one_helper/onegroup_helper.rb
|
87
153
|
- lib/one_helper/onehook_helper.rb
|
154
|
+
- lib/one_helper/onehost_helper.rb
|
155
|
+
- lib/one_helper/oneimage_helper.rb
|
88
156
|
- lib/one_helper/onemarket_helper.rb
|
157
|
+
- lib/one_helper/onemarketapp_helper.rb
|
89
158
|
- lib/one_helper/onequota_helper.rb
|
90
159
|
- lib/one_helper/onesecgroup_helper.rb
|
160
|
+
- lib/one_helper/onetemplate_helper.rb
|
91
161
|
- lib/one_helper/oneuser_helper.rb
|
92
162
|
- lib/one_helper/onevcenter_helper.rb
|
93
163
|
- lib/one_helper/onevdc_helper.rb
|
@@ -95,15 +165,6 @@ files:
|
|
95
165
|
- lib/one_helper/onevmgroup_helper.rb
|
96
166
|
- lib/one_helper/onevnet_helper.rb
|
97
167
|
- lib/one_helper/onevntemplate_helper.rb
|
98
|
-
- lib/one_helper/oneacct_helper.rb
|
99
|
-
- lib/one_helper/onedatastore_helper.rb
|
100
|
-
- lib/one_helper/oneflow_helper.rb
|
101
|
-
- lib/one_helper/oneflowtemplate_helper.rb
|
102
|
-
- lib/one_helper/onehost_helper.rb
|
103
|
-
- lib/one_helper/oneimage_helper.rb
|
104
|
-
- lib/one_helper/onemarketapp_helper.rb
|
105
|
-
- lib/one_helper/oneprovision_helper.rb
|
106
|
-
- lib/one_helper/onetemplate_helper.rb
|
107
168
|
- lib/one_helper/onevrouter_helper.rb
|
108
169
|
- lib/one_helper/onezone_helper.rb
|
109
170
|
- NOTICE
|
@@ -123,9 +184,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
184
|
version: '0'
|
124
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
186
|
requirements:
|
126
|
-
- - '
|
187
|
+
- - '>'
|
127
188
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
189
|
+
version: 1.3.1
|
129
190
|
requirements: []
|
130
191
|
rubyforge_project:
|
131
192
|
rubygems_version: 2.0.14.1
|
@@ -1,362 +0,0 @@
|
|
1
|
-
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-2020, 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 'nokogiri'
|
18
|
-
require 'securerandom'
|
19
|
-
|
20
|
-
# OneProvision Helper
|
21
|
-
class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
22
|
-
|
23
|
-
RESOURCES = %w[
|
24
|
-
CLUSTERS
|
25
|
-
DATASTORES
|
26
|
-
HOSTS
|
27
|
-
NETWORKS
|
28
|
-
IMAGES
|
29
|
-
TEMPLATES
|
30
|
-
VNTEMPLATES
|
31
|
-
FLOWTEMPLATES
|
32
|
-
]
|
33
|
-
|
34
|
-
def self.rname
|
35
|
-
'PROVISION'
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.conf_file
|
39
|
-
'oneprovision.yaml'
|
40
|
-
end
|
41
|
-
|
42
|
-
def parse_options(options)
|
43
|
-
OneProvision::OneProvisionLogger.get_logger(options)
|
44
|
-
OneProvision::Mode.get_run_mode(options)
|
45
|
-
OneProvision::Options.get_run_options(options)
|
46
|
-
OneProvision::ObjectOptions.get_obj_options(options)
|
47
|
-
end
|
48
|
-
|
49
|
-
def format_pool
|
50
|
-
config_file = self.class.table_conf
|
51
|
-
|
52
|
-
CLIHelper::ShowTable.new(config_file, self) do
|
53
|
-
column :ID, 'Identifier for the Provision', :size => 36 do |p|
|
54
|
-
p['ID']
|
55
|
-
end
|
56
|
-
|
57
|
-
column :NAME, 'Name of the Provision', :left, :size => 25 do |p|
|
58
|
-
p['NAME']
|
59
|
-
end
|
60
|
-
|
61
|
-
column :CLUSTERS, 'Number of Clusters', :size => 8 do |p|
|
62
|
-
p['CLUSTERS']['ID'].size rescue 0
|
63
|
-
end
|
64
|
-
|
65
|
-
column :HOSTS, 'Number of Hosts', :size => 5 do |p|
|
66
|
-
p['HOSTS']['ID'].size rescue 0
|
67
|
-
end
|
68
|
-
|
69
|
-
column :NETWORKS, 'Number of Networks', :size => 5 do |p|
|
70
|
-
p['NETWORKS']['ID'].size rescue 0
|
71
|
-
end
|
72
|
-
|
73
|
-
column :DATASTORES, 'Number of Datastores', :size => 10 do |p|
|
74
|
-
p['DATASTORES']['ID'].size rescue 0
|
75
|
-
end
|
76
|
-
|
77
|
-
column :STAT, 'Status of the Provision', :left, :size => 15 do |p|
|
78
|
-
p['STATUS'] rescue '-'
|
79
|
-
end
|
80
|
-
|
81
|
-
default :ID, :NAME, :CLUSTERS, :HOSTS, :NETWORKS, :DATASTORES, :STAT
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
#######################################################################
|
86
|
-
# Helper provision functions
|
87
|
-
#######################################################################
|
88
|
-
|
89
|
-
def create(config, cleanup, timeout, virtual)
|
90
|
-
msg = 'OpenNebula is not running'
|
91
|
-
|
92
|
-
OneProvision::Utils.fail(msg) if OneProvision::Utils.one_running?
|
93
|
-
|
94
|
-
provision = OneProvision::Provision.new(SecureRandom.uuid)
|
95
|
-
|
96
|
-
provision.create(config, cleanup, timeout, virtual)
|
97
|
-
end
|
98
|
-
|
99
|
-
def configure(provision_id, force)
|
100
|
-
provision = OneProvision::Provision.new(provision_id)
|
101
|
-
|
102
|
-
provision.refresh
|
103
|
-
|
104
|
-
provision.configure(force)
|
105
|
-
end
|
106
|
-
|
107
|
-
def delete(provision_id, cleanup, timeout)
|
108
|
-
provision = OneProvision::Provision.new(provision_id)
|
109
|
-
|
110
|
-
provision.refresh
|
111
|
-
|
112
|
-
provision.delete(cleanup, timeout)
|
113
|
-
end
|
114
|
-
|
115
|
-
#######################################################################
|
116
|
-
# Helper host functions
|
117
|
-
#######################################################################
|
118
|
-
|
119
|
-
def host_operation(id, operation, options, args)
|
120
|
-
host = OneProvision::Host.new
|
121
|
-
host.info(id)
|
122
|
-
|
123
|
-
case operation[:operation]
|
124
|
-
when 'resume'
|
125
|
-
host.resume
|
126
|
-
when 'poweroff'
|
127
|
-
host.poweroff
|
128
|
-
when 'reboot'
|
129
|
-
host.reboot((options.key? :hard))
|
130
|
-
when 'delete'
|
131
|
-
host.delete
|
132
|
-
when 'configure'
|
133
|
-
host.configure((options.key? :force))
|
134
|
-
when 'ssh'
|
135
|
-
host.ssh(args)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
#######################################################################
|
140
|
-
# Helper datastore functions
|
141
|
-
#######################################################################
|
142
|
-
|
143
|
-
def datastore_operation(datastore, operation)
|
144
|
-
case operation[:operation]
|
145
|
-
when 'delete'
|
146
|
-
msg = "Deleting datastore #{datastore['ID']}"
|
147
|
-
|
148
|
-
OneProvision::OneProvisionLogger.info(msg)
|
149
|
-
|
150
|
-
datastore.delete
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
#######################################################################
|
155
|
-
# Helper network functions
|
156
|
-
#######################################################################
|
157
|
-
|
158
|
-
def network_operation(network, operation)
|
159
|
-
case operation[:operation]
|
160
|
-
when 'delete'
|
161
|
-
msg = "Deleting network #{network['ID']}"
|
162
|
-
|
163
|
-
OneProvision::OneProvisionLogger.info(msg)
|
164
|
-
|
165
|
-
network.delete
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
#######################################################################
|
170
|
-
# Helper resource functions
|
171
|
-
#######################################################################
|
172
|
-
|
173
|
-
def resources_operation(args, operation, options, type)
|
174
|
-
parse_options(options)
|
175
|
-
|
176
|
-
helper = nil
|
177
|
-
|
178
|
-
case type
|
179
|
-
when 'HOST' then helper = OneHostHelper.new
|
180
|
-
when 'DATASTORE' then helper = OneDatastoreHelper.new
|
181
|
-
when 'NETWORK' then helper = OneVNetHelper.new
|
182
|
-
end
|
183
|
-
|
184
|
-
objects = names_to_ids(args[0], type)
|
185
|
-
|
186
|
-
helper.set_client(options)
|
187
|
-
helper.perform_actions(objects,
|
188
|
-
options,
|
189
|
-
operation[:message]) do |obj|
|
190
|
-
case type
|
191
|
-
when 'HOST'
|
192
|
-
host_operation(obj['ID'], operation, options, args[1])
|
193
|
-
when 'DATASTORE'
|
194
|
-
datastore_operation(obj, operation)
|
195
|
-
when 'NETWORK'
|
196
|
-
network_operation(obj, operation)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
#######################################################################
|
202
|
-
# Utils functions
|
203
|
-
#######################################################################
|
204
|
-
|
205
|
-
def provision_ids
|
206
|
-
clusters = OneProvision::Cluster.new.pool
|
207
|
-
rc = clusters.info
|
208
|
-
|
209
|
-
if OpenNebula.is_error?(rc)
|
210
|
-
OneProvision::Utils.fail(rc.message)
|
211
|
-
end
|
212
|
-
|
213
|
-
clusters = clusters.reject do |x|
|
214
|
-
x['TEMPLATE/PROVISION/PROVISION_ID'].nil?
|
215
|
-
end
|
216
|
-
|
217
|
-
clusters = clusters.uniq do |x|
|
218
|
-
x['TEMPLATE/PROVISION/PROVISION_ID']
|
219
|
-
end
|
220
|
-
|
221
|
-
ids = []
|
222
|
-
|
223
|
-
clusters.each {|c| ids << c['TEMPLATE/PROVISION/PROVISION_ID'] }
|
224
|
-
|
225
|
-
ids
|
226
|
-
end
|
227
|
-
|
228
|
-
def names_to_ids(objects, type)
|
229
|
-
[objects].flatten.map do |obj|
|
230
|
-
OpenNebulaHelper.rname_to_id(obj.to_s, type)[1]
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
def get_list(provision_list)
|
235
|
-
ret = []
|
236
|
-
ids = provision_ids
|
237
|
-
|
238
|
-
ids.each do |i|
|
239
|
-
provision = OneProvision::Provision.new(i)
|
240
|
-
provision.refresh
|
241
|
-
|
242
|
-
element = {}
|
243
|
-
|
244
|
-
element['ID'] = i if provision_list
|
245
|
-
element['ID'] = provision.clusters[0]['ID'] unless provision_list
|
246
|
-
|
247
|
-
element['NAME'] = provision.name
|
248
|
-
element['STATUS'] = provision.status
|
249
|
-
|
250
|
-
RESOURCES.each do |c|
|
251
|
-
obj = OneProvision::Resource.object(c)
|
252
|
-
obj_ids = obj.get(i).map do |o|
|
253
|
-
o['ID']
|
254
|
-
end
|
255
|
-
|
256
|
-
next if obj_ids.empty?
|
257
|
-
|
258
|
-
element[c.to_s.upcase] = { 'ID' => [] }
|
259
|
-
element[c.to_s.upcase]['ID'] = obj_ids
|
260
|
-
end
|
261
|
-
|
262
|
-
ret << element
|
263
|
-
end
|
264
|
-
|
265
|
-
ret
|
266
|
-
end
|
267
|
-
|
268
|
-
def list(options)
|
269
|
-
list = get_list(true)
|
270
|
-
|
271
|
-
if options.key? :xml
|
272
|
-
list.map {|e| to_xml(e) }
|
273
|
-
else
|
274
|
-
format_pool.show(list, options)
|
275
|
-
end
|
276
|
-
|
277
|
-
0
|
278
|
-
end
|
279
|
-
|
280
|
-
def show(provision_id, xml)
|
281
|
-
provision = OneProvision::Provision.new(provision_id)
|
282
|
-
|
283
|
-
provision.refresh
|
284
|
-
|
285
|
-
OneProvision::Utils.fail('Provision not found.') unless provision.exists
|
286
|
-
|
287
|
-
ret = {}
|
288
|
-
ret['ID'] = provision_id
|
289
|
-
ret['NAME'] = provision.name
|
290
|
-
ret['STATUS'] = provision.status
|
291
|
-
|
292
|
-
RESOURCES.each do |r|
|
293
|
-
obj = OneProvision::Resource.object(r)
|
294
|
-
|
295
|
-
next unless obj
|
296
|
-
|
297
|
-
obj_ids = obj.get(provision_id).map {|o| o['ID'] }
|
298
|
-
|
299
|
-
next if obj_ids.empty?
|
300
|
-
|
301
|
-
ret[r] = obj_ids
|
302
|
-
end
|
303
|
-
|
304
|
-
if xml
|
305
|
-
to_xml(ret)
|
306
|
-
else
|
307
|
-
format_resource(ret)
|
308
|
-
end
|
309
|
-
|
310
|
-
0
|
311
|
-
end
|
312
|
-
|
313
|
-
def format_resource(provision)
|
314
|
-
str_h1 = '%-80s'
|
315
|
-
status = provision['STATUS']
|
316
|
-
id = provision['ID']
|
317
|
-
|
318
|
-
CLIHelper.print_header(str_h1 % "PROVISION #{id} INFORMATION")
|
319
|
-
puts format('ID : %<s>s', :s => id)
|
320
|
-
puts format('NAME : %<s>s', :s => provision['NAME'])
|
321
|
-
puts format('STATUS : %<s>s', :s => CLIHelper.color_state(status))
|
322
|
-
|
323
|
-
RESOURCES.each do |r|
|
324
|
-
next unless provision[r]
|
325
|
-
|
326
|
-
puts
|
327
|
-
CLIHelper.print_header(format('%<s>s', :s => r.upcase))
|
328
|
-
provision[r].each do |i|
|
329
|
-
puts format('%<s>s', :s => i)
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
private
|
335
|
-
|
336
|
-
def to_xml(provision)
|
337
|
-
xml = "<PROVISION>
|
338
|
-
<ID>#{provision['ID']}</ID>
|
339
|
-
<NAME>#{provision['NAME']}</NAME>
|
340
|
-
<STATUS>#{provision['STATUS']}</STATUS>
|
341
|
-
#{
|
342
|
-
RESOURCES.map do |r|
|
343
|
-
next unless provision[r]
|
344
|
-
|
345
|
-
provision[r] = provision[r]['ID'] if provision[r].is_a? Hash
|
346
|
-
|
347
|
-
ids = provision[r].map do |id|
|
348
|
-
"<ID>#{id}</ID>"
|
349
|
-
end.join("\n")
|
350
|
-
|
351
|
-
"<#{r.upcase}>
|
352
|
-
#{ids}
|
353
|
-
</#{r.upcase}"
|
354
|
-
end.join("\n")
|
355
|
-
}
|
356
|
-
</PROVISION>"
|
357
|
-
|
358
|
-
doc = Nokogiri.XML(xml) {|config| config.default_xml.noblanks }
|
359
|
-
puts doc.root.to_xml(:indent => 2)
|
360
|
-
end
|
361
|
-
|
362
|
-
end
|