class NSXDriver::NSXTLogicalPort
Class NSXTLogicalPort
Attributes
id[R]
ATTRIBUTES
name[R]
ATTRIBUTES
type[R]
ATTRIBUTES
url[R]
ATTRIBUTES
Public Class Methods
new(nsx_client, id = nil, data = nil)
click to toggle source
CONSTRUCTOR Logical port class variables: @lp_id @url_lp @lp_name @lp_type
Calls superclass method
# 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.message}" 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
Public Instance Methods
initialize_with_id(id)
click to toggle source
Creates a NSXTLogicalPort
from its id
# 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?()
click to toggle source
Check if logical port exists
# File lib/nsxt_logical_port.rb, line 68 def lp? @nsx_client.get(@url) end
lp_name()
click to toggle source
Get logical port display name
# File lib/nsxt_logical_port.rb, line 81 def lp_name lp = @nsx_client.get(@url) lp['display_name'] end
lp_type()
click to toggle source
Get resource type
# 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)
click to toggle source
Get logical port id from attach id
# 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