Class: OneviewSDK::API300::Synergy::Enclosure
- Inherits:
-
OneviewSDK::API200::Enclosure
- Object
- Resource
- OneviewSDK::API200::Resource
- OneviewSDK::API200::Enclosure
- OneviewSDK::API300::Synergy::Enclosure
- Defined in:
- lib/oneview-sdk/resource/api300/synergy/enclosure.rb
Overview
Enclosure resource implementation for API300 Synergy
Constant Summary
Constants inherited from OneviewSDK::API200::Enclosure
OneviewSDK::API200::Enclosure::BASE_URI, OneviewSDK::API200::Enclosure::UNIQUE_IDENTIFIERS
Constants inherited from Resource
Resource::BASE_URI, Resource::UNIQUE_IDENTIFIERS
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Class Method Summary collapse
-
.update_enclosure_names(client, hostname, name = '') ⇒ Array<OneviewSDK:API300:Synergy::Enclosure>
Method for renaming all enclosures that share the same frameLinkModuleDomain.
Instance Method Summary collapse
-
#add ⇒ Array<OneviewSDK:API300:Synergy::Enclosure>
Claim/configure the enclosure and its components to the appliance.
-
#initialize(client, params = {}, api_ver = nil) ⇒ Enclosure
constructor
Create a resource object, associate it with a client, and set its properties.
-
#patch(operation, path, value = nil) ⇒ Object
Update specific attributes of a given enclosure.
-
#set_enclosure_group ⇒ Object
Method is not available.
-
#set_environmental_configuration ⇒ Object
Method is not available.
Methods inherited from OneviewSDK::API200::Enclosure
#configuration, #create, #delete, #environmental_configuration, #remove, #script, #set_refresh_state, #update, #utilization
Methods inherited from Resource
#==, #[], #[]=, build_query, #create, #create!, #delete, #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) ⇒ Enclosure
25 26 27 28 29 30 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 25 def initialize(client, params = {}, api_ver = nil) @data ||= {} # Default values: @data['type'] ||= 'EnclosureV300' super end |
Class Method Details
.update_enclosure_names(client, hostname, name = '') ⇒ Array<OneviewSDK:API300:Synergy::Enclosure>
Method for renaming all enclosures that share the same frameLinkModuleDomain. The naming pattern for the enclosures is <name><1..number of enclosures>.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 83 def self.update_enclosure_names(client, hostname, name = '') raise IncompleteResource, 'Missing parameters for update_enclosure_names' unless client && hostname frame_link = '' # Retrieve the frameLinkModuleDomain of the specified enclosure, then use it to find all enclosures # that share that frameLinkModuleDomain. all_enclosures = OneviewSDK::API300::Synergy::Enclosure.find_by(client, {}) all_enclosures.each do |encl| frame_link = encl['frameLinkModuleDomain'] if encl['managerBays'].first['ipAddress'] == hostname end enclosures = all_enclosures.select { |encl| encl['frameLinkModuleDomain'] == frame_link } # Return enclosures without modifying them if a name has not been specified return enclosures if name == '' # Updates the enclosure names and return the array containing the enclosures number_of_enclosures = enclosures.count enclosures.each do |encl| encl['name'] = "#{name}#{number_of_enclosures}" encl.update number_of_enclosures -= 1 end enclosures end |
Instance Method Details
#add ⇒ Array<OneviewSDK:API300:Synergy::Enclosure>
Calls the update_enclosure_names method to set the enclosure names
Claim/configure the enclosure and its components to the appliance
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 35 def add ensure_client required_attributes = %w(hostname) required_attributes.each { |k| raise IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) } temp_data = @data.select { |k, _v| required_attributes.include?(k) } response = @client.rest_post(self.class::BASE_URI, { 'body' => temp_data }, @api_version) @client.response_handler(response) # Renames the enclosures if the @data['name'] is not nil, otherwise only returns the enclosures @data['name'] ||= '' OneviewSDK::API300::Synergy::Enclosure.update_enclosure_names(@client, @data['hostname'], @data['name']) end |
#patch(operation, path, value = nil) ⇒ Object
Update specific attributes of a given enclosure
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 53 def patch(operation, path, value = nil) ensure_client && ensure_uri body = if value { op: operation, path: path, value: value } else { op: operation, path: path } end response = @client.rest_patch(@data['uri'], { 'body' => [body] }, @api_version) @client.response_handler(response) end |
#set_enclosure_group ⇒ Object
Method is not available
72 73 74 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 72 def set_enclosure_group unavailable_method end |
#set_environmental_configuration ⇒ Object
Method is not available
66 67 68 |
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 66 def set_environmental_configuration unavailable_method end |