class OneviewSDK::API200::Rack

Rack resource implementation

Constants

BASE_URI
UNIQUE_IDENTIFIERS

Public Class Methods

new(client, params = {}, api_ver = nil) click to toggle source

Create a resource object, associate it with a client, and set its properties. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Hash] params The options for this resource (key-value pairs) @param [Integer] api_ver The api version to use when interracting with this resource.

Calls superclass method OneviewSDK::Resource::new
# File lib/oneview-sdk/resource/api200/rack.rb, line 36
def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['rackMounts'] ||= []
end

Public Instance Methods

add(*)

Add the resource on OneView using the current data @note Calls the refresh method to set additional data @raise [OneviewSDK::IncompleteResource] if the client is not set @raise [StandardError] if the resource creation fails @return [OneviewSDK::Rack] self

Alias for: create
add_rack_resource(resource, options = {}) click to toggle source

Adds the rack resource with specified options @param [OneviewSDK::Resource] resource Resource to be added @param [String] options rack options

# File lib/oneview-sdk/resource/api200/rack.rb, line 64
def add_rack_resource(resource, options = {})
  rack_resource_options = {}
  # Write values to hash and transform any symbol to string
  options.each { |key, val| rack_resource_options[key.to_s] = val }

  # Verify if the rack resource exists in the rack, if not init add it
  rack_resource = @data['rackMounts'].find { |resource_from_rack| resource_from_rack['mountUri'] == resource['uri'] }
  if rack_resource
    rack_resource_options.each { |key, val| rack_resource[key] = val }
  else
    # Set default values if not given
    rack_resource_options['mountUri'] = resource['uri']
    rack_resource_options['location'] = 'CenterFront' unless rack_resource_options['location']
    @data['rackMounts'] << rack_resource_options
  end
end
create(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/rack.rb, line 44
def create(*)
  unavailable_method
end
Also aliased as: add
delete(*) click to toggle source

Method is not available @raise [OneviewSDK::MethodUnavailable] method is not available

# File lib/oneview-sdk/resource/api200/rack.rb, line 50
def delete(*)
  unavailable_method
end
Also aliased as: remove
get_device_topology() click to toggle source

Gets topology information for the rack @return [Hash] Environmental analysis

# File lib/oneview-sdk/resource/api200/rack.rb, line 89
def get_device_topology
  response = @client.rest_get(@data['uri'] + '/deviceTopology')
  @client.response_handler(response)
end
remove(*)

Remove resource from OneView @return [true] if resource was removed successfully

Alias for: delete
remove_rack_resource(resource) click to toggle source

Remove resources from the rack @param [OneviewSDK::Resource] resource Resource to be removed from rack

# File lib/oneview-sdk/resource/api200/rack.rb, line 83
def remove_rack_resource(resource)
  @data['rackMounts'].reject! { |rack_resource| rack_resource['mountUri'] == resource['uri'] }
end
update(attributes = {}, header = { 'If-Match' => '*' }) click to toggle source

Updates a rack @param [Hash] attributes attributes to be updated @return [OneviewSDK::Rack] self

Calls superclass method OneviewSDK::Resource#update
# File lib/oneview-sdk/resource/api200/rack.rb, line 57
def update(attributes = {}, header = { 'If-Match' => '*' })
  super(attributes, header)
end