Skip to content

Commit

Permalink
Merge pull request #450 from HewlettPackard/API1800_serverhardware
Browse files Browse the repository at this point in the history
API1800 support for server hardware and profile
  • Loading branch information
VenkateshRavula committed Jul 16, 2020
2 parents cb70a63 + 1452726 commit d71d0ad
Show file tree
Hide file tree
Showing 22 changed files with 470 additions and 81 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -15,11 +15,14 @@ This release extends support to OneView Rest API version 1800 (OneView v5.30) fo
- Network Set
- Scope
- Server Certificate
- Server Hardware
- Server Hardware Type
- Server Profile
- Server Profile Template
- Storage Pool
- Storage System
- Uplink Set


## v5.13.0

#### Notes
Expand Down
98 changes: 50 additions & 48 deletions endpoints-support.md

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion examples/shared_samples/server_hardware.rb
Expand Up @@ -20,7 +20,7 @@
#
# Resources that can be created according to parameters:
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# Supported Variants:
# C7000 and Synergy for all api-versions

Expand Down Expand Up @@ -108,6 +108,14 @@
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}"

puts "\nRetrieving historical utilization with day view."
utilization2 = item3.utilization(view: 'day')
puts "\nHistorical utilization retrieved sucessfully: \n#{utilization2}"
Expand Down
4 changes: 2 additions & 2 deletions examples/shared_samples/server_hardware_type.rb
@@ -1,4 +1,4 @@
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# (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.
Expand All @@ -14,7 +14,7 @@
# Example: Actions with a Server Hardware Type
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800
# Supported API variants:
# C7000, Synergy

Expand Down
17 changes: 6 additions & 11 deletions examples/shared_samples/server_profile.rb
@@ -1,4 +1,4 @@
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# (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.
Expand All @@ -12,16 +12,11 @@
require_relative '../_client' # Gives access to @client

# Supported APIs:
# - 200, 300, 500, 600

# Resources that can be created according to parameters:
# api_version = 200 & variant = any to OneviewSDK::API200::ServerProfile
# api_version = 300 & variant = C7000 to OneviewSDK::API300::C7000::ServerProfile
# api_version = 300 & variant = Synergy to OneviewSDK::API300::Synergy::ServerProfile
# api_version = 500 & variant = C7000 to OneviewSDK::API500::C7000::ServerProfile
# api_version = 500 & variant = Synergy to OneviewSDK::API500::Synergy::ServerProfile
# api_version = 600 & variant = C7000 to OneviewSDK::API600::C7000::ServerProfile
# api_version = 600 & variant = Synergy to OneviewSDK::API600::Synergy::ServerProfile
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800

# Supported Variants:
# - C7000 and Synergy for all supported API versions


# Resource Class used in this sample
server_profile_class = OneviewSDK.resource_named('ServerProfile', @client.api_version)
Expand Down
23 changes: 5 additions & 18 deletions examples/shared_samples/server_profile_template.rb
@@ -1,4 +1,4 @@
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# (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.
Expand All @@ -12,24 +12,11 @@
require_relative '../_client' # Gives access to @client

# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, and 1600.
# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800.

# Supported Variants:
# - C7000 and Synergy for all supported API versions.

# Resources that can be created according to parameters:
# api_version = 200 & variant = any to OneviewSDK::API200::ServerProfileTemplate
# api_version = 300 & variant = C7000 to OneviewSDK::API300::C7000::ServerProfileTemplate
# api_version = 300 & variant = Synergy to OneviewSDK::API300::Synergy::ServerProfileTemplate
# api_version = 500 & variant = C7000 to OneviewSDK::API500::C7000::ServerProfileTemplate
# api_version = 500 & variant = Synergy to OneviewSDK::API500::Synergy::ServerProfileTemplate
# api_version = 600 & variant = C7000 to OneviewSDK::API600::C7000::ServerProfileTemplate
# api_version = 600 & variant = Synergy to OneviewSDK::API600::Synergy::ServerProfileTemplate
# api_version = 800 & variant = C7000 to OneviewSDK::API800::C7000::ServerProfileTemplate
# api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::ServerProfileTemplate
# api_version = 1000 & variant = C7000 to OneviewSDK::API1000::C7000::ServerProfileTemplate
# api_version = 1000 & variant = Synergy to OneviewSDK::API1000::Synergy::ServerProfileTemplate
# api_version = 1200 & variant = C7000 to OneviewSDK::API1200::C7000::ServerProfileTemplate
# api_version = 1200 & variant = Synergy to OneviewSDK::API1200::Synergy::ServerProfileTemplate
# api_version = 1600 & variant = C7000 to OneviewSDK::API1600::C7000::ServerProfileTemplate
# api_version = 1600 & variant = Synergy to OneviewSDK::API1600::Synergy::ServerProfileTemplate

