Class: Brocade::SAN::Alias

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

Overview

Alias model

Constant Summary collapse

MEMBER_RULE =

alias member naming rule (regular expresion)

member can be WWN or Domain,Index port notation

allowed examples:

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

2,61

'([\da-f]{2}:){7}[\da-f]{2}|\d{1,3},\d{1,3}'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Alias

inititialize new alias with name

opts reserved for future use



23
24
25
26
27
28
# File 'lib/brocadesan/alias.rb', line 23

def initialize(name,opts={})
  # checked against alias name rule - not alias member
  Switch::verify_name(name)
  @name=name 
  @members=[]
end

Instance Attribute Details

#nameObject (readonly)

returns name of the alias



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

def name
  @name
end

Class Method Details

.verify_member_name(str) ⇒ Object

verifies if str matches convetion defined in Alias::MEMBER_RULE

raises Switch::Error: Incorrect name format “str” if not

this method is used mostly internally



55
56
57
# File 'lib/brocadesan/alias.rb', line 55

def self.verify_member_name(str)
  raise Switch::Error.incorrect(str) if !str.match(/#{MEMBER_RULE}/i)
end

Instance Method Details

#add_member(member) ⇒ Object

add new member to the alias

members of aliases are WWNs or Domain,Index port notation

member is name of the zone

return all members, otherwises raises error



44
45
46
47
# File 'lib/brocadesan/alias.rb', line 44

def add_member(member)
  Alias::verify_member_name(member)
  @members<<member
end

#membersObject

returns array of members



32
33
34
# File 'lib/brocadesan/alias.rb', line 32

def members
  @members
end

#to_sObject



59
60
61
# File 'lib/brocadesan/alias.rb', line 59

def to_s
  @name
end