Class: NSXDriver::NSXTLogicalPort
- Inherits:
-
LogicalPort
- Object
- NSXComponent
- LogicalPort
- NSXDriver::NSXTLogicalPort
- Defined in:
- lib/nsxt_logical_port.rb
Overview
Class NSXTLogicalPort
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
ATTRIBUTES.
-
#name ⇒ Object
readonly
ATTRIBUTES.
-
#type ⇒ Object
readonly
ATTRIBUTES.
-
#url ⇒ Object
readonly
ATTRIBUTES.
Instance Method Summary collapse
-
#initialize(nsx_client, id = nil, data = nil) ⇒ NSXTLogicalPort
constructor
CONSTRUCTOR Logical port class variables:.
-
#initialize_with_id(id) ⇒ Object
Creates a NSXTLogicalPort from its id.
-
#lp? ⇒ Boolean
Check if logical port exists.
-
#lp_name ⇒ Object
# Get logical port display name.
-
#lp_type ⇒ Object
# Get resource type.
-
#lp_with_attachid(attach_id) ⇒ Object
Get logical port id from attach id.
Methods inherited from LogicalPort
Constructor Details
#initialize(nsx_client, id = nil, data = nil) ⇒ NSXTLogicalPort
CONSTRUCTOR Logical port class variables:
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nsxt_logical_port.rb', line 30 def initialize(nsx_client, id = nil, data = nil) super(nsx_client) # lpid can be: # - Logical port attach ID if id initialize_with_id(id) else if data begin @id = new_logical_port(data) rescue NSXError::IncorrectResponseCodeError => e raise 'Logical Port not created in ' \ "NSX Manager: #{e.}" end unless @id raise 'Logical Port not created in NSX Manager: '\ 'generic error' end # Construct logical port class variables @url = NSXConstants::NSXT_LP_BASE + @id @name = lp_name @type = lp_type end end end |
Instance Attribute Details
#id ⇒ Object (readonly)
ATTRIBUTES
22 23 24 |
# File 'lib/nsxt_logical_port.rb', line 22 def id @id end |
#name ⇒ Object (readonly)
ATTRIBUTES
22 23 24 |
# File 'lib/nsxt_logical_port.rb', line 22 def name @name end |
#type ⇒ Object (readonly)
ATTRIBUTES
22 23 24 |
# File 'lib/nsxt_logical_port.rb', line 22 def type @type end |
#url ⇒ Object (readonly)
ATTRIBUTES
22 23 24 |
# File 'lib/nsxt_logical_port.rb', line 22 def url @url end |
Instance Method Details
#initialize_with_id(id) ⇒ Object
Creates a NSXTLogicalPort from its id
57 58 59 60 61 62 63 64 65 |
# File 'lib/nsxt_logical_port.rb', line 57 def initialize_with_id(id) @id = lp_with_attachid(id) # Construct URL of the created logical switch @url = NSXConstants::NSXT_LP_BASE + @id return unless lp? @name = lp_name @type = lp_type end |
#lp? ⇒ Boolean
Check if logical port exists
68 69 70 |
# File 'lib/nsxt_logical_port.rb', line 68 def lp? @nsx_client.get(@url) end |
#lp_name ⇒ Object
# Get logical port display name
81 82 83 84 |
# File 'lib/nsxt_logical_port.rb', line 81 def lp_name lp = @nsx_client.get(@url) lp['display_name'] end |
#lp_type ⇒ Object
# Get resource type
87 88 89 90 |
# File 'lib/nsxt_logical_port.rb', line 87 def lp_type lp = @nsx_client.get(@url) lp['resource_type'] end |
#lp_with_attachid(attach_id) ⇒ Object
Get logical port id from attach id
73 74 75 76 77 78 |
# File 'lib/nsxt_logical_port.rb', line 73 def lp_with_attachid(attach_id) lps = @nsx_client.get(NSXConstants::NSXT_LP_BASE) lps['results'].each do |lp| return lp['id'] if lp['attachment']['id'] == attach_id end end |