Class: BrocadeAPIClient::Ports
- Inherits:
-
Object
- Object
- BrocadeAPIClient::Ports
- Defined in:
- lib/BrocadeAPIClient/ports.rb
Overview
Ports REST API Methods
Instance Method Summary collapse
- #allports ⇒ Object
- #change_persistentportstates(switchwwn, state, *portwwns) ⇒ Object
- #change_portstates(switchwwn, state, *portwwns) ⇒ Object
-
#initialize(http_client) ⇒ Ports
constructor
A new instance of Ports.
- #set_portname(switchwwn, portwwn, portname) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ Ports
Returns a new instance of Ports.
13 14 15 16 |
# File 'lib/BrocadeAPIClient/ports.rb', line 13 def initialize(http_client) @http_client = http_client @base_url = '/resourcegroups/All' end |
Instance Method Details
#allports ⇒ Object
18 19 20 21 |
# File 'lib/BrocadeAPIClient/ports.rb', line 18 def allports api_url = @base_url + '/fcports' _response, _body = @http_client.get(api_url) end |
#change_persistentportstates(switchwwn, state, *portwwns) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/BrocadeAPIClient/ports.rb', line 32 def change_persistentportstates(switchwwn, state, *portwwns) payload = {} api_url = @base_url + '/fcswitches/' + switchwwn.upcase + '/fcports/fcportpersistentstate' portwwns.map!(&:upcase) payload['fcPortState'] = state payload['fcPortWWNs'] = portwwns _response, _body = @http_client.post(api_url, body: payload) end |
#change_portstates(switchwwn, state, *portwwns) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/BrocadeAPIClient/ports.rb', line 23 def change_portstates(switchwwn, state, *portwwns) payload = {} portwwns.map!(&:upcase) api_url = @base_url + '/fcswitches/' + switchwwn.upcase + '/fcports/fcportstate' payload['fcPortState'] = state payload['fcPortWWNs'] = portwwns _response, _body = @http_client.post(api_url, body: payload) end |
#set_portname(switchwwn, portwwn, portname) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/BrocadeAPIClient/ports.rb', line 41 def set_portname(switchwwn, portwwn, portname) porthash = {} portarray = [] api_url = @base_url + '/fcswitches/' + switchwwn.upcase + '/fcports/fcportnames' porthash['fcPortWWN'] = portwwn.upcase porthash['fcPortName'] = portname portarray.push(porthash) payload = { 'fcPortNameChangeReqEntry' => portarray } _response, _body = @http_client.post(api_url, body: payload) end |