opennebula 5.12.13 → 5.13.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +1 -1
- data/lib/DriverExecHelper.rb +44 -28
- data/lib/OpenNebulaDriver.rb +8 -4
- data/lib/VirtualMachineDriver.rb +9 -2
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/datacenter.rb +1258 -0
- data/lib/datastore.rb +1025 -0
- data/lib/distributed_firewall.rb +280 -0
- data/lib/file_helper.rb +370 -0
- data/lib/host.rb +1517 -0
- data/lib/logical_port.rb +50 -0
- data/lib/logical_switch.rb +77 -0
- data/lib/memoize.rb +74 -0
- data/lib/models/role.rb +39 -8
- data/lib/models/service.rb +92 -31
- data/lib/models.rb +5 -5
- data/lib/network.rb +635 -0
- data/lib/nsx_client.rb +144 -0
- data/lib/nsx_component.rb +28 -0
- data/lib/nsx_constants.rb +149 -0
- data/lib/nsx_driver.rb +78 -0
- data/lib/nsx_error.rb +77 -0
- data/lib/nsx_rule.rb +193 -0
- data/lib/nsxt_client.rb +176 -0
- data/lib/nsxt_dfw.rb +196 -0
- data/lib/nsxt_logical_port.rb +94 -0
- data/lib/nsxt_rule.rb +188 -0
- data/lib/nsxt_tz.rb +38 -0
- data/lib/nsxv_client.rb +176 -0
- data/lib/nsxv_dfw.rb +202 -0
- data/lib/nsxv_logical_port.rb +107 -0
- data/lib/nsxv_rule.rb +172 -0
- data/lib/nsxv_tz.rb +41 -0
- data/lib/opaque_network.rb +134 -0
- data/lib/opennebula/acl.rb +1 -1
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +1 -1
- data/lib/opennebula/cluster.rb +1 -1
- data/lib/opennebula/cluster_pool.rb +1 -1
- data/lib/opennebula/datastore.rb +1 -1
- data/lib/opennebula/datastore_pool.rb +1 -1
- data/lib/opennebula/document.rb +8 -29
- data/lib/opennebula/document_json.rb +42 -12
- data/lib/opennebula/document_pool.rb +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +4 -1
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/{models → opennebula/flow}/service_pool.rb +26 -2
- data/lib/{models → opennebula/flow}/service_template.rb +86 -17
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/{models → opennebula/flow}/service_template_pool.rb +1 -1
- data/lib/opennebula/flow/validator.rb +499 -0
- data/lib/opennebula/flow.rb +23 -0
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/hook.rb +5 -12
- data/lib/opennebula/hook_log.rb +1 -1
- data/lib/opennebula/hook_pool.rb +1 -1
- data/lib/opennebula/host.rb +1 -1
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +17 -14
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +163 -0
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +9 -119
- data/lib/opennebula/marketplaceapp_ext.rb +522 -0
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +4 -3
- data/lib/opennebula/pool.rb +4 -3
- data/lib/opennebula/pool_element.rb +1 -1
- data/lib/opennebula/security_group.rb +1 -1
- data/lib/opennebula/security_group_pool.rb +1 -1
- data/lib/opennebula/server_cipher_auth.rb +1 -1
- data/lib/opennebula/server_x509_auth.rb +1 -1
- data/lib/opennebula/ssh_auth.rb +1 -1
- data/lib/opennebula/system.rb +1 -1
- data/lib/opennebula/template.rb +4 -13
- data/lib/opennebula/template_ext.rb +325 -0
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +26 -2
- data/lib/opennebula/user_pool.rb +1 -1
- data/lib/opennebula/utils.rb +1 -1
- data/lib/opennebula/vdc.rb +1 -1
- data/lib/opennebula/vdc_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +25 -207
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +1 -5
- data/lib/opennebula/virtual_network.rb +4 -10
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +4 -12
- data/lib/opennebula/virtual_router_pool.rb +1 -1
- data/lib/opennebula/vm_group.rb +4 -11
- data/lib/opennebula/vm_group_pool.rb +1 -1
- data/lib/opennebula/vntemplate.rb +4 -13
- data/lib/opennebula/vntemplate_pool.rb +1 -1
- data/lib/opennebula/wait_ext.rb +222 -0
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +1 -1
- data/lib/opennebula/xml_pool.rb +1 -1
- data/lib/opennebula/xml_utils.rb +1 -1
- data/lib/opennebula/zone.rb +1 -1
- data/lib/opennebula/zone_pool.rb +1 -1
- data/lib/opennebula.rb +5 -2
- data/lib/rest_client.rb +201 -0
- data/lib/scripts_common.rb +180 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +9 -22
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +312 -0
- data/lib/virtual_machine.rb +3477 -0
- data/lib/virtual_wire.rb +158 -0
- data/lib/vm_device.rb +80 -0
- data/lib/vm_disk.rb +202 -0
- data/lib/vm_folder.rb +69 -0
- data/lib/vm_helper.rb +30 -0
- data/lib/vm_monitor.rb +303 -0
- data/lib/vm_nic.rb +70 -0
- data/lib/vm_template.rb +1961 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +101 -35
data/lib/logical_port.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2021, 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
|
+
module NSXDriver
|
17
|
+
|
18
|
+
# Class Logical Switch
|
19
|
+
class LogicalPort < NSXComponent
|
20
|
+
|
21
|
+
# ATTRIBUTES
|
22
|
+
|
23
|
+
def self.new_child(nsx_client, id = nil)
|
24
|
+
case nsx_client.nsx_type.upcase
|
25
|
+
when NSXConstants::NSXT
|
26
|
+
NSXTLogicalPort.new(nsx_client, id)
|
27
|
+
when NSXConstants::NSXV
|
28
|
+
NSXVLogicalPort.new(nsx_client, id)
|
29
|
+
else
|
30
|
+
error_msg = "Unknown NSX type: #{type}"
|
31
|
+
error = NSXError::UnknownObject.new(error_msg)
|
32
|
+
raise error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Check if logical port exists
|
37
|
+
def lp?; end
|
38
|
+
|
39
|
+
# Get logical port id
|
40
|
+
def lp_id; end
|
41
|
+
|
42
|
+
# Get logical port display name
|
43
|
+
def lp_name; end
|
44
|
+
|
45
|
+
# Get resource type
|
46
|
+
def lp_type; end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2021, 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
|
+
module NSXDriver
|
17
|
+
|
18
|
+
# Class Logical Switch
|
19
|
+
class LogicalSwitch < NSXComponent
|
20
|
+
|
21
|
+
# ATTRIBUTES
|
22
|
+
attr_reader :ls_id
|
23
|
+
attr_reader :tz_id
|
24
|
+
attr_reader :replication_mode
|
25
|
+
attr_reader :display_name
|
26
|
+
attr_reader :description
|
27
|
+
|
28
|
+
def ls?; end
|
29
|
+
|
30
|
+
# Get logical switch's name
|
31
|
+
def ls_name; end
|
32
|
+
|
33
|
+
# Get logical switch's vni
|
34
|
+
def ls_vni; end
|
35
|
+
|
36
|
+
# Get the Transport Zone of the logical switch
|
37
|
+
def ls_tz; end
|
38
|
+
|
39
|
+
# Create a new logical switch
|
40
|
+
def new_logical_switch(ls_data); end
|
41
|
+
|
42
|
+
# Delete a logical switch
|
43
|
+
def delete_logical_switch; end
|
44
|
+
|
45
|
+
# Update a logical switch
|
46
|
+
def update_logical_switch; end
|
47
|
+
|
48
|
+
# Return nsx nics of type NSX-V and NSX-T
|
49
|
+
# If only_new_attached = true --> Only returns new attached nsx nics
|
50
|
+
def self.nsx_nics(template_xml, only_new_attached = true)
|
51
|
+
if only_new_attached == true
|
52
|
+
nics = template_xml.xpath('//TEMPLATE/NIC[ATTACH="YES"]')
|
53
|
+
else
|
54
|
+
nics = template_xml.xpath('//TEMPLATE/NIC')
|
55
|
+
end
|
56
|
+
nics_array = []
|
57
|
+
nics.each do |nic|
|
58
|
+
network_id = nic.xpath('NETWORK_ID').text
|
59
|
+
# Check Networks exists
|
60
|
+
one_vnet = VCenterDriver::VIHelper
|
61
|
+
.one_item(OpenNebula::VirtualNetwork, network_id)
|
62
|
+
rc = one_vnet.info
|
63
|
+
if OpenNebula.is_error?(rc)
|
64
|
+
err_msg = rc.message
|
65
|
+
raise err_msg
|
66
|
+
end
|
67
|
+
pg_type = one_vnet['TEMPLATE/VCENTER_PORTGROUP_TYPE']
|
68
|
+
nics_array << nic if [NSXConstants::NSXV_LS_TYPE,
|
69
|
+
NSXConstants::NSXT_LS_TYPE]
|
70
|
+
.include?(pg_type)
|
71
|
+
end
|
72
|
+
nics_array
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/lib/memoize.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2021, 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
|
+
##############################################################################
|
18
|
+
# Module Memoize
|
19
|
+
##############################################################################
|
20
|
+
module Memoize
|
21
|
+
|
22
|
+
def [](property)
|
23
|
+
@memoize = {} unless defined?(@memoize)
|
24
|
+
|
25
|
+
if (value = @memoize[property])
|
26
|
+
return value
|
27
|
+
end
|
28
|
+
|
29
|
+
current_item = @item
|
30
|
+
|
31
|
+
property_path = ''
|
32
|
+
|
33
|
+
property.split('.').each do |elem|
|
34
|
+
if property_path.empty?
|
35
|
+
property_path << elem
|
36
|
+
else
|
37
|
+
property_path << '.' << elem
|
38
|
+
end
|
39
|
+
|
40
|
+
if (val = @memoize[property_path])
|
41
|
+
current_item = val
|
42
|
+
else
|
43
|
+
begin
|
44
|
+
current_item = current_item.send(elem)
|
45
|
+
rescue StandardError
|
46
|
+
current_item = nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
break if current_item.nil?
|
51
|
+
|
52
|
+
@memoize[property_path] = current_item
|
53
|
+
end
|
54
|
+
|
55
|
+
@memoize[property] = current_item
|
56
|
+
end
|
57
|
+
|
58
|
+
def clear(property)
|
59
|
+
@memoize = {} unless defined?(@memoize)
|
60
|
+
@memoize.clear[property] if @memoize[property]
|
61
|
+
end
|
62
|
+
|
63
|
+
def clear_all
|
64
|
+
@memoize = {}
|
65
|
+
end
|
66
|
+
|
67
|
+
def []=(property, value)
|
68
|
+
@memoize = {} unless defined?(@memoize)
|
69
|
+
|
70
|
+
@memoize[property] = value
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
# module Memoize
|
data/lib/models/role.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'treetop'
|
18
18
|
require 'treetop/version'
|
19
|
-
require 'grammar'
|
19
|
+
require 'opennebula/flow/grammar'
|
20
20
|
require 'parse-cron'
|
21
21
|
|
22
22
|
if Gem::Version.create('1.6.3') >= Gem.loaded_specs['treetop'].version
|
@@ -120,6 +120,22 @@ module OpenNebula
|
|
120
120
|
'DOWN' => 1
|
121
121
|
}
|
122
122
|
|
123
|
+
# List of attributes that can't be changed in update operation
|
124
|
+
# cardinality: this is internal information managed by OneFlow server
|
125
|
+
# last_vmname: this is internal information managed by OneFlow server
|
126
|
+
# nodes: this is internal information managed by OneFlow server
|
127
|
+
# parents: this has only sense in deploy operation
|
128
|
+
# state: this is internal information managed by OneFlow server
|
129
|
+
# vm_template: this will affect scale operation
|
130
|
+
IMMUTABLE_ATTRS = %w[
|
131
|
+
cardinality
|
132
|
+
last_vmname
|
133
|
+
nodes
|
134
|
+
parents
|
135
|
+
state
|
136
|
+
vm_template
|
137
|
+
]
|
138
|
+
|
123
139
|
# VM information to save in document
|
124
140
|
VM_INFO = %w[ID UID GID UNAME GNAME NAME]
|
125
141
|
|
@@ -163,8 +179,9 @@ module OpenNebula
|
|
163
179
|
@service.roles.each do |role_name, role|
|
164
180
|
next if role_name == name
|
165
181
|
|
166
|
-
if role.parents.include?
|
167
|
-
|
182
|
+
if role.parents.include?(name) &&
|
183
|
+
role.state != STATE['DONE']
|
184
|
+
return false
|
168
185
|
end
|
169
186
|
end
|
170
187
|
end
|
@@ -685,6 +702,22 @@ module OpenNebula
|
|
685
702
|
nil
|
686
703
|
end
|
687
704
|
|
705
|
+
# Check that changes values are correct
|
706
|
+
#
|
707
|
+
# @param template_json [String] New template
|
708
|
+
#
|
709
|
+
# @return [Boolean, String] True, nil if everything is correct
|
710
|
+
# False, attr if attr was changed
|
711
|
+
def check_new_template(template)
|
712
|
+
IMMUTABLE_ATTRS.each do |attr|
|
713
|
+
next if template[attr] == @body[attr]
|
714
|
+
|
715
|
+
return [false, "role/#{attr}"]
|
716
|
+
end
|
717
|
+
|
718
|
+
[true, nil]
|
719
|
+
end
|
720
|
+
|
688
721
|
########################################################################
|
689
722
|
# Recover
|
690
723
|
########################################################################
|
@@ -984,10 +1017,8 @@ module OpenNebula
|
|
984
1017
|
true_evals = elasticity_pol['true_evals'].to_i
|
985
1018
|
expression = elasticity_pol['expression']
|
986
1019
|
|
987
|
-
if !last_eval.nil?
|
988
|
-
|
989
|
-
return [0, 0]
|
990
|
-
end
|
1020
|
+
if !last_eval.nil? && now < (last_eval + period_duration)
|
1021
|
+
return [0, 0]
|
991
1022
|
end
|
992
1023
|
|
993
1024
|
elasticity_pol['last_eval'] = now
|
data/lib/models/service.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -80,6 +80,31 @@ module OpenNebula
|
|
80
80
|
SCALING
|
81
81
|
]
|
82
82
|
|
83
|
+
# List of attributes that can't be changed in update operation
|
84
|
+
#
|
85
|
+
# custom_attrs: it only has sense when deploying, not in running
|
86
|
+
# custom_attrs_values: it only has sense when deploying, not in running
|
87
|
+
# deployment: changing this, changes the undeploy operation
|
88
|
+
# log: this is just internal information, no sense to change it
|
89
|
+
# name: this has to be changed using rename operation
|
90
|
+
# networks: it only has sense when deploying, not in running
|
91
|
+
# networks_values: it only has sense when deploying, not in running
|
92
|
+
# ready_status_gate: it only has sense when deploying, not in running
|
93
|
+
# state: this is internal information managed by OneFlow server
|
94
|
+
# start_time: this is internal information managed by OneFlow server
|
95
|
+
IMMUTABLE_ATTRS = %w[
|
96
|
+
custom_attrs
|
97
|
+
custom_attrs_values
|
98
|
+
deployment
|
99
|
+
log
|
100
|
+
name
|
101
|
+
networks
|
102
|
+
networks_values
|
103
|
+
ready_status_gate
|
104
|
+
state
|
105
|
+
start_time
|
106
|
+
]
|
107
|
+
|
83
108
|
LOG_COMP = 'SER'
|
84
109
|
|
85
110
|
# Returns the service state
|
@@ -123,6 +148,12 @@ module OpenNebula
|
|
123
148
|
end
|
124
149
|
end
|
125
150
|
|
151
|
+
# Return true if the service can be updated
|
152
|
+
# @return true if the service can be updated, false otherwise
|
153
|
+
def can_update?
|
154
|
+
!transient_state? && !failed_state?
|
155
|
+
end
|
156
|
+
|
126
157
|
def can_recover_deploy?
|
127
158
|
RECOVER_DEPLOY_STATES.include? STATE_STR[state]
|
128
159
|
end
|
@@ -212,6 +243,8 @@ module OpenNebula
|
|
212
243
|
end
|
213
244
|
end
|
214
245
|
|
246
|
+
template['start_time'] = Integer(Time.now)
|
247
|
+
|
215
248
|
super(template.to_json, template['name'])
|
216
249
|
end
|
217
250
|
|
@@ -267,28 +300,6 @@ module OpenNebula
|
|
267
300
|
end
|
268
301
|
end
|
269
302
|
|
270
|
-
# Delete the service. All the VMs are also deleted from OpenNebula.
|
271
|
-
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
272
|
-
# otherwise
|
273
|
-
def delete
|
274
|
-
networks = JSON.parse(self['TEMPLATE/BODY'])['networks_values']
|
275
|
-
|
276
|
-
networks.each do |net|
|
277
|
-
next unless net[net.keys[0]].key? 'template_id'
|
278
|
-
|
279
|
-
net_id = net[net.keys[0]]['id'].to_i
|
280
|
-
|
281
|
-
rc = OpenNebula::VirtualNetwork
|
282
|
-
.new_with_id(net_id, @client).delete
|
283
|
-
|
284
|
-
if OpenNebula.is_error?(rc)
|
285
|
-
log_info("Error deleting vnet #{net_id}: #{rc}")
|
286
|
-
end
|
287
|
-
end if networks
|
288
|
-
|
289
|
-
super()
|
290
|
-
end
|
291
|
-
|
292
303
|
# Retrieves the information of the Service and all its Nodes.
|
293
304
|
#
|
294
305
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
@@ -471,6 +482,38 @@ module OpenNebula
|
|
471
482
|
super(template_raw, append)
|
472
483
|
end
|
473
484
|
|
485
|
+
# Check that changes values are correct
|
486
|
+
#
|
487
|
+
# @param template_json [String] New template
|
488
|
+
#
|
489
|
+
# @return [Boolean, String] True, nil if everything is correct
|
490
|
+
# False, attr if attr was changed
|
491
|
+
def check_new_template(template_json)
|
492
|
+
template = JSON.parse(template_json)
|
493
|
+
|
494
|
+
if template['roles'].size != @roles.size
|
495
|
+
return [false, 'service/roles size']
|
496
|
+
end
|
497
|
+
|
498
|
+
IMMUTABLE_ATTRS.each do |attr|
|
499
|
+
next if template[attr] == @body[attr]
|
500
|
+
|
501
|
+
return [false, "service/#{attr}"]
|
502
|
+
end
|
503
|
+
|
504
|
+
template['roles'].each do |role|
|
505
|
+
# Role name can't be changed, if it is changed some problems
|
506
|
+
# may appear, as name is used to reference roles
|
507
|
+
return [false, 'name'] unless @roles[role['name']]
|
508
|
+
|
509
|
+
rc = @roles[role['name']].check_new_template(role)
|
510
|
+
|
511
|
+
return rc unless rc[0]
|
512
|
+
end
|
513
|
+
|
514
|
+
[true, nil]
|
515
|
+
end
|
516
|
+
|
474
517
|
def deploy_networks
|
475
518
|
body = JSON.parse(self['TEMPLATE/BODY'])
|
476
519
|
|
@@ -525,6 +568,25 @@ module OpenNebula
|
|
525
568
|
state == Service::STATE['RUNNING']
|
526
569
|
end
|
527
570
|
|
571
|
+
# Check if role is terminated or not
|
572
|
+
#
|
573
|
+
# @param role [OpenNebula::Role] Role information
|
574
|
+
#
|
575
|
+
# @return [Boolean]
|
576
|
+
# True if the service should be undeployed
|
577
|
+
# False otherwise
|
578
|
+
def check_role(role)
|
579
|
+
return unless @body['automatic_deletion']
|
580
|
+
|
581
|
+
return unless role.nodes.empty?
|
582
|
+
|
583
|
+
ret = true
|
584
|
+
|
585
|
+
@body['roles'].each {|r| ret &= r['nodes'].empty? }
|
586
|
+
|
587
|
+
ret
|
588
|
+
end
|
589
|
+
|
528
590
|
private
|
529
591
|
|
530
592
|
# Maximum number of log entries per service
|
@@ -611,14 +673,13 @@ module OpenNebula
|
|
611
673
|
# (letter, number, underscore)
|
612
674
|
role['vm_template_contents'].scan(/\$(\w+)/).each do |key|
|
613
675
|
# Check if $ var value is in custom_attrs_values
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
end
|
676
|
+
if !template['custom_attrs_values'].nil? &&
|
677
|
+
template['custom_attrs_values'].key?(key[0])
|
678
|
+
role['vm_template_contents'].gsub!(
|
679
|
+
'$'+key[0],
|
680
|
+
template['custom_attrs_values'][key[0]]
|
681
|
+
)
|
682
|
+
next
|
622
683
|
end
|
623
684
|
|
624
685
|
# Check if $ var value is in networks
|
data/lib/models.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -22,11 +22,11 @@ include OpenNebula
|
|
22
22
|
|
23
23
|
require 'opennebula/document_json'
|
24
24
|
require 'opennebula/document_pool_json'
|
25
|
+
require 'opennebula/flow/service_pool'
|
26
|
+
require 'opennebula/flow/service_template_pool'
|
27
|
+
require 'opennebula/flow/service_template'
|
25
28
|
|
26
|
-
require 'validator'
|
29
|
+
require 'opennebula/flow/validator'
|
27
30
|
|
28
31
|
require 'models/role'
|
29
|
-
require 'models/service_pool'
|
30
32
|
require 'models/service'
|
31
|
-
require 'models/service_template_pool'
|
32
|
-
require 'models/service_template'
|