# Resource Class used in this sample
server_profile_template_class = OneviewSDK.resource_named('ServerProfileTemplate', @client.api_version)
Expand Down
51 changes: 51 additions & 0 deletions lib/oneview-sdk/resource/api1800/c7000/server_hardware.rb
@@ -0,0 +1,51 @@
# (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 '../../api1600/c7000/server_hardware'

module OneviewSDK
module API1800
module C7000
# Server Hardware resource implementation on API1800 C7000
class ServerHardware < OneviewSDK::API1600::C7000::ServerHardware
# Create a resource object, associate it with a client, and set its properties.
# @param [OneviewSDK::Client] client The client object for the OneView appliance
# @param [Hash] params The options for this resource (key-value pairs)
# @param [Integer] api_ver The api version to use when interracting with this resource.
def initialize(client, params = {}, api_ver = nil)
@data ||= {}
# Default values
@data['type'] ||= 'server-hardware-12'
super
end

# Gets the local storage resource for the server, including storage controllers,
# storage enclosures, physical drives, and logical drives.
# @return [Hash] Contains the actual subresource data collected from the Management Processor
def get_local_storage
ensure_client && ensure_uri
response = @client.rest_get(@data['uri'] + '/localStorage')
@client.response_handler(response)
end

# Gets the updated version 2 local storage resource for the server, including storage controllers,
# drives, and volumes. Starting with Gen 10 Plus, certain storage adapters will
# provide /localStorageV2 instead of (or in addition to) /localStorage
# @return [Hash] Contains the storage data based on the following schema.
def get_local_storagev2
ensure_client && ensure_uri
response = @client.rest_get(@data['uri'] + '/localStorageV2')
@client.response_handler(response)
end
end
end
end
end
25 changes: 25 additions & 0 deletions lib/oneview-sdk/resource/api1800/c7000/server_hardware_type.rb
@@ -0,0 +1,25 @@
# (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 '../../api1600/c7000/server_hardware_type'

module OneviewSDK
module API1800
module C7000
# Server hardware type resource implementation for API1800 C7000
class ServerHardwareType < OneviewSDK::API1600::C7000::ServerHardwareType
def self.api_version
1800
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/c7000/server_profile.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 '../../api1600/c7000/server_profile'

module OneviewSDK
module API1800
module C7000
# Server Profile resource implementation on API1800 C7000
class ServerProfile < OneviewSDK::API1600::C7000::ServerProfile
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/c7000/server_profile_template.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 '../../api1600/c7000/server_profile_template'

module OneviewSDK
module API1800
module C7000
# Server Profile Template resource implementation on API1800 C7000
class ServerProfileTemplate < OneviewSDK::API1600::C7000::ServerProfileTemplate
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/synergy/server_hardware.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 '../c7000/server_hardware'

module OneviewSDK
module API1800
module Synergy
# Server Hardware resource implementation on API1800 Synergy
class ServerHardware < OneviewSDK::API1800::C7000::ServerHardware
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/synergy/server_hardware_type.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 '../c7000/server_hardware_type'

module OneviewSDK
module API1800
module Synergy
# Server hardware type resource implementation for API1800 Synergy
class ServerHardwareType < OneviewSDK::API1800::C7000::ServerHardwareType
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/synergy/server_profile.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 '../c7000/server_profile'

module OneviewSDK
module API1800
module Synergy
# Server profile resource implementation for API1800 Synergy
class ServerProfile < OneviewSDK::API1800::C7000::ServerProfile
end
end
end
end
@@ -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 '../c7000/server_profile_template'

module OneviewSDK
module API1800
module Synergy
# Server Profile Template resource implementation for API1800 Synergy
class ServerProfileTemplate < OneviewSDK::API1800::C7000::ServerProfileTemplate
end
end
end
end
46 changes: 46 additions & 0 deletions spec/unit/resource/api1800/c7000/server_hardware_spec.rb
@@ -0,0 +1,46 @@
# (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::API1800::C7000::ServerHardware do
include_context 'shared context'

it 'inherits from OneviewSDK::API1600::C7000::ServerHardware' do
expect(described_class).to be < OneviewSDK::API1600::C7000::ServerHardware
end

before(:each) do
@item = OneviewSDK::API1800::C7000::ServerHardware.new(@client_1800, uri: '/rest/fake')
end

describe '#initialize' do
it 'sets the type correctly' do
expect(@item[:type]).to eq('server-hardware-12')
end
end

describe '#get_local_storage' do
it 'Makes a GET call on local storage' do
expect(@client_1800).to receive(:rest_get).with(@item['uri'] + '/localStorage')
.and_return(FakeResponse.new({}))
@item.get_local_storage
end
end

describe '#get_local_storagev2' do
it 'Makes a GET call on local storagev2' do
expect(@client_1800).to receive(:rest_get).with(@item['uri'] + '/localStorageV2')
.and_return(FakeResponse.new({}))
@item.get_local_storagev2
end
end
end

0 comments on commit d71d0ad

Please sign in to comment.