Class: OneviewSDK::API200::Rack
- Defined in:
- lib/oneview-sdk/resource/api200/rack.rb
Overview
Rack resource implementation
Direct Known Subclasses
OneviewSDK::API300::C7000::Rack, OneviewSDK::API300::Synergy::Rack
Constant Summary collapse
- BASE_URI =
'/rest/racks'.freeze
- UNIQUE_IDENTIFIERS =
%w[name uri serialNumber].freeze
Constants inherited from Resource
Resource::DEFAULT_REQUEST_HEADER
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#add ⇒ OneviewSDK::Rack
Add the resource on OneView using the current data.
-
#add_rack_resource(resource, options = {}) ⇒ Object
Adds the rack resource with specified options.
-
#create ⇒ Object
Method is not available.
-
#delete ⇒ Object
Method is not available.
-
#get_device_topology ⇒ Hash
Gets topology information for the rack.
-
#initialize(client, params = {}, api_ver = nil) ⇒ Rack
constructor
Create a resource object, associate it with a client, and set its properties.
-
#remove ⇒ true
Remove resource from OneView.
-
#remove_rack_resource(resource) ⇒ Object
Remove resources from the rack.
-
#update(attributes = {}, header = { 'If-Match' => '*' }) ⇒ OneviewSDK::Rack
Updates a rack.
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
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ Rack
Create a resource object, associate it with a client, and set its properties.
36 37 38 39 40 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 36 def initialize(client, params = {}, api_ver = nil) super # Default values: @data['rackMounts'] ||= [] end |
Instance Method Details
#add ⇒ OneviewSDK::Rack
Calls the refresh method to set additional data
Add the resource on OneView using the current data
26 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 26 alias add create |
#add_rack_resource(resource, options = {}) ⇒ Object
Adds the rack resource with specified options
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 64 def add_rack_resource(resource, = {}) = {} # Write values to hash and transform any symbol to string .each { |key, val| [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 .each { |key, val| rack_resource[key] = val } else # Set default values if not given ['mountUri'] = resource['uri'] ['location'] = 'CenterFront' unless ['location'] @data['rackMounts'] << end end |
#create ⇒ Object
Method is not available
44 45 46 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 44 def create(*) unavailable_method end |
#delete ⇒ Object
Method is not available
50 51 52 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 50 def delete(*) unavailable_method end |
#get_device_topology ⇒ Hash
Gets topology information for the rack
89 90 91 92 |
# 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 ⇒ true
Remove resource from OneView
30 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 30 alias remove delete |
#remove_rack_resource(resource) ⇒ Object
Remove resources from the rack
83 84 85 |
# 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' => '*' }) ⇒ OneviewSDK::Rack
Updates a rack
57 58 59 |
# File 'lib/oneview-sdk/resource/api200/rack.rb', line 57 def update(attributes = {}, header = { 'If-Match' => '*' }) super(attributes, header) end |