class Connect
The Connect
class provides a class implementation and methods for establishing node connections and initializations. This class presents an abstraction
Public Class Methods
This function is used to initialise node paramters.
@param params [Hash] Hash to hold the switch connection parameters
@return None
# File lib/sonic-rbapi/connect.rb, line 39 def initialize(params) @protocol = params['protocol'] @port = params['port'] @ip_addr = params['ip_addr'] @user = params['user'] @password = params['password'] if @protocol == 'http' @url = @protocol + '://' + @ip_addr + ':' + @port end # https is not supported # Need to get certificate from user and form ssl connection for https @hdr = {} @hdr['Accept'] = 'application/json' @hdr['Content-type'] = 'application/json' end
Public Instance Methods
This API returns Header Info for the current node connection.
@return [String] REST Header
# File lib/sonic-rbapi/connect.rb, line 95 def getHdr() return @hdr end
This API returns IP for the current node connection.
@return [String] Node IP Address
# File lib/sonic-rbapi/connect.rb, line 74 def getIpAddr() return @ip_addr end
This API returns Password for the current node connection.
@return [String] Password credentials
# File lib/sonic-rbapi/connect.rb, line 88 def getPassword() return @password end
This API returns REST Port for the current node connection.
@return [String] REST Port
# File lib/sonic-rbapi/connect.rb, line 67 def getPort() return @port end
This API returns Protocol protocol for the current node connection.
@return [String] Protocol protocol
# File lib/sonic-rbapi/connect.rb, line 60 def getProtocol() return @protocol end
This API returns User for the current node connection.
@return [String] User name credentials
# File lib/sonic-rbapi/connect.rb, line 81 def getUser() return @user end