Class List Method List File List

# Class: LookupServiceHelper

Inherits:
  Object
  - Object
  - LookupServiceHelper
  show all
Defined in:
  /build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb

## Overview

Utility class that helps use the lookup service.

## Instance Attribute Summary (collapse)

- - (Object) sample readonly

  Returns the value of attribute sample.

- - (Object) serviceRegistration readonly

  Returns the value of attribute serviceRegistration.

- - (Object) soap_url readonly

  Returns the value of attribute soap_url.

- - (Object) wsdl_url readonly

  Returns the value of attribute wsdl_url.

## Instance Method Summary (collapse)

- - (Object) connect

  Connects to the lookup service.

- - (Hash) find_mgmt_nodes

  Finds all the management nodes.

- - (String) find_sso_url

  Finds the SSO service URL.

- - (String) find_vapi_url(node_id)

  Finds the vapi service endpoint URL of a management node.

- - (Hash) find_vapi_urls

  Finds all the vAPI service endpoint URLs.

- - (String) find_vim_pbm_url(node_id)

  Finds the spbm service endpoint URL of a management node.

- - (Hash) find_vim_pbm_urls

  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.

- - (String) find_vim_url(node_id)

  Finds the vim service endpoint URL of a management node.

- - (Hash) find_vim_urls

  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.

- - (Object) get_default_mgmt_node

  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.

- - (String) get_mgmt_node_id(instance_name)

  Get the management node id from the instance name.

- - (Object) get_mgmt_node_instance_name(node_id)
- - (LookupServiceHelper) initialize(sample) constructor

  Constructs a new instance.

## Constructor Details

### - (`LookupServiceHelper`) initialize(sample)

Constructs a new instance.

Parameters:

- sample (`SampleBase`) —

  the associated sample, which provides access to the configuration properties of the sample

    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 24

    def initialize(sample)
        @sample = sample
        if sample.ls_ip
            @soap_url = "https://#{sample.ls_ip}/lookupservice/sdk"
            @wsdl_url = "https://#{sample.ls_ip}/lookupservice/wsdl/lookup.wsdl"
        elsif sample.ls_url
            @soap_url = sample.ls_url
            @wsdl_url = sample.ls_url.sub("sdk", "wsdl/lookup.wsdl")
        end
    end

## Instance Attribute Details

### - (`Object`) sample (readonly)

Returns the value of attribute sample

    18
    19
    20
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 18

    def sample
      @sample
    end

### - (`Object`) serviceRegistration (readonly)

Returns the value of attribute serviceRegistration

    19
    20
    21
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 19

    def serviceRegistration
      @serviceRegistration
    end

### - (`Object`) soap_url (readonly)

Returns the value of attribute soap_url

    18
    19
    20
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 18

    def soap_url
      @soap_url
    end

### - (`Object`) wsdl_url (readonly)

Returns the value of attribute wsdl_url

    18
    19
    20
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 18

    def wsdl_url
      @wsdl_url
    end

## Instance Method Details

### - (`Object`) connect

Connects to the lookup service.

    36
    37
    38
    39
    40
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 36

    def connect
        rsc = RetrieveServiceContent.new(client).invoke()
        @serviceRegistration = rsc.get_service_registration()
        Sample.log.info "service registration = #{serviceRegistration}"
    end

### - (`Hash`) find_mgmt_nodes

Finds all the management nodes

Returns:

- (`Hash`) —

  management node instance name and node id (UUID) in a dictionary.

    164
    165
    166
    167
    168
    169
    170
    171
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 164

    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

### - (`String`) find_sso_url

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.

Returns:

- (`String`) —

  SSO Service endpoint URL.

    48
    49
    50
    51
    52
    53
    54
    55
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 48

    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

### - (`String`) find_vapi_url(node_id)

Finds the vapi service endpoint URL of a management node.

Parameters:

- node_id (`String`) —

  The UUID of the management node.

Returns:

- (`String`) —

  vapi service endpoint URL of a management node or nil if no vapi endpoint is found.

    75
    76
    77
    78
    79
    80
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 75

    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

### - (`Hash`) find_vapi_urls

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

Returns:

- (`Hash`) —

  vapi service endpoint URLs in a dictionary where the key is the node_id and the value is the service URL.

    63
    64
    65
    66
    67
    68
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 63

    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

### - (`String`) find_vim_pbm_url(node_id)

Finds the spbm service endpoint URL of a management node

Parameters:

- node_id (`String`) —

  The UUID of the management node.

Returns:

- (`String`) —

  spbm service endpoint URL of a management node or nil if no spbm endpoint is found.

    125
    126
    127
    128
    129
    130
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 125

    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

### - (`Hash`) find_vim_pbm_urls

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

Returns:

- (`Hash`) —

  spbm service endpoint URLs in a dictionary where the key is the node_id and the value is the service URL.

    113
    114
    115
    116
    117
    118
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 113

    def find_vim_pbm_urls
        return find_service_url(product='com.vmware.vim.sms',
                                service='sms',
                                endpoint='com.vmware.vim.pbm',
                                protocol='https')
    end

### - (`String`) find_vim_url(node_id)

Finds the vim service endpoint URL of a management node

Parameters:

- node_id (`String`) —

  The UUID of the management node.

Returns:

- (`String`) —

  vim service endpoint URL of a management node or nil if no vim endpoint is found.

    100
    101
    102
    103
    104
    105
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 100

    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

### - (`Hash`) find_vim_urls

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

Returns:

- (`Hash`) —

  vim service endpoint URLs in a dictionary where the key is the node_id and the value is the service URL.

    88
    89
    90
    91
    92
    93
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 88

    def find_vim_urls
        return find_service_url(product='com.vmware.cis',
                                service='vcenterserver',
                                endpoint='com.vmware.vim',
                                protocol='vmomi')
    end

### - (`Object`) get_default_mgmt_node

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.

    154
    155
    156
    157
    158
    159
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 154

    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

### - (`String`) get_mgmt_node_id(instance_name)

Get the management node id from the instance name

Parameters:

- instance_name (`String`) —

  The instance name of the management node

Returns:

- (`String`) —

  The UUID of the management node or nil is no management node is found by the given instance name

    137
    138
    139
    140
    141
    142
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 137

    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

### - (`Object`) get_mgmt_node_instance_name(node_id)

    144
    145
    146
    147
    148
    149
    150
    # File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 144

    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