Class: Brocade::SAN::Wwn

Inherits:
Object
  • Object
show all
Defined in:
lib/brocadesan/wwn.rb

Overview

Wwn model

Constant Summary collapse

VALUE_RULE =

value naming rule value ca be only WWN

50:00:10:20:30:40:50:60

'([\da-f]{2}:){7}[\da-f]{2}'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, dev_type, domain_id, port_index, opts = {}) ⇒ Wwn

init method

opts => :symbol => “text” - device description



49
50
51
52
53
54
55
56
# File 'lib/brocadesan/wwn.rb', line 49

def initialize(value,dev_type,domain_id,port_index,opts={}) # :nodoc:
  Wwn::verify_value(value)
  @value=value 
  @dev_type=dev_type
  @domain_id=domain_id.to_i
  @port_index=port_index.to_i
  @symbol= !opts[:symbol].nil? ? opts[:symbol] : ""
end

Instance Attribute Details

#dev_typeObject (readonly)

device type - usualy target or initiator



14
15
16
# File 'lib/brocadesan/wwn.rb', line 14

def dev_type
  @dev_type
end

#domain_idObject (readonly)

domain of switch where wwn is online

domain of 0 means the switch does not have any domain id



24
25
26
# File 'lib/brocadesan/wwn.rb', line 24

def domain_id
  @domain_id
end

#port_indexObject (readonly)

port index where wwn is located



18
19
20
# File 'lib/brocadesan/wwn.rb', line 18

def port_index
  @port_index
end

#symbolObject (readonly)

description of WWN is provided by device itself



10
11
12
# File 'lib/brocadesan/wwn.rb', line 10

def symbol
  @symbol
end

#valueObject (readonly)

returns value of the WWN



6
7
8
# File 'lib/brocadesan/wwn.rb', line 6

def value
  @value
end

Class Method Details

.verify_value(str) ⇒ Object

verifies if str matches convetion defined in Wwn::VALUE_RULE raises Switch::Error: Incorrect value format if not this method is used internally mostly

Raises:



37
38
39
# File 'lib/brocadesan/wwn.rb', line 37

def self.verify_value(str)
  raise Switch::Error.new("Incorrect value format \"#{str}\"") if !str.match(/#{VALUE_RULE}/i)
end

Instance Method Details

#nameObject

shadows value



42
43
44
# File 'lib/brocadesan/wwn.rb', line 42

def name
  @value
end

#to_sObject



58
59
60
# File 'lib/brocadesan/wwn.rb', line 58

def to_s
  @value
end