Skip to content

Commit

Permalink
Merge pull request #466 from HewlettPackard/API2000_enclosure
Browse files Browse the repository at this point in the history
Added API2000 support to enclosure resource
  • Loading branch information
VenkateshRavula committed Sep 10, 2020
2 parents aefc985 + ea75068 commit 620148d
Show file tree
Hide file tree
Showing 28 changed files with 567 additions and 112 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@ This release extends support to OneView Rest API version 2000 (OneView v5.40) fo

#### Features supported
- Connection Template
- Enclosure
- Enclosure Group
- Ethernet Network
- FC Network
- FCOE Network
Expand All @@ -13,7 +15,10 @@ This release extends support to OneView Rest API version 2000 (OneView v5.40) fo
- Hypervisor Manager
- Network Set
- OS Deployment Plan
- Scope
- Server Certificate
- Server Hardware
- Server Hardware Type
- Server Profile
- Server Profile Template
- Storage Pool
Expand Down
114 changes: 57 additions & 57 deletions endpoints-support.md

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions examples/shared_samples/enclosure.rb
Expand Up @@ -16,7 +16,7 @@
# It will create a bulk of ethernet networks and then delete them.
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000

# Supported Variants:
# C7000 and Synergy for all API versions
Expand Down Expand Up @@ -91,7 +91,12 @@
item4 = enclosure_class.get_all_with_query(@client, query)
puts "Found enclosure '#{item4}'."

bay_number = 1 if variant == 'C7000'
if variant == 'C7000'
bay_number = 1
elsif variant == 'Synergy'
bay_number = nil
end

