Class: IscsiadmWrapper::Portal
- Inherits:
-
Object
- Object
- IscsiadmWrapper::Portal
- Defined in:
- lib/iscsiadm/portal.rb
Constant Summary collapse
- DEFAULT_TYPE =
'sendtargets'
Instance Attribute Summary collapse
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.parse(portal, type = DEFAULT_TYPE) ⇒ Object
Takes the typical portal string from iscsiadm and the type and returns a new Portal object.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Portal
constructor
Instance Methods.
- #to_s ⇒ Object
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
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
5 6 7 |
# File 'lib/iscsiadm/portal.rb', line 5 def interface @interface end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
5 6 7 |
# File 'lib/iscsiadm/portal.rb', line 5 def ip @ip end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/iscsiadm/portal.rb', line 5 def port @port end |
#type ⇒ Object (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_s ⇒ Object
34 35 36 |
# File 'lib/iscsiadm/portal.rb', line 34 def to_s "#{@ip}:#{@port},#{@interface}" end |