class BrocadeAPIClient::Zones
Zones
REST API Methods
Public Class Methods
new(http_client)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 15 def initialize(http_client) @http_client = http_client @base_url = '/resourcegroups/All/fcfabrics/' end
Public Instance Methods
alicreate(fabrickey, aliname, *wwn)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 63 def alicreate(fabrickey, aliname, *wwn) wwn.map!(&:upcase) api_url = @base_url + fabrickey.upcase + '/createzoningobject' alihash ||= { name: aliname, memberNames: wwn } (aliarray ||= []) << alihash payload ||= { zoneAliases: aliarray } _response, _body = @http_client.post(api_url, body: payload) end
alidelete(fabrickey, *alinames)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 105 def alidelete(fabrickey, *alinames) api_url = @base_url + fabrickey.upcase + '/deletezoningobject' payload ||= { zoneAliasNames: alinames } _response, _body = @http_client.post(api_url, body: payload) end
alishow(fabrickey, zakey = 'none')
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 45 def alishow(fabrickey, zakey = 'none') api_url = @base_url + fabrickey.upcase + '/zonealiases' api_url += '/' + zakey unless zakey == 'none' _response, _body = @http_client.get(api_url) end
alteralias(fabrickey, action, aliname, *wwn)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 120 def alteralias(fabrickey, action, aliname, *wwn) api_url = @base_url + fabrickey.upcase + '/updatezoningobject' payload ||= { action: validate_answer(action) } wwn.map!(&:upcase) alihash ||= { name: aliname, memberNames: wwn } (aliarray ||= []) << alihash payload.store(:zoneAliases, aliarray) _response, _body = @http_client.post(api_url, body: payload) end
altercfg(fabrickey, action, cfgname, *zonenames)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 111 def altercfg(fabrickey, action, cfgname, *zonenames) api_url = @base_url + fabrickey.upcase + '/updatezoningobject' payload ||= { action: validate_answer(action) } cfghash ||= { name: cfgname, zoneNames: zonenames } (cfgarray ||= []) << cfghash payload.store(:zoneSets, cfgarray) _response, _body = @http_client.post(api_url, body: payload) end
alterzoning_peerzone(fabrickey, action, zonename, **wwn)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 139 def alterzoning_peerzone(fabrickey, action, zonename, **wwn) api_url = @base_url + fabrickey.upcase + '/updatezoningobject' peerdetails = {} peermembers = {} payload ||= { action: validate_answer(action) } case (wwn.keys & %i[principal members]).sort when %i[members principal] wwn[:members].map!(&:upcase) wwn[:principal].map!(&:upcase) peermembers = { peerMemberName: wwn[:members] } peerdetails = { principalMemberName: wwn[:principal] } when [:principal] wwn[:principal].map!(&:upcase) peerdetails = { principalMemberName: wwn[:principal] } when [:members] wwn[:members].map!(&:upcase) peermembers = { peerMemberName: wwn[:members] } else raise BrocadeAPIClient::InvalidPeerzoneOptions end peerdetails.store(:peerMembers, peermembers) zonedetails ||= { name: zonename, type: 'STANDARD', peerZone: 'True', peerZoneDetails: peerdetails } (zonearray ||= []) << zonedetails payload.store(:zones, zonearray) _response, _body = @http_client.post(api_url, body: payload) end
alterzoning_standard(fabrickey, action, zonename, *aliases)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 130 def alterzoning_standard(fabrickey, action, zonename, *aliases) api_url = @base_url + fabrickey.upcase + '/updatezoningobject' payload ||= { action: validate_answer(action) } zonehash ||= { name: zonename, aliasNames: aliases } (zonearray ||= []) << zonehash payload.store(:zones, zonearray) _response, _body = @http_client.post(api_url, body: payload) end
cfgenable(fabrickey, cfgname)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 166 def cfgenable(fabrickey, cfgname) api_url = @base_url + fabrickey.upcase + '/zonesets/' + cfgname + '-false/activate' payload = {} _response, _body = @http_client.post(api_url, body: payload) end
cfgshow(fabrickey, type)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 51 def cfgshow(fabrickey, type) api_url = @base_url + fabrickey.upcase + '/zonesets' if type == 'all' elsif type == 'active' api_url += '?active=true' elsif type == 'defined' api_url += '?active=false' else raise BrocadeAPIClient::UnsupportedOption end _response, _body = @http_client.get(api_url) end
control_transaction(fabrickey, action)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 72 def control_transaction(fabrickey, action) payload ||= { lsanZoning: 'false', action: action.upcase } api_url = @base_url + fabrickey.upcase + '/controlzonetransaction' _response, _body = @http_client.post(api_url, body: payload) end
zonecreate_peerzone(fabrickey, zonename, **members)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 87 def zonecreate_peerzone(fabrickey, zonename, **members) raise BrocadeAPIClient::InvalidPeerzoneOptions unless members.key?(:principal) && members.key?(:members) api_url = @base_url + fabrickey.upcase + '/createzoningobject' peermembers ||= { peerMemberName: members[:members] } peerdetails ||= { principalMemberName: members[:principal], peerMembers: peermembers } zonedetails ||= { name: zonename, type: 'STANDARD', peerZone: 'True', peerZoneDetails: peerdetails } (zonearray ||= []) << zonedetails payload ||= { zones: zonearray } _response, _body = @http_client.post(api_url, body: payload) end
zonecreate_standard(fabrickey, zonename, *aliases)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 78 def zonecreate_standard(fabrickey, zonename, *aliases) api_url = @base_url + fabrickey.upcase + '/createzoningobject' zonearray = [] zonehash ||= { name: zonename, aliasNames: aliases, type: 'STANDARD' } (zonearray ||= []) << zonehash payload ||= { zones: zonearray } _response, _body = @http_client.post(api_url, body: payload) end
zonedbs(fabrickey)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 40 def zonedbs(fabrickey) api_url = @base_url + fabrickey.upcase + '/zonedbs' _response, _body = @http_client.get(api_url) end
zonedelete(fabrickey, *zonenames)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 99 def zonedelete(fabrickey, *zonenames) api_url = @base_url + fabrickey.upcase + '/deletezoningobject' payload ||= { zoneNames: zonenames } _response, _body = @http_client.post(api_url, body: payload) end
zoneshow(fabrickey, zones = 'all', zkey = 'none')
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 20 def zoneshow(fabrickey, zones = 'all', zkey = 'none') api_url = @base_url + fabrickey.upcase + '/zones' if zones == 'all' elsif zones == 'active' api_url += if zkey == 'none' '?active=true' else '/' + zkey + '-true' end elsif zones == 'defined' api_url += if zkey == 'none' '?active=false' else '/' + zkey + '-false' end else err_msg = 'Unsupported Zoning Option, supported ALL is without zonename' raise BrocadeAPIClient::UnsupportedOption end _response, _body = @http_client.get(api_url) end
Private Instance Methods
validate_answer(action)
click to toggle source
# File lib/BrocadeAPIClient/zones.rb, line 174 def validate_answer(action) case action.upcase when 'ADD', 'REMOVE' action.upcase else raise BrocadeAPIClient::UnsupportedAction end end