Class: IscsiadmWrapper::Portal

Inherits:
Object
  • Object
show all
Defined in:
lib/iscsiadm/portal.rb

Constant Summary collapse

DEFAULT_TYPE =
'sendtargets'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Portal

Instance Methods



27
28
29
30
31
32
# File 'lib/iscsiadm/portal.rb', line 27

def initialize(args = {})
  @ip = args[:ip] 
  @port = args[:port]
  @interface = args[:interface]
  @type = args[:type]
end

Instance Attribute Details

#interfaceObject (readonly)

Returns the value of attribute interface.



5
6
7
# File 'lib/iscsiadm/portal.rb', line 5

def interface
  @interface
end

#ipObject (readonly)

Returns the value of attribute ip.



5
6
7
# File 'lib/iscsiadm/portal.rb', line 5

def ip
  @ip
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/iscsiadm/portal.rb', line 5

def port
  @port
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/iscsiadm/portal.rb', line 5

def type
  @type
end

Class Method Details

.parse(portal, type = DEFAULT_TYPE) ⇒ Object

Takes the typical portal string from iscsiadm and the type and returns a new Portal object.

eg Portal.parse(‘20.20.20.20:3260,1’,‘sendtargets’)

XXX: whats the trailing ,1 again..?



18
19
20
21
22
# File 'lib/iscsiadm/portal.rb', line 18

def parse(portal,type=DEFAULT_TYPE)
  if portal =~ %r{^(.*):(\d+),?(\d+)?$}
    return Portal.new(:ip => $1, :port => $2, :interface => $3, :type => type)
  end
end

Instance Method Details

#to_sObject



34
35
36
# File 'lib/iscsiadm/portal.rb', line 34

def to_s
  "#{@ip}:#{@port},#{@interface}"
end