Class: OneviewSDK::Rack
- Defined in:
- lib/oneview-sdk/resource/rack.rb
Overview
Rack resource implementation
Constant Summary collapse
- BASE_URI =
'/rest/racks'.freeze
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.
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) ⇒ Rack
Create a resource object, associate it with a client, and set its properties.
32 33 34 35 36 |
# File 'lib/oneview-sdk/resource/rack.rb', line 32 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
22 |
# File 'lib/oneview-sdk/resource/rack.rb', line 22 alias add create |
#add_rack_resource(resource, options = {}) ⇒ Object
Adds the rack resource with specified options
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/oneview-sdk/resource/rack.rb', line 53 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
40 41 42 |
# File 'lib/oneview-sdk/resource/rack.rb', line 40 def create unavailable_method end |
#delete ⇒ Object
Method is not available
46 47 48 |
# File 'lib/oneview-sdk/resource/rack.rb', line 46 def delete unavailable_method end |
#get_device_topology ⇒ Hash
Gets topology information for the rack
78 79 80 81 |
# File 'lib/oneview-sdk/resource/rack.rb', line 78 def get_device_topology response = @client.rest_get(@data['uri'] + '/deviceTopology') @client.response_handler(response) end |
#remove ⇒ true
Remove resource from OneView
26 |
# File 'lib/oneview-sdk/resource/rack.rb', line 26 alias remove delete |
#remove_rack_resource(resource) ⇒ Object
Remove resources from the rack
72 73 74 |
# File 'lib/oneview-sdk/resource/rack.rb', line 72 def remove_rack_resource(resource) @data['rackMounts'].reject! { |rack_resource| rack_resource['mountUri'] == resource['uri'] } end |