Method: Cisco::Platform.virtual_services

Defined in:
lib/cisco_node_utils/platform.rb

.virtual_servicesObject

Returns hash of hashes with inner keys “state”, “application”, … Ex: { ‘chef’ => {

  'package_info' => { 'name'     => 'n3k_chef.ova',
                      'path'     => 'bootflash:/n3k_chef.ova' },
  'application'  => { 'name'     => 'ChefAgent',
                      'version'  => '0.1',
                      'descr'    => 'Cisco Chef Agent' },
  'signing'      => { 'key_type' => 'Cisco development key',
                      'method'   => 'SHA-1' }
  'licensing'    => { 'name'     => 'none',
                      'version'  => 'none' }
  'reservation'  => { 'disk'     => '111 MB',
                      'memory'   => '0 MB',
                      'cpu'      => '0% system CPU' }},
{ ... }}


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/cisco_node_utils/platform.rb', line 190

def self.virtual_services
  # If no virtual-services are installed, this will result
  # in a RuntimeError.  We need to rescue this specific case.
  begin
    virts = config_get('virtual_service', 'services')
  rescue RuntimeError => e
    return {} if e.message[/No key \"TABLE_detail\"/]
    raise
  end
  return {} if virts.nil?
  # NXAPI returns hash instead of array if there's only 1
  virts = [virts] if virts.is_a? Hash
  # convert to expected format
  virts_hsh = {}
  virts.each do |serv|
    # rubocop:disable Style/AlignHash
    virts_hsh[serv['name']] = {
      'package_info' => { 'name'     => serv['package_name'],
                          'path'     => serv['ova_path'],
      },
      'application'  => { 'name'     => serv['application_name'],
                          'version'  => serv['application_version'],
                          'descr'    => serv['application_description'],
      },
      'signing'      => { 'key_type' => serv['key_type'],
                          'method'   => serv['signing_method'],
      },
      'licensing'    => { 'name'     => serv['licensing_name'],
                          'version'  => serv['licensing_version'],
      },
      'reservation'  => { 'disk'     => serv['disk_reservation'],
                          'memory'   => serv['memory_reservation'],
                          'cpu'      => serv['cpu_reservation'],
      },
    }
    # rubocop:enable Style/AlignHash
  end
  virts_hsh
end