brocade_api_client 0.1.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 +7 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +82 -0
- data/LICENSE +234 -0
- data/README.md +248 -0
- data/Rakefile +38 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/brocade_api_client.gemspec +45 -0
- data/lib/BrocadeAPIClient/apiversion.rb +47 -0
- data/lib/BrocadeAPIClient/client.rb +533 -0
- data/lib/BrocadeAPIClient/events.rb +35 -0
- data/lib/BrocadeAPIClient/exceptions.rb +79 -0
- data/lib/BrocadeAPIClient/fabrics.rb +28 -0
- data/lib/BrocadeAPIClient/httpclient.rb +149 -0
- data/lib/BrocadeAPIClient/ports.rb +52 -0
- data/lib/BrocadeAPIClient/static.rb +16 -0
- data/lib/BrocadeAPIClient/switches.rb +29 -0
- data/lib/BrocadeAPIClient/version.rb +13 -0
- data/lib/BrocadeAPIClient/zones.rb +183 -0
- data/lib/brocade_api_client.rb +19 -0
- metadata +176 -0
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
task :console do
|
5
|
+
exec 'irb -r brocade_api_client -I ./lib'
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :build do
|
9
|
+
begin
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
13
|
+
puts '', 'RSpec Task started....'
|
14
|
+
t.pattern = Dir.glob('spec/**/*_spec.rb')
|
15
|
+
t.rspec_opts = '--format html --out test_reports/rspec_results.html'
|
16
|
+
t.fail_on_error = true
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: :spec
|
20
|
+
rescue LoadError => e
|
21
|
+
# no rspec available
|
22
|
+
puts "(#{e.message})"
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'rubocop/rake_task'
|
27
|
+
desc 'Run RuboCop - Ruby static code analyzer'
|
28
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
29
|
+
puts '', 'Rubocop Task started....'
|
30
|
+
# task.patterns = ['lib/**/*.rb']
|
31
|
+
task.fail_on_error = false
|
32
|
+
task.formatters = ['simple']
|
33
|
+
task.options = ['--out', 'rubocop_report.txt']
|
34
|
+
end
|
35
|
+
rescue LoadError => e
|
36
|
+
puts "(#{e.message})"
|
37
|
+
end
|
38
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'brocadeapi_client'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
#
|
6
|
+
# Unless required by applicable law or agreed to in writing,
|
7
|
+
# software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
10
|
+
# specific language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
lib = File.expand_path('lib', __dir__)
|
13
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
14
|
+
require 'BrocadeAPIClient/version'
|
15
|
+
|
16
|
+
Gem::Specification.new do |spec|
|
17
|
+
spec.name = 'brocade_api_client'
|
18
|
+
spec.version = BrocadeAPIClient::VERSION
|
19
|
+
spec.authors = ['raldi87']
|
20
|
+
spec.email = ['dima.radu.lucian@gmail.com']
|
21
|
+
|
22
|
+
spec.summary = 'Brocade Network Advisor REST API Client'
|
23
|
+
spec.description = 'This gem is used query to Brocade Network Advisor via API'
|
24
|
+
spec.homepage = 'https://github.com/raldi87/brocadeapi_client'
|
25
|
+
spec.license = 'Apache-2.0'
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The git ls-files -z
|
29
|
+
# loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.required_ruby_version = '~> 2.3.0'
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
39
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
40
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
+
spec.add_development_dependency 'rubocop', '~> 0.66'
|
42
|
+
spec.add_development_dependency 'sinatra', '~> 2.0', '>= 2.0.3'
|
43
|
+
spec.add_development_dependency 'webmock', '~> 3.5', '>= 3.5.1'
|
44
|
+
spec.add_runtime_dependency 'httparty', '~> 0.16.4'
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
4
|
+
#
|
5
|
+
# Unless required by applicable law or agreed to in writing,
|
6
|
+
# software distributed
|
7
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
8
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
9
|
+
# specific language governing permissions and limitations under the License.
|
10
|
+
require_relative 'exceptions'
|
11
|
+
module BrocadeAPIClient
|
12
|
+
# Class for checking supported API versions
|
13
|
+
class APIVersion
|
14
|
+
attr_accessor :major, :minor, :patch
|
15
|
+
include Comparable
|
16
|
+
def initialize(major, minor, patch)
|
17
|
+
@major = major
|
18
|
+
@minor = minor
|
19
|
+
@patch = patch
|
20
|
+
end
|
21
|
+
|
22
|
+
def <=>(other)
|
23
|
+
return -1 if major < other.major
|
24
|
+
return 1 if major > other.major
|
25
|
+
return -1 if minor < other.minor
|
26
|
+
return 1 if minor > other.minor
|
27
|
+
return -1 if patch < other.patch
|
28
|
+
return 1 if patch > other.patch
|
29
|
+
|
30
|
+
0
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.validate(version)
|
34
|
+
raise BrocadeAPIClient::InvalidVersion if version.length != 3
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parser(version)
|
38
|
+
version_array = version.split('.')
|
39
|
+
validate(version_array)
|
40
|
+
@major = version_array[0].to_i
|
41
|
+
@minor = version_array[1].to_i
|
42
|
+
@patch = version_array[2].to_i
|
43
|
+
obj_v = APIVersion.new(@major, @minor, @patch)
|
44
|
+
obj_v
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,533 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
4
|
+
#
|
5
|
+
# Unless required by applicable law or agreed to in writing,
|
6
|
+
# software distributed
|
7
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
8
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
9
|
+
# specific language governing permissions and limitations under the License.
|
10
|
+
require_relative 'httpclient'
|
11
|
+
require_relative 'fabrics'
|
12
|
+
require_relative 'switches'
|
13
|
+
require_relative 'ports'
|
14
|
+
require_relative 'zones'
|
15
|
+
require_relative 'exceptions'
|
16
|
+
require_relative 'apiversion'
|
17
|
+
require_relative 'static'
|
18
|
+
require_relative 'events'
|
19
|
+
|
20
|
+
module BrocadeAPIClient
|
21
|
+
# Class for connecting to BNA
|
22
|
+
class Client
|
23
|
+
@http = nil
|
24
|
+
attr_reader :http, :logger
|
25
|
+
def initialize(api_url, debug: false, secure: false, app_type: 'ruby_brocade', enable_logger: nil, log_file_path: nil)
|
26
|
+
unless api_url.is_a?(String)
|
27
|
+
raise BrocadeAPIClient::BrocadeException.new(nil,
|
28
|
+
"'api_url' parameter is mandatory and should be of type String")
|
29
|
+
end
|
30
|
+
@api_url = api_url
|
31
|
+
@debug = debug
|
32
|
+
@secure = secure
|
33
|
+
@log_level = Logger::INFO
|
34
|
+
@enable_logger = enable_logger
|
35
|
+
@client_logger = nil
|
36
|
+
@log_file_path = log_file_path
|
37
|
+
init_log
|
38
|
+
@http = JSONRestClient.new(
|
39
|
+
@api_url, @secure, @debug,
|
40
|
+
@client_logger
|
41
|
+
)
|
42
|
+
@fabrics = Fabrics.new(@http)
|
43
|
+
@switches = Switches.new(@http)
|
44
|
+
@ports = Ports.new(@http)
|
45
|
+
@zones = Zones.new(@http)
|
46
|
+
@events = Events.new(@http)
|
47
|
+
@app_type = app_type
|
48
|
+
@peer_zone_support = false
|
49
|
+
end
|
50
|
+
|
51
|
+
def login(username, password, options = nil)
|
52
|
+
# Authenticate on the Brocade Network Advisor API
|
53
|
+
login_info = @http.authenticate(username, password, options)
|
54
|
+
api_v = APIVersion.parser(login_info['version'])
|
55
|
+
min_api_version = APIVersion.parser(BrocadeAPIClient::BNASupport::BNA_MIN_SUPPORTED)
|
56
|
+
min_peerzoning_version = APIVersion.parser(BrocadeAPIClient::BNASupport::BNA_PEER_ZONING_TDZ_MIN_SUPPORTED)
|
57
|
+
raise BrocadeAPIClient::UnsupportedVersion if api_v < min_api_version
|
58
|
+
|
59
|
+
@peer_zone_support = true if api_v >= min_peerzoning_version
|
60
|
+
end
|
61
|
+
|
62
|
+
def logout
|
63
|
+
# Delete Session on REST API
|
64
|
+
@http.unauthenticate
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get All networks
|
68
|
+
#
|
69
|
+
#
|
70
|
+
# ==== Returns
|
71
|
+
# Hash with value as
|
72
|
+
# Array of Networks (FC + IP)
|
73
|
+
def resourcegroups
|
74
|
+
result = @http.get('/resourcegroups')
|
75
|
+
result[1]
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get All FC Fabrics
|
79
|
+
#
|
80
|
+
#
|
81
|
+
# ==== Returns
|
82
|
+
# Hash with value as
|
83
|
+
# Array of Fabrics - Details of the ALL fabrics
|
84
|
+
def fabrics
|
85
|
+
# API GET for fabrics
|
86
|
+
result = @fabrics.fabrics
|
87
|
+
result[1]
|
88
|
+
end
|
89
|
+
|
90
|
+
# Get FC Fabric Information based on Fabric ID
|
91
|
+
#
|
92
|
+
# fabricID = string containing fabricID , ex '10:00:00:00:00:00'
|
93
|
+
# ==== Returns
|
94
|
+
#
|
95
|
+
# Hash - Details of the specified fabric
|
96
|
+
def fabric(fabricid)
|
97
|
+
result = @fabrics.fabric(fabricid)
|
98
|
+
result[1]
|
99
|
+
end
|
100
|
+
|
101
|
+
# Get FC switches members of a specific Fabric ID
|
102
|
+
#
|
103
|
+
# fabricID = string containing fabricID , ex '10:00:00:00:00:00'
|
104
|
+
# ==== Returns
|
105
|
+
#
|
106
|
+
# Hash - with Value Array with all the switches part of fabricID
|
107
|
+
def fabricswitches(fabricid)
|
108
|
+
result = @switches.fabricswitches(fabricid)
|
109
|
+
result[1]
|
110
|
+
end
|
111
|
+
|
112
|
+
# Get ALL FC Swiches in the Brocade Network Advisor
|
113
|
+
#
|
114
|
+
#
|
115
|
+
# ==== Returns
|
116
|
+
#
|
117
|
+
# Hash - Key fcswitches and Value of all the switches in BNA
|
118
|
+
def allswitches
|
119
|
+
result = @switches.allswitches
|
120
|
+
result[1]
|
121
|
+
end
|
122
|
+
|
123
|
+
# Get ALL FC Ports in the Brocade Network Advisor
|
124
|
+
#
|
125
|
+
#
|
126
|
+
# ==== Returns
|
127
|
+
#
|
128
|
+
# Hash - Key fcports , Value of all the ports in BNA
|
129
|
+
def allports
|
130
|
+
result = @ports.allports
|
131
|
+
result[1]
|
132
|
+
end
|
133
|
+
|
134
|
+
# Change port states for on FC switch(non-persistent)
|
135
|
+
# Input:
|
136
|
+
# switchWWN - switch WWN (it can be retrived using the Switches method)
|
137
|
+
# portWWNs - Multiple PortWWN in the same switch that should be changed
|
138
|
+
# state - 'disabled|enable'
|
139
|
+
#
|
140
|
+
# ==== Returns
|
141
|
+
#
|
142
|
+
# Hash - Key fcPortStateChangeResponseEntry , Value Array of Hashes with all ports changed
|
143
|
+
def change_portstates(switchwwn, state, *portwwns)
|
144
|
+
result = @ports.change_portstates(switchwwn, state, *portwwns)
|
145
|
+
result[1]
|
146
|
+
end
|
147
|
+
|
148
|
+
# Change port states for on FC switch(persistent)
|
149
|
+
# Input:
|
150
|
+
# switchWWN - switch WWN (it can be retrived using the Switches method)
|
151
|
+
# portWWNs - Multiple PortWWN in same switch that should be changed
|
152
|
+
# state - 'disabled|enable'
|
153
|
+
#
|
154
|
+
# ==== Returns
|
155
|
+
#
|
156
|
+
# Hash - Key fcPortStateChangeResponseEntry , Value Array of Hashes with all ports changed
|
157
|
+
def change_persistentportstates(switchwwn, state, *portwwns)
|
158
|
+
result = @ports.change_persistentportstates(switchwwn, state, *portwwns)
|
159
|
+
result[1]
|
160
|
+
end
|
161
|
+
|
162
|
+
# Set Port Name for a specified port
|
163
|
+
# Input:
|
164
|
+
# the resource method(ussualy the of the Fabric)
|
165
|
+
# switchWWN - switch WWN (it can be retrived using the Switches method)
|
166
|
+
# portWWN - Port WWN
|
167
|
+
# portNames - the name for the PortName
|
168
|
+
#
|
169
|
+
# ==== Returns
|
170
|
+
#
|
171
|
+
# Hash - Key fcPortStateChangeResponseEntry , Value Array of Hashes with all ports changed
|
172
|
+
def set_portname(switchwwn, portwwns, portname)
|
173
|
+
result = @ports.set_portname(switchwwn, portwwns, portname)
|
174
|
+
result[1]
|
175
|
+
end
|
176
|
+
|
177
|
+
# Get all Zones in a Fabric(both active and defined)
|
178
|
+
# Input:
|
179
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
180
|
+
#
|
181
|
+
# ==== Returns
|
182
|
+
#
|
183
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
184
|
+
def zoneshow_all(fabrickey)
|
185
|
+
result = @zones.zoneshow(fabrickey, 'all')
|
186
|
+
result[1]
|
187
|
+
end
|
188
|
+
|
189
|
+
# Get all Zones in a Fabric(active)
|
190
|
+
# Input:
|
191
|
+
# fabrickey - fabric key WWN(it can be retrived
|
192
|
+
# using the fabrics methond
|
193
|
+
#
|
194
|
+
# ==== Returns
|
195
|
+
#
|
196
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
197
|
+
def zoneshow_all_active(fabrickey)
|
198
|
+
result = @zones.zoneshow(fabrickey, 'active')
|
199
|
+
result[1]
|
200
|
+
end
|
201
|
+
|
202
|
+
# Get all Zones in a Fabric( defined)
|
203
|
+
# Input:
|
204
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
205
|
+
#
|
206
|
+
# ==== Returns
|
207
|
+
#
|
208
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
209
|
+
def zoneshow_all_defined(fabrickey)
|
210
|
+
result = @zones.zoneshow(fabrickey, 'defined')
|
211
|
+
result[1]
|
212
|
+
end
|
213
|
+
|
214
|
+
# Get INFO about active zone in a Fabric( defined)
|
215
|
+
# Input:
|
216
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
217
|
+
# zonename - string containing the zone name
|
218
|
+
# ==== Returns
|
219
|
+
#
|
220
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
221
|
+
def zoneshow_active(fabrickey, zonename)
|
222
|
+
result = @zones.zoneshow(fabrickey, 'active', zonename)
|
223
|
+
result[1]
|
224
|
+
end
|
225
|
+
|
226
|
+
# Get INFO about a defined zone in a Fabric( defined)
|
227
|
+
# Input:
|
228
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
229
|
+
# zonename - string containing the zone name
|
230
|
+
# ==== Returns
|
231
|
+
#
|
232
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
233
|
+
def zoneshow_defined(fabrickey, zonename)
|
234
|
+
result = @zones.zoneshow(fabrickey, 'defined', zonename)
|
235
|
+
result[1]
|
236
|
+
end
|
237
|
+
|
238
|
+
# Create standard zone
|
239
|
+
# Input:
|
240
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
241
|
+
# zonename - string containing the zone name
|
242
|
+
# *aliases - list of aliases to be added in the zone
|
243
|
+
# ==== Returns
|
244
|
+
#
|
245
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
246
|
+
def zonecreate_standard(fabrickey, zonename, *aliases)
|
247
|
+
result = @zones.zonecreate_standard(fabrickey, zonename, *aliases)
|
248
|
+
result[1]
|
249
|
+
end
|
250
|
+
|
251
|
+
# Create Peerzone
|
252
|
+
# Input:
|
253
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
254
|
+
# zonename - string containing the zone name
|
255
|
+
# *aliases - list of aliases to be added in the zone
|
256
|
+
# ==== Returns
|
257
|
+
#
|
258
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
259
|
+
def zonecreate_peerzone(fabrickey, zonename, **members)
|
260
|
+
raise BrocadeAPIClient::UnsupportedVersion unless @peer_zone_support
|
261
|
+
|
262
|
+
result = @zones.zonecreate_peerzone(fabrickey, zonename, **members)
|
263
|
+
result[1]
|
264
|
+
end
|
265
|
+
|
266
|
+
# Delete Zones from defined configuration
|
267
|
+
# Input:
|
268
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
269
|
+
# *zonenames - a list of zones to be delete
|
270
|
+
# ==== Returns
|
271
|
+
#
|
272
|
+
# status of request
|
273
|
+
def zonedelete(fabrickey, *zonenames)
|
274
|
+
result = @zones.zonedelete(fabrickey, *zonenames)
|
275
|
+
result[1]
|
276
|
+
end
|
277
|
+
|
278
|
+
# Add aliases to standard zone
|
279
|
+
# Input:
|
280
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
281
|
+
# *aliasnames - a list of zones to be delete
|
282
|
+
# ==== Returns
|
283
|
+
#
|
284
|
+
# status of request
|
285
|
+
def zoneadd_standard(fabrickey, zonename, *aliases)
|
286
|
+
result = @zones.alterzoning_standard(fabrickey, 'ADD', zonename, *aliases)
|
287
|
+
result[1]
|
288
|
+
end
|
289
|
+
|
290
|
+
# Add aliases to standard zone
|
291
|
+
# Input:
|
292
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
293
|
+
# *aliasnames - a list of zones to be delete
|
294
|
+
# ==== Returns
|
295
|
+
#
|
296
|
+
# status of request
|
297
|
+
def zoneremove_standard(fabrickey, zonename, *aliases)
|
298
|
+
result = @zones.alterzoning_standard(fabrickey, 'REMOVE', zonename, *aliases)
|
299
|
+
result[1]
|
300
|
+
end
|
301
|
+
|
302
|
+
# Add aliases to standard zone
|
303
|
+
# Input:
|
304
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
305
|
+
# **wwns - hash with principal and members as keys and values as an array of wwns
|
306
|
+
# ==== Returns
|
307
|
+
#
|
308
|
+
# status of request
|
309
|
+
def zoneadd_peerzone(fabrickey, zonename, **wwns)
|
310
|
+
result = @zones.alterzoning_peerzone(fabrickey, 'ADD', zonename, **wwns)
|
311
|
+
result[1]
|
312
|
+
end
|
313
|
+
|
314
|
+
# Remove members/principal from peerzone
|
315
|
+
# Input:
|
316
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
317
|
+
# **wwns - hash with principal and members as keys and values as an array of wwns
|
318
|
+
# ==== Returns
|
319
|
+
#
|
320
|
+
# status of request
|
321
|
+
def zoneremove_peerzone(fabrickey, zonename, **wwns)
|
322
|
+
result = @zones.alterzoning_peerzone(fabrickey, 'REMOVE', zonename, **wwns)
|
323
|
+
result[1]
|
324
|
+
end
|
325
|
+
|
326
|
+
# Get Zone DB in a fabric(active and defined)
|
327
|
+
# Input:
|
328
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
329
|
+
#
|
330
|
+
# ==== Returns
|
331
|
+
#
|
332
|
+
# Hash - Key zones , Value Array of Hashes with all zones
|
333
|
+
def zonedbs(fabrickey)
|
334
|
+
result = @zones.zonedbs(fabrickey)
|
335
|
+
result[1]
|
336
|
+
end
|
337
|
+
|
338
|
+
# Get Zone Aliases in a fabric
|
339
|
+
# Input:
|
340
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
341
|
+
#
|
342
|
+
# ==== Returns
|
343
|
+
#
|
344
|
+
# Hash - Key zoneAliases , Value Array of Hashes with all aliases
|
345
|
+
def alishow(fabrickey, zakey = 'none')
|
346
|
+
result = @zones.alishow(fabrickey, zakey)
|
347
|
+
result[1]
|
348
|
+
end
|
349
|
+
|
350
|
+
# Get Fabric configuration
|
351
|
+
# Input:
|
352
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
353
|
+
#
|
354
|
+
# ==== Returns
|
355
|
+
#
|
356
|
+
# Hash - Key zoneAliases , Value Array of Hashes with all aliases
|
357
|
+
def cfgshow(fabrickey, type)
|
358
|
+
result = @zones.cfgshow(fabrickey, type)
|
359
|
+
result[1]
|
360
|
+
end
|
361
|
+
|
362
|
+
# Add zones to defined configuration
|
363
|
+
# Input:
|
364
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
365
|
+
# cfgname - Fabric configuration name to which to add the zones
|
366
|
+
# zonenames - list of zones to be added to the cfg
|
367
|
+
# ==== Returns
|
368
|
+
#
|
369
|
+
# Status of request
|
370
|
+
def cfgadd(fabrickey, cfgname, *zonenames)
|
371
|
+
result = @zones.altercfg(fabrickey, 'ADD', cfgname, *zonenames)
|
372
|
+
result[1]
|
373
|
+
end
|
374
|
+
|
375
|
+
# Remove zones to defined configuration
|
376
|
+
# Input:
|
377
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
378
|
+
# cfgname - Fabric configuration name from which to remove the zones
|
379
|
+
# zonenames - list of zones to be removed to the cfg
|
380
|
+
# ==== Returns
|
381
|
+
#
|
382
|
+
# Status of request
|
383
|
+
def cfgremove(fabrickey, cfgname, *zonenames)
|
384
|
+
result = @zones.altercfg(fabrickey, 'REMOVE', cfgname, *zonenames)
|
385
|
+
result[1]
|
386
|
+
end
|
387
|
+
|
388
|
+
# Enable defined zoning by configuration by name
|
389
|
+
# Input:
|
390
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
391
|
+
# cfgname - Fabric configuration name from which to remove the zones
|
392
|
+
# ==== Returns
|
393
|
+
#
|
394
|
+
# Status of request
|
395
|
+
def cfgenable(fabrickey, cfgname)
|
396
|
+
result = @zones.cfgenable(fabrickey, cfgname)
|
397
|
+
result[1]
|
398
|
+
end
|
399
|
+
|
400
|
+
# Create Zone Aliases in a fabric
|
401
|
+
# Input:
|
402
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
403
|
+
# aliname - name for new alias
|
404
|
+
# wwn - to be added to aliname , it supports multiple wwns separated by comma
|
405
|
+
# ==== Returns
|
406
|
+
#
|
407
|
+
# Status of request
|
408
|
+
def alicreate(fabrickey, aliname, *wwn)
|
409
|
+
result = @zones.alicreate(fabrickey, aliname, *wwn)
|
410
|
+
result[1]
|
411
|
+
end
|
412
|
+
|
413
|
+
# Add wwn to existing Alias
|
414
|
+
# Input:
|
415
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
416
|
+
# aliname - name for new alias
|
417
|
+
# wwn - to be added to aliname , it supports multiple wwns separated by comma
|
418
|
+
# ==== Returns
|
419
|
+
#
|
420
|
+
# Status of request
|
421
|
+
def aliadd(fabrickey, aliname, *wwn)
|
422
|
+
result = @zones.alteralias(fabrickey, 'ADD', aliname, *wwn)
|
423
|
+
result[1]
|
424
|
+
end
|
425
|
+
|
426
|
+
# Remove wwn to existing Alias
|
427
|
+
# Input:
|
428
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
429
|
+
# aliname - name for new alias
|
430
|
+
# wwn - to be added to aliname , it supports multiple wwns separated by comma
|
431
|
+
# ==== Returns
|
432
|
+
#
|
433
|
+
# Status of request
|
434
|
+
def aliremove(fabrickey, aliname, *wwn)
|
435
|
+
result = @zones.alteralias(fabrickey, 'REMOVE', aliname, *wwn)
|
436
|
+
result[1]
|
437
|
+
end
|
438
|
+
|
439
|
+
# Delete Aliases in defined Fabric
|
440
|
+
# Input:
|
441
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
442
|
+
# alinames - list of aliases to be delete
|
443
|
+
# ==== Returns
|
444
|
+
#
|
445
|
+
# Status of request
|
446
|
+
def alidelete(fabrickey, *alinames)
|
447
|
+
result = @zones.alidelete(fabrickey, *alinames)
|
448
|
+
result[1]
|
449
|
+
end
|
450
|
+
|
451
|
+
# Start Fabric transaction
|
452
|
+
# Input:
|
453
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
454
|
+
#
|
455
|
+
# ==== Returns
|
456
|
+
# Status of request
|
457
|
+
def trans_start(fabrickey)
|
458
|
+
result = @zones.control_transaction(fabrickey, 'start')
|
459
|
+
result[1]
|
460
|
+
end
|
461
|
+
|
462
|
+
# Commit Fabric transaction
|
463
|
+
# Input:
|
464
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
465
|
+
#
|
466
|
+
# ==== Returns
|
467
|
+
# Status of request
|
468
|
+
def trans_commit(fabrickey)
|
469
|
+
result = @zones.control_transaction(fabrickey, 'commit')
|
470
|
+
result[1]
|
471
|
+
end
|
472
|
+
|
473
|
+
# Abort Fabric transaction
|
474
|
+
# Input:
|
475
|
+
# fabrickey - fabric key WWN(it can be retrived using the fabrics methond
|
476
|
+
#
|
477
|
+
# ==== Returns
|
478
|
+
# Status of request
|
479
|
+
def trans_abort(fabrickey)
|
480
|
+
result = @zones.control_transaction(fabrickey, 'abort')
|
481
|
+
result[1]
|
482
|
+
end
|
483
|
+
|
484
|
+
# Get syslog events
|
485
|
+
# Input:
|
486
|
+
# count - String value to retrive the number of last events
|
487
|
+
#
|
488
|
+
# ==== Returns
|
489
|
+
# Status of request
|
490
|
+
def syslog_events(count)
|
491
|
+
result = @events.syslog_events(count)
|
492
|
+
result[1]
|
493
|
+
end
|
494
|
+
|
495
|
+
# Get trap events
|
496
|
+
# Input:
|
497
|
+
# count - String value to retrive the number of last events
|
498
|
+
#
|
499
|
+
# ==== Returns
|
500
|
+
# Status of request
|
501
|
+
def trap_events(count)
|
502
|
+
result = @events.trap_events(count)
|
503
|
+
result[1]
|
504
|
+
end
|
505
|
+
|
506
|
+
# Get custom events based on params
|
507
|
+
# Input:
|
508
|
+
# count - String value to retrive the number of last events
|
509
|
+
#
|
510
|
+
# ==== Returns
|
511
|
+
# Status of request
|
512
|
+
def custom_events(startindex = '0', count = '10', origin = 'syslog', severity = 'INFO')
|
513
|
+
result = @events.custom_events(startindex, count, origin, severity)
|
514
|
+
result[1]
|
515
|
+
end
|
516
|
+
|
517
|
+
private
|
518
|
+
|
519
|
+
def init_log
|
520
|
+
# Create Logger
|
521
|
+
@client_logger = if @enable_logger
|
522
|
+
if @log_file_path.nil?
|
523
|
+
Logger.new(STDOUT)
|
524
|
+
else
|
525
|
+
Logger.new(@log_file_path, 'daily')
|
526
|
+
end
|
527
|
+
else @enable_logger = false
|
528
|
+
end
|
529
|
+
|
530
|
+
@log_level = Logger::DEBUG if @debug
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|