From 8f42e01f18ac408589503f907238e5348b53cee6 Mon Sep 17 00:00:00 2001 From: Harika Date: Fri, 23 Oct 2020 14:17:07 +0530 Subject: [PATCH 01/16] refactored examples --- examples/api600/storage_system.rb | 107 --------- examples/api600/volume.rb | 206 ------------------ .../shared_samples/connection_template.rb | 3 - examples/shared_samples/enclosure.rb | 2 - examples/shared_samples/enclosure_group.rb | 36 ++- examples/shared_samples/ethernet_network.rb | 11 +- examples/shared_samples/fc_network.rb | 8 +- examples/shared_samples/fcoe_network.rb | 3 - examples/shared_samples/firmware_driver.rb | 2 - examples/shared_samples/hypervisor_manager.rb | 2 - examples/shared_samples/interconnect.rb | 85 ++++---- examples/shared_samples/logical_enclosure.rb | 2 - .../shared_samples/logical_interconnect.rb | 6 - examples/shared_samples/network_set.rb | 2 - examples/shared_samples/scope.rb | 15 +- examples/shared_samples/server_certificate.rb | 3 - examples/shared_samples/server_hardware.rb | 3 - .../shared_samples/server_hardware_type.rb | 2 - examples/shared_samples/server_profile.rb | 3 - .../shared_samples/server_profile_template.rb | 3 - examples/shared_samples/storage_pool.rb | 6 - examples/shared_samples/storage_system.rb | 111 ++++++---- examples/shared_samples/uplink_set.rb | 6 - examples/shared_samples/volume.rb | 174 ++++++++------- examples/shared_samples/volume_attachment.rb | 6 - examples/shared_samples/volume_template.rb | 10 +- 26 files changed, 265 insertions(+), 552 deletions(-) delete mode 100644 examples/api600/storage_system.rb delete mode 100644 examples/api600/volume.rb diff --git a/examples/api600/storage_system.rb b/examples/api600/storage_system.rb deleted file mode 100644 index 11ad24b33..000000000 --- a/examples/api600/storage_system.rb +++ /dev/null @@ -1,107 +0,0 @@ -# (C) Copyright 2017 Hewlett Packard Enterprise Development LP -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# You may not use this file except in compliance with the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed -# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -# CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -require_relative '../_client' # Gives access to @client - -# NOTE 1: You'll need to add a FCNetwork before execute this sample -# NOTE 2: You'll need to add the following instance variables to the _client.rb file with valid credentials for your environment: -# @storage_system_ip -# @storage_system_username -# @storage_system_password - -# All supported APIs for Storage System: -# - API200 for C7000 and Synergy (see /examples/shared_samples/storage_system.rb) -# - API300 for C7000 and Synergy (see /examples/shared_samples/storage_system.rb) -# - API500 for C7000 and Synergy (see /examples/api500/storage_system.rb) -# - API600 for C7000 and Synergy - -raise 'ERROR: Must set @storage_system_ip in _client.rb' unless @storage_system_ip -raise 'ERROR: Must set @storage_system_username in _client.rb' unless @storage_system_username -raise 'ERROR: Must set @storage_system_password in _client.rb' unless @storage_system_password - -if @client.api_version < 500 - raise "If you want execute sample for API < #{@client.api_version}," \ - "you should execute the ruby file '/examples/shared_samples/storage_system.rb'" -elsif @client.api_version == 500 - raise "If you want execute sample for API #{@client.api_version}," \ - "you should execute the ruby file '/examples/api500/storage_system.rb'" -end - -# Resources classes that you can use for Storage System in this example: -# storage_system_class = OneviewSDK::API600::C7000::StorageSystem -# storage_system_class = OneviewSDK::API600::Synergy::StorageSystem -storage_system_class = OneviewSDK.resource_named('StorageSystem', @client.api_version) - -# for StorageSystem with family StoreServ -options = { - credentials: { - username: @storage_system_username, - password: @storage_system_password - }, - hostname: @storage_system_ip, - family: 'StoreServ', - deviceSpecificAttributes: { - managedDomain: 'TestDomain' - } -} - -# for StorageSystem with family StoreVirtual -# options = { -# credentials: { -# username: @store_virtual_user, -# password: @store_virtual_password -# }, -# hostname: @store_virtual_ip, -# family: 'StoreVirtual' -# } - -storage_system = storage_system_class.new(@client, options) -puts "\nAdding a storage system with" -puts "Managed Domain: #{storage_system['deviceSpecificAttributes']['managedDomain']}" if options['family'] == 'StoreServ' -puts "Family: #{storage_system['family']}" -puts "Hostname: #{storage_system['hostname']}." -storage_system.add -puts "\nStorage system with uri='#{storage_system['uri']}' added successfully." - -puts "\nFinding a storage system with hostname: #{storage_system['hostname']}" -storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| - puts "\nStorage system with uri='#{storage['uri']}' found." -end - -storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) -storage_system.retrieve! -port = storage_system['ports'].find { |item| item['protocolType'].downcase.include?('fc') } # find first correct protocolType for using our fc network -if port - fc_network = OneviewSDK::API600::C7000::FCNetwork.get_all(@client).first - puts "\n Adding a fc network named '#{fc_network['name']}' with uri='#{fc_network['uri']}' to the storage system." - port['expectedNetworkUri'] = fc_network['uri'] - port['expectedNetworkName'] = fc_network['name'] - port['mode'] = 'Managed' - storage_system.update - puts "\nNetwork added successfully." - storage_system.refresh -end - -puts "\nReachable ports:" -puts storage_system.get_reachable_ports - -puts "\nTemplates:" -storage_system.get_templates - -puts "\nLast refresh time: #{storage_system['lastRefreshTime']}" -puts "\nRefreshing the storage system" -storage_system.request_refresh -storage_system.refresh -puts "\nLast refresh time: #{storage_system['lastRefreshTime']}" - -puts "\nRemoving the storage system." -storage_system.remove -puts "\nStorage system removed successfully." diff --git a/examples/api600/volume.rb b/examples/api600/volume.rb deleted file mode 100644 index 0de5407d4..000000000 --- a/examples/api600/volume.rb +++ /dev/null @@ -1,206 +0,0 @@ -# (C) Copyright 2017 Hewlett Packard Enterprise Development LP -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# You may not use this file except in compliance with the License. -# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed -# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -# CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -require_relative '../_client' # Gives access to @client - -# NOTE: You'll need to add the following instance variable to the _client.rb file with valid values for your environment: -# @storage_system_ip -# @storage_virtual_ip -# NOTE: This sample is for API 600 only. To see sample for previous APIs, look at: -# example volume.rb in the shared_examples folder for api300 and below. -# example volume.rb in the api500 folder for api500. -# -# Resources that can be created according to parameters: -# api_version = 600 & variant = C7000 to OneviewSDK::API600::C7000::Volume -# api_version = 600 & variant = Synergy to OneviewSDK::API600::Synergy::Volume - -# Resource Class used in this sample -volume_class = OneviewSDK.resource_named('Volume', @client.api_version) - -# Extras Classes used in this sample -storage_system_class = OneviewSDK.resource_named('StorageSystem', @client.api_version) -storage_pool_class = OneviewSDK.resource_named('StoragePool', @client.api_version) -volume_template_class = OneviewSDK.resource_named('VolumeTemplate', @client.api_version) - -# Network class for getting volumes by query parameter connections -# Use Fc networks, Fcoe networks based on your requirement. -ethernet_class = OneviewSDK.resource_named('EthernetNetwork', @client.api_version) - -# Set Storage System -storage_system = storage_system_class.new(@client, hostname: @storage_system_ip) -storage_system.retrieve! - -# Retrieve a Storage Pool -pools = storage_pool_class.find_by(@client, storageSystemUri: storage_system[:uri], isManaged: true) -raise 'ERROR: No storage pools found attached to the provided storage system' if pools.empty? -storage_pool = pools.first - -puts "\nCreating a volume with a Storage Pool..." - -options1 = { - properties: { - name: 'ONEVIEW_SDK_TEST_VOLUME_1', - description: 'Volume store serv', - size: 1024 * 1024 * 1024, - provisioningType: 'Thin', - isShareable: false - } -} - -item1 = volume_class.new(@client, options1) -item1.set_storage_pool(storage_pool) -item1.create -item1.retrieve! -puts "\nVolume created successfully! \nName: #{item1['name']} \nURI: #{item1['uri']}" - -puts "\nCreating a volume with a volume template..." - -options2 = { - properties: { - name: 'ONEVIEW_SDK_TEST_VOLUME_2', - description: 'Volume store serv', - size: 1024 * 1024 * 1024, - provisioningType: 'Thin', - isShareable: false - } -} - -volume_template = volume_template_class.find_by(@client, storagePoolUri: storage_pool['uri']).first -item2 = volume_class.new(@client, options2) -item2.set_storage_pool(storage_pool) -item2.set_storage_volume_template(volume_template) -item2.create -item2.retrieve! -puts "\nVolume created successfully! \nName: #{item2['name']} \nURI: #{item2['uri']}" - -puts "\nCreating a volume with a snapshot pool specified..." - -options3 = { - properties: { - name: 'ONEVIEW_SDK_TEST_VOLUME_3', - description: 'Volume store serv', - size: 1024 * 1024 * 1024, - provisioningType: 'Thin', - isShareable: false - } -} - -item3 = volume_class.new(@client, options3) -item3.set_storage_pool(storage_pool) -item3.set_snapshot_pool(storage_pool) -item3.set_storage_volume_template(volume_template) -item3.create -item3.retrieve! -puts "\nVolume created successfully! \nName: #{item3['name']} \nURI: #{item3['uri']}" - -puts "\nCreating a snapshot..." -snapshot_name = 'ONEVIEW_SDK_TEST_VOLUME_3_SNAPSHOT' -item3.set_snapshot_pool(storage_pool) -item3.create_snapshot(snapshot_name) -puts "\nGetting the snapshot created by name" -snap = item3.get_snapshot(snapshot_name) -puts "\nSnapshot found: \n Name: #{snap['name']} \n URI: #{snap['uri']}" - -puts "\nCreating a volume from a snapshot..." -properties = { - 'provisioningType' => 'Thin', - 'name' => 'ONEVIEW_SDK_TEST_VOLUME_4', - 'isShareable' => false -} - -item4 = item3.create_from_snapshot(snapshot_name, properties, volume_template) -item4.retrieve! -puts "\nVolume created successfully! \nName: #{item4['name']} \nURI: #{item4['uri']}" - -puts "\nRemoving a volume only from Oneview and maintaining on the Storage System" -device_volume = item1['deviceVolumeName'] -item1.delete(:oneview) -puts "\nVolume removed successfully!" - -puts "\nAdding a unmanaged volume..." - -options5 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_5', - description: 'Volume added', - deviceVolumeName: device_volume, - isShareable: false, - storageSystemUri: storage_system['uri'] -} - -item5 = volume_class.new(@client, options5) -item5.add -puts "\nVolume added successfully! \nName: #{item5['name']} \nURI: #{item5['uri']}" - -puts "\nCreating a volume from Storage Virtual..." - -options6 = { - properties: { - name: 'ONEVIEW_SDK_TEST_VOLUME_VIRTUAL_1', - description: 'Volume store virtual', - size: 1024 * 1024 * 1024, - provisioningType: 'Thin', - isShareable: false, - dataProtectionLevel: 'NetworkRaid10Mirror2Way' - } -} - -storage_virtual = storage_system_class.find_by(@client, hostname: @store_virtual_ip).first -storage_virtual_pool = storage_pool_class.find_by(@client, storageSystemUri: storage_virtual['uri'], isManaged: true).first -vol_template_virtual = volume_template_class.find_by(@client, storagePoolUri: storage_virtual_pool['uri']).first - -item6 = volume_class.new(@client, options6) -item6.set_storage_pool(storage_virtual_pool) -item6.set_storage_volume_template(vol_template_virtual) -item6.create -puts "\nVolume added successfully! \nName: #{item6['name']} \nURI: #{item6['uri']}" - -puts "\nUpdating the volume name" -old_name = item2['name'] -item2.update(name: "#{old_name}_Updated") -item2.retrieve! -puts "\nVolume updated successfully! New name: #{item2['name']}." - -puts "\nRemoving a snapshot..." -item3.retrieve! -item3.delete_snapshot(snapshot_name) -puts "\nSnapshot removed successfully!" - -puts "\nGetting the attachable volumes managed by the appliance" -attachables = volume_class.get_attachable_volumes(@client) -puts "\nAttachable volumes found: #{attachables}" - -# Getting volumes by query parameter connections -networks = ethernet_class.find_by(@client, {}) - -puts "\n Getting the attachable volumes managed by the applicance by connections" -query = { - connections: { - networkUri: networks.first['uri'] - } -} -attachables_connections = volume_class.get_all_with_query(@client, query) -puts "\nAttachable volumes found: #{attachables_connections}" - -puts "\nGetting the list of extra managed storage volume paths" -paths = volume_class.get_extra_managed_volume_paths(@client) -puts "\nExtra managed storage volume paths found: #{paths}" - -puts "Remove extra presentations from the specified volume on the storage system: \nURI: #{paths['uri']}" -item2.repair -puts "\nExtra managed storage volume paths has been repaired" - -puts "\nRemoving all volumes created in this sample..." -item2.delete -item3.delete -item4.delete -item5.delete -item6.delete -puts "\nVolumes removed successfully!" diff --git a/examples/shared_samples/connection_template.rb b/examples/shared_samples/connection_template.rb index b7fd462e2..b4bcb44e7 100644 --- a/examples/shared_samples/connection_template.rb +++ b/examples/shared_samples/connection_template.rb @@ -12,9 +12,6 @@ require_relative '../_client' # Gives access to @client # Example: Manage connection templates -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported variants: # - C7000 and Synergy for all api versions diff --git a/examples/shared_samples/enclosure.rb b/examples/shared_samples/enclosure.rb index 7eff10ad0..983b947f6 100644 --- a/examples/shared_samples/enclosure.rb +++ b/examples/shared_samples/enclosure.rb @@ -15,8 +15,6 @@ # NOTE: This will add an enclosure named 'OneViewSDK-Test-Enclosure', then delete it. # It will create a bulk of ethernet networks and then delete them. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported Variants: # C7000 and Synergy for all API versions diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index 6efabafdf..a3390a03e 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -14,8 +14,6 @@ # Example: Create an enclosure group for an API2000 C7000 Appliance # NOTE: This will create an enclosure group named 'OneViewSDK Test Enclosure Group', then delete it. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1200, 1600, 1800, 2000. # Supported Variants: # C7000 and Synergy for all API versions @@ -46,6 +44,11 @@ interconnectBayMappings: interconnect_bay_mapping } +options_for_scope = { + name: 'Scope', + description: 'Sample Scope description' +} + item = encl_group_class.new(@client, options) item.add_logical_interconnect_group(lig) @@ -53,17 +56,29 @@ # Gets enclosure group by scopeUris scope_class = OneviewSDK.resource_named('Scope', @client.api_version) scope_item = scope_class.get_all(@client).first - query = { - scopeUris: scope_item['uri'] - } + if scope_item + query = { + scopeUris: scope_item['uri'] + } + else + { + scope = scope_class.new(@client, options_for_scope) + scope.create + query = { + scopeUris: scope['uri'] + } + } puts "\nGets enclosure group with scope '#{query[:scopeUris]}'" items = encl_group_class.get_all_with_query(@client, query) puts "Found enclosure group '#{items}'." end -puts "\nCreating an #{type} with name = '#{item[:name]}' and logical interconnect group uri = '#{lig[:uri]}''" -item.create! -puts "\nCreated #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'" +def add_enclosure_group(item) + puts "\nCreating an #{type} with name = '#{item[:name]}' and logical interconnect group uri = '#{lig[:uri]}''" + item.create! + puts "\nCreated #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'" + +add_enclosure_group(item) item2 = encl_group_class.new(@client, name: encl_group_name) item2.retrieve! @@ -91,3 +106,8 @@ puts "\nDeleting the #{type} with name = '#{item[:name]}' and uri = '#{item[:uri]}''" item.delete puts "\nSucessfully deleted #{type} '#{item[:name]}'." + +# creating enclosureGroup to ensure continuity for automation script +item = encl_group_class.new(@client, options) +item.add_logical_interconnect_group(lig) +add_enclosure_group(item) \ No newline at end of file diff --git a/examples/shared_samples/ethernet_network.rb b/examples/shared_samples/ethernet_network.rb index 30084ec09..c478f7bdf 100644 --- a/examples/shared_samples/ethernet_network.rb +++ b/examples/shared_samples/ethernet_network.rb @@ -14,12 +14,6 @@ # Example: Create/Update/Delete ethernet networks # NOTE: This will create an ethernet network named 'OneViewSDK Test Vlan', update it and then delete it. # It will create a bulk of ethernet networks and then delete them. -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 - -# Supported Variants -# C7000 and Synergy for all api versions # Resource Class used in this sample @@ -138,3 +132,8 @@ # Delete this network ethernet2.delete puts "\nSuccessfully deleted ethernet-network '#{ethernet[:name]}'." + +# Creating another ethernet network to ensure continuity for automation script +ethernet4 = ethernet_class.new(@client, options) +ethernet4.create! +puts "\nCreated ethernet-network '#{ethernet4[:name]}' successfully.\n uri = '#{ethernet4[:uri]}'" diff --git a/examples/shared_samples/fc_network.rb b/examples/shared_samples/fc_network.rb index 8a3a29de4..5c3e71cf6 100644 --- a/examples/shared_samples/fc_network.rb +++ b/examples/shared_samples/fc_network.rb @@ -15,9 +15,6 @@ # NOTE: This will create an fc network named 'OneViewSDK Test FC Network', update it and then delete it. # It will create a bulk of fc networks and then delete them. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 -# # Supported Variants # C7000 and Synergy for all api versions @@ -111,3 +108,8 @@ bulk_options = { 'networkUris' => delete_networks } fc_network_class.bulk_delete(@client, bulk_options) puts "\nBulk deleted the fc networks successfully." + +# created fc-network to ensure continuity for automation script +fc6 = fc_network_class.new(@client, options) +fc6.create! +puts "\nCreated fc-network '#{fc6[:name]}' successfully.\n uri = '#{fc6[:uri]}'" diff --git a/examples/shared_samples/fcoe_network.rb b/examples/shared_samples/fcoe_network.rb index de1016eaa..e094607a9 100644 --- a/examples/shared_samples/fcoe_network.rb +++ b/examples/shared_samples/fcoe_network.rb @@ -14,9 +14,6 @@ # Example: Create/Update/Delete ethernet networks # NOTE: This will create an ethernet network named 'OneViewSDK Test FCoE Network', update it and then delete it. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 -# # Supported Variants # C7000 and Synergy for all api versions diff --git a/examples/shared_samples/firmware_driver.rb b/examples/shared_samples/firmware_driver.rb index e928f726e..f5b2b9359 100644 --- a/examples/shared_samples/firmware_driver.rb +++ b/examples/shared_samples/firmware_driver.rb @@ -15,8 +15,6 @@ # NOTE: This will create a custom firmware driver, then delete it. # The OneView appliance must have a valid spp and hotfix # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported API variants # C7000, Synergy diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 9beca5400..8b1b9573a 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -14,8 +14,6 @@ # Example: Create/Update/Delete hypervisor manager # NOTE: This will create a hypervisor manager named 'vcenter.corp.com', update it and then delete it. # -# Supported APIs: -# - 800, 1000, 1200, 1600, 1800, 2000 # Supported Variants: # - C7000 and Synergy for all API versions diff --git a/examples/shared_samples/interconnect.rb b/examples/shared_samples/interconnect.rb index 44797be29..322c74cae 100644 --- a/examples/shared_samples/interconnect.rb +++ b/examples/shared_samples/interconnect.rb @@ -13,12 +13,6 @@ # Example: Actions with interconnect # NOTE: You'll need to add an interconnect with state Configured and a port linked. -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supoported Variants -# C7000, Synergy # for example, if api_version = 800 & variant = C7000 then, resource created will be in form # OneviewSDK::API800::C7000::Interconnect @@ -42,21 +36,25 @@ # Retrieving the named servers for this interconnect puts "\nRetrieving the named servers for interconnect #{item['name']}" -servers = item.name_servers -puts 'Server not found.' unless servers.empty? -puts servers +if item + servers = item.name_servers + puts 'Server not found.' unless servers.empty? + puts servers # Get statistics for an interconnect, for the specified port -port = item[:ports].last -puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}" -stats = item.statistics(port['name']) -puts "\nStatistics for the interconnect #{item['name']} and port #{port['name']}" -puts stats +if item: + port = item[:ports].last +if item && port + puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}" + stats = item.statistics(port['name']) + puts "\nStatistics for the interconnect #{item['name']} and port #{port['name']}" + puts stats # Resert Port Protection -puts "\nReseting port protection for interconnect #{item['name']}" -item.reset_port_protection -puts 'Reset port protection successfully.' +if item: + puts "\nReseting port protection for interconnect #{item['name']}" + item.reset_port_protection + puts 'Reset port protection successfully.' # Update port ports = item['ports'].select { |k| k['portType'] == 'Uplink' } @@ -79,16 +77,17 @@ puts "\nPort #{port_original_state['name']} with status #{port_original_state['enabled']}" # Patch -puts "\nUpdating an interconnect across a patch." -puts "Interconnect #{item['name']} with uidState #{item['uidState']}" -item.patch('replace', '/uidState', 'Off') -item.retrieve! -puts "Interconnect #{item['name']} updated successfully with new uidState #{item['uidState']}" -# Returning to original state -puts "\nReturning for original state" -item.patch('replace', '/uidState', 'On') -item.retrieve! -puts "Interconnect #{item['name']} updated successfully with previous uidState #{item['uidState']}" +if item + puts "\nUpdating an interconnect across a patch." + puts "Interconnect #{item['name']} with uidState #{item['uidState']}" + item.patch('replace', '/uidState', 'Off') + item.retrieve! + puts "Interconnect #{item['name']} updated successfully with new uidState #{item['uidState']}" + # Returning to original state + puts "\nReturning for original state" + item.patch('replace', '/uidState', 'On') + item.retrieve! + puts "Interconnect #{item['name']} updated successfully with previous uidState #{item['uidState']}" # List of synergy interconnect link topologies begin @@ -102,21 +101,23 @@ # Gets all the Small Form-factor Pluggable (SFP) instances from an interconnect. # This method 'get_pluggable_module_information' was added from api version 500. -begin - puts "\nGets all the Small Form-factor Pluggable (SFP) instances of interconnect #{item['uri']}." - results = item.get_pluggable_module_information - puts "\nThe Small Form-factor Pluggable (SFP) instances retrieved successfully:" - puts results -rescue NoMethodError - puts 'The method #get_pluggable_module_information is available only for api greater than or equal to 500.' -end +if @client.api_version >= 500 + begin + puts "\nGets all the Small Form-factor Pluggable (SFP) instances of interconnect #{item['uri']}." + results = item.get_pluggable_module_information + puts "\nThe Small Form-factor Pluggable (SFP) instances retrieved successfully:" + puts results + rescue NoMethodError + puts 'The method #get_pluggable_module_information is available only for api greater than or equal to 500.' + end # Applies or reapplies the current interconnect configuration. # This method 'configuration' was added in API version 500. -begin - puts "\nApplying the configuration to interconnect #{item['uri']}." - item.configuration - puts "\nThe action was executed successfully" -rescue NoMethodError - puts 'The method #configuration is available only for API version greater than or equal to 500.' -end +if @client.api_version >= 500 + begin + puts "\nApplying the configuration to interconnect #{item['uri']}." + item.configuration + puts "\nThe action was executed successfully" + rescue NoMethodError + puts 'The method #configuration is available only for API version greater than or equal to 500.' + end diff --git a/examples/shared_samples/logical_enclosure.rb b/examples/shared_samples/logical_enclosure.rb index 7964a61fb..be7601b2b 100644 --- a/examples/shared_samples/logical_enclosure.rb +++ b/examples/shared_samples/logical_enclosure.rb @@ -15,8 +15,6 @@ # NOTE: This will create a logical enclosure named 'OneViewSDK Test Logical Enclosure', update it and then delete it. # To run this test with Synergy you must have an enclosureGroup with enclosure count = 3. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 # Supported Variants: # - C7000 and Synergy for all API versions diff --git a/examples/shared_samples/logical_interconnect.rb b/examples/shared_samples/logical_interconnect.rb index f6e88e024..164622a19 100644 --- a/examples/shared_samples/logical_interconnect.rb +++ b/examples/shared_samples/logical_interconnect.rb @@ -12,12 +12,6 @@ require_relative '../_client' # Gives access to @client # Example: Explores functionalities of Logical Interconnects -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported Variants: -# - C7000, Synergy # for example, if api_version = 800 & variant = C7000 then, resource that can be created will be in form # OneviewSDK::API800::C7000::LogicalInterconnect diff --git a/examples/shared_samples/network_set.rb b/examples/shared_samples/network_set.rb index 3175c05e4..815441e8c 100644 --- a/examples/shared_samples/network_set.rb +++ b/examples/shared_samples/network_set.rb @@ -15,8 +15,6 @@ # NOTE: This will create a network set named 'NetworkSet_1', update it and then delete it. # PRE-REQUISITE:Tagged ethernet networks should be created. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported variants: # - C7000 and Synergy for all api versions diff --git a/examples/shared_samples/scope.rb b/examples/shared_samples/scope.rb index 5e05d266e..876e0c977 100644 --- a/examples/shared_samples/scope.rb +++ b/examples/shared_samples/scope.rb @@ -12,12 +12,6 @@ require_relative '../_client' # Gives access to @client # NOTE: It is necessary a server hardware and an enclosure previous created -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 - -# Supported Variants -# C7000 and Synergy for all API versions # NOTE: Scopes doesn't support versions smaller than 300. @@ -129,3 +123,12 @@ scope.refresh scope.delete puts "'Scope' was successfully deleted." unless scope.retrieve! + +# creating scope to ensure continuity for automation script +options = { + name: 'Scope', + description: 'Sample Scope description' +} +scope = scope_class.new(@client, options) +scope.create +puts 'Created scope' diff --git a/examples/shared_samples/server_certificate.rb b/examples/shared_samples/server_certificate.rb index caa5b9c2f..742676a27 100644 --- a/examples/shared_samples/server_certificate.rb +++ b/examples/shared_samples/server_certificate.rb @@ -14,9 +14,6 @@ # NOTE: You'll need to add the following instance variable to the _client.rb file with valid values for your environment: # @hypervisor_manager_ip -# All supported APIs for Server Certificate: -# - 600, 800, 1000, 1200, 1600, 1800, 2000 - # Supported Variants: # - C7000 and Synergy for all API versions diff --git a/examples/shared_samples/server_hardware.rb b/examples/shared_samples/server_hardware.rb index 4fed08f6b..f11b0ca72 100644 --- a/examples/shared_samples/server_hardware.rb +++ b/examples/shared_samples/server_hardware.rb @@ -18,9 +18,6 @@ # @server_hardware_username # @server_hardware_password # -# Resources that can be created according to parameters: -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported Variants: # C7000 and Synergy for all api-versions diff --git a/examples/shared_samples/server_hardware_type.rb b/examples/shared_samples/server_hardware_type.rb index 0298de7c6..5d9db1056 100644 --- a/examples/shared_samples/server_hardware_type.rb +++ b/examples/shared_samples/server_hardware_type.rb @@ -13,8 +13,6 @@ # Example: Actions with a Server Hardware Type # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000 # Supported API variants: # C7000, Synergy diff --git a/examples/shared_samples/server_profile.rb b/examples/shared_samples/server_profile.rb index 8c4d5a8ec..1bc2fbf11 100644 --- a/examples/shared_samples/server_profile.rb +++ b/examples/shared_samples/server_profile.rb @@ -11,9 +11,6 @@ require_relative '../_client' # Gives access to @client -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - # Supported Variants: # - C7000 and Synergy for all supported API versions diff --git a/examples/shared_samples/server_profile_template.rb b/examples/shared_samples/server_profile_template.rb index 2e29a3d67..a59dc9d7b 100644 --- a/examples/shared_samples/server_profile_template.rb +++ b/examples/shared_samples/server_profile_template.rb @@ -11,9 +11,6 @@ require_relative '../_client' # Gives access to @client -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800. - # Supported Variants: # - C7000 and Synergy for all supported API versions. diff --git a/examples/shared_samples/storage_pool.rb b/examples/shared_samples/storage_pool.rb index ffe365ea7..3756209db 100644 --- a/examples/shared_samples/storage_pool.rb +++ b/examples/shared_samples/storage_pool.rb @@ -15,12 +15,6 @@ # NOTE: You'll need to add the following instance variables to the _client.rb file with valid URIs for your environment: # @storage_system_ip -# Supported API Versions: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported Variants: -# C7000 and Synergy for all API versions - storage_pool_class = OneviewSDK.resource_named('StoragePool', @client.api_version) if @client.api_version <= 300 diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index 082ff6682..e9625383f 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -1,4 +1,4 @@ -# (C) Copyright 2020 Hewlett Packard Enterprise Development LP +# (C) Copyright 2017 Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. @@ -11,60 +11,95 @@ require_relative '../_client' # Gives access to @client -# NOTE: You'll need to add the following instance variables to the _client.rb file with valid credentials for your environment: +# NOTE 1: You'll need to add a FCNetwork before execute this sample +# NOTE 2: You'll need to add the following instance variables to the _client.rb file with valid credentials for your environment: # @storage_system_ip # @storage_system_username # @storage_system_password -# Supported API Versions: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported Variants: -# C7000 and Synergy for all API versions -# raise 'ERROR: Must set @storage_system_ip in _client.rb' unless @storage_system_ip raise 'ERROR: Must set @storage_system_username in _client.rb' unless @storage_system_username raise 'ERROR: Must set @storage_system_password in _client.rb' unless @storage_system_password -if @client.api_version >= 600 - raise "If you want execute sample for API #{@client.api_version}," \ - "you should execute the ruby file '/examples/api600/storage_system.rb'" +if @client.api_version < 500 + raise "If you want execute sample for API < #{@client.api_version}," \ + "you should execute the ruby file '/examples/shared_samples/storage_system.rb'" elsif @client.api_version == 500 raise "If you want execute sample for API #{@client.api_version}," \ - "you should execute the ruby file '/examples/api500/storage_system.rb'" + "you should execute the ruby file '/examples/api500/storage_system.rb'" end -# Resources classes that you can use for Storage System in this example: -# storage_system_class = OneviewSDK::API200::StorageSystem -# storage_system_class = OneviewSDK::API300::C7000::StorageSystem -# storage_system_class = OneviewSDK::API300::Synergy::StorageSystem + storage_system_class = OneviewSDK.resource_named('StorageSystem', @client.api_version) +storage_system = storage_system_class.new(@client, options) +# for StorageSystem with family StoreServ options = { - ip_hostname: @storage_system_ip, - username: @storage_system_username, - password: @storage_system_password + credentials: { + username: @storage_system_username, + password: @storage_system_password + }, + hostname: @storage_system_ip, + family: 'StoreServ', + deviceSpecificAttributes: { + managedDomain: 'TestDomain' + } } -storage1 = storage_system_class.new(@client) -storage1['credentials'] = options -storage1['managedDomain'] = 'TestDomain' -puts "\nAdding a storage system with Managed Domain: #{storage1['managedDomain']}" -puts "and hostname: #{options[:ip_hostname]}." -storage1.add -puts "\nStorage system added successfully." - -puts "\nFinding a storage system with hostname: #{options[:ip_hostname]}" -storage_system_class.find_by(@client, credentials: { ip_hostname: options[:ip_hostname] }).each do |storage| - puts "\nStorage system with name #{storage['name']} found." +# for StorageSystem with family StoreVirtual +# options = { +# credentials: { +# username: @store_virtual_user, +# password: @store_virtual_password +# }, +# hostname: @store_virtual_ip, +# family: 'StoreVirtual' +# } + +def add_storage_system(storage_system) + puts "\nAdding a storage system with" + puts "Managed Domain: #{storage_system['deviceSpecificAttributes']['managedDomain']}" if options['family'] == 'StoreServ' + puts "Family: #{storage_system['family']}" + puts "Hostname: #{storage_system['hostname']}." + storage_system.add + puts "\nStorage system with uri='#{storage_system['uri']}' added successfully." + + puts "\nFinding a storage system with hostname: #{storage_system['hostname']}" + storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| + puts "\nStorage system with uri='#{storage['uri']}' found." + end + +add_storage_system(storage_system) + +storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) +storage_system.retrieve! +port = storage_system['ports'].find { |item| item['protocolType'].downcase.include?('fc') } # find first correct protocolType for using our fc network +if port + fc_network = OneviewSDK::API600::C7000::FCNetwork.get_all(@client).first + puts "\n Adding a fc network named '#{fc_network['name']}' with uri='#{fc_network['uri']}' to the storage system." + port['expectedNetworkUri'] = fc_network['uri'] + port['expectedNetworkName'] = fc_network['name'] + port['mode'] = 'Managed' + storage_system.update + puts "\nNetwork added successfully." + storage_system.refresh end -storage2 = storage_system_class.new(@client, credentials: { ip_hostname: options[:ip_hostname] }) -storage2.retrieve! -puts "\nRefreshing a storage system with #{options[:ip_hostname]}" -puts "and state #{storage2['refreshState']}" -storage2.set_refresh_state('RefreshPending') -puts "\nStorage system refreshed successfully and with new state: #{storage2['refreshState']}." +puts "\nReachable ports:" +puts storage_system.get_reachable_ports + +puts "\nTemplates:" +storage_system.get_templates -puts "\nRemoving the Storage system." -storage2.remove +puts "\nLast refresh time: #{storage_system['lastRefreshTime']}" +puts "\nRefreshing the storage system" +storage_system.request_refresh +storage_system.refresh +puts "\nLast refresh time: #{storage_system['lastRefreshTime']}" + +puts "\nRemoving the storage system." +storage_system.remove puts "\nStorage system removed successfully." + +# adding storage system to ensure continuity for automation script +storage_system = storage_system_class.new(@client, options) +add_storage_system(storage_system) \ No newline at end of file diff --git a/examples/shared_samples/uplink_set.rb b/examples/shared_samples/uplink_set.rb index bcf900aa3..25f46dbdc 100644 --- a/examples/shared_samples/uplink_set.rb +++ b/examples/shared_samples/uplink_set.rb @@ -15,12 +15,6 @@ # NOTE: This will create a uplink set named 'UplinkSet Example', then update it with network, then delete it. # NOTE 2: Dependencies: Enclosure, EthernetNetwork, LogicalInterconnectGroup, LogicalInterconnect, Interconnect. # NOTE 3: To add an ethernet network, the interconnect must support ethernet network. -# -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported variants: -# - C7000 and Synergy for all api versions # Resource Class used in this sample diff --git a/examples/shared_samples/volume.rb b/examples/shared_samples/volume.rb index 63e628f14..1fa12b851 100644 --- a/examples/shared_samples/volume.rb +++ b/examples/shared_samples/volume.rb @@ -1,4 +1,4 @@ -# (C) Copyright 2020 Hewlett Packard Enterprise Development LP +# (C) Copyright 2017 Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. @@ -13,16 +13,9 @@ # NOTE: You'll need to add the following instance variable to the _client.rb file with valid values for your environment: # @storage_system_ip -# @unmanaged_volume_wwn (optional) -# NOTE: This sample is for APIs 200 and 300 only. To see sample for API 500, look at the example volume.rb in the examples/api500 folder. +# @storage_virtual_ip # -# Supported API Versions -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported Variants: -# C7000 and Synergy for all API versions - # Resource Class used in this sample volume_class = OneviewSDK.resource_named('Volume', @client.api_version) @@ -31,38 +24,32 @@ storage_pool_class = OneviewSDK.resource_named('StoragePool', @client.api_version) volume_template_class = OneviewSDK.resource_named('VolumeTemplate', @client.api_version) -if @client.api_version >= 600 - raise "If you want execute sample for API #{@client.api_version}," \ - "you should execute the ruby file '/examples/api600/volume.rb'" -elsif @client.api_version == 500 - raise "If you want execute sample for API #{@client.api_version}," \ - "you should execute the ruby file '/examples/api500/volume.rb'" -end - -puts '1) Common = Storage System + Storage Pool' +# Network class for getting volumes by query parameter connections +# Use Fc networks, Fcoe networks based on your requirement. +ethernet_class = OneviewSDK.resource_named('EthernetNetwork', @client.api_version) # Set Storage System -storage_system = storage_system_class.new(@client, credentials: { ip_hostname: @storage_system_ip }) +storage_system = storage_system_class.new(@client, hostname: @storage_system_ip) storage_system.retrieve! # Retrieve a Storage Pool -pools = storage_pool_class.find_by(@client, storageSystemUri: storage_system[:uri]) +pools = storage_pool_class.find_by(@client, storageSystemUri: storage_system[:uri], isManaged: true) raise 'ERROR: No storage pools found attached to the provided storage system' if pools.empty? storage_pool = pools.first -puts "\nCreating a volume with Storage System + Storage Pool..." +puts "\nCreating a volume with a Storage Pool..." options1 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_1', - description: 'Volume example', - provisioningParameters: { - provisionType: 'Thin', - requestedCapacity: 1024 * 1024 * 1024 + properties: { + name: 'ONEVIEW_SDK_TEST_VOLUME_1', + description: 'Volume store serv', + size: 1024 * 1024 * 1024, + provisioningType: 'Thin', + isShareable: false } } item1 = volume_class.new(@client, options1) -item1.set_storage_system(storage_system) item1.set_storage_pool(storage_pool) item1.create item1.retrieve! @@ -71,15 +58,18 @@ puts "\nCreating a volume with a volume template..." options2 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_2', - description: 'Volume example', - provisioningParameters: { - requestedCapacity: 1024 * 1024 * 1024 + properties: { + name: 'ONEVIEW_SDK_TEST_VOLUME_2', + description: 'Volume store serv', + size: 1024 * 1024 * 1024, + provisioningType: 'Thin', + isShareable: false } } -volume_template = volume_template_class.get_all(@client).first +volume_template = volume_template_class.find_by(@client, storagePoolUri: storage_pool['uri']).first item2 = volume_class.new(@client, options2) +item2.set_storage_pool(storage_pool) item2.set_storage_volume_template(volume_template) item2.create item2.retrieve! @@ -88,18 +78,19 @@ puts "\nCreating a volume with a snapshot pool specified..." options3 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_3', - description: 'Volume example', - provisioningParameters: { - provisionType: 'Thin', - requestedCapacity: 1024 * 1024 * 1024 + properties: { + name: 'ONEVIEW_SDK_TEST_VOLUME_3', + description: 'Volume store serv', + size: 1024 * 1024 * 1024, + provisioningType: 'Thin', + isShareable: false } } item3 = volume_class.new(@client, options3) -item3.set_storage_system(storage_system) item3.set_storage_pool(storage_pool) item3.set_snapshot_pool(storage_pool) +item3.set_storage_volume_template(volume_template) item3.create item3.retrieve! puts "\nVolume created successfully! \nName: #{item3['name']} \nURI: #{item3['uri']}" @@ -110,70 +101,101 @@ item3.create_snapshot(snapshot_name) puts "\nGetting the snapshot created by name" snap = item3.get_snapshot(snapshot_name) -puts "\nSnaphot found: \n Name: #{snap['name']} \n URI: #{snap['uri']}" +puts "\nSnapshot found: \n Name: #{snap['name']} \n URI: #{snap['uri']}" puts "\nCreating a volume from a snapshot..." -options4 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_4', - description: 'Volume example', - snapshotUri: "#{item3[:uri]}/snapshots/#{snap['uri']}", - provisioningParameters: { - provisionType: 'Thin', - requestedCapacity: 1024 * 1024 * 1024 - } +properties = { + 'provisioningType' => 'Thin', + 'name' => 'ONEVIEW_SDK_TEST_VOLUME_4', + 'isShareable' => false } -item4 = volume_class.new(@client, options4) -item4.set_storage_system(storage_system) -item4.set_storage_pool(storage_pool) -item4.create +item4 = item3.create_from_snapshot(snapshot_name, properties, volume_template) item4.retrieve! puts "\nVolume created successfully! \nName: #{item4['name']} \nURI: #{item4['uri']}" -if @unmanaged_volume_wwn - puts "\nAdding a unmanaged volume wwn..." +puts "\nRemoving a volume only from Oneview and maintaining on the Storage System" +if item1 + device_volume = item1['deviceVolumeName'] + item1.delete(:oneview) + puts "\nVolume removed successfully!" + +puts "\nAdding a unmanaged volume..." - options5 = { - name: 'ONEVIEW_SDK_TEST_VOLUME_5', - description: 'Test volume - management creation: Storage System + wwn', - wwn: @unmanaged_volume_wwn, # Need unmanaged volume - provisioningParameters: { - shareable: false - } +options5 = { + name: 'ONEVIEW_SDK_TEST_VOLUME_5', + description: 'Volume added', + deviceVolumeName: device_volume, + isShareable: false, + storageSystemUri: storage_system['uri'] +} + +item5 = volume_class.new(@client, options5) +item5.add +puts "\nVolume added successfully! \nName: #{item5['name']} \nURI: #{item5['uri']}" + +puts "\nCreating a volume from Storage Virtual..." + +options6 = { + properties: { + name: 'ONEVIEW_SDK_TEST_VOLUME_VIRTUAL_1', + description: 'Volume store virtual', + size: 1024 * 1024 * 1024, + provisioningType: 'Thin', + isShareable: false, + dataProtectionLevel: 'NetworkRaid10Mirror2Way' } +} - item5 = volume_class.new(@client, options5) - item5.set_storage_system(storage_system) - item5.create - item4.retrieve! - puts "\nVolume added successfully! \nName: #{item5['name']} \nURI: #{item5['uri']}" -end +storage_virtual = storage_system_class.find_by(@client, hostname: @store_virtual_ip).first +storage_virtual_pool = storage_pool_class.find_by(@client, storageSystemUri: storage_virtual['uri'], isManaged: true).first +vol_template_virtual = volume_template_class.find_by(@client, storagePoolUri: storage_virtual_pool['uri']).first + +item6 = volume_class.new(@client, options6) +item6.set_storage_pool(storage_virtual_pool) +item6.set_storage_volume_template(vol_template_virtual) +item6.create +puts "\nVolume added successfully! \nName: #{item6['name']} \nURI: #{item6['uri']}" puts "\nUpdating the volume name" -old_name = item1['name'] -item1.update(name: "#{old_name}_Updated") -item1.retrieve! -puts "\nVolume updated successfully! New name: #{item1['name']}." +old_name = item2['name'] +item2.update(name: "#{old_name}_Updated") +item2.retrieve! +puts "\nVolume updated successfully! New name: #{item2['name']}." puts "\nRemoving a snapshot..." +item3.retrieve! item3.delete_snapshot(snapshot_name) puts "\nSnapshot removed successfully!" puts "\nGetting the attachable volumes managed by the appliance" +attachables = volume_class.get_attachable_volumes(@client) +puts "\nAttachable volumes found: #{attachables}" + +# Getting volumes by query parameter connections +networks = ethernet_class.find_by(@client, {}) + +puts "\n Getting the attachable volumes managed by the applicance by connections" query = { - connections: '' + connections: { + networkUri: networks.first['uri'] + } } -attachables = volume_class.get_attachable_volumes(@client, query) -puts "\nAttachable volumes found: #{attachables}" +attachables_connections = volume_class.get_all_with_query(@client, query) +puts "\nAttachable volumes found: #{attachables_connections}" puts "\nGetting the list of extra managed storage volume paths" paths = volume_class.get_extra_managed_volume_paths(@client) puts "\nExtra managed storage volume paths found: #{paths}" +puts "Remove extra presentations from the specified volume on the storage system: \nURI: #{paths['uri']}" +item2.repair +puts "\nExtra managed storage volume paths has been repaired" + puts "\nRemoving all volumes created in this sample..." -item1.delete item2.delete item3.delete item4.delete -item5.delete(:oneview) if @unmanaged_volume_wwn # Removes only of the Oneview and keep on' the Storage System -puts "\nVolumes removed successfully!" +item5.delete +item6.delete +puts "\nVolumes removed successfully!" \ No newline at end of file diff --git a/examples/shared_samples/volume_attachment.rb b/examples/shared_samples/volume_attachment.rb index f01cf6b7d..9b205bcb1 100644 --- a/examples/shared_samples/volume_attachment.rb +++ b/examples/shared_samples/volume_attachment.rb @@ -11,12 +11,6 @@ require_relative '../_client' # Gives access to @client -# All supported APIs for Volume Attachment: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000 - -# Supported Variants: -# C7000 and Synergy for all API versions - volume_attachment_class = OneviewSDK.resource_named('VolumeAttachment', @client.api_version) # List volume attachments diff --git a/examples/shared_samples/volume_template.rb b/examples/shared_samples/volume_template.rb index 110c19e73..17cbd24d3 100644 --- a/examples/shared_samples/volume_template.rb +++ b/examples/shared_samples/volume_template.rb @@ -14,9 +14,6 @@ # NOTE: You'll need to add the following instance variable to the _client.rb file with valid values for your environment: # @storage_system_ip -# All supported APIs for Volume Template: -# - 200, 300, 500. 600, 800, 1000, 1200, 1600, 1800 and 2000 - raise 'Must set @storage_system_ip in _client.rb' unless @storage_system_ip # Supported Variants for Storage System, Storage Pool and Volume Attachment @@ -39,6 +36,7 @@ } puts "\nCreating a Storage Volume Template" + if @client.api_version < 500 # Retrieve storage pool and storage system storage_pool = storage_pool_class.find_by(@client, {}).first @@ -127,6 +125,6 @@ puts "\nFound Volume Template by name: '#{volume_template_4[:name]}'.\n uri = '#{volume_template_4[:uri]}'" # Delete Volume Template -volume_template.retrieve! -volume_template.delete -puts "\nDeleted Volume Template '#{volume_template[:name]}' successfully.\n" +# volume_template.retrieve! +# volume_template.delete +# puts "\nDeleted Volume Template '#{volume_template[:name]}' successfully.\n" From 90bfd7f7ceba141d8b021e35c1e504d8debb39be Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Wed, 4 Nov 2020 13:27:39 +0530 Subject: [PATCH 02/16] Refactored Enclosure, EG, Storage System --- examples/shared_samples/enclosure.rb | 26 +++++++++++----------- examples/shared_samples/enclosure_group.rb | 18 +++++---------- examples/shared_samples/storage_system.rb | 14 +++++------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/examples/shared_samples/enclosure.rb b/examples/shared_samples/enclosure.rb index 983b947f6..aab99d70b 100644 --- a/examples/shared_samples/enclosure.rb +++ b/examples/shared_samples/enclosure.rb @@ -28,21 +28,25 @@ encl_group = encl_group_class.get_all(@client).first type = 'enclosure' -encl_name = 'OneViewSDK-Test-Enclosure' +encl_name = '0000AA66101' -variant = OneviewSDK.const_get("API#{@client.api_version}").variant unless @client.api_version < 300 +variant = 'Synergy' scope_class = OneviewSDK.resource_named('Scope', @client.api_version) -scope_1 = scope_class.new(@client, name: 'Scope 1') +scope_1 = scope_class.new(@client, name: 'Scope_for_enclosure') scope_1.create options = if variant == 'Synergy' { - name: encl_name, - hostname: @synergy_enclosure_hostname, - initialScopeUris: [scope_1['uri']] - } - else + name: encl_name, + hostname: @enclosure_hostname, + username: @enclosure_username, + password: @enclosure_password, + enclosureGroupUri: encl_group['uri'], + licensingIntent: 'OneView', + initialScopeUris: [scope_1['uri']] + } + else { name: encl_name, hostname: @enclosure_hostname, @@ -57,15 +61,11 @@ item = enclosure_class.new(@client, options) puts "\nAdding an #{type} with name = '#{item[:name]}'" -if variant == 'Synergy' +if variant == 'C7000' enclosures_added = item.add enclosures_added.each do |encl| puts "\nAdded #{type} '#{encl[:name]}' sucessfully.\n uri = '#{encl[:uri]}'" end - encl_name = 'OneViewSDK-Test-Enclosure1' -else - item.add - puts "\nAdded #{type} '#{item[:name]}' successfully.\n uri = '#{item[:uri]}'" end item2 = enclosure_class.new(@client, name: encl_name) diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index a3390a03e..cdbe84abf 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -56,18 +56,9 @@ # Gets enclosure group by scopeUris scope_class = OneviewSDK.resource_named('Scope', @client.api_version) scope_item = scope_class.get_all(@client).first - if scope_item - query = { - scopeUris: scope_item['uri'] - } - else - { - scope = scope_class.new(@client, options_for_scope) - scope.create - query = { - scopeUris: scope['uri'] - } - } + query = { + scopeUris: scope_item['uri'] + } puts "\nGets enclosure group with scope '#{query[:scopeUris]}'" items = encl_group_class.get_all_with_query(@client, query) puts "Found enclosure group '#{items}'." @@ -77,6 +68,7 @@ def add_enclosure_group(item) puts "\nCreating an #{type} with name = '#{item[:name]}' and logical interconnect group uri = '#{lig[:uri]}''" item.create! puts "\nCreated #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'" +end add_enclosure_group(item) @@ -110,4 +102,4 @@ def add_enclosure_group(item) # creating enclosureGroup to ensure continuity for automation script item = encl_group_class.new(@client, options) item.add_logical_interconnect_group(lig) -add_enclosure_group(item) \ No newline at end of file +add_enclosure_group(item) diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index e9625383f..086639c9a 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -30,7 +30,6 @@ end storage_system_class = OneviewSDK.resource_named('StorageSystem', @client.api_version) -storage_system = storage_system_class.new(@client, options) # for StorageSystem with family StoreServ options = { @@ -54,21 +53,23 @@ # hostname: @store_virtual_ip, # family: 'StoreVirtual' # } +storage_system = storage_system_class.new(@client, options) -def add_storage_system(storage_system) +def add_storage_system(storage_system, options) puts "\nAdding a storage system with" puts "Managed Domain: #{storage_system['deviceSpecificAttributes']['managedDomain']}" if options['family'] == 'StoreServ' puts "Family: #{storage_system['family']}" puts "Hostname: #{storage_system['hostname']}." storage_system.add - puts "\nStorage system with uri='#{storage_system['uri']}' added successfully." - + puts "\nStorage system with uri='#{storage_system['uri']}' added successfully. + " puts "\nFinding a storage system with hostname: #{storage_system['hostname']}" storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| puts "\nStorage system with uri='#{storage['uri']}' found." end +end -add_storage_system(storage_system) +add_storage_system(storage_system, options) storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) storage_system.retrieve! @@ -100,6 +101,3 @@ def add_storage_system(storage_system) storage_system.remove puts "\nStorage system removed successfully." -# adding storage system to ensure continuity for automation script -storage_system = storage_system_class.new(@client, options) -add_storage_system(storage_system) \ No newline at end of file From 7c99ed9ba912a5668c55422b23a77a8b4c2a3c8e Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Wed, 4 Nov 2020 14:43:10 +0530 Subject: [PATCH 03/16] refactored HM,Interconnect,StoragePool,StorageSystem --- examples/shared_samples/hypervisor_manager.rb | 10 +++-- examples/shared_samples/interconnect.rb | 41 ++++++++++--------- examples/shared_samples/storage_pool.rb | 24 ++++++----- examples/shared_samples/storage_system.rb | 14 ++++++- 4 files changed, 54 insertions(+), 35 deletions(-) diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 8b1b9573a..2a50ebd77 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -32,14 +32,18 @@ } hm = hypervisor_manager_class.new(@client, options) -hm.create! -puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" # Find recently created hypervisor manager by name matches = hypervisor_manager_class.find_by(@client, name: hm[:name]) hm2 = matches.first puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" +if not hm2 + hm.create! + puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" +end + + # Retrieve recently created hypervisor manager hm3 = hypervisor_manager_class.new(@client, name: hm[:name]) hm3.retrieve! @@ -59,5 +63,5 @@ end # Delete this hypervisor manager -hm.delete +hm2.delete puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." diff --git a/examples/shared_samples/interconnect.rb b/examples/shared_samples/interconnect.rb index 322c74cae..ef381ed2a 100644 --- a/examples/shared_samples/interconnect.rb +++ b/examples/shared_samples/interconnect.rb @@ -40,21 +40,25 @@ servers = item.name_servers puts 'Server not found.' unless servers.empty? puts servers +end # Get statistics for an interconnect, for the specified port -if item: +if item port = item[:ports].last +end if item && port puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}" stats = item.statistics(port['name']) puts "\nStatistics for the interconnect #{item['name']} and port #{port['name']}" puts stats +end # Resert Port Protection -if item: +if item puts "\nReseting port protection for interconnect #{item['name']}" item.reset_port_protection puts 'Reset port protection successfully.' +end # Update port ports = item['ports'].select { |k| k['portType'] == 'Uplink' } @@ -88,6 +92,7 @@ item.patch('replace', '/uidState', 'On') item.retrieve! puts "Interconnect #{item['name']} updated successfully with previous uidState #{item['uidState']}" +end # List of synergy interconnect link topologies begin @@ -101,23 +106,21 @@ # Gets all the Small Form-factor Pluggable (SFP) instances from an interconnect. # This method 'get_pluggable_module_information' was added from api version 500. -if @client.api_version >= 500 - begin - puts "\nGets all the Small Form-factor Pluggable (SFP) instances of interconnect #{item['uri']}." - results = item.get_pluggable_module_information - puts "\nThe Small Form-factor Pluggable (SFP) instances retrieved successfully:" - puts results - rescue NoMethodError - puts 'The method #get_pluggable_module_information is available only for api greater than or equal to 500.' - end +begin + puts "\nGets all the Small Form-factor Pluggable (SFP) instances of interconnect #{item['uri']}." + results = item.get_pluggable_module_information + puts "\nThe Small Form-factor Pluggable (SFP) instances retrieved successfully:" + puts results +rescue NoMethodError + puts 'The method #get_pluggable_module_information is available only for api greater than or equal to 500.' +end # Applies or reapplies the current interconnect configuration. # This method 'configuration' was added in API version 500. -if @client.api_version >= 500 - begin - puts "\nApplying the configuration to interconnect #{item['uri']}." - item.configuration - puts "\nThe action was executed successfully" - rescue NoMethodError - puts 'The method #configuration is available only for API version greater than or equal to 500.' - end +begin + puts "\nApplying the configuration to interconnect #{item['uri']}." + item.configuration + puts "\nThe action was executed successfully" +rescue NoMethodError + puts 'The method #configuration is available only for API version greater than or equal to 500.' +end diff --git a/examples/shared_samples/storage_pool.rb b/examples/shared_samples/storage_pool.rb index 3756209db..911180231 100644 --- a/examples/shared_samples/storage_pool.rb +++ b/examples/shared_samples/storage_pool.rb @@ -63,18 +63,20 @@ puts "\nChanging the storage pool to managed" item_4 = storage_pool_class.find_by(@client, isManaged: false).first - puts 'Before:' - puts item_4.data - item_4.manage(true) - item_4.refresh - puts 'After:' - puts item_4.data + if item_4 + puts 'Before:' + puts item_4.data + item_4.manage(true) + item_4.refresh + puts 'After:' + puts item_4.data - puts "\nRefreshing the storage system" - puts "Last refresh time: #{item_4['lastRefreshTime']}" - item_4.request_refresh - item_4.refresh - puts "Last refresh time: #{item_4['lastRefreshTime']}" + puts "\nRefreshing the storage system" + puts "Last refresh time: #{item_4['lastRefreshTime']}" + item_4.request_refresh + item_4.refresh + puts "Last refresh time: #{item_4['lastRefreshTime']}" + end end if @client.api_version <= 300 diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index 086639c9a..2340f81a5 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -64,12 +64,15 @@ def add_storage_system(storage_system, options) puts "\nStorage system with uri='#{storage_system['uri']}' added successfully. " puts "\nFinding a storage system with hostname: #{storage_system['hostname']}" +end storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| puts "\nStorage system with uri='#{storage['uri']}' found." end -end -add_storage_system(storage_system, options) +storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) +if not storage_system + add_storage_system(storage_system, options) +end storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) storage_system.retrieve! @@ -101,3 +104,10 @@ def add_storage_system(storage_system, options) storage_system.remove puts "\nStorage system removed successfully." +# creating another storage_system to ensure continuity for automation script +storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) +storage_system.retrieve! +if not storage_system + storage_system = storage_system_class.new(@client, options) + add_storage_system(storage_system, options) +end From a791eb40dfeb5686c91062913f810b5bb0d2d6ee Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Wed, 4 Nov 2020 17:40:55 +0530 Subject: [PATCH 04/16] refactored few examples --- examples/shared_samples/enclosure.rb | 34 ++++++---------- examples/shared_samples/enclosure_group.rb | 39 +++++++++++-------- examples/shared_samples/ethernet_network.rb | 8 ++++ examples/shared_samples/hypervisor_manager.rb | 10 +++-- examples/shared_samples/logical_enclosure.rb | 16 ++++---- examples/shared_samples/server_profile.rb | 2 +- examples/shared_samples/storage_system.rb | 8 +++- examples/shared_samples/volume.rb | 7 ++-- examples/shared_samples/volume_attachment.rb | 1 - 9 files changed, 69 insertions(+), 56 deletions(-) diff --git a/examples/shared_samples/enclosure.rb b/examples/shared_samples/enclosure.rb index aab99d70b..c9d478e56 100644 --- a/examples/shared_samples/enclosure.rb +++ b/examples/shared_samples/enclosure.rb @@ -28,7 +28,7 @@ encl_group = encl_group_class.get_all(@client).first type = 'enclosure' -encl_name = '0000AA66101' +encl_name = '0000A66101' variant = 'Synergy' @@ -36,27 +36,15 @@ scope_1 = scope_class.new(@client, name: 'Scope_for_enclosure') scope_1.create -options = if variant == 'Synergy' - { - name: encl_name, - hostname: @enclosure_hostname, - username: @enclosure_username, - password: @enclosure_password, - enclosureGroupUri: encl_group['uri'], - licensingIntent: 'OneView', - initialScopeUris: [scope_1['uri']] - } - else - { - name: encl_name, - hostname: @enclosure_hostname, - username: @enclosure_username, - password: @enclosure_password, - enclosureGroupUri: encl_group['uri'], - licensingIntent: 'OneView', - initialScopeUris: [scope_1['uri']] - } - end +options = { + name: encl_name, + hostname: @enclosure_hostname, + username: @enclosure_username, + password: @enclosure_password, + enclosureGroupUri: encl_group['uri'], + licensingIntent: 'OneView', + initialScopeUris: [scope_1['uri']] + } item = enclosure_class.new(@client, options) @@ -214,3 +202,5 @@ rescue OneviewSDK::TaskError puts "\nRemoving Synergy enclosures on OneView requires the enclosures to be physically disconnected first." end + +scope_1.delete diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index cdbe84abf..b97eb654c 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -28,9 +28,9 @@ variant = 'Synergy' type = 'enclosure group' -encl_group_name = 'OneViewSDK Test Enclosure Group' +encl_group_name = 'EG' -lig = lig_class.find_by(@client, name: @logical_interconnect_name).first +lig = lig_class.find_by(@client, name: 'LIG').first interconnect_bay_mapping = [ { interconnectBay: 3, logicalInterconnectGroupUri: lig[:uri] }, @@ -40,7 +40,7 @@ options = { name: encl_group_name, ipAddressingMode: 'External', - enclosureCount: 1, + enclosureCount: 3, interconnectBayMappings: interconnect_bay_mapping } @@ -64,22 +64,25 @@ puts "Found enclosure group '#{items}'." end -def add_enclosure_group(item) +def add_enclosure_group(item, type, lig) puts "\nCreating an #{type} with name = '#{item[:name]}' and logical interconnect group uri = '#{lig[:uri]}''" item.create! - puts "\nCreated #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'" + puts "\nCreated #{type} '#{item[:name]}' successfully.\n uri = '#{item[:uri]}'" end -add_enclosure_group(item) +item = encl_group_class.new(@client, name: encl_group_name) +if not item + add_enclosure_group(item, type, lig) +end item2 = encl_group_class.new(@client, name: encl_group_name) item2.retrieve! puts "\nFound #{type} by name: '#{item[:name]}'.\n uri = '#{item2[:uri]}'" -item.refresh -puts "\nUpdating an #{type} with name = '#{item[:name]}' and uri = '#{item[:uri]}''" -item.update(name: 'OneViewSDK Test Enclosure_Group Updated') -puts "\nUpdated #{type} with new name = '#{item[:name]}' sucessfully." +item2.refresh +puts "\nUpdating an #{type} with name = '#{item2[:name]}' and uri = '#{item2[:uri]}''" +item2.update(name: 'OneViewSDK Test Enclosure_Group Updated') +puts "\nUpdated #{type} with new name = '#{item2[:name]}' successfully." if variant == 'C7000' command = '#TEST COMMAND' @@ -95,11 +98,15 @@ def add_enclosure_group(item) puts script end -puts "\nDeleting the #{type} with name = '#{item[:name]}' and uri = '#{item[:uri]}''" -item.delete -puts "\nSucessfully deleted #{type} '#{item[:name]}'." +begin + puts "\nDeleting the #{type} with name = '#{item2[:name]}' and uri = '#{item2[:uri]}''" + item2.delete + puts "\nSucessfully deleted #{type} '#{item2[:name]}'." +rescue + puts "Unable to delete EG #{item2[:name]}" +end # creating enclosureGroup to ensure continuity for automation script -item = encl_group_class.new(@client, options) -item.add_logical_interconnect_group(lig) -add_enclosure_group(item) +item3 = encl_group_class.new(@client, options) +item3.add_logical_interconnect_group(lig) +add_enclosure_group(item3, type, lig) diff --git a/examples/shared_samples/ethernet_network.rb b/examples/shared_samples/ethernet_network.rb index c478f7bdf..a926fb543 100644 --- a/examples/shared_samples/ethernet_network.rb +++ b/examples/shared_samples/ethernet_network.rb @@ -134,6 +134,14 @@ puts "\nSuccessfully deleted ethernet-network '#{ethernet[:name]}'." # Creating another ethernet network to ensure continuity for automation script +options = { + vlanId: '1001', + purpose: 'General', + name: 'OneViewSDK Test Vlan', + smartLink: false, + privateNetwork: false, + connectionTemplateUri: nil +} ethernet4 = ethernet_class.new(@client, options) ethernet4.create! puts "\nCreated ethernet-network '#{ethernet4[:name]}' successfully.\n uri = '#{ethernet4[:uri]}'" diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 2a50ebd77..bb6e0d2fe 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -36,7 +36,9 @@ # Find recently created hypervisor manager by name matches = hypervisor_manager_class.find_by(@client, name: hm[:name]) hm2 = matches.first -puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" +if hm2 + puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" +end if not hm2 hm.create! @@ -51,8 +53,8 @@ # Update hypervisor manager registration attribute = { name: @hypervisor_manager_ip } -hm2.update(attribute) -puts "\nUpdated hypervisor-manager: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" +hm3.update(attribute) +puts "\nUpdated hypervisor-manager: '#{hm3[:name]}'.\n uri = '#{hm3[:uri]}'" puts "with attribute: #{attribute}" # Example: List all hypervisor managers certain attributes @@ -63,5 +65,5 @@ end # Delete this hypervisor manager -hm2.delete +hm3.delete puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." diff --git a/examples/shared_samples/logical_enclosure.rb b/examples/shared_samples/logical_enclosure.rb index be7601b2b..31ac89a25 100644 --- a/examples/shared_samples/logical_enclosure.rb +++ b/examples/shared_samples/logical_enclosure.rb @@ -26,10 +26,10 @@ encl_group_class = OneviewSDK.resource_named('EnclosureGroup', @client.api_version) enclosure_class = OneviewSDK.resource_named('Enclosure', @client.api_version) -variant = OneviewSDK.const_get("API#{@client.api_version}").variant unless @client.api_version < 300 +variant = 'Synergy' scope_class = OneviewSDK.resource_named('Scope', @client.api_version) -scope_1 = scope_class.new(@client, name: 'Scope 1') +scope_1 = scope_class.new(@client, name: 'Scope_for_LE') scope_1.create if variant == 'Synergy' @@ -115,11 +115,13 @@ # Set configuration script puts "\nSetting a logical enclosure script" -begin - item3.set_script(orig_script) - puts "\nOperation performed successfully." -rescue OneviewSDK::MethodUnavailable => e - puts "\n#{e}. Available only for C7000." +if variant == 'C7000' + begin + item3.set_script(orig_script) + puts "\nOperation performed successfully." + rescue OneviewSDK::MethodUnavailable => e + puts "\n#{e}. Available only for C7000." + end end # Update from Group diff --git a/examples/shared_samples/server_profile.rb b/examples/shared_samples/server_profile.rb index 1bc2fbf11..5a585e639 100644 --- a/examples/shared_samples/server_profile.rb +++ b/examples/shared_samples/server_profile.rb @@ -95,7 +95,7 @@ puts "\nGetting the error or status messages associated with the specified profile" begin msgs = item3.get_messages - puts "\nMessasses retrieved successfully! \n Message: #{msgs}" + puts "\nMessages retrieved successfully! \n Message: #{msgs}" rescue OneviewSDK::MethodUnavailable puts "\nThe method #get_messages available for API version <= 500" end diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index 2340f81a5..b438753ab 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -101,8 +101,12 @@ def add_storage_system(storage_system, options) puts "\nLast refresh time: #{storage_system['lastRefreshTime']}" puts "\nRemoving the storage system." -storage_system.remove -puts "\nStorage system removed successfully." +begin + storage_system.remove + puts "\nStorage system removed successfully." +rescue + puts "\nUnable to delete: #{storage_system['hostname']}" +end # creating another storage_system to ensure continuity for automation script storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) diff --git a/examples/shared_samples/volume.rb b/examples/shared_samples/volume.rb index 1fa12b851..0b446324f 100644 --- a/examples/shared_samples/volume.rb +++ b/examples/shared_samples/volume.rb @@ -119,6 +119,7 @@ device_volume = item1['deviceVolumeName'] item1.delete(:oneview) puts "\nVolume removed successfully!" +end puts "\nAdding a unmanaged volume..." @@ -142,8 +143,8 @@ description: 'Volume store virtual', size: 1024 * 1024 * 1024, provisioningType: 'Thin', - isShareable: false, - dataProtectionLevel: 'NetworkRaid10Mirror2Way' + isShareable: false + #dataProtectionLevel: 'NetworkRaid10Mirror2Way' } } @@ -198,4 +199,4 @@ item4.delete item5.delete item6.delete -puts "\nVolumes removed successfully!" \ No newline at end of file +puts "\nVolumes removed successfully!" diff --git a/examples/shared_samples/volume_attachment.rb b/examples/shared_samples/volume_attachment.rb index 9b205bcb1..37ab3b8cc 100644 --- a/examples/shared_samples/volume_attachment.rb +++ b/examples/shared_samples/volume_attachment.rb @@ -37,4 +37,3 @@ puts "- #{path['initiatorName']}" end end -puts From bb97a28bb7a6ebc2a329fa4f6aa72a6acadf304f Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Wed, 4 Nov 2020 19:39:07 +0530 Subject: [PATCH 05/16] refactored other examples --- examples/shared_samples/enclosure_group.rb | 9 ++++++--- examples/shared_samples/hypervisor_cluster_profile.rb | 2 -- examples/shared_samples/hypervisor_manager.rb | 9 +++++++++ examples/shared_samples/logical_enclosure.rb | 2 +- examples/shared_samples/logical_interconnect_group.rb | 4 +--- examples/shared_samples/uplink_set.rb | 3 ++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index b97eb654c..69ecb47ab 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -107,6 +107,9 @@ def add_enclosure_group(item, type, lig) end # creating enclosureGroup to ensure continuity for automation script -item3 = encl_group_class.new(@client, options) -item3.add_logical_interconnect_group(lig) -add_enclosure_group(item3, type, lig) +item = encl_group_class.new(@client, name: encl_group_name) +if not item + item.add_logical_interconnect_group(lig) + add_enclosure_group(item, type, lig) +end + diff --git a/examples/shared_samples/hypervisor_cluster_profile.rb b/examples/shared_samples/hypervisor_cluster_profile.rb index 6e4fd3f88..1ede474af 100644 --- a/examples/shared_samples/hypervisor_cluster_profile.rb +++ b/examples/shared_samples/hypervisor_cluster_profile.rb @@ -14,8 +14,6 @@ # Example: Create/Update/Delete hypervisor cluster profile # NOTE: This will create a hypervisor cluster profile named 'cluster5', update it and then delete it. # -# Supported API Versions: -# - 800, 1000, 1200, 1600, 1800, 2000 # Supported Variants: # - C7000 and Synergy for all API versions diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index bb6e0d2fe..3e6cf517c 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -67,3 +67,12 @@ # Delete this hypervisor manager hm3.delete puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." + +# Created HypervisorManager to ensure continuity for automation script +hm4 = hypervisor_manager_class.find_by(@client, name: hm[:name]).first +if not hm4 + hm5 = hypervisor_manager_class.new(@client, options) + hm5.create! + puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" +end + diff --git a/examples/shared_samples/logical_enclosure.rb b/examples/shared_samples/logical_enclosure.rb index 31ac89a25..1cb5a74c3 100644 --- a/examples/shared_samples/logical_enclosure.rb +++ b/examples/shared_samples/logical_enclosure.rb @@ -34,7 +34,7 @@ if variant == 'Synergy' options = { - name: 'OneViewSDK Test Logical Enclosure', + name: 'LE', forceInstallFirmware: false, firmwareBaselineUri: nil, initialScopeUris: [scope_1['uri']] diff --git a/examples/shared_samples/logical_interconnect_group.rb b/examples/shared_samples/logical_interconnect_group.rb index c6c6c12cd..7813dee2b 100644 --- a/examples/shared_samples/logical_interconnect_group.rb +++ b/examples/shared_samples/logical_interconnect_group.rb @@ -14,8 +14,6 @@ # Example: Create/Update/Delete logical interconnects groups # NOTE: This will create a few networks (ethernet & FC), as well as a LIG named 'ONEVIEW_SDK_TEST_LIG', then delete them all. # -# Supported APIs: -# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800 # Supported API variants # C7000, Synergy @@ -44,7 +42,7 @@ HP_VC_FF_24_MODEL = 'HP VC FlexFabric 10Gb/24-Port Module'.freeze VIRTUAL_CONNECT_SE_40_SYNERGY = 'Virtual Connect SE 40Gb F8 Module for Synergy'.freeze -lig = lig_class.new(@client, name: 'ONEVIEW_SDK_TEST_LIG') +lig = lig_class.new(@client, name: 'LIG') # Create an Ethernet Uplink Set eth1_options = { diff --git a/examples/shared_samples/uplink_set.rb b/examples/shared_samples/uplink_set.rb index 25f46dbdc..ab95575fe 100644 --- a/examples/shared_samples/uplink_set.rb +++ b/examples/shared_samples/uplink_set.rb @@ -23,8 +23,9 @@ li_class = OneviewSDK.resource_named('LogicalInterconnect', @client.api_version) interconnect_class = OneviewSDK.resource_named('Interconnect', @client.api_version) +logical_interconnect_name = 'LE-LIG' ethernet = ethernet_class.get_all(@client).first -logical_interconnect = li_class.find_by(@client, name: @logical_interconnect_name).first +logical_interconnect = li_class.find_by(@client, name: logical_interconnect_name).first interconnect = interconnect_class.find_by(@client, logicalInterconnectUri: logical_interconnect['uri']).first port = interconnect['ports'].select { |item| item['portType'] == 'Uplink' && item['portStatus'] == 'Unlinked' }.first From e96d3dc61644c079e0fb5326b4819886dff0b29f Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Wed, 4 Nov 2020 19:58:03 +0530 Subject: [PATCH 06/16] Refactored scope --- examples/shared_samples/scope.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shared_samples/scope.rb b/examples/shared_samples/scope.rb index 876e0c977..a8b66baea 100644 --- a/examples/shared_samples/scope.rb +++ b/examples/shared_samples/scope.rb @@ -84,7 +84,7 @@ puts 'Server hardware resource added to scope3' puts "\nRemoving resource from scope3" - scope_class.remove_resource_scope(@client, enclosure, scopes: [scope3, scope_item]) + scope_class.remove_resource_scope(@client, enclosure, scopes: [scope2, scope_item]) scope_class.add_resource_scope(@client, server_hardware, scopes: [scope_item]) scope_class.resource_patch(@client, server_hardware, add_scopes: [scope3], remove_scopes: [scope_item]) puts 'Removed resource from scope3' From b9a2f14880b1cb6edaae93cf0d7a824cf9230c8c Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Wed, 4 Nov 2020 20:21:10 +0530 Subject: [PATCH 07/16] fix flake errors --- examples/shared_samples/enclosure.rb | 16 ++++++++-------- examples/shared_samples/enclosure_group.rb | 11 ++--------- examples/shared_samples/hypervisor_manager.rb | 7 ++----- examples/shared_samples/interconnect.rb | 5 ++--- examples/shared_samples/storage_system.rb | 10 +++------- examples/shared_samples/volume.rb | 1 - 6 files changed, 17 insertions(+), 33 deletions(-) diff --git a/examples/shared_samples/enclosure.rb b/examples/shared_samples/enclosure.rb index c9d478e56..5ddb4afe9 100644 --- a/examples/shared_samples/enclosure.rb +++ b/examples/shared_samples/enclosure.rb @@ -37,14 +37,14 @@ scope_1.create options = { - name: encl_name, - hostname: @enclosure_hostname, - username: @enclosure_username, - password: @enclosure_password, - enclosureGroupUri: encl_group['uri'], - licensingIntent: 'OneView', - initialScopeUris: [scope_1['uri']] - } + name: encl_name, + hostname: @enclosure_hostname, + username: @enclosure_username, + password: @enclosure_password, + enclosureGroupUri: encl_group['uri'], + licensingIntent: 'OneView', + initialScopeUris: [scope_1['uri']] +} item = enclosure_class.new(@client, options) diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index 69ecb47ab..81470cc2c 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -44,11 +44,6 @@ interconnectBayMappings: interconnect_bay_mapping } -options_for_scope = { - name: 'Scope', - description: 'Sample Scope description' -} - item = encl_group_class.new(@client, options) item.add_logical_interconnect_group(lig) @@ -57,7 +52,7 @@ scope_class = OneviewSDK.resource_named('Scope', @client.api_version) scope_item = scope_class.get_all(@client).first query = { - scopeUris: scope_item['uri'] + scopeUris: scope_item['uri'] } puts "\nGets enclosure group with scope '#{query[:scopeUris]}'" items = encl_group_class.get_all_with_query(@client, query) @@ -71,9 +66,7 @@ def add_enclosure_group(item, type, lig) end item = encl_group_class.new(@client, name: encl_group_name) -if not item - add_enclosure_group(item, type, lig) -end +add_enclosure_group(item, type, lig) unless item item2 = encl_group_class.new(@client, name: encl_group_name) item2.retrieve! diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 3e6cf517c..7fdc845c6 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -40,11 +40,8 @@ puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" end -if not hm2 - hm.create! - puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" -end - +hm.create! unless hm2 +puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" # Retrieve recently created hypervisor manager hm3 = hypervisor_manager_class.new(@client, name: hm[:name]) diff --git a/examples/shared_samples/interconnect.rb b/examples/shared_samples/interconnect.rb index ef381ed2a..256c71ca4 100644 --- a/examples/shared_samples/interconnect.rb +++ b/examples/shared_samples/interconnect.rb @@ -43,9 +43,8 @@ end # Get statistics for an interconnect, for the specified port -if item - port = item[:ports].last -end +port = item[:ports].last if item + if item && port puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}" stats = item.statistics(port['name']) diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index b438753ab..df85037e2 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -70,9 +70,7 @@ def add_storage_system(storage_system, options) end storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) -if not storage_system - add_storage_system(storage_system, options) -end +add_storage_system(storage_system, options) unless storage_system storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) storage_system.retrieve! @@ -111,7 +109,5 @@ def add_storage_system(storage_system, options) # creating another storage_system to ensure continuity for automation script storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) storage_system.retrieve! -if not storage_system - storage_system = storage_system_class.new(@client, options) - add_storage_system(storage_system, options) -end +storage_system = storage_system_class.new(@client, options) unless storage_system +add_storage_system(storage_system, options) unless storage_system diff --git a/examples/shared_samples/volume.rb b/examples/shared_samples/volume.rb index 0b446324f..2d8650eeb 100644 --- a/examples/shared_samples/volume.rb +++ b/examples/shared_samples/volume.rb @@ -144,7 +144,6 @@ size: 1024 * 1024 * 1024, provisioningType: 'Thin', isShareable: false - #dataProtectionLevel: 'NetworkRaid10Mirror2Way' } } From 49b87b6f963d6d30009dba46da2b18315b9cb5a9 Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Wed, 4 Nov 2020 21:57:46 +0530 Subject: [PATCH 08/16] fix flake errors --- examples/shared_samples/enclosure.rb | 14 +++++++------- examples/shared_samples/enclosure_group.rb | 7 ++----- examples/shared_samples/hypervisor_manager.rb | 3 +-- examples/shared_samples/storage_system.rb | 8 ++++---- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/shared_samples/enclosure.rb b/examples/shared_samples/enclosure.rb index 5ddb4afe9..61a785543 100644 --- a/examples/shared_samples/enclosure.rb +++ b/examples/shared_samples/enclosure.rb @@ -37,13 +37,13 @@ scope_1.create options = { - name: encl_name, - hostname: @enclosure_hostname, - username: @enclosure_username, - password: @enclosure_password, - enclosureGroupUri: encl_group['uri'], - licensingIntent: 'OneView', - initialScopeUris: [scope_1['uri']] + name: encl_name, + hostname: @enclosure_hostname, + username: @enclosure_username, + password: @enclosure_password, + enclosureGroupUri: encl_group['uri'], + licensingIntent: 'OneView', + initialScopeUris: [scope_1['uri']] } item = enclosure_class.new(@client, options) diff --git a/examples/shared_samples/enclosure_group.rb b/examples/shared_samples/enclosure_group.rb index 81470cc2c..fe0d4d1a0 100644 --- a/examples/shared_samples/enclosure_group.rb +++ b/examples/shared_samples/enclosure_group.rb @@ -101,8 +101,5 @@ def add_enclosure_group(item, type, lig) # creating enclosureGroup to ensure continuity for automation script item = encl_group_class.new(@client, name: encl_group_name) -if not item - item.add_logical_interconnect_group(lig) - add_enclosure_group(item, type, lig) -end - +item.add_logical_interconnect_group(lig) unless item +add_enclosure_group(item, type, lig) unless item diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 7fdc845c6..6c73ca376 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -67,9 +67,8 @@ # Created HypervisorManager to ensure continuity for automation script hm4 = hypervisor_manager_class.find_by(@client, name: hm[:name]).first -if not hm4 +if !hm4 hm5 = hypervisor_manager_class.new(@client, options) hm5.create! puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" end - diff --git a/examples/shared_samples/storage_system.rb b/examples/shared_samples/storage_system.rb index df85037e2..d2cb09a4a 100644 --- a/examples/shared_samples/storage_system.rb +++ b/examples/shared_samples/storage_system.rb @@ -65,9 +65,9 @@ def add_storage_system(storage_system, options) " puts "\nFinding a storage system with hostname: #{storage_system['hostname']}" end - storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| - puts "\nStorage system with uri='#{storage['uri']}' found." - end +storage_system_class.find_by(@client, hostname: storage_system['hostname']).each do |storage| + puts "\nStorage system with uri='#{storage['uri']}' found." +end storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) add_storage_system(storage_system, options) unless storage_system @@ -109,5 +109,5 @@ def add_storage_system(storage_system, options) # creating another storage_system to ensure continuity for automation script storage_system = storage_system_class.new(@client, hostname: storage_system['hostname']) storage_system.retrieve! -storage_system = storage_system_class.new(@client, options) unless storage_system +storage_system ||= storage_system_class.new(@client, options) add_storage_system(storage_system, options) unless storage_system From 325a159502f3d024b9736f59013041378be0d46d Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Wed, 4 Nov 2020 22:06:36 +0530 Subject: [PATCH 09/16] added lib files for OSDeploymentPlan --- .../api2200/synergy/os_deployment_plan.rb | 22 +++++++++++++++++++ .../synergy/os_deployment_plan_spec.rb | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/oneview-sdk/resource/api2200/synergy/os_deployment_plan.rb create mode 100644 spec/unit/resource/api2200/synergy/os_deployment_plan_spec.rb diff --git a/lib/oneview-sdk/resource/api2200/synergy/os_deployment_plan.rb b/lib/oneview-sdk/resource/api2200/synergy/os_deployment_plan.rb new file mode 100644 index 000000000..bc8f293c1 --- /dev/null +++ b/lib/oneview-sdk/resource/api2200/synergy/os_deployment_plan.rb @@ -0,0 +1,22 @@ +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. + +require_relative '../../api2000/synergy/os_deployment_plan' + +module OneviewSDK + module API2200 + module Synergy + # OS Deployment Plan resource implementation for API2200 Synergy + class OSDeploymentPlan < OneviewSDK::API2000::Synergy::OSDeploymentPlan + end + end + end +end diff --git a/spec/unit/resource/api2200/synergy/os_deployment_plan_spec.rb b/spec/unit/resource/api2200/synergy/os_deployment_plan_spec.rb new file mode 100644 index 000000000..230f390a5 --- /dev/null +++ b/spec/unit/resource/api2200/synergy/os_deployment_plan_spec.rb @@ -0,0 +1,20 @@ +# (C) Copyright 2020 Hewlett Packard Enterprise Development LP +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + +require 'spec_helper' + +RSpec.describe OneviewSDK::API2200::Synergy::OSDeploymentPlan do + include_context 'shared context' + + it 'inherits from OneviewSDK::API2000::Synergy::OSDeploymentPlan' do + expect(described_class).to be < OneviewSDK::API2000::Synergy::OSDeploymentPlan + end +end From 90e879e8c1579f98d0341be6356289b12c6453b4 Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Thu, 5 Nov 2020 09:37:56 +0530 Subject: [PATCH 10/16] fix robocop errors --- examples/shared_samples/hypervisor_manager.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index 6c73ca376..9c3da9b0f 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -67,8 +67,6 @@ # Created HypervisorManager to ensure continuity for automation script hm4 = hypervisor_manager_class.find_by(@client, name: hm[:name]).first -if !hm4 - hm5 = hypervisor_manager_class.new(@client, options) - hm5.create! - puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" -end +hm5 = hypervisor_manager_class.new(@client, options) unless hm4 +hm5.create! unless hm4 +puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" unless hm4 From 0c49cc2f5ec4819c20a1b3068322c359ce297b3a Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Thu, 5 Nov 2020 11:16:38 +0530 Subject: [PATCH 11/16] added type for HCP --- examples/shared_samples/server_profile_template.rb | 1 - .../resource/api2200/c7000/hypervisor_cluster_profile.rb | 5 +++++ .../resource/api2200/synergy/hypervisor_cluster_profile.rb | 4 ++-- lib/oneview-sdk/resource/api2200/synergy/server_profile.rb | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/shared_samples/server_profile_template.rb b/examples/shared_samples/server_profile_template.rb index a59dc9d7b..440ce2bdb 100644 --- a/examples/shared_samples/server_profile_template.rb +++ b/examples/shared_samples/server_profile_template.rb @@ -14,7 +14,6 @@ # Supported Variants: # - C7000 and Synergy for all supported API versions. - # Resource Class used in this sample server_profile_template_class = OneviewSDK.resource_named('ServerProfileTemplate', @client.api_version) diff --git a/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb b/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb index e653b4ecd..12fddee8c 100644 --- a/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb +++ b/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb @@ -16,6 +16,11 @@ module API2200 module C7000 # Hypervisor cluster profile resource implementation for API2200 C7000 class HypervisorClusterProfile < OneviewSDK::API2000::C7000::HypervisorClusterProfile + def initialize(client, params = {}, api_ver = nil) + super + # Default values + @data['type'] ||= 'HypervisorClusterProfileV4' + end end end end diff --git a/lib/oneview-sdk/resource/api2200/synergy/hypervisor_cluster_profile.rb b/lib/oneview-sdk/resource/api2200/synergy/hypervisor_cluster_profile.rb index b6dfce4de..9343a8d09 100644 --- a/lib/oneview-sdk/resource/api2200/synergy/hypervisor_cluster_profile.rb +++ b/lib/oneview-sdk/resource/api2200/synergy/hypervisor_cluster_profile.rb @@ -9,13 +9,13 @@ # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. -require_relative '../../api2000/synergy/hypervisor_cluster_profile' +require_relative '../../api2200/c7000/hypervisor_cluster_profile' module OneviewSDK module API2200 module Synergy # Hypervisor cluster profile resource implementation for API2200 Synergy - class HypervisorClusterProfile < OneviewSDK::API2000::Synergy::HypervisorClusterProfile + class HypervisorClusterProfile < OneviewSDK::API2200::C7000::HypervisorClusterProfile end end end diff --git a/lib/oneview-sdk/resource/api2200/synergy/server_profile.rb b/lib/oneview-sdk/resource/api2200/synergy/server_profile.rb index 30052fa3a..bd7ac940f 100644 --- a/lib/oneview-sdk/resource/api2200/synergy/server_profile.rb +++ b/lib/oneview-sdk/resource/api2200/synergy/server_profile.rb @@ -17,6 +17,8 @@ module API2200 module Synergy # Server profile resource implementation for API2200 Synergy class ServerProfile < OneviewSDK::API2200::C7000::ServerProfile + extend OneviewSDK::API300::Synergy::SASLogicalJBODHelper + include OneviewSDK::API300::Synergy::ServerProfileHelper end end end From 7597e46343c3e4a51adea11e461d2077e1aa2b66 Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Thu, 5 Nov 2020 12:01:09 +0530 Subject: [PATCH 12/16] fix robocop errors --- .../resource/api2200/c7000/hypervisor_cluster_profile.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb b/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb index 12fddee8c..1afc917c2 100644 --- a/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb +++ b/lib/oneview-sdk/resource/api2200/c7000/hypervisor_cluster_profile.rb @@ -17,9 +17,9 @@ module C7000 # Hypervisor cluster profile resource implementation for API2200 C7000 class HypervisorClusterProfile < OneviewSDK::API2000::C7000::HypervisorClusterProfile def initialize(client, params = {}, api_ver = nil) - super - # Default values - @data['type'] ||= 'HypervisorClusterProfileV4' + super + # Default values + @data['type'] ||= 'HypervisorClusterProfileV4' end end end From b6d6daced1b186daa2ac908b56359a6ec4b0a24c Mon Sep 17 00:00:00 2001 From: Chebrolu Date: Thu, 5 Nov 2020 12:13:35 +0530 Subject: [PATCH 13/16] fix UTs --- .../api2200/synergy/hypervisor_cluster_profile_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/unit/resource/api2200/synergy/hypervisor_cluster_profile_spec.rb b/spec/unit/resource/api2200/synergy/hypervisor_cluster_profile_spec.rb index 418c4d2e7..7ac5156e0 100644 --- a/spec/unit/resource/api2200/synergy/hypervisor_cluster_profile_spec.rb +++ b/spec/unit/resource/api2200/synergy/hypervisor_cluster_profile_spec.rb @@ -14,8 +14,8 @@ RSpec.describe OneviewSDK::API2200::Synergy::HypervisorClusterProfile do include_context 'shared context' - # it inherit latest changes from API2000 Synergy lib file - it 'inherits from OneviewSDK::API2000::Synergy::HypervisorClusterProfile' do - expect(described_class).to be < OneviewSDK::API2000::Synergy::HypervisorClusterProfile + # it inherit latest changes from API2200 C7000 lib file + it 'inherits from OneviewSDK::API2200::C7000::HypervisorClusterProfile' do + expect(described_class).to be < OneviewSDK::API2200::C7000::HypervisorClusterProfile end end From 5b0695a19652ec658636e9d3c146a4ce21257fbb Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Fri, 6 Nov 2020 14:28:24 +0530 Subject: [PATCH 14/16] modify interconnect library --- lib/oneview-sdk/resource/api2200/c7000/interconnect.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oneview-sdk/resource/api2200/c7000/interconnect.rb b/lib/oneview-sdk/resource/api2200/c7000/interconnect.rb index 0c16bb74d..f2566242f 100644 --- a/lib/oneview-sdk/resource/api2200/c7000/interconnect.rb +++ b/lib/oneview-sdk/resource/api2200/c7000/interconnect.rb @@ -16,6 +16,7 @@ module API2200 module C7000 # Interconnect resource implementation on API2200 C7000 class Interconnect < OneviewSDK::API2000::C7000::Interconnect + include OneviewSDK::ResourceHelper::ConfigurationOperation end end end From f45d3c0e6b02a76e5892a64425e8c44f4bfabfc8 Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Fri, 6 Nov 2020 15:41:49 +0530 Subject: [PATCH 15/16] modify spt example to support hcp --- .../shared_samples/server_profile_template.rb | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/examples/shared_samples/server_profile_template.rb b/examples/shared_samples/server_profile_template.rb index 440ce2bdb..028435cd0 100644 --- a/examples/shared_samples/server_profile_template.rb +++ b/examples/shared_samples/server_profile_template.rb @@ -20,10 +20,31 @@ # Extra classes used in this sample enclosure_group_class = OneviewSDK.resource_named('EnclosureGroup', @client.api_version) server_hardware_type_class = OneviewSDK.resource_named('ServerHardwareType', @client.api_version) +ethernet_network_class = OneviewSDK.resource_named('EthernetNetwork', @client.api_version) -server_profile_template_name = 'OneViewSDK Test ServerProfileTemplate' +mgmt_name = 'mgmt_nw' +eth_nw = ethernet_network_class.new(@client, name: mgmt_name) +eth_nw.retrieve! + +server_profile_template_name = @hypervisor_serverProfileTemplate puts "\n### Creating a new Server Profile Template based on a Server Hardware Type and Enclosure Group" -item = server_profile_template_class.new(@client, name: server_profile_template_name) + +options = { + name: server_profile_template_name, + connectionSettings: { + connections: [{ + name: 'mgmt', + id: 1, + functionType: 'Ethernet', + portId: 'Auto', + networkUri: eth_nw[:uri] + }], + manageConnections: true, + complianceControl: 'Checked' + } +} + +item = server_profile_template_class.new(@client, options) server_hardware_type = server_hardware_type_class.find_by(@client, {}).first raise 'Failed to find Server Hardware Type' unless server_hardware_type || server_hardware_type['uri'] @@ -32,6 +53,7 @@ raise 'Failed to find Enclosure Group' unless enclosure_group || enclosure_group['uri'] item.set_enclosure_group(enclosure_group) item.create + puts "\nCreated Server Profile Template '#{item['name']}' successfully.\n uri = '#{item['uri']}'" puts "\nServer Hardware Type '#{server_hardware_type['name']}'.\n uri = '#{item['serverHardwareTypeUri']}'" puts "\nEnclosure Group '#{enclosure_group['name']}'.\n uri = '#{item['enclosureGroupUri']}'" @@ -81,7 +103,7 @@ puts "\nThe method #get_available_networks is available from API 600 onwards." end -puts "\n\n### Deleting all Server Profiles Template created in this sample" -item2.delete +puts "\n\n### Deleting Server Profiles Template created in this sample" +# item2.delete item3.delete puts "\nServer Profiles Template removed successfully." From 06568f76b5399cd2c964c3954151779d485211b1 Mon Sep 17 00:00:00 2001 From: VenkateshRavula Date: Fri, 6 Nov 2020 15:48:47 +0530 Subject: [PATCH 16/16] modify LE example --- examples/shared_samples/logical_enclosure.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/shared_samples/logical_enclosure.rb b/examples/shared_samples/logical_enclosure.rb index 1cb5a74c3..f3d0a1cd7 100644 --- a/examples/shared_samples/logical_enclosure.rb +++ b/examples/shared_samples/logical_enclosure.rb @@ -155,8 +155,9 @@ item3.support_dump(dump) puts "\nGenerated dump for logical enclosure '#{item3['name']}'." -if variant == 'Synergy' - puts "\nRemoving the logical enclosure" - item3.delete - puts "\nRemoved logical enclosure '#{item3['name']}'." -end +# Skipping delete LE since the system will goto bad state after LE delete +# if variant == 'Synergy' +# puts "\nRemoving the logical enclosure" +# item3.delete +# puts "\nRemoved logical enclosure '#{item3['name']}'." +# end