Module: OneviewSDK

Defined in:
lib/oneview-sdk.rb,
lib/oneview-sdk/cli.rb,
lib/oneview-sdk/rest.rb,
lib/oneview-sdk/client.rb,
lib/oneview-sdk/version.rb,
lib/oneview-sdk/resource.rb,
lib/oneview-sdk/exceptions.rb,
lib/oneview-sdk/ssl_helper.rb,
lib/oneview-sdk/config_loader.rb,
lib/oneview-sdk/image_streamer.rb,
lib/oneview-sdk/resource/api200.rb,
lib/oneview-sdk/resource/api300.rb,
lib/oneview-sdk/resource/api200/rack.rb,
lib/oneview-sdk/resource/api200/user.rb,
lib/oneview-sdk/image-streamer/client.rb,
lib/oneview-sdk/resource/api300/c7000.rb,
lib/oneview-sdk/resource/api200/fabric.rb,
lib/oneview-sdk/resource/api200/switch.rb,
lib/oneview-sdk/resource/api200/volume.rb,
lib/oneview-sdk/resource/api300/synergy.rb,
lib/oneview-sdk/resource/api200/resource.rb,
lib/oneview-sdk/resource/api200/enclosure.rb,
lib/oneview-sdk/resource/api200/datacenter.rb,
lib/oneview-sdk/resource/api200/fc_network.rb,
lib/oneview-sdk/resource/api200/uplink_set.rb,
lib/oneview-sdk/resource/api300/c7000/rack.rb,
lib/oneview-sdk/resource/api300/c7000/user.rb,
lib/oneview-sdk/resource/api200/managed_san.rb,
lib/oneview-sdk/resource/api200/network_set.rb,
lib/oneview-sdk/resource/api200/san_manager.rb,
lib/oneview-sdk/resource/api300/c7000/scope.rb,
lib/oneview-sdk/resource/api200/fcoe_network.rb,
lib/oneview-sdk/resource/api200/interconnect.rb,
lib/oneview-sdk/resource/api200/power_device.rb,
lib/oneview-sdk/resource/api200/storage_pool.rb,
lib/oneview-sdk/resource/api300/c7000/fabric.rb,
lib/oneview-sdk/resource/api300/c7000/switch.rb,
lib/oneview-sdk/resource/api300/c7000/volume.rb,
lib/oneview-sdk/resource/api300/synergy/rack.rb,
lib/oneview-sdk/resource/api300/synergy/user.rb,
lib/oneview-sdk/resource/api300/synergy/scope.rb,
lib/oneview-sdk/resource/api200/lig_uplink_set.rb,
lib/oneview-sdk/resource/api200/logical_switch.rb,
lib/oneview-sdk/resource/api200/server_profile.rb,
lib/oneview-sdk/resource/api200/storage_system.rb,
lib/oneview-sdk/resource/api300/c7000/resource.rb,
lib/oneview-sdk/resource/api300/synergy/fabric.rb,
lib/oneview-sdk/resource/api300/synergy/switch.rb,
lib/oneview-sdk/resource/api300/synergy/volume.rb,
lib/oneview-sdk/image-streamer/resource/api_300.rb,
lib/oneview-sdk/resource/api200/enclosure_group.rb,
lib/oneview-sdk/resource/api200/firmware_bundle.rb,
lib/oneview-sdk/resource/api200/firmware_driver.rb,
lib/oneview-sdk/resource/api200/server_hardware.rb,
lib/oneview-sdk/resource/api200/volume_snapshot.rb,
lib/oneview-sdk/resource/api200/volume_template.rb,
lib/oneview-sdk/resource/api300/c7000/enclosure.rb,
lib/oneview-sdk/resource/api200/ethernet_network.rb,
lib/oneview-sdk/resource/api200/logical_downlink.rb,
lib/oneview-sdk/resource/api200/unmanaged_device.rb,
lib/oneview-sdk/resource/api300/c7000/datacenter.rb,
lib/oneview-sdk/resource/api300/c7000/fc_network.rb,
lib/oneview-sdk/resource/api300/c7000/uplink_set.rb,
lib/oneview-sdk/resource/api300/synergy/resource.rb,
lib/oneview-sdk/resource/api200/logical_enclosure.rb,
lib/oneview-sdk/resource/api200/volume_attachment.rb,
lib/oneview-sdk/resource/api300/c7000/managed_san.rb,
lib/oneview-sdk/resource/api300/c7000/network_set.rb,
lib/oneview-sdk/resource/api300/c7000/san_manager.rb,
lib/oneview-sdk/resource/api300/synergy/enclosure.rb,
lib/oneview-sdk/resource/api300/c7000/fcoe_network.rb,
lib/oneview-sdk/resource/api300/c7000/interconnect.rb,
lib/oneview-sdk/resource/api300/c7000/power_device.rb,
lib/oneview-sdk/resource/api300/c7000/storage_pool.rb,
lib/oneview-sdk/resource/api300/synergy/datacenter.rb,
lib/oneview-sdk/resource/api300/synergy/fc_network.rb,
lib/oneview-sdk/resource/api300/synergy/uplink_set.rb,
lib/oneview-sdk/resource/api200/connection_template.rb,
lib/oneview-sdk/resource/api300/synergy/managed_san.rb,
lib/oneview-sdk/resource/api300/synergy/network_set.rb,
lib/oneview-sdk/resource/api300/synergy/san_manager.rb,
lib/oneview-sdk/resource/api200/logical_interconnect.rb,
lib/oneview-sdk/resource/api200/logical_switch_group.rb,
lib/oneview-sdk/resource/api200/server_hardware_type.rb,
lib/oneview-sdk/resource/api300/c7000/lig_uplink_set.rb,
lib/oneview-sdk/resource/api300/c7000/logical_switch.rb,
lib/oneview-sdk/resource/api300/c7000/server_profile.rb,
lib/oneview-sdk/resource/api300/c7000/storage_system.rb,
lib/oneview-sdk/resource/api300/synergy/fcoe_network.rb,
lib/oneview-sdk/resource/api300/synergy/interconnect.rb,
lib/oneview-sdk/resource/api300/synergy/power_device.rb,
lib/oneview-sdk/resource/api300/synergy/storage_pool.rb,
lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb,
lib/oneview-sdk/resource/api300/c7000/firmware_bundle.rb,
lib/oneview-sdk/resource/api300/c7000/firmware_driver.rb,
lib/oneview-sdk/resource/api300/c7000/server_hardware.rb,
lib/oneview-sdk/resource/api300/c7000/volume_snapshot.rb,
lib/oneview-sdk/resource/api300/c7000/volume_template.rb,
lib/oneview-sdk/resource/api300/c7000/ethernet_network.rb,
lib/oneview-sdk/resource/api300/c7000/logical_downlink.rb,
lib/oneview-sdk/resource/api300/c7000/unmanaged_device.rb,
lib/oneview-sdk/resource/api300/synergy/lig_uplink_set.rb,
lib/oneview-sdk/resource/api300/synergy/logical_switch.rb,
lib/oneview-sdk/resource/api300/synergy/server_profile.rb,
lib/oneview-sdk/resource/api300/synergy/storage_system.rb,
lib/oneview-sdk/image-streamer/resource/api300/resource.rb,
lib/oneview-sdk/resource/api200/server_profile_template.rb,
lib/oneview-sdk/resource/api300/c7000/logical_enclosure.rb,
lib/oneview-sdk/resource/api300/c7000/volume_attachment.rb,
lib/oneview-sdk/resource/api300/synergy/drive_enclosure.rb,
lib/oneview-sdk/resource/api300/synergy/enclosure_group.rb,
lib/oneview-sdk/resource/api300/synergy/firmware_bundle.rb,
lib/oneview-sdk/resource/api300/synergy/firmware_driver.rb,
lib/oneview-sdk/resource/api300/synergy/server_hardware.rb,
lib/oneview-sdk/resource/api300/synergy/volume_snapshot.rb,
lib/oneview-sdk/resource/api300/synergy/volume_template.rb,
lib/oneview-sdk/image-streamer/resource/api300/os_volume.rb,
lib/oneview-sdk/resource/api300/synergy/ethernet_network.rb,
lib/oneview-sdk/resource/api300/synergy/logical_downlink.rb,
lib/oneview-sdk/resource/api300/synergy/sas_interconnect.rb,
lib/oneview-sdk/resource/api300/synergy/unmanaged_device.rb,
lib/oneview-sdk/image-streamer/resource/api300/build_plan.rb,
lib/oneview-sdk/resource/api300/c7000/connection_template.rb,
lib/oneview-sdk/resource/api300/synergy/logical_enclosure.rb,
lib/oneview-sdk/resource/api300/synergy/volume_attachment.rb,
lib/oneview-sdk/image-streamer/resource/api300/plan_script.rb,
lib/oneview-sdk/resource/api200/logical_interconnect_group.rb,
lib/oneview-sdk/resource/api300/c7000/logical_interconnect.rb,
lib/oneview-sdk/resource/api300/c7000/logical_switch_group.rb,
lib/oneview-sdk/resource/api300/c7000/server_hardware_type.rb,
lib/oneview-sdk/image-streamer/resource/api300/golden_image.rb,
lib/oneview-sdk/resource/api300/synergy/connection_template.rb,
lib/oneview-sdk/resource/api300/synergy/logical_interconnect.rb,
lib/oneview-sdk/resource/api300/synergy/server_hardware_type.rb,
lib/oneview-sdk/resource/api300/c7000/server_profile_template.rb,
lib/oneview-sdk/image-streamer/resource/api300/artifact_bundle.rb,
lib/oneview-sdk/image-streamer/resource/api300/deployment_plan.rb,
lib/oneview-sdk/image-streamer/resource/api300/deployment_group.rb,
lib/oneview-sdk/resource/api300/synergy/server_profile_template.rb,
lib/oneview-sdk/resource/api300/c7000/logical_interconnect_group.rb,
lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect.rb,
lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb,
lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb

