Module: OneviewSDK::API1000

Defined in:
lib/oneview-sdk/resource/api1000.rb,
lib/oneview-sdk/resource/api1000/c7000.rb,
lib/oneview-sdk/resource/api1000/synergy.rb,
lib/oneview-sdk/resource/api1000/c7000/scope.rb,
lib/oneview-sdk/resource/api1000/c7000/volume.rb,
lib/oneview-sdk/resource/api1000/synergy/scope.rb,
lib/oneview-sdk/resource/api1000/synergy/volume.rb,
lib/oneview-sdk/resource/api1000/c7000/enclosure.rb,
lib/oneview-sdk/resource/api1000/c7000/fc_network.rb,
lib/oneview-sdk/resource/api1000/c7000/uplink_set.rb,
lib/oneview-sdk/resource/api1000/c7000/network_set.rb,
lib/oneview-sdk/resource/api1000/synergy/enclosure.rb,
lib/oneview-sdk/resource/api1000/c7000/fcoe_network.rb,
lib/oneview-sdk/resource/api1000/c7000/interconnect.rb,
lib/oneview-sdk/resource/api1000/c7000/storage_pool.rb,
lib/oneview-sdk/resource/api1000/synergy/fc_network.rb,
lib/oneview-sdk/resource/api1000/synergy/uplink_set.rb,
lib/oneview-sdk/resource/api1000/synergy/network_set.rb,
lib/oneview-sdk/resource/api1000/c7000/lig_uplink_set.rb,
lib/oneview-sdk/resource/api1000/c7000/server_profile.rb,
lib/oneview-sdk/resource/api1000/c7000/storage_system.rb,
lib/oneview-sdk/resource/api1000/synergy/fcoe_network.rb,
lib/oneview-sdk/resource/api1000/synergy/interconnect.rb,
lib/oneview-sdk/resource/api1000/synergy/storage_pool.rb,
lib/oneview-sdk/resource/api1000/c7000/enclosure_group.rb,
lib/oneview-sdk/resource/api1000/c7000/server_hardware.rb,
lib/oneview-sdk/resource/api1000/c7000/volume_template.rb,
lib/oneview-sdk/resource/api1000/c7000/ethernet_network.rb,
lib/oneview-sdk/resource/api1000/synergy/lig_uplink_set.rb,
lib/oneview-sdk/resource/api1000/synergy/server_profile.rb,
lib/oneview-sdk/resource/api1000/synergy/storage_system.rb,
lib/oneview-sdk/resource/api1000/c7000/logical_enclosure.rb,
lib/oneview-sdk/resource/api1000/c7000/volume_attachment.rb,
lib/oneview-sdk/resource/api1000/synergy/enclosure_group.rb,
lib/oneview-sdk/resource/api1000/synergy/server_hardware.rb,
lib/oneview-sdk/resource/api1000/synergy/volume_template.rb,
lib/oneview-sdk/resource/api1000/synergy/ethernet_network.rb,
lib/oneview-sdk/resource/api1000/synergy/logical_enclosure.rb,
lib/oneview-sdk/resource/api1000/synergy/volume_attachment.rb,
lib/oneview-sdk/resource/api1000/c7000/logical_interconnect.rb,
lib/oneview-sdk/resource/api1000/c7000/server_hardware_type.rb,
lib/oneview-sdk/resource/api1000/synergy/os_deployment_plan.rb,
lib/oneview-sdk/resource/api1000/synergy/logical_interconnect.rb,
lib/oneview-sdk/resource/api1000/synergy/server_hardware_type.rb,
lib/oneview-sdk/resource/api1000/c7000/server_profile_template.rb,
lib/oneview-sdk/resource/api1000/synergy/server_profile_template.rb,
lib/oneview-sdk/resource/api1000/c7000/logical_interconnect_group.rb,
lib/oneview-sdk/resource/api1000/synergy/logical_interconnect_group.rb

Overview

Module for API v1000

Defined Under Namespace

Modules: C7000, Synergy

Constant Summary collapse

SUPPORTED_VARIANTS =
%w[C7000 Synergy].freeze
DEFAULT_VARIANT =
'C7000'.freeze

Class Method Summary collapse

Class Method Details

.const_missing(const) ⇒ Object

Helps redirect resources to the correct API1000 variant


56
57
58
59
60
61
# File 'lib/oneview-sdk/resource/api1000.rb', line 56

def self.const_missing(const)
  api1000_module = OneviewSDK::API1000.const_get(@variant.to_s)
  api1000_module.const_get(const)
rescue NameError
  raise NameError, "The #{const} method or resource does not exist for OneView API1000 variant #{@variant}."
end

.resource_named(type, variant = @variant) ⇒ Class

Get resource class that matches the type given

Parameters:

  • type (String)

    Name of the desired class type

  • variant (String) (defaults to: @variant)

    Variant (C7000 or Synergy)

Returns:

  • (Class)

    Resource class or nil if not found


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/oneview-sdk/resource/api1000.rb', line 24

def self.resource_named(type, variant = @variant)
  raise "API1000 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
  new_type = type.to_s.downcase.gsub(/[ -_]/, '')
  api_module = OneviewSDK::API1000.const_get(variant)
  api_module.constants.each do |c|
    klass = api_module.const_get(c)
    next unless klass.is_a?(Class)
    name = klass.name.split('::').last.downcase.delete('_').delete('-')
    return klass if new_type =~ /^#{name}[s]?$/
  end
  nil
end

.variantObject

Get the current API1000 variant


38
39
40
# File 'lib/oneview-sdk/resource/api1000.rb', line 38

def self.variant
  @variant
end

.variant=(variant) ⇒ Object

Sets the API1000 variant


49
50
51
52
53
# File 'lib/oneview-sdk/resource/api1000.rb', line 49

def self.variant=(variant)
  raise "API1000 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant)
  @variant_updated = true
  @variant = variant
end

.variant_updated?TrueClass, FalseClass

Has the API1000 variant been set by the user?

Returns:

  • (TrueClass, FalseClass)

44
45
46
# File 'lib/oneview-sdk/resource/api1000.rb', line 44

def self.variant_updated?
  @variant_updated
end