csr_data = {
type: 'CertificateDtoV2',
organization: 'Acme Corp.',
Expand Down
23 changes: 11 additions & 12 deletions examples/shared_samples/enclosure_group.rb
Expand Up @@ -11,27 +11,32 @@

require_relative '../_client' # Gives access to @client

# Example: Create an enclosure group for an API300 C7000 Appliance
# 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 and 1800.
# - 200, 300, 500, 600, 800, 1200, 1600, 1800, 2000.

# Supported Variants:
# C7000 and Synergy for all API versions
# NOTE: Logical interconnect group variable "logical_interconnect_name" should be uncommented and created as a pre-requisite
# NOTE: variant should be updated before running example

# Resource Class used in this sample
encl_group_class = OneviewSDK.resource_named('EnclosureGroup', @client.api_version)

# LogicalInterconnectGroup class used in this sample.
lig_class = OneviewSDK.resource_named('LogicalInterconnectGroup', @client.api_version)

variant = 'Synergy'
type = 'enclosure group'
encl_group_name = 'OneViewSDK Test Enclosure Group'

lig = lig_class.find_by(@client, name: @logical_interconnect_name).first

interconnect_bay_mapping = [
{ interconnectBay: 3, logicalInterconnectGroupUri: '/rest/logical-interconnect-groups/6aabd433-7ed0-4c59-963c-c3f36bbd4f85' },
{ interconnectBay: 6, logicalInterconnectGroupUri: '/rest/logical-interconnect-groups/6aabd433-7ed0-4c59-963c-c3f36bbd4f85' }
{ interconnectBay: 3, logicalInterconnectGroupUri: lig[:uri] },
{ interconnectBay: 6, logicalInterconnectGroupUri: lig[:uri] }
]

options = {
Expand All @@ -42,8 +47,6 @@
}

item = encl_group_class.new(@client, options)

lig = lig_class.get_all(@client).first
item.add_logical_interconnect_group(lig)

if @client.api_version >= 600
Expand Down Expand Up @@ -71,22 +74,18 @@
item.update(name: 'OneViewSDK Test Enclosure_Group Updated')
puts "\nUpdated #{type} with new name = '#{item[:name]}' sucessfully."

begin
if variant == 'C7000'
command = '#TEST COMMAND'
puts "\nSetting a script with command = '#{command}'"
item.set_script(command)
puts "\nScript attributed sucessfully."
rescue OneviewSDK::MethodUnavailable => e
puts "\n#{e}. Available only for C7000."
end

begin
if variant == 'C7000'
puts "\nGetting a script"
script = item.get_script
puts "\nScript retrieved sucessfully."
puts script
rescue OneviewSDK::MethodUnavailable => e
puts "\n#{e}. Available only for C7000."
end

puts "\nDeleting the #{type} with name = '#{item[:name]}' and uri = '#{item[:uri]}''"
Expand Down
9 changes: 3 additions & 6 deletions examples/shared_samples/hypervisor_cluster_profile.rb
Expand Up @@ -27,12 +27,9 @@
os_deployment_plan_class = OneviewSDK.resource_named('OSDeploymentPlan', @client.api_version, 'Synergy')

# Making GET calls on below resources and fetch URI
hm_matches = hypervisor_manager_class.find_by(@client, name: @hypervisor_manager_ip)
hm = hm_matches.first
spt_matches = server_profile_template_class.find_by(@client, name: @hypervisor_serverProfileTemplate)
spt = spt_matches.first
dp_matches = os_deployment_plan_class.find_by(@client, name: @hypervisor_deploymentPlan)
osdp = dp_matches.first
hm = hypervisor_manager_class.find_by(@client, name: @hypervisor_manager_ip).first
spt = server_profile_template_class.find_by(@client, name: @hypervisor_serverProfileTemplate).first
osdp = os_deployment_plan_class.find_by(@client, name: @hypervisor_deploymentPlan).first

options = {
type: @hypervisor_type,
Expand Down
13 changes: 7 additions & 6 deletions examples/shared_samples/scope.rb
Expand Up @@ -14,7 +14,7 @@
# NOTE: It is necessary a server hardware and an enclosure previous created
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000

# Supported Variants
# C7000 and Synergy for all API versions
Expand Down Expand Up @@ -77,7 +77,7 @@
scope_class.replace_resource_assigned_scopes(@client, server_hardware, scopes: [scope2])
puts 'Replaced resouce scope uris'

puts '\nAdd a resource to scope3'
puts "\nAdd a resource to scope3"
options = {
name: 'Scope3',
description: 'Sample Scope description3'
Expand All @@ -89,7 +89,7 @@
scope_class.add_resource_scope(@client, enclosure, scopes: [scope3, scope_item])
puts 'Server hardware resource added to scope3'

puts '\nRemoving resource from scope3'
puts "\nRemoving resource from scope3"
scope_class.remove_resource_scope(@client, enclosure, scopes: [scope3, 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])
Expand All @@ -98,19 +98,20 @@
# Delete all scopes created.
scope2.delete
scope3.delete
puts 'Deleted scope2 and scope3 successfully'
end

puts "\nUnsetting resource from the '#{scope['name']}'"
scope.unset_resources(server_hardware, enclosure)
server_hardware.refresh
enclosure.refresh
puts 'scopeUris from Resources:', server_hardware['scopeUris'], enclosure['scopeUris']
puts "scopeUris from Resources: '#{server_hardware['scopeUris']}' and '#{enclosure['scopeUris']}'"

puts "\nReplacing resources from the '#{scope['name']}'"
scope.change_resource_assignments(add_resources: [server_hardware], remove_resources: [enclosure])
server_hardware.refresh
enclosure.refresh
puts 'scopeUris from Resources:', server_hardware['scopeUris'], enclosure['scopeUris']
puts "scopeUris from Resources: '#{server_hardware['scopeUris']}' and '#{enclosure['scopeUris']}'"

if @client.api_version >= 500
puts "\nUpdating the scope name '#{scope['name']}' with a patch."
Expand All @@ -127,4 +128,4 @@
puts "\nDeleting scope"
scope.refresh
scope.delete
puts 'Scope was successfully deleted.' unless scope.retrieve!
puts "'Scope' was successfully deleted." unless scope.retrieve!
80 changes: 53 additions & 27 deletions examples/shared_samples/server_hardware.rb
Expand Up @@ -20,14 +20,18 @@
#
# Resources that can be created according to parameters:
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000
# Supported Variants:
# C7000 and Synergy for all api-versions

# NOTE: User should update variant name before running this example
variant = 'Synergy'

# Resource Class used in this sample
server_harware_class = OneviewSDK.resource_named('ServerHardware', @client.api_version)

type = 'server hardware'
sh_name = '0000A66103, bay 4'
options = {
hostname: @server_hardware_hostname,
username: @server_hardware_username,
Expand All @@ -37,10 +41,19 @@
}

# Below Endpoint is supported only for C7000.
puts "\nAdding #{type} with hostname = '#{@server_hardware_hostname}'"
item = server_harware_class.new(@client, options)
item.add
puts "\nAdded #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'"
if variant == 'C7000'
puts "\nAdding #{type} with hostname = '#{@server_hardware_hostname}'"
item = server_harware_class.new(@client, options)
item.add
puts "\nAdded #{type} '#{item[:name]}' sucessfully.\n uri = '#{item[:uri]}'"
end

# Retrieve server hardware
if variant == 'Synergy'
sh_matches = server_harware_class.find_by(@client, name: sh_name)
item = sh_matches.first
puts "\nFound #{type} by name: '#{item[:name]}'.\n uri = '#{item[:uri]}'"
end

# Setting powerstate of the server to off.
item.set_power_state('off', 'true')
Expand All @@ -51,18 +64,22 @@
puts "\nRefresh server hardware successful"

# Get physical server hardware
physical_server_hardware = item.get_physical_server_hardware
puts "\nPhysical hardware found :\n#{physical_server_hardware}"
if variant == 'C7000'
physical_server_hardware = item.get_physical_server_hardware
puts "\nPhysical hardware found :\n#{physical_server_hardware}"
end

# Update ilo firmware
item.update_ilo_firmware
puts "\niLO firmware updated to minimum ILO firmware version required by OneView to manage the server"

# Below Endpoint is supported only for C7000.
puts "\nAdding multiple #{type} with hostname Range = #{@server_mpHostsAndRanges}'"
item_multiple = server_harware_class.new(@client, options)
item_multiple.add_multiple_servers
puts "\nAdded multiple #{type} successfully \n'#{item_multiple}'"
if variant == 'C7000'
puts "\nAdding multiple #{type} with hostname Range = #{@server_mpHostsAndRanges}'"
item_multiple = server_harware_class.new(@client, options)
item_multiple.add_multiple_servers
puts "\nAdded multiple #{type} successfully \n'#{item_multiple}'"
end

# Find recently created item by name
puts "\nSearch server by name = #{item[:name]}"
Expand All @@ -78,10 +95,16 @@
end

# Retrieve recently created item
puts "\nSearch server by hostname = #{@server_hardware_hostname}"
item3 = server_harware_class.new(@client, hostname: @server_hardware_hostname)
item3.retrieve!
puts "\nFound #{type} by hostname: '#{item3[:hostname]}'.\n uri = '#{item3[:uri]}'"
if variant == 'C7000'
puts "\nSearch server by hostname = #{@server_hardware_hostname}"
item3 = server_harware_class.new(@client, hostname: @server_hardware_hostname)
item3.retrieve!
puts "\nFound #{type} by hostname: '#{item3[:hostname]}'.\n uri = '#{item3[:uri]}'"
elsif variant == 'Synergy'
sh_matches = server_harware_class.find_by(@client, name: sh_name)
item3 = sh_matches.first
item3.retrieve!
end

puts "\nGetting list of bios UEFI values"
bios = item3.get_bios
Expand All @@ -108,13 +131,15 @@
utilization = item3.utilization
puts "\nHistorical utilization retrieved sucessfully: \n#{utilization}"

puts "\nRetrieving local storage data for the specified resource."
local_storage = item3.get_local_storage
puts "\nLocal storage data retrieved sucessfully: \n#{local_storage}"

puts "\nRetrieving local storageV2 data for the specified resource of Gen10 plus model."
local_storagev2 = item3.get_local_storagev2
puts "\nLocal storageV2 data retrieved sucessfully: \n#{local_storagev2}"
begin
puts "\nRetrieving local storage data for the specified resource."
local_storage = item3.get_local_storage
puts "\nLocal storage data retrieved sucessfully: \n#{local_storage}"
rescue
puts "\nRetrieving local storageV2 data for the specified resource of Gen10 plus model."
local_storagev2 = item3.get_local_storagev2
puts "\nLocal storageV2 data retrieved sucessfully: \n#{local_storagev2}"
end

puts "\nRetrieving historical utilization with day view."
utilization2 = item3.utilization(view: 'day')
Expand Down Expand Up @@ -147,8 +172,7 @@

puts 'Get a list of firmware with filters componentName and serverName'
filters = [
{ name: 'components.componentName', operation: '=', value: 'iLO' },
{ name: 'serverName', operation: '=', value: @server_hardware_hostname }
{ name: 'components.componentName', operation: '=', value: 'iLO' }
]
response2 = item3.get_firmwares(filters)
puts "\nFound firware inventory: '#{response2}'."
Expand Down Expand Up @@ -194,6 +218,8 @@
end

# Delete this item
puts "\nRemoving the #{type} with name = '#{item[:name]}'."
item3.remove
puts "\n#{type} was removed sucessfully."
if variant == 'C7000'
puts "\nRemoving the #{type} with name = '#{item[:name]}'."
item3.remove
puts "\n#{type} was removed sucessfully."
end
3 changes: 1 addition & 2 deletions examples/shared_samples/server_hardware_type.rb
Expand Up @@ -14,13 +14,12 @@
# Example: Actions with a Server Hardware Type
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800, 2000
# Supported API variants:
# C7000, Synergy

# Resource Class used in this sample
shw_type_class = OneviewSDK.resource_named('ServerHardwareType', @client.api_version)

shw_class = OneviewSDK.resource_named('ServerHardware', @client.api_version)

def print_server_hardware_type(item)
Expand Down
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api2000/c7000/enclosure.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 '../../api1800/c7000/enclosure'

module OneviewSDK
module API2000
module C7000
# Enclosure resource implementation for API2000 C7000
class Enclosure < OneviewSDK::API1800::C7000::Enclosure
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api2000/c7000/enclosure_group.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 '../../api1800/c7000/enclosure_group'

module OneviewSDK
module API2000
module C7000
# Enclosure group resource implementation on API2000 C7000
class EnclosureGroup < OneviewSDK::API1800::C7000::EnclosureGroup
end
end
end
end

0 comments on commit 620148d

Please sign in to comment.