Class: LookupServiceHelper
- Inherits:
-
Object
- Object
- LookupServiceHelper
- Defined in:
- lib/lookup_service_helper.rb
Overview
Utility class that helps use the lookup service.
Instance Attribute Summary collapse
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
-
#serviceRegistration ⇒ Object
readonly
Returns the value of attribute serviceRegistration.
-
#soap_url ⇒ Object
readonly
Returns the value of attribute soap_url.
-
#wsdl_url ⇒ Object
readonly
Returns the value of attribute wsdl_url.
Instance Method Summary collapse
-
#connect ⇒ Object
Connects to the lookup service.
-
#find_mgmt_nodes ⇒ Hash
Finds all the management nodes.
-
#find_sso_url ⇒ String
Finds the SSO service URL.
-
#find_vapi_url(node_id) ⇒ String
Finds the vapi service endpoint URL of a management node.
-
#find_vapi_urls ⇒ Hash
Finds all the vAPI service endpoint URLs.
-
#find_vim_pbm_url(node_id) ⇒ String
Finds the spbm service endpoint URL of a management node.
-
#find_vim_pbm_urls ⇒ Hash
Finds all the spbm service endpoint URLs In a MxN setup where there are more than one management node; this method returns more than one URL.
-
#find_vim_url(node_id) ⇒ String
Finds the vim service endpoint URL of a management node.
-
#find_vim_urls ⇒ Hash
Finds all the vim service endpoint URLs In a MxN setup where there are more than one management node; this method returns more than one URL.
-
#get_default_mgmt_node ⇒ Object
Finds the instance name and UUID of the management node for M1xN1 or when the PSC and management services all reside on a single node.
-
#get_mgmt_node_id(instance_name) ⇒ String
Get the management node id from the instance name.
- #get_mgmt_node_instance_name(node_id) ⇒ Object
-
#initialize(host) ⇒ LookupServiceHelper
constructor
Constructs a new instance.
Constructor Details
#initialize(host) ⇒ LookupServiceHelper
Constructs a new instance.
18 19 20 21 22 23 |
# File 'lib/lookup_service_helper.rb', line 18 def initialize(host) @soap_url = format("https://%s/lookupservice/sdk", host) @wsdl_url = format("https://%s/lookupservice/wsdl/lookup.wsdl", host) end |
Instance Attribute Details
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
12 13 14 |
# File 'lib/lookup_service_helper.rb', line 12 def sample @sample end |
#serviceRegistration ⇒ Object (readonly)
Returns the value of attribute serviceRegistration.
13 14 15 |
# File 'lib/lookup_service_helper.rb', line 13 def serviceRegistration @serviceRegistration end |
#soap_url ⇒ Object (readonly)
Returns the value of attribute soap_url.
12 13 14 |
# File 'lib/lookup_service_helper.rb', line 12 def soap_url @soap_url end |
#wsdl_url ⇒ Object (readonly)
Returns the value of attribute wsdl_url.
12 13 14 |
# File 'lib/lookup_service_helper.rb', line 12 def wsdl_url @wsdl_url end |
Instance Method Details
#connect ⇒ Object
Connects to the lookup service.
26 27 28 29 30 |
# File 'lib/lookup_service_helper.rb', line 26 def connect rsc = RetrieveServiceContent.new(client).invoke() @serviceRegistration = rsc.get_service_registration() Base.log.info "service registration = #{serviceRegistration}" end |
#find_mgmt_nodes ⇒ Hash
Finds all the management nodes
154 155 156 157 158 159 160 161 |
# File 'lib/lookup_service_helper.rb', line 154 def find_mgmt_nodes #assert self.serviceRegistration is not None list = List.new(client, 'com.vmware.cis', 'vcenterserver', 'vmomi', 'com.vmware.vim') list.invoke() list.get_instance_names() end |
#find_sso_url ⇒ String
Finds the SSO service URL. In a MxN setup where there are more than one PSC nodes; This method returns the first SSO service endpoint URL as returned by the lookup service.
38 39 40 41 42 43 44 45 |
# File 'lib/lookup_service_helper.rb', line 38 def find_sso_url result = find_service_url(product='com.vmware.cis', service='cs.identity', endpoint='com.vmware.cis.cs.identity.sso', protocol='wsTrust') raise 'SSO URL not found' unless result && result.size > 0 return result.values[0] end |
#find_vapi_url(node_id) ⇒ String
Finds the vapi service endpoint URL of a management node.
65 66 67 68 69 70 |
# File 'lib/lookup_service_helper.rb', line 65 def find_vapi_url(node_id) raise 'node_id is required' if node_id.nil? result = find_vapi_urls() raise 'VAPI URLs not found' unless result && result.size > 0 return result[node_id] end |
#find_vapi_urls ⇒ Hash
Finds all the vAPI service endpoint URLs. In a MxN setup where there are more than one management node; this method returns more than one URL
53 54 55 56 57 58 |
# File 'lib/lookup_service_helper.rb', line 53 def find_vapi_urls return find_service_url(product='com.vmware.cis', service='cs.vapi', endpoint='com.vmware.vapi.endpoint', protocol='vapi.json.https.public') end |
#find_vim_pbm_url(node_id) ⇒ String
Finds the spbm service endpoint URL of a management node
115 116 117 118 119 120 |
# File 'lib/lookup_service_helper.rb', line 115 def find_vim_pbm_url(node_id) raise 'node_id is required' if node_id.nil? result = find_vim_pbm_urls() raise 'PBM URLs not found' unless result && result.size > 0 return result[node_id] end |
#find_vim_pbm_urls ⇒ Hash
Finds all the spbm service endpoint URLs In a MxN setup where there are more than one management node; this method returns more than one URL
103 104 105 106 107 108 |
# File 'lib/lookup_service_helper.rb', line 103 def find_vim_pbm_urls return find_service_url(product='com.vmware.vim.sms', service='sms', endpoint='com.vmware.vim.pbm', protocol='https') end |
#find_vim_url(node_id) ⇒ String
Finds the vim service endpoint URL of a management node
90 91 92 93 94 95 |
# File 'lib/lookup_service_helper.rb', line 90 def find_vim_url(node_id) raise 'node_id is required' if node_id.nil? result = find_vim_urls() raise 'VIM URLs not found' unless result && result.size > 0 return result[node_id] end |
#find_vim_urls ⇒ Hash
Finds all the vim service endpoint URLs In a MxN setup where there are more than one management node; this method returns more than one URL
78 79 80 81 82 83 |
# File 'lib/lookup_service_helper.rb', line 78 def find_vim_urls return find_service_url(product='com.vmware.cis', service='vcenterserver', endpoint='com.vmware.vim', protocol='vmomi') end |
#get_default_mgmt_node ⇒ Object
Finds the instance name and UUID of the management node for M1xN1 or when the PSC and management services all reside on a single node.
144 145 146 147 148 149 |
# File 'lib/lookup_service_helper.rb', line 144 def get_default_mgmt_node result = find_mgmt_nodes() raise 'Management nodes not found' unless result && result.size > 0 #WHY: raise MultipleManagementNodeException.new if result.size > 1 return [result.keys[0], result.values[0]] end |
#get_mgmt_node_id(instance_name) ⇒ String
Get the management node id from the instance name
127 128 129 130 131 132 |
# File 'lib/lookup_service_helper.rb', line 127 def get_mgmt_node_id(instance_name) raise 'instance_name is required' if instance_name.nil? result = find_mgmt_nodes() raise 'Management nodes not found' unless result && result.size > 0 return result[instance_name] end |
#get_mgmt_node_instance_name(node_id) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/lookup_service_helper.rb', line 134 def get_mgmt_node_instance_name(node_id) raise 'node_id is required' if node_id.nil? result = find_mgmt_nodes() raise 'Management nodes not found' unless result && result.size > 0 result.each { |k, v| return k if v == node_id } nil end |