Class: OneviewSDK::Datacenter

Inherits:
Resource
  • Object
show all
Defined in:
lib/oneview-sdk/resource/datacenter.rb

Overview

Datacenter resource implementation

Constant Summary collapse

BASE_URI =
'/rest/datacenters'.freeze

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update

Constructor Details

#initialize(client, params = {}, api_ver = nil) ⇒ Datacenter

Create a resource object, associate it with a client, and set its properties.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • params (Hash) (defaults to: {})

    The options for this resource (key-value pairs)

  • api_ver (Integer) (defaults to: nil)

    The api version to use when interracting with this resource.



32
33
34
35
36
# File 'lib/oneview-sdk/resource/datacenter.rb', line 32

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['contents'] ||= []
end

Instance Method Details

#addOneviewSDK::Datacenter

Note:

Calls the refresh method to set additional data

Add the resource on OneView using the current data

Returns:

Raises:



22
# File 'lib/oneview-sdk/resource/datacenter.rb', line 22

alias add create

#add_rack(rack, pos_x, pos_y, rotation = 0) ⇒ Object

Adds an existing rack to the datacenter

Parameters:

  • rack (OneviewSDK::Rack)

    rack

  • pos_x (Decimal)

    x position

  • pos_y (Decimal)

    y position

  • rotation (Decimal) (defaults to: 0)

    Rotation degrees (0-359) around the center of the resource



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

def add_rack(rack, pos_x, pos_y, rotation = 0)
  @data['contents'] << {
    'resourceUri' => rack['uri'],
    'x' => pos_x,
    'y' => pos_y,
    'rotation' => rotation
  }
end

#createObject

Method is not available

Raises:



40
41
42
# File 'lib/oneview-sdk/resource/datacenter.rb', line 40

def create
  unavailable_method
end

#deleteObject

Method is not available

Raises:



46
47
48
# File 'lib/oneview-sdk/resource/datacenter.rb', line 46

def delete
  unavailable_method
end

#get_visual_contentHash

Gets a list of the visual content objects

Returns:

  • (Hash)


72
73
74
75
# File 'lib/oneview-sdk/resource/datacenter.rb', line 72

def get_visual_content
  response = @client.rest_get(@data['uri'] + '/visualContent')
  @client.response_handler(response)
end

#removetrue

Remove resource from OneView

Returns:

  • (true)

    if resource was removed successfully



26
# File 'lib/oneview-sdk/resource/datacenter.rb', line 26

alias remove delete

#remove_rack(rack) ⇒ Object

Removes a rack from the datacenter

Parameters:



66
67
68
# File 'lib/oneview-sdk/resource/datacenter.rb', line 66

def remove_rack(rack)
  @data['contents'].reject! { |resource| resource['resourceUri'] == rack['uri'] }
end