Overview

© Copyright 2016 Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: API200, API300, ImageStreamer, Rest, SSLHelper Classes: BadRequest, Cli, Client, Config, ConnectionError, Console, IncompleteResource, InvalidClient, InvalidFormat, InvalidRequest, InvalidResource, InvalidURL, MethodUnavailable, NotFound, OneViewError, RequestError, Resource, TaskError, Unauthorized, UnsupportedVariant, UnsupportedVersion

Constant Summary collapse

ENV_VARS =
env_sdk.concat(env_i3s).freeze
SUPPORTED_API_VERSIONS =
[200, 300].freeze
DEFAULT_API_VERSION =
200
VERSION =
'4.1.0'.freeze

Class Method Summary collapse

Class Method Details

.api_versionObject

Get the current API version


33
34
35
# File 'lib/oneview-sdk.rb', line 33

def self.api_version
  @api_version
end

.api_version=(version) ⇒ Object

Set the default API version

Raises:


38
39
40
41
42
43
44
45
46
# File 'lib/oneview-sdk.rb', line 38

def self.api_version=(version)
  version = version.to_i rescue version
  raise UnsupportedVersion, "API version #{version} is not supported!"\
    unless SUPPORTED_API_VERSIONS.include?(version)
  raise UnsupportedVariant, "The module for API version #{@api_version} is undefined"\
    unless constants.include?("API#{@api_version}".to_sym)
  @api_version_updated = true
  @api_version = version
