Class: OneviewSDK::API200::Datacenter

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

Overview

Datacenter resource implementation

Constant Summary collapse

BASE_URI =
'/rest/datacenters'.freeze

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #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.



35
36
37
38
39
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 35

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:

  • (OneviewSDK::Datacenter)

    self

Raises:



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

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



58
59
60
61
62
63
64
65
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 58

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:



43
44
45
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 43

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:



49
50
51
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 49

def delete(*)
  unavailable_method
end

#get_visual_contentHash

Gets a list of the visual content objects

Returns:

  • (Hash)


75
76
77
78
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 75

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



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

alias remove delete

#remove_rack(rack) ⇒ Object

Removes a rack from the datacenter

Parameters:

  • rack (OneviewSDK::Rack)

    rack



69
70
71
# File 'lib/oneview-sdk/resource/api200/datacenter.rb', line 69

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