Class: Hpe3parSdk::PortManager

Inherits:
Object
  • Object
show all
Defined in:
lib/Hpe3parSdk/port_manager.rb

Overview

Port Manager Rest API methods

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ PortManager

Returns a new instance of PortManager.



19
20
21
22
# File 'lib/Hpe3parSdk/port_manager.rb', line 19

def initialize(http)
  @http = http
  @ports_uri = '/ports'
end

Instance Method Details

#get_fc_ports(state) ⇒ Object



33
34
35
# File 'lib/Hpe3parSdk/port_manager.rb', line 33

def get_fc_ports(state)
  get_protocol_ports(PortProtocol::FC, state)
end

#get_ip_ports(state) ⇒ Object



41
42
43
# File 'lib/Hpe3parSdk/port_manager.rb', line 41

def get_ip_ports(state)
  get_protocol_ports(PortProtocol::IP, state)
end

#get_iscsi_ports(state) ⇒ Object



37
38
39
# File 'lib/Hpe3parSdk/port_manager.rb', line 37

def get_iscsi_ports(state)
  get_protocol_ports(PortProtocol::ISCSI, state)
end

#get_portsObject



24
25
26
27
28
29
30
31
# File 'lib/Hpe3parSdk/port_manager.rb', line 24

def get_ports
  ports_list = []
  response = @http.get(@ports_uri)
  response[1]['members'].each do |port|
      ports_list.push(Port.new(port))
  end
  ports_list
end

#get_protocol_ports(protocol, state = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/Hpe3parSdk/port_manager.rb', line 45

def get_protocol_ports(protocol, state = nil)
  return_ports = []
  ports = get_ports
  if ports
    ports.each do |port|
      if port.protocol == protocol
        if state.nil?
          return_ports.push(port)
        elsif port.linkState == state
          return_ports.push(port)
        end
      end
    end
  end
  return_ports
end