end

.api_version_updated?TrueClass, FalseClass

Has the API version been set by the user?

Returns:

  • (TrueClass, FalseClass)

50
51
52
# File 'lib/oneview-sdk.rb', line 50

def self.api_version_updated?
  @api_version_updated
end

.const_missing(const) ⇒ Object

This method will help redirect to resources within the API module that is currently in use. It should NOT be called directly. For example, if @@api_version is set to 200, then accessing OneviewSDK::EthernetNetwork will redirect to OneviewSDK::API200::EthernetNetwork


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

def self.const_missing(const)
  api_module = OneviewSDK.const_get("API#{@api_version}")
  api_module.const_get(const)
rescue NameError
  raise NameError, "The #{const} method or resource does not exist for OneView API version #{@api_version}."
end

.resource_named(type, api_ver = @api_version, variant = nil) ⇒ Class

Get resource class that matches the type given

Parameters:

  • type (String)

    Name of the desired class type

  • api_ver (Fixnum) (defaults to: @api_version)

    API module version to fetch resource from

  • variant (String) (defaults to: nil)

    API module variant to fetch resource from

Returns:

  • (Class)

    Resource class or nil if not found

Raises:


367
368
369
370
371
372
# File 'lib/oneview-sdk/resource.rb', line 367

def self.resource_named(type, api_ver = @api_version, variant = nil)
  raise UnsupportedVersion, "API version #{api_ver} is not supported! Try one of: #{SUPPORTED_API_VERSIONS}"\
    unless SUPPORTED_API_VERSIONS.include?(api_ver)
  api_module = OneviewSDK.const_get("API#{api_ver}")
  variant ? api_module.resource_named(type, variant) : api_module.resource_named(type)
end