class NSXDriver::NSXClient
Class NSXClient
Attributes
nsx_password[RW]
nsx_user[RW]
nsxmgr[RW]
ATTIBUTES
Public Class Methods
new(nsxmgr, nsx_user, nsx_password)
click to toggle source
CONSTRUCTORS
# File lib/nsx_client.rb, line 72 def initialize(nsxmgr, nsx_user, nsx_password) @nsxmgr = nsxmgr @nsx_user = nsx_user @nsx_password = nsx_password end
new_child(nsxmgr, nsx_user, nsx_password, type)
click to toggle source
# File lib/nsx_client.rb, line 78 def self.new_child(nsxmgr, nsx_user, nsx_password, type) [nsxmgr, nsx_user, nsx_password, type].each do |v| next if !v.nil? && !v.empty? return nil end case type.upcase when NSXConstants::NSXT NSXTClient.new(nsxmgr, nsx_user, nsx_password) when NSXConstants::NSXV NSXVClient.new(nsxmgr, nsx_user, nsx_password) else error_msg = "Unknown NSX type: #{type}" error = NSXError::UnknownObject.new(error_msg) raise error end end
new_from_host(host)
click to toggle source
# File lib/nsx_client.rb, line 97 def self.new_from_host(host) nsxmgr = host['TEMPLATE/NSX_MANAGER'] nsx_user = host['TEMPLATE/NSX_USER'] nsx_password = host['TEMPLATE/NSX_PASSWORD'] nsx_type = host['TEMPLATE/NSX_TYPE'] new_child(nsxmgr, nsx_user, nsx_password, nsx_type) end
new_from_id(hid)
click to toggle source
# File lib/nsx_client.rb, line 106 def self.new_from_id(hid) client = OpenNebula::Client.new host = OpenNebula::Host.new_with_id(hid, client) rc = host.info(true) if OpenNebula.is_error?(rc) raise "Could not get host info for ID: #{hid} - #{rc.message}" end new_from_host(host) end
Public Instance Methods
add_headers(aditional_headers = [])
click to toggle source
Prepare headers
# File lib/nsx_client.rb, line 153 def add_headers(aditional_headers = []); end
check_response(response, codes_array)
click to toggle source
Return response if match with responses codes, If response not match with expected responses codes then raise an IncorrectResponseCodeError
# File lib/nsx_client.rb, line 123 def check_response(response, codes_array) unless response.nil? return response if codes_array.include?(response.code.to_i) response_json = JSON.parse(response.body) nsx_error = "\nNSX error code: " \ "#{response_json['errorCode']}, " \ "\nNSX error details: " \ "#{response_json['details']}" raise NSXError::IncorrectResponseCodeError, nsx_error end raise NSXError::IncorrectResponseCodeError, nsx_error end
delete(url)
click to toggle source
# File lib/nsx_client.rb, line 148 def delete(url); end
get(url, aditional_headers = [])
click to toggle source
Return: respose.body
# File lib/nsx_client.rb, line 138 def get(url, aditional_headers = []); end
get_full_response(url, aditional_headers = [])
click to toggle source
Return: response
# File lib/nsx_client.rb, line 141 def get_full_response(url, aditional_headers = []); end
get_token(url)
click to toggle source
# File lib/nsx_client.rb, line 150 def get_token(url); end
post(url, data, aditional_headers = [])
click to toggle source
Return: id of the created object
# File lib/nsx_client.rb, line 144 def post(url, data, aditional_headers = []); end
put(url, data, aditional_headers = [])
click to toggle source
# File lib/nsx_client.rb, line 146 def put(url, data, aditional_headers = []); end