opennebula 5.12.9 → 6.0.0.1
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.
- checksums.yaml +4 -4
- 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 +1257 -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.rb +32 -0
- data/lib/models/role.rb +1126 -0
- data/lib/models/service.rb +709 -0
- data/lib/network.rb +699 -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.rb +5 -2
- data/lib/opennebula/acl.rb +1 -1
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +10 -2
- 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.rb +23 -0
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/opennebula/flow/service_pool.rb +190 -0
- data/lib/opennebula/flow/service_template.rb +608 -0
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/opennebula/flow/service_template_pool.rb +32 -0
- data/lib/opennebula/flow/validator.rb +499 -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 +19 -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 +586 -0
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +4 -3
- data/lib/opennebula/pool.rb +6 -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 +342 -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 +26 -206
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +1 -1
- 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 +257 -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/rest_client.rb +201 -0
- data/lib/scripts_common.rb +183 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +13 -12
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +313 -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 +1963 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +140 -27
data/lib/opennebula/x509_auth.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 #
|
|
@@ -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 #
|
data/lib/opennebula/xml_pool.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 #
|
data/lib/opennebula/xml_utils.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 #
|
data/lib/opennebula/zone.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 #
|
data/lib/opennebula/zone_pool.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 #
|
data/lib/rest_client.rb
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
require 'openssl'
|
|
17
|
+
require 'yaml'
|
|
18
|
+
require 'vsphere-automation-vcenter'
|
|
19
|
+
require 'vsphere-automation-cis'
|
|
20
|
+
|
|
21
|
+
module VCenterDriver
|
|
22
|
+
|
|
23
|
+
########################################################################
|
|
24
|
+
# Class RESTClient
|
|
25
|
+
########################################################################
|
|
26
|
+
class RESTClient
|
|
27
|
+
|
|
28
|
+
attr_accessor :configuration
|
|
29
|
+
|
|
30
|
+
def initialize(opts)
|
|
31
|
+
@opts = {
|
|
32
|
+
:insecure => true,
|
|
33
|
+
:associable_types => [
|
|
34
|
+
ClusterComputeResource,
|
|
35
|
+
DistributedVirtualSwitch,
|
|
36
|
+
VmwareDistributedVirtualSwitch,
|
|
37
|
+
LibraryItem,
|
|
38
|
+
ResourcePool,
|
|
39
|
+
Folder,
|
|
40
|
+
HostNetwork,
|
|
41
|
+
DistributedVirtualPortgroup,
|
|
42
|
+
VirtualApp,
|
|
43
|
+
StoragePod,
|
|
44
|
+
Datastore,
|
|
45
|
+
Network,
|
|
46
|
+
Datacenter,
|
|
47
|
+
Library,
|
|
48
|
+
HostSystem,
|
|
49
|
+
OpaqueNetwork,
|
|
50
|
+
VirtualMachine
|
|
51
|
+
],
|
|
52
|
+
:category_name => 'OpenNebula',
|
|
53
|
+
:category_description => 'OpenNebula Category',
|
|
54
|
+
:cardinality =>
|
|
55
|
+
VSphereAutomation::CIS::CisTaggingCategoryModelCardinality
|
|
56
|
+
.const_get(
|
|
57
|
+
'multiple'.upcase
|
|
58
|
+
)
|
|
59
|
+
}.merge(opts)
|
|
60
|
+
|
|
61
|
+
@configuration = VSphereAutomation::Configuration.new.tap do |c|
|
|
62
|
+
c.host = @opts[:hostname]
|
|
63
|
+
c.username = @opts[:username]
|
|
64
|
+
c.password = @opts[:password]
|
|
65
|
+
c.scheme = 'https'
|
|
66
|
+
c.verify_ssl = !@opts[:insecure]
|
|
67
|
+
c.verify_ssl_host = !@opts[:insecure]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.new_from_host(host_id)
|
|
72
|
+
begin
|
|
73
|
+
client = OpenNebula::Client.new
|
|
74
|
+
host = OpenNebula::Host.new_with_id(host_id, client)
|
|
75
|
+
rc = host.info(true)
|
|
76
|
+
if OpenNebula.is_error?(rc)
|
|
77
|
+
raise "Could not get host info for ID: \
|
|
78
|
+
#{host_id} - #{rc.message}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
connection = {
|
|
82
|
+
:hostname => host['TEMPLATE/VCENTER_HOST'],
|
|
83
|
+
:username => host['TEMPLATE/VCENTER_USER'],
|
|
84
|
+
:password => host['TEMPLATE/VCENTER_PASSWORD']
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
new(connection)
|
|
88
|
+
rescue StandardError => e
|
|
89
|
+
raise e
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_or_create_tag(
|
|
94
|
+
api_client,
|
|
95
|
+
category_id,
|
|
96
|
+
tag_name,
|
|
97
|
+
tag_description
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
tag_api = VSphereAutomation::CIS::TaggingTagApi.new(api_client)
|
|
101
|
+
tag = tag_api.list.value.find do |id|
|
|
102
|
+
c = tag_api.get(id).value
|
|
103
|
+
break c if c.name == tag_name
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if tag.nil?
|
|
107
|
+
create_spec =
|
|
108
|
+
VSphereAutomation::CIS::CisTaggingTagCreateSpec
|
|
109
|
+
.new(
|
|
110
|
+
name => tag_name,
|
|
111
|
+
description => tag_description,
|
|
112
|
+
category_id => category_id
|
|
113
|
+
)
|
|
114
|
+
create_model = VSphereAutomation::CIS::CisTaggingTagCreate.new(
|
|
115
|
+
create_spec => create_spec
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
api_instance =
|
|
119
|
+
VSphereAutomation::CIS::TaggingTagApi.new(api_client)
|
|
120
|
+
api_instance.create(create_model).value
|
|
121
|
+
else
|
|
122
|
+
tag.id
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def get_or_create_category(api_client, category_name)
|
|
127
|
+
category_api =
|
|
128
|
+
VSphereAutomation::CIS::TaggingCategoryApi.new(api_client)
|
|
129
|
+
category = category_api.list.value.find do |id|
|
|
130
|
+
c = category_api.get(id).value
|
|
131
|
+
break c if c.name == category_name
|
|
132
|
+
end
|
|
133
|
+
if category.nil?
|
|
134
|
+
create_spec =
|
|
135
|
+
VSphereAutomation::CIS::CisTaggingCategoryCreateSpec
|
|
136
|
+
.new(
|
|
137
|
+
name => category_name,
|
|
138
|
+
description => @opts[:category_description],
|
|
139
|
+
associable_types => @opts[:associable_types],
|
|
140
|
+
cardinality => @opts[:cardinality]
|
|
141
|
+
)
|
|
142
|
+
create_model =
|
|
143
|
+
VSphereAutomation::CIS::CisTaggingCategoryCreate
|
|
144
|
+
.new(create_spec => create_spec)
|
|
145
|
+
|
|
146
|
+
category = category_api.create(create_model)
|
|
147
|
+
category.value
|
|
148
|
+
else
|
|
149
|
+
category.id
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def sync_tags(vm)
|
|
154
|
+
api_client = VSphereAutomation::ApiClient.new(@configuration)
|
|
155
|
+
VSphereAutomation::CIS::SessionApi.new(api_client).create('')
|
|
156
|
+
|
|
157
|
+
association_api =
|
|
158
|
+
VSphereAutomation::CIS::TaggingTagAssociationApi
|
|
159
|
+
.new(api_client)
|
|
160
|
+
|
|
161
|
+
vm.vcenter_tags.each do |tag|
|
|
162
|
+
category_name = @opts[:category_name]
|
|
163
|
+
|
|
164
|
+
unless tag['CATEGORY_NAME'].nil?
|
|
165
|
+
category_name = tag['CATEGORY_NAME']
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
category_id = get_or_create_category(api_client, category_name)
|
|
169
|
+
|
|
170
|
+
tag_name = tag['NAME']
|
|
171
|
+
tag_description = tag['DESCRIPTION']
|
|
172
|
+
|
|
173
|
+
tag_id =
|
|
174
|
+
get_or_create_tag(
|
|
175
|
+
api_client,
|
|
176
|
+
category_id,
|
|
177
|
+
tag_name,
|
|
178
|
+
tag_description
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
request_body =
|
|
182
|
+
VSphereAutomation::CIS::CisTaggingTagAssociationAttach.new
|
|
183
|
+
|
|
184
|
+
object_id = VSphereAutomation::CIS::VapiStdDynamicID.new
|
|
185
|
+
object_id.id = vm['_ref']
|
|
186
|
+
object_id.type = 'VirtualMachine'
|
|
187
|
+
|
|
188
|
+
request_body.object_id = object_id
|
|
189
|
+
|
|
190
|
+
begin
|
|
191
|
+
association_api.attach(tag_id, request_body)
|
|
192
|
+
rescue VSphereAutomation::ApiError => e
|
|
193
|
+
puts "Exception when calling \
|
|
194
|
+
TaggingTagAssociationApi->attach: #{e}"
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
end
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
require 'shellwords'
|
|
18
|
+
|
|
19
|
+
module OpenNebula
|
|
20
|
+
|
|
21
|
+
# Generic log function
|
|
22
|
+
def self.log_function(severity, message)
|
|
23
|
+
STDERR.puts "#{severity}: #{File.basename $0}: #{message}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Logs an info message
|
|
27
|
+
def self.log_info(message)
|
|
28
|
+
log_function("INFO", message)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Logs an error message
|
|
32
|
+
def self.log_error(message)
|
|
33
|
+
log_function("ERROR", message)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Logs a debug message
|
|
37
|
+
def self.log_debug(message)
|
|
38
|
+
log_function("DEBUG", message)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Alias log to log_info in the singleton class
|
|
42
|
+
class << self
|
|
43
|
+
alias :log :log_info
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# This function is used to pass error message to the mad
|
|
47
|
+
def self.error_message(message)
|
|
48
|
+
STDERR.puts format_error_message(message)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#This function formats an error message for OpenNebula
|
|
52
|
+
def self.format_error_message(message)
|
|
53
|
+
error_str = "ERROR MESSAGE --8<------\n"
|
|
54
|
+
error_str << message
|
|
55
|
+
error_str << "\nERROR MESSAGE ------>8--"
|
|
56
|
+
|
|
57
|
+
return error_str
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.is_disk?(arg)
|
|
61
|
+
arg.match("disk\.[0-9]+$")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Gets the host from an argument
|
|
65
|
+
def self.arg_host(arg)
|
|
66
|
+
result = arg.match("^\([^:]*\):.*$")
|
|
67
|
+
|
|
68
|
+
return result[1] if result
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.arg_path(arg)
|
|
72
|
+
result = arg.match('^[^:]*:(.*)$')
|
|
73
|
+
|
|
74
|
+
return result[1] if result
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Executes a command, if it fails returns error message and exits
|
|
78
|
+
# If a second parameter is present it is used as the error message when
|
|
79
|
+
# the command fails
|
|
80
|
+
def self.exec_and_log(command, message=nil, allowed_return_code=0)
|
|
81
|
+
command = command.shellsplit.shelljoin # escape
|
|
82
|
+
output=`#{command} 2>&1 1>/dev/null`
|
|
83
|
+
code=$?.exitstatus
|
|
84
|
+
|
|
85
|
+
if code!=0 && code!=allowed_return_code
|
|
86
|
+
log_error "Command \"#{command}\" failed."
|
|
87
|
+
log_error output
|
|
88
|
+
if !message
|
|
89
|
+
error_message output
|
|
90
|
+
else
|
|
91
|
+
error_message message
|
|
92
|
+
end
|
|
93
|
+
exit code
|
|
94
|
+
end
|
|
95
|
+
log "Executed \"#{command}\"."
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.send_to_monitor(msg_type, result, oid, data)
|
|
99
|
+
# Read monitord.conf
|
|
100
|
+
one_location = ENV['ONE_LOCATION']
|
|
101
|
+
|
|
102
|
+
if !one_location
|
|
103
|
+
file_dir = '/etc/one/'
|
|
104
|
+
else
|
|
105
|
+
file_dir = one_location + '/etc/'
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
file_name = 'monitord.conf'
|
|
109
|
+
|
|
110
|
+
begin
|
|
111
|
+
# Suppress augeas require warning message
|
|
112
|
+
$VERBOSE = nil
|
|
113
|
+
|
|
114
|
+
require 'augeas'
|
|
115
|
+
|
|
116
|
+
aug = Augeas.create(:no_modl_autoload => true,
|
|
117
|
+
:no_load => true,
|
|
118
|
+
:root => file_dir,
|
|
119
|
+
:loadpath => file_name)
|
|
120
|
+
|
|
121
|
+
aug.clear_transforms
|
|
122
|
+
aug.transform(:lens => 'Oned.lns', :incl => file_name)
|
|
123
|
+
aug.context = "/files/#{file_name}"
|
|
124
|
+
aug.load
|
|
125
|
+
|
|
126
|
+
mon_address = aug.get('NETWORK/MONITOR_ADDRESS')
|
|
127
|
+
mon_port = aug.get('NETWORK/PORT')
|
|
128
|
+
mon_key = aug.get('NETWORK/PUBKEY').tr('"', '')
|
|
129
|
+
|
|
130
|
+
mon_address = "127.0.0.1" if mon_address.include? "auto"
|
|
131
|
+
rescue LoadError
|
|
132
|
+
mon_address = "127.0.0.1"
|
|
133
|
+
mon_port = 4124
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Encrypt
|
|
137
|
+
if mon_key && !mon_key.empty?
|
|
138
|
+
block_size = mon_key.n.num_bytes - 11
|
|
139
|
+
|
|
140
|
+
edata = ''
|
|
141
|
+
index = 0
|
|
142
|
+
|
|
143
|
+
loop do
|
|
144
|
+
break if index >= data.length
|
|
145
|
+
|
|
146
|
+
edata << mon_key.public_encrypt(data[index, block_size])
|
|
147
|
+
|
|
148
|
+
index += block_size
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
data = edata
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Send data
|
|
155
|
+
begin
|
|
156
|
+
require 'base64'
|
|
157
|
+
require 'zlib'
|
|
158
|
+
require 'socket'
|
|
159
|
+
|
|
160
|
+
zdata = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION)
|
|
161
|
+
data64 = Base64.strict_encode64(zdata)
|
|
162
|
+
|
|
163
|
+
if (result == "SUCCESS" || result == "0")
|
|
164
|
+
result = "SUCCESS"
|
|
165
|
+
else
|
|
166
|
+
result = "FAILURE"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if Integer(oid) == -1
|
|
170
|
+
ts = 0
|
|
171
|
+
else
|
|
172
|
+
ts = Time.now.to_i
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
msg = "#{msg_type} #{result} #{oid} #{ts} #{data64}"
|
|
176
|
+
|
|
177
|
+
socket_udp = UDPSocket.new()
|
|
178
|
+
socket_udp.send(msg, 0, mon_address, mon_port)
|
|
179
|
+
rescue LoadError
|
|
180
|
+
STDERR.puts('Unable to send data to Monitor Daemon')
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
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 Transport Zone
|
|
19
|
+
class TransportZone < NSXComponent
|
|
20
|
+
|
|
21
|
+
# ATTRIBUTES
|
|
22
|
+
attr_reader :tz_id
|
|
23
|
+
|
|
24
|
+
def self.new_child(nsx_client)
|
|
25
|
+
case nsx_client.nsx_type.upcase
|
|
26
|
+
when NSXConstants::NSXT
|
|
27
|
+
NSXTtz.new(nsx_client)
|
|
28
|
+
when NSXConstants::NSXV
|
|
29
|
+
NSXVtz.new(nsx_client)
|
|
30
|
+
else
|
|
31
|
+
error_msg = "Unknown NSX type: #{nsx_client.nsx_type}"
|
|
32
|
+
error = NSXError::UnknownObject.new(error_msg)
|
|
33
|
+
raise error
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# METHODS
|
|
38
|
+
# Return the transport zones list
|
|
39
|
+
def tzs; end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|