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.
17 18 19 20 |
# File 'lib/lookup_service_helper.rb', line 17 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.
11 12 13 |
# File 'lib/lookup_service_helper.rb', line 11 def sample @sample end |
#serviceRegistration ⇒ Object (readonly)
Returns the value of attribute serviceRegistration.
12 13 14 |
# File 'lib/lookup_service_helper.rb', line 12 def serviceRegistration @serviceRegistration end |
#soap_url ⇒ Object (readonly)
Returns the value of attribute soap_url.
11 12 13 |
# File 'lib/lookup_service_helper.rb', line 11 def soap_url @soap_url end |
#wsdl_url ⇒ Object (readonly)
Returns the value of attribute wsdl_url.
11 12 13 |
# File 'lib/lookup_service_helper.rb', line 11 def wsdl_url @wsdl_url end |
Instance Method Details
#connect ⇒ Object
Connects to the lookup service.
23 24 25 26 27 |
# File 'lib/lookup_service_helper.rb', line 23 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
157 158 159 160 161 162 163 164 |
# File 'lib/lookup_service_helper.rb', line 157 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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/lookup_service_helper.rb', line 35 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 result.values[0] end |
#find_vapi_url(node_id) ⇒ String
Finds the vapi service endpoint URL of a management node.
63 64 65 66 67 68 |
# File 'lib/lookup_service_helper.rb', line 63 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 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
51 52 53 54 55 56 |
# File 'lib/lookup_service_helper.rb', line 51 def find_vapi_urls 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
113 114 115 116 117 118 |
# File 'lib/lookup_service_helper.rb', line 113 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 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
101 102 103 104 105 106 |
# File 'lib/lookup_service_helper.rb', line 101 def find_vim_pbm_urls 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
88 89 90 91 92 93 |
# File 'lib/lookup_service_helper.rb', line 88 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 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
76 77 78 79 80 81 |
# File 'lib/lookup_service_helper.rb', line 76 def find_vim_urls 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.
146 147 148 149 150 151 152 |
# File 'lib/lookup_service_helper.rb', line 146 def get_default_mgmt_node result = find_mgmt_nodes raise "Management nodes not found" unless result && !result.empty? # WHY: raise MultipleManagementNodeException.new if result.size > 1 [result.keys[0], result.values[0]] end |
#get_mgmt_node_id(instance_name) ⇒ String
Get the management node id from the instance name
125 126 127 128 129 130 131 132 |
# File 'lib/lookup_service_helper.rb', line 125 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.empty? result[instance_name] end |
#get_mgmt_node_instance_name(node_id) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# 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.empty? result.each { |k, v| return k if v == node_id } nil end |