Class: OneviewSDK::API200::EnclosureGroup
- Defined in:
- lib/oneview-sdk/resource/api200/enclosure_group.rb
Overview
Enclosure group resource implementation
Direct Known Subclasses
Constant Summary collapse
- BASE_URI =
'/rest/enclosure-groups'.freeze
Constants inherited from Resource
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#add_logical_interconnect_group(lig) ⇒ OneviewSDK::EnclosureGroup
Adds the logical interconnect group.
-
#create_interconnect_bay_mapping ⇒ OneviewSDK::EnclosureGroup
Creates the interconnect bay mapping.
-
#get_script ⇒ String
Get the script executed by enclosures in this enclosure group.
-
#initialize(client, params = {}, api_ver = nil) ⇒ EnclosureGroup
constructor
Create a resource object, associate it with a client, and set its properties.
-
#set_script(body) ⇒ Object
Changes the script executed by the enclosures in this enclosure group.
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) ⇒ EnclosureGroup
Create a resource object, associate it with a client, and set its properties.
24 25 26 27 28 29 30 |
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 24 def initialize(client, params = {}, api_ver = nil) super # Default values: @data['type'] ||= 'EnclosureGroupV200' @data['interconnectBayMappingCount'] ||= 8 create_interconnect_bay_mapping unless @data['interconnectBayMappings'] end |
Instance Method Details
#add_logical_interconnect_group(lig) ⇒ OneviewSDK::EnclosureGroup
Adds the logical interconnect group
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 54 def add_logical_interconnect_group(lig) lig.retrieve! unless lig['uri'] raise(NotFound, "The logical interconnect group #{lig['name']} was not found.") unless lig['uri'] lig['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry| entry['logicalLocation']['locationEntries'].each do |location| add_lig_to_bay(location['relativeValue'], lig) if location['type'] == 'Bay' && entry['permittedInterconnectTypeUri'] end end self end |
#create_interconnect_bay_mapping ⇒ OneviewSDK::EnclosureGroup
Creates the interconnect bay mapping
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 67 def create_interconnect_bay_mapping @data['interconnectBayMappings'] = [] 1.upto(@data['interconnectBayMappingCount']) do |bay_number| entry = { 'interconnectBay' => bay_number, 'logicalInterconnectGroupUri' => nil } @data['interconnectBayMappings'] << entry end self end |
#get_script ⇒ String
Get the script executed by enclosures in this enclosure group
34 35 36 37 38 |
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 34 def get_script ensure_client && ensure_uri response = @client.rest_get(@data['uri'] + '/script', @api_version) @client.response_handler(response) end |
#set_script(body) ⇒ Object
Changes the script executed by the enclosures in this enclosure group
43 44 45 46 47 48 |
# File 'lib/oneview-sdk/resource/api200/enclosure_group.rb', line 43 def set_script(body) ensure_client && ensure_uri response = @client.rest_put(@data['uri'] + '/script', { 'body' => body }, @api_version) @client.response_handler(response) true end |