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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +1 -1
  4. data/lib/DriverExecHelper.rb +44 -28
  5. data/lib/OpenNebulaDriver.rb +8 -4
  6. data/lib/VirtualMachineDriver.rb +9 -2
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/datacenter.rb +1257 -0
  9. data/lib/datastore.rb +1025 -0
  10. data/lib/distributed_firewall.rb +280 -0
  11. data/lib/file_helper.rb +370 -0
  12. data/lib/host.rb +1517 -0
  13. data/lib/logical_port.rb +50 -0
  14. data/lib/logical_switch.rb +77 -0
  15. data/lib/memoize.rb +74 -0
  16. data/lib/models.rb +32 -0
  17. data/lib/models/role.rb +1126 -0
  18. data/lib/models/service.rb +709 -0
  19. data/lib/network.rb +699 -0
  20. data/lib/nsx_client.rb +144 -0
  21. data/lib/nsx_component.rb +28 -0
  22. data/lib/nsx_constants.rb +149 -0
  23. data/lib/nsx_driver.rb +78 -0
  24. data/lib/nsx_error.rb +77 -0
  25. data/lib/nsx_rule.rb +193 -0
  26. data/lib/nsxt_client.rb +176 -0
  27. data/lib/nsxt_dfw.rb +196 -0
  28. data/lib/nsxt_logical_port.rb +94 -0
  29. data/lib/nsxt_rule.rb +188 -0
  30. data/lib/nsxt_tz.rb +38 -0
  31. data/lib/nsxv_client.rb +176 -0
  32. data/lib/nsxv_dfw.rb +202 -0
  33. data/lib/nsxv_logical_port.rb +107 -0
  34. data/lib/nsxv_rule.rb +172 -0
  35. data/lib/nsxv_tz.rb +41 -0
  36. data/lib/opaque_network.rb +134 -0
  37. data/lib/opennebula.rb +5 -2
  38. data/lib/opennebula/acl.rb +1 -1
  39. data/lib/opennebula/acl_pool.rb +1 -1
  40. data/lib/opennebula/client.rb +10 -2
  41. data/lib/opennebula/cluster.rb +1 -1
  42. data/lib/opennebula/cluster_pool.rb +1 -1
  43. data/lib/opennebula/datastore.rb +1 -1
  44. data/lib/opennebula/datastore_pool.rb +1 -1
  45. data/lib/opennebula/document.rb +8 -29
  46. data/lib/opennebula/document_json.rb +42 -12
  47. data/lib/opennebula/document_pool.rb +1 -1
  48. data/lib/opennebula/document_pool_json.rb +1 -1
  49. data/lib/opennebula/error.rb +4 -1
  50. data/lib/opennebula/flow.rb +23 -0
  51. data/lib/opennebula/flow/grammar.rb +1195 -0
  52. data/lib/opennebula/flow/service_pool.rb +190 -0
  53. data/lib/opennebula/flow/service_template.rb +608 -0
  54. data/lib/opennebula/flow/service_template_ext.rb +84 -0
  55. data/lib/opennebula/flow/service_template_pool.rb +32 -0
  56. data/lib/opennebula/flow/validator.rb +499 -0
  57. data/lib/opennebula/group.rb +1 -1
  58. data/lib/opennebula/group_pool.rb +1 -1
  59. data/lib/opennebula/hook.rb +5 -12
  60. data/lib/opennebula/hook_log.rb +1 -1
  61. data/lib/opennebula/hook_pool.rb +1 -1
  62. data/lib/opennebula/host.rb +1 -1
  63. data/lib/opennebula/host_pool.rb +1 -1
  64. data/lib/opennebula/image.rb +19 -14
  65. data/lib/opennebula/image_pool.rb +1 -1
  66. data/lib/opennebula/ldap_auth.rb +1 -1
  67. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  68. data/lib/opennebula/lockable_ext.rb +163 -0
  69. data/lib/opennebula/marketplace.rb +1 -1
  70. data/lib/opennebula/marketplace_pool.rb +1 -1
  71. data/lib/opennebula/marketplaceapp.rb +9 -119
  72. data/lib/opennebula/marketplaceapp_ext.rb +586 -0
  73. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  74. data/lib/opennebula/oneflow_client.rb +4 -3
  75. data/lib/opennebula/pool.rb +6 -3
  76. data/lib/opennebula/pool_element.rb +1 -1
  77. data/lib/opennebula/security_group.rb +1 -1
  78. data/lib/opennebula/security_group_pool.rb +1 -1
  79. data/lib/opennebula/server_cipher_auth.rb +1 -1
  80. data/lib/opennebula/server_x509_auth.rb +1 -1
  81. data/lib/opennebula/ssh_auth.rb +1 -1
  82. data/lib/opennebula/system.rb +1 -1
  83. data/lib/opennebula/template.rb +4 -13
  84. data/lib/opennebula/template_ext.rb +342 -0
  85. data/lib/opennebula/template_pool.rb +1 -1
  86. data/lib/opennebula/user.rb +26 -2
  87. data/lib/opennebula/user_pool.rb +1 -1
  88. data/lib/opennebula/utils.rb +1 -1
  89. data/lib/opennebula/vdc.rb +1 -1
  90. data/lib/opennebula/vdc_pool.rb +1 -1
  91. data/lib/opennebula/virtual_machine.rb +26 -206
  92. data/lib/opennebula/virtual_machine_ext.rb +469 -0
  93. data/lib/opennebula/virtual_machine_pool.rb +1 -1
  94. data/lib/opennebula/virtual_network.rb +4 -10
  95. data/lib/opennebula/virtual_network_pool.rb +1 -1
  96. data/lib/opennebula/virtual_router.rb +4 -12
  97. data/lib/opennebula/virtual_router_pool.rb +1 -1
  98. data/lib/opennebula/vm_group.rb +4 -11
  99. data/lib/opennebula/vm_group_pool.rb +1 -1
  100. data/lib/opennebula/vntemplate.rb +4 -13
  101. data/lib/opennebula/vntemplate_pool.rb +1 -1
  102. data/lib/opennebula/wait_ext.rb +257 -0
  103. data/lib/opennebula/x509_auth.rb +1 -1
  104. data/lib/opennebula/xml_element.rb +1 -1
  105. data/lib/opennebula/xml_pool.rb +1 -1
  106. data/lib/opennebula/xml_utils.rb +1 -1
  107. data/lib/opennebula/zone.rb +1 -1
  108. data/lib/opennebula/zone_pool.rb +1 -1
  109. data/lib/rest_client.rb +201 -0
  110. data/lib/scripts_common.rb +183 -0
  111. data/lib/transport_zone.rb +43 -0
  112. data/lib/vcenter_driver.rb +13 -12
  113. data/lib/vcenter_importer.rb +616 -0
  114. data/lib/vi_client.rb +281 -0
  115. data/lib/vi_helper.rb +313 -0
  116. data/lib/virtual_machine.rb +3477 -0
  117. data/lib/virtual_wire.rb +158 -0
  118. data/lib/vm_device.rb +80 -0
  119. data/lib/vm_disk.rb +202 -0
  120. data/lib/vm_folder.rb +69 -0
  121. data/lib/vm_helper.rb +30 -0
  122. data/lib/vm_monitor.rb +303 -0
  123. data/lib/vm_nic.rb +70 -0
  124. data/lib/vm_template.rb +1963 -0
  125. data/lib/vmm_importer.rb +121 -0
  126. metadata +140 -27
data/lib/nsx_client.rb ADDED
@@ -0,0 +1,144 @@
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
+ ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION)
19
+
20
+ if !ONE_LOCATION
21
+ RUBY_LIB_LOCATION = '/usr/lib/one/ruby' \
22
+ unless defined?(RUBY_LIB_LOCATION)
23
+ GEMS_LOCATION = '/usr/share/one/gems' \
24
+ unless defined?(GEMS_LOCATION)
25
+ else
26
+ RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' \
27
+ unless defined?(RUBY_LIB_LOCATION)
28
+ GEMS_LOCATION = ONE_LOCATION + '/share/gems' \
29
+ unless defined?(GEMS_LOCATION)
30
+ end
31
+
32
+ if File.directory?(GEMS_LOCATION)
33
+ real_gems_path = File.realpath(GEMS_LOCATION)
34
+ if !defined?(Gem) || Gem.path != [real_gems_path]
35
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
+ require 'rubygems'
37
+ Gem.use_paths(real_gems_path)
38
+ end
39
+ end
40
+
41
+ $LOAD_PATH << RUBY_LIB_LOCATION
42
+
43
+ require 'net/http'
44
+ require 'json'
45
+ require 'nokogiri'
46
+ require 'opennebula'
47
+ require 'vcenter_driver'
48
+ require 'nsx_driver'
49
+
50
+ # Class NSXClient
51
+ class NSXClient
52
+
53
+ # ATTIBUTES
54
+ attr_accessor :nsxmgr
55
+ attr_accessor :nsx_user
56
+ attr_accessor :nsx_password
57
+
58
+ # CONSTRUCTORS
59
+ def initialize(nsxmgr, nsx_user, nsx_password)
60
+ @nsxmgr = nsxmgr
61
+ @nsx_user = nsx_user
62
+ @nsx_password = nsx_password
63
+ end
64
+
65
+ def self.new_child(nsxmgr, nsx_user, nsx_password, type)
66
+ [nsxmgr, nsx_user, nsx_password, type].each do |v|
67
+ next if !v.nil? && !v.empty?
68
+
69
+ return nil
70
+ end
71
+
72
+ case type.upcase
73
+ when NSXConstants::NSXT
74
+ NSXTClient.new(nsxmgr, nsx_user, nsx_password)
75
+ when NSXConstants::NSXV
76
+ NSXVClient.new(nsxmgr, nsx_user, nsx_password)
77
+ else
78
+ error_msg = "Unknown NSX type: #{type}"
79
+ error = NSXError::UnknownObject.new(error_msg)
80
+ raise error
81
+ end
82
+ end
83
+
84
+ def self.new_from_host(host)
85
+ nsxmgr = host['TEMPLATE/NSX_MANAGER']
86
+ nsx_user = host['TEMPLATE/NSX_USER']
87
+ nsx_password = host['TEMPLATE/NSX_PASSWORD']
88
+ nsx_type = host['TEMPLATE/NSX_TYPE']
89
+
90
+ new_child(nsxmgr, nsx_user, nsx_password, nsx_type)
91
+ end
92
+
93
+ def self.new_from_id(hid)
94
+ client = OpenNebula::Client.new
95
+ host = OpenNebula::Host.new_with_id(hid, client)
96
+
97
+ rc = host.info(true)
98
+
99
+ if OpenNebula.is_error?(rc)
100
+ raise "Could not get host info for ID: #{hid} - #{rc.message}"
101
+ end
102
+
103
+ new_from_host(host)
104
+ end
105
+
106
+ # METHODS
107
+
108
+ # Return response if match with responses codes, If response not match
109
+ # with expected responses codes then raise an IncorrectResponseCodeError
110
+ def check_response(response, codes_array)
111
+ unless response.nil?
112
+ return response if codes_array.include?(response.code.to_i)
113
+
114
+ response_json = JSON.parse(response.body)
115
+ nsx_error = "\nNSX error code: " \
116
+ "#{response_json['errorCode']}, " \
117
+ "\nNSX error details: " \
118
+ "#{response_json['details']}"
119
+ raise NSXError::IncorrectResponseCodeError, nsx_error
120
+ end
121
+ raise NSXError::IncorrectResponseCodeError, nsx_error
122
+ end
123
+
124
+ # Return: respose.body
125
+ def get(url, aditional_headers = []); end
126
+
127
+ # Return: response
128
+ def get_full_response(url, aditional_headers = []); end
129
+
130
+ # Return: id of the created object
131
+ def post(url, data, aditional_headers = []); end
132
+
133
+ def put(url, data, aditional_headers = []); end
134
+
135
+ def delete(url); end
136
+
137
+ def get_token(url); end
138
+
139
+ # Prepare headers
140
+ def add_headers(aditional_headers = []); end
141
+
142
+ end
143
+
144
+ end
@@ -0,0 +1,28 @@
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 NSXComponent
20
+
21
+ # CONSTRUCTOR
22
+ def initialize(nsx_client)
23
+ @nsx_client = nsx_client
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,149 @@
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
+ ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION)
19
+
20
+ if !ONE_LOCATION
21
+ RUBY_LIB_LOCATION = '/usr/lib/one/ruby' \
22
+ unless defined?(RUBY_LIB_LOCATION)
23
+ GEMS_LOCATION = '/usr/share/one/gems' \
24
+ unless defined?(GEMS_LOCATION)
25
+ else
26
+ RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' \
27
+ unless defined?(RUBY_LIB_LOCATION)
28
+ GEMS_LOCATION = ONE_LOCATION + '/share/gems' \
29
+ unless defined?(GEMS_LOCATION)
30
+ end
31
+
32
+ if File.directory?(GEMS_LOCATION)
33
+ real_gems_path = File.realpath(GEMS_LOCATION)
34
+ if !defined?(Gem) || Gem.path != [real_gems_path]
35
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
+ require 'rubygems'
37
+ Gem.use_paths(real_gems_path)
38
+ end
39
+ end
40
+
41
+ $LOAD_PATH << RUBY_LIB_LOCATION
42
+
43
+ class NSXConstants
44
+
45
+ # CONSTANTS
46
+ NSXT = 'NSX-T'
47
+ NSXV = 'NSX-V'
48
+ HEADER_JSON = { 'Content-Type' => 'application/json' }
49
+ HEADER_XML = { 'Content-Type' => 'application/xml' }
50
+ # NSX Manager
51
+ NSXT_EXTENSION_LIST = 'com.vmware.nsx.management.nsxt'
52
+ NSXV_EXTENSION_LIST = 'com.vmware.vShieldManager'
53
+ NSXT_BASE = '/api/v1'
54
+ NSXV_BASE = '/api/2.0'
55
+ # Transport Zones
56
+ NSXV_TZS = NSXV_BASE + '/vdn/scopes'
57
+ NSXV_TZS_XPATH = '//vdnScope'
58
+ NSXT_TZS = NSXT_BASE + '/transport-zones'
59
+ # VirtualWire
60
+ NSXV_AUTH = NSXV_BASE + '/services/auth/token'
61
+ NSXV_LS_TYPE = 'NSX-V'
62
+ NSXV_LS_NAME_XPATH = '//virtualWire/name'
63
+ NSXV_LS_VNI_XPATH = '//virtualWire/vdnId'
64
+ NSXV_LS_BACKING_XPATH = '//virtualWire/vdsContextWithBacking' \
65
+ '/backingValue'
66
+ NSXV_LS_OBJECTID_XPATH = '//virtualWire/vdsContextWithBacking' \
67
+ '/switch/objectId'
68
+ NSXV_LS_XPATH = '//virtualWire'
69
+ NSXV_LS_SECTION = NSXV_BASE + '/vdn/virtualwires/'
70
+ NSXV_TZ_SECTION = NSXV_BASE + '/vdn/scopes/'
71
+ NSXV_TZ_XPATH = '//virtualWire/vdnScopeId'
72
+ # OpaqueNetwork
73
+ NSXT_AUTH = NSXT_BASE + '/aaa/registration-token'
74
+ NSXT_LS_TYPE = 'Opaque Network'
75
+ NSXT_LS_SECTION = NSXT_BASE + '/logical-switches/'
76
+ # DFW
77
+ ONE_SECTION_NAME = 'OpenNebula'
78
+ NSXT_DFW_BASE = NSXT_BASE + '/firewall'
79
+ NSXV_DFW_BASE = '/api/4.0/firewall/globalroot-0/config'
80
+ NSXT_DFW_SECTIONS = '/sections'
81
+ NSXV_DFW_SECTIONS = '/layer3sections'
82
+ NSXV_DFW_SECTION_XPATH = '//section'
83
+ NSXV_DFW_RULE_XPATH = '//rule'
84
+ # RULE
85
+ NSXT_RULE_BASE = NSXT_BASE + '/firewall/rules'
86
+ NSXT_RULE_PROTOCOL = {
87
+ 'TCP' => {
88
+ :service => {
89
+ :l4_protocol => 'TCP',
90
+ :source_ports => [],
91
+ :destination_ports => [],
92
+ :resource_type => 'L4PortSetNSService'
93
+ }
94
+ },
95
+ 'UDP' => {
96
+ :service => {
97
+ :l4_protocol => 'UDP',
98
+ :source_ports => [],
99
+ :destination_ports => [],
100
+ :resource_type => 'L4PortSetNSService'
101
+ }
102
+ },
103
+ 'ICMP' => {
104
+ :service => {
105
+ :protocol => 'ICMPv4',
106
+ :resource_type => 'ICMPTypeNSService'
107
+ }
108
+ },
109
+ 'ICMPv6' => {
110
+ :service => {
111
+ :protocol => 'ICMPv6',
112
+ :resource_type => 'ICMPTypeNSService'
113
+ }
114
+ }
115
+ }
116
+ NSXV_RULE_BASE = 'xxx'
117
+ NSX_RULE_IPSEC_PORTS = %w[500 4500]
118
+ # Logical Ports
119
+ NSXT_LP_BASE = NSXT_BASE + '/logical-ports/'
120
+ NSXV_LP_BASE = ''
121
+ # Messages
122
+ MSG_INCOMPLETE_REQ = 'Incomplete request, NSX_MANAGER, NSX_USER, \
123
+ NSX_PASSWORD and NSX_TYPE are needed'
124
+ MSG_INVALID_REQ = 'Invalid request, check that NSX_MANAGER, NSX_USER, \
125
+ NSX_PASSWORD and NSX_TYPE are correct'
126
+ MSG_INVALID_NSXTYPE = 'Invalid NSX-TYPE: Only NSX-T and NSX-V are \
127
+ supported'
128
+ # Responses codes
129
+ # 2xx
130
+ CODE_OK = 200
131
+ CODE_CREATED = 201
132
+ CODE_ACCEPTED = 202
133
+ CODE_NO_CONTENT = 204
134
+ # 4xx
135
+ CODE_BAD_REQUEST = 400
136
+ CODE_UNAUTHORIZED = 401
137
+ CODE_FORBIDDEN = 403
138
+ CODE_NOT_FOUND = 404
139
+ CODE_METHOD_NOT_ALLOWED = 405
140
+ CODE_NOT_ACCEPTABLE = 406
141
+ # 5xx
142
+ CODE_INTERNAL_SERVER_ERROR = 500
143
+ CODE_BAD_GATEWAY = 502
144
+ CODE_SERVICE_UNAVAILABLE = 503
145
+ CODE_GATEWAY_TIMEOUT = 504
146
+
147
+ end
148
+
149
+ end
data/lib/nsx_driver.rb ADDED
@@ -0,0 +1,78 @@
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
+ # Set up the environment for the driver #
19
+ # ---------------------------------------------------------------------------- #
20
+
21
+ ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION)
22
+
23
+ if !ONE_LOCATION
24
+ BIN_LOCATION = '/usr/bin' unless defined?(BIN_LOCATION)
25
+ LIB_LOCATION = '/usr/lib/one' unless defined?(LIB_LOCATION)
26
+ ETC_LOCATION = '/etc/one/' unless defined?(ETC_LOCATION)
27
+ VAR_LOCATION = '/var/lib/one' unless defined?(VAR_LOCATION)
28
+ GEMS_LOCATION = '/usr/share/one/gems' unless defined?(GEMS_LOCATION)
29
+ else
30
+ BIN_LOCATION = ONE_LOCATION + '/bin' unless defined?(BIN_LOCATION)
31
+ LIB_LOCATION = ONE_LOCATION + '/lib' unless defined?(LIB_LOCATION)
32
+ ETC_LOCATION = ONE_LOCATION + '/etc/' unless defined?(ETC_LOCATION)
33
+ VAR_LOCATION = ONE_LOCATION + '/var/' unless defined?(VAR_LOCATION)
34
+ GEMS_LOCATION = ONE_LOCATION + '/share/gems' unless defined?(GEMS_LOCATION)
35
+ end
36
+
37
+ ENV['LANG'] = 'C'
38
+
39
+ if File.directory?(GEMS_LOCATION)
40
+ real_gems_path = File.realpath(GEMS_LOCATION)
41
+ if !defined?(Gem) || Gem.path != [real_gems_path]
42
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
43
+ require 'rubygems'
44
+ Gem.use_paths(real_gems_path)
45
+ end
46
+ end
47
+
48
+ $LOAD_PATH << LIB_LOCATION + '/ruby'
49
+ $LOAD_PATH << LIB_LOCATION + '/ruby/nsx_driver'
50
+
51
+ # ---------------------------------------------------------------------------- #
52
+ # NSX Library #
53
+ # ---------------------------------------------------------------------------- #
54
+ require 'nsx_constants'
55
+ require 'nsx_error'
56
+ require 'nsx_component'
57
+ require 'nsx_client'
58
+ require 'nsxt_client'
59
+ require 'nsxv_client'
60
+ require 'logical_switch'
61
+ require 'opaque_network'
62
+ require 'transport_zone'
63
+ require 'nsxt_tz'
64
+ require 'nsxv_tz'
65
+ require 'virtual_wire'
66
+ require 'distributed_firewall'
67
+ require 'nsxt_dfw'
68
+ require 'nsxv_dfw'
69
+ require 'logical_port'
70
+ require 'nsxt_logical_port'
71
+ require 'nsxv_logical_port'
72
+ require 'nsx_rule'
73
+ require 'nsxt_rule'
74
+ require 'nsxv_rule'
75
+
76
+ # NSX Driver module
77
+ module NSXDriver
78
+ end
data/lib/nsx_error.rb ADDED
@@ -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 NSXError < StandardError
19
+
20
+ # Class IncorrectResponseCodeError
21
+ class IncorrectResponseCodeError < NSXError
22
+
23
+ def initialize(msg = 'Incorrect response code')
24
+ super(msg)
25
+ end
26
+
27
+ end
28
+
29
+ # Class ObjectNotFound
30
+ class ObjectNotFound < NSXError
31
+
32
+ def initialize(msg = 'Object not found')
33
+ super(msg)
34
+ end
35
+
36
+ end
37
+
38
+ # Class UnknownObject
39
+ class UnknownObject < NSXError
40
+
41
+ def initialize(msg = 'Unknown object type')
42
+ super(msg)
43
+ end
44
+
45
+ end
46
+
47
+ # Class CreateError
48
+ class CreateError < NSXError
49
+
50
+ def initialize(msg = 'Error creating NSX object')
51
+ super(msg)
52
+ end
53
+
54
+ end
55
+
56
+ # Class DeleteError
57
+ class DeleteError < NSXError
58
+
59
+ def initialize(msg = 'Error deleting NSX object')
60
+ super(msg)
61
+ end
62
+
63
+ end
64
+
65
+ # Class DeleteError
66
+ class MissingParameter < NSXError
67
+
68
+ def initialize(parameter)
69
+ msg = "Missing NSX parameter #{parameter}"
70
+ super(msg)
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end