From 9f7fb6ff5b156b77e2cf642678f372b0b5c2141f Mon Sep 17 00:00:00 2001 From: soodpr Date: Mon, 26 Mar 2018 14:58:18 +0530 Subject: [PATCH 1/6] Adding Hypervisor Manager for API800 --- examples/shared_samples/hypervisor_manager.rb | 68 +++++++++++++++++++ .../api800/c7000/hypervisor_manager.rb | 33 +++++++++ .../resource/api800/c7000/resource.rb | 21 ++++++ .../api800/synergy/hypervisor_manager.rb | 33 +++++++++ .../resource/api800/synergy/resource.rb | 21 ++++++ .../integration/one_view_secrets.json.example | 3 + .../one_view_synergy_secrets.json.example | 3 + .../c7000/hypervisor_manager/create_spec.rb | 8 +++ .../c7000/hypervisor_manager/delete_spec.rb | 8 +++ .../c7000/hypervisor_manager/update_spec.rb | 7 ++ .../synergy/hypervisor_manager/create_spec.rb | 8 +++ .../synergy/hypervisor_manager/delete_spec.rb | 8 +++ .../synergy/hypervisor_manager/update_spec.rb | 7 ++ spec/integration/sequence_and_naming.rb | 3 + .../hypervisor_manager/create.rb | 48 +++++++++++++ .../hypervisor_manager/delete.rb | 27 ++++++++ .../hypervisor_manager/update.rb | 27 ++++++++ .../integration/hypervisor_manager.json | 9 +++ .../api800/c7000/hypervisor_manager_spec.rb | 13 ++++ .../api800/synergy/hypervisor_manager_spec.rb | 13 ++++ 20 files changed, 368 insertions(+) create mode 100644 examples/shared_samples/hypervisor_manager.rb create mode 100644 lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb create mode 100644 lib/oneview-sdk/resource/api800/c7000/resource.rb create mode 100644 lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb create mode 100644 lib/oneview-sdk/resource/api800/synergy/resource.rb create mode 100644 spec/integration/resource/api800/c7000/hypervisor_manager/create_spec.rb create mode 100644 spec/integration/resource/api800/c7000/hypervisor_manager/delete_spec.rb create mode 100644 spec/integration/resource/api800/c7000/hypervisor_manager/update_spec.rb create mode 100644 spec/integration/resource/api800/synergy/hypervisor_manager/create_spec.rb create mode 100644 spec/integration/resource/api800/synergy/hypervisor_manager/delete_spec.rb create mode 100644 spec/integration/resource/api800/synergy/hypervisor_manager/update_spec.rb create mode 100644 spec/integration/shared_examples/hypervisor_manager/create.rb create mode 100644 spec/integration/shared_examples/hypervisor_manager/delete.rb create mode 100644 spec/integration/shared_examples/hypervisor_manager/update.rb create mode 100644 spec/support/fixtures/integration/hypervisor_manager.json create mode 100644 spec/unit/resource/api800/c7000/hypervisor_manager_spec.rb create mode 100644 spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb new file mode 100644 index 000000000..ebd05e599 --- /dev/null +++ b/examples/shared_samples/hypervisor_manager.rb @@ -0,0 +1,68 @@ +# (C) Copyright 2018 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 + +# Example: Create/Update/Delete hypervisor manager +# NOTE: This will create a hypervisor manager named 'vcenter.corp.com', update it and then delete it. +# It will create a bulk of hypervisor managers and then delete them. +# +# Supported APIs: +# - API800 for C7000 +# - API800 for Synergy + +# Resources that can be created according to parameters: +# api_version = 800 & variant = C7000 to OneviewSDK::API800::C7000::HypervisorManager +# api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::HypervisorManager + +raise 'ERROR: Must set @storage_system_ip in _client.rb' unless @hypervisor_manager_ip +raise 'ERROR: Must set @storage_system_username in _client.rb' unless @hypervisor_manager_username +raise 'ERROR: Must set @storage_system_password in _client.rb' unless @hypervisor_manager_password + +# Resource Class used in this sample +hypervisor_manager_class = OneviewSDK.resource_named('HypervisorManager', @client.api_version) + +options = { + name: @hypervisor_manager_ip, + username: @hypervisor_manager_username, + password: @hypervisor_manager_password +} + +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]}'" + +# Retrieve recently created network +hm3 = hypervisor_manager_class.new(@client, name: hm[:name]) +hm3.retrieve! +puts "\nRetrieved hypervisor-manager data by name: '#{hm3[:name]}'.\n uri = '#{hm3[:uri]}'" + +# Update hypervisor manager registration +attribute = { name: @hypervisor_manager_ip } +hm2.update(attribute) +puts "\nUpdated hypervisor-manager: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" +puts "with attribute: #{attribute}" + +# Example: List all hypervisor managers certain attributes +attributes = { name: @hypervisor_manager_ip } +puts "\nHypervisor manager with #{attributes}" +hypervisor_manager_class.find_by(@client, attributes).each do |hypervisor_manager| + puts " #{hypervisor_manager[:name]}" +end + +# Delete this network +hm.delete +puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." diff --git a/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb b/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb new file mode 100644 index 000000000..0720fd31c --- /dev/null +++ b/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb @@ -0,0 +1,33 @@ +# (C) Copyright 2018 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 'resource' + +module OneviewSDK + module API800 + module C7000 + # Hypervisor Manager resource implementation + class HypervisorManager < Resource + BASE_URI = '/rest/hypervisor-managers'.freeze + + # 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) + super + # Default values + @data['hypervisorType'] ||= 'Vmware' + @data['type'] ||= 'HypervisorManagerV2' + end + end + end + end +end diff --git a/lib/oneview-sdk/resource/api800/c7000/resource.rb b/lib/oneview-sdk/resource/api800/c7000/resource.rb new file mode 100644 index 000000000..5f714c7da --- /dev/null +++ b/lib/oneview-sdk/resource/api800/c7000/resource.rb @@ -0,0 +1,21 @@ +# (c) Copyright 2018 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 '../../../resource' + +module OneviewSDK + module API800 + module C7000 + # Base Resource implementation for API200 resources + class Resource < OneviewSDK::Resource + end + end + end +end diff --git a/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb b/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb new file mode 100644 index 000000000..ef2dceea0 --- /dev/null +++ b/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb @@ -0,0 +1,33 @@ +# (C) Copyright 2018 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/hypervisor_manager' + +module OneviewSDK + module API800 + module Synergy + # Hypervisor Manager resource implementation + class HypervisorManager < OneviewSDK::API800::C7000::HypervisorManager + # 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['hypervisorType'] ||= 'Vmware' + @data['type'] ||= 'HypervisorManagerV2' + super + end + end + end + end +end diff --git a/lib/oneview-sdk/resource/api800/synergy/resource.rb b/lib/oneview-sdk/resource/api800/synergy/resource.rb new file mode 100644 index 000000000..15f9038e6 --- /dev/null +++ b/lib/oneview-sdk/resource/api800/synergy/resource.rb @@ -0,0 +1,21 @@ +# (c) Copyright 2018 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 '../../../resource' + +module OneviewSDK + module API800 + module Synergy + class Resource < OneviewSDK::Resource + end + end + end +end diff --git a/spec/integration/one_view_secrets.json.example b/spec/integration/one_view_secrets.json.example index 3932ee840..4aef2370a 100644 --- a/spec/integration/one_view_secrets.json.example +++ b/spec/integration/one_view_secrets.json.example @@ -5,6 +5,9 @@ "enclosure2_ip": "172.18.1.13", "enclosure2_user": "dcs", "enclosure2_password": "dcs", + "hypervisor_manager_ip": "172.18.13.11", + "hypervisor_manager_username": "dcs", + "hypervisor_manager_password": "dcs", "storage_system1_ip": "172.18.11.11", "storage_system1_user": "dcs", "storage_system1_password": "dcs", diff --git a/spec/integration/one_view_synergy_secrets.json.example b/spec/integration/one_view_synergy_secrets.json.example index 9eb3519e5..611b32aae 100644 --- a/spec/integration/one_view_synergy_secrets.json.example +++ b/spec/integration/one_view_synergy_secrets.json.example @@ -5,6 +5,9 @@ "enclosure2_ip": "172.18.1.13", "enclosure2_user": "dcs", "enclosure2_password": "dcs", + "hypervisor_manager_ip": "172.18.13.11", + "hypervisor_manager_username": "dcs", + "hypervisor_manager_password": "dcs", "storage_system1_ip": "172.18.11.11", "storage_system1_user": "dcs", "storage_system1_password": "dcs", diff --git a/spec/integration/resource/api800/c7000/hypervisor_manager/create_spec.rb b/spec/integration/resource/api800/c7000/hypervisor_manager/create_spec.rb new file mode 100644 index 000000000..7b0edbab4 --- /dev/null +++ b/spec/integration/resource/api800/c7000/hypervisor_manager/create_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +klass = OneviewSDK::API800::C7000::HypervisorManager +RSpec.describe klass, integration: true, type: CREATE, sequence: seq(klass) do + include_examples 'HypervisorManagerCreateExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/resource/api800/c7000/hypervisor_manager/delete_spec.rb b/spec/integration/resource/api800/c7000/hypervisor_manager/delete_spec.rb new file mode 100644 index 000000000..31adda8b7 --- /dev/null +++ b/spec/integration/resource/api800/c7000/hypervisor_manager/delete_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +klass = OneviewSDK::API800::C7000::HypervisorManager +RSpec.describe klass, integration: true, type: DELETE, sequence: rseq(klass) do + include_examples 'HypervisorManagerDeleteExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/resource/api800/c7000/hypervisor_manager/update_spec.rb b/spec/integration/resource/api800/c7000/hypervisor_manager/update_spec.rb new file mode 100644 index 000000000..b64cbd6b4 --- /dev/null +++ b/spec/integration/resource/api800/c7000/hypervisor_manager/update_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +RSpec.describe OneviewSDK::API800::C7000::HypervisorManager, integration: true, type: UPDATE do + include_examples 'HypervisorManagerUpdateExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/resource/api800/synergy/hypervisor_manager/create_spec.rb b/spec/integration/resource/api800/synergy/hypervisor_manager/create_spec.rb new file mode 100644 index 000000000..0e34648fe --- /dev/null +++ b/spec/integration/resource/api800/synergy/hypervisor_manager/create_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +klass = OneviewSDK::API800::Synergy::HypervisorManager +RSpec.describe klass, integration: true, type: CREATE, sequence: seq(klass) do + include_examples 'HypervisorManagerCreateExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/resource/api800/synergy/hypervisor_manager/delete_spec.rb b/spec/integration/resource/api800/synergy/hypervisor_manager/delete_spec.rb new file mode 100644 index 000000000..65b04338e --- /dev/null +++ b/spec/integration/resource/api800/synergy/hypervisor_manager/delete_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +klass = OneviewSDK::API800::Synergy::HypervisorManager +RSpec.describe klass, integration: true, type: DELETE, sequence: rseq(klass) do + include_examples 'HypervisorManagerDeleteExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/resource/api800/synergy/hypervisor_manager/update_spec.rb b/spec/integration/resource/api800/synergy/hypervisor_manager/update_spec.rb new file mode 100644 index 000000000..f81a8294a --- /dev/null +++ b/spec/integration/resource/api800/synergy/hypervisor_manager/update_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +RSpec.describe OneviewSDK::API800::Synergy::HypervisorManager, integration: true, type: UPDATE do + include_examples 'HypervisorManagerUpdateExample', 'integration api800 context' do + let(:current_client) { $client_800 } + end +end diff --git a/spec/integration/sequence_and_naming.rb b/spec/integration/sequence_and_naming.rb index a6eec2dcf..a9ee0ac21 100644 --- a/spec/integration/sequence_and_naming.rb +++ b/spec/integration/sequence_and_naming.rb @@ -28,6 +28,7 @@ def tsort_each_child(node, &block) FCoENetwork: [], FirmwareBundle: [], FirmwareDriver: [:FirmwareBundle], + HypervisorManager: [], IDPool: [], Interconnect: [:LogicalInterconnect], LIGUplinkSet: [], @@ -275,3 +276,5 @@ def rseq(klass, rseq = RSEQ) SERVER_HARDWARE_TYPE2_NAME = 'SY 480 Gen9 1'.freeze DRIVE_ENCLOSURE_NAME = 'Encl11, bay 1'.freeze + +HYPERVISOR_MGR_NAME = '172.18.13.11'.freeze diff --git a/spec/integration/shared_examples/hypervisor_manager/create.rb b/spec/integration/shared_examples/hypervisor_manager/create.rb new file mode 100644 index 000000000..ec7453463 --- /dev/null +++ b/spec/integration/shared_examples/hypervisor_manager/create.rb @@ -0,0 +1,48 @@ +# (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. + +RSpec.shared_examples 'HypervisorManagerCreateExample' do |context_name| + include_context context_name + + let(:file_path) { 'spec/support/fixtures/integration/hypervisor_manager.json' } + + describe '#create' do + it 'can create resources' do + item = described_class.from_file(current_client, file_path) + + item.create + expect(item[:name]).to eq(HYPERVISOR_MGR_NAME) + expect(item[:hypervisorType]).to eq('Vmware') + end + end + + describe '#retrieve!' do + it 'retrieves the resource' do + item = described_class.new(current_client, name: HYPERVISOR_MGR_NAME) + item.retrieve! + expect(item[:name]).to eq(HYPERVISOR_MGR_NAME) + expect(item[:hypervisorType]).to eq('Vmware') + end + end + + describe '#find_by' do + it 'returns all resources when the hash is empty' do + names = described_class.find_by(current_client, {}).map { |item| item[:name] } + expect(names).to include(HYPERVISOR_MGR_NAME) + end + + it 'finds hypervisor manager by multiple attributes' do + attrs = { name: HYPERVISOR_MGR_NAME, hypervisorType: 'Vmware' } + names = described_class.find_by(current_client, attrs).map { |item| item[:name] } + expect(names).to include(HYPERVISOR_MGR_NAME) + end + end +end diff --git a/spec/integration/shared_examples/hypervisor_manager/delete.rb b/spec/integration/shared_examples/hypervisor_manager/delete.rb new file mode 100644 index 000000000..aa12ca1bf --- /dev/null +++ b/spec/integration/shared_examples/hypervisor_manager/delete.rb @@ -0,0 +1,27 @@ +# (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. + +RSpec.shared_examples 'HypervisorManagerDeleteExample' do |context_name| + include_context context_name + + describe '#delete' do + it 'deletes the resource' do + item = described_class.new(current_client, name: HYPERVISOR_MGR_NAME) + + expect(item.retrieve!).to eq(true) + + expect { item.delete }.not_to raise_error + + expect(item.retrieve!).to eq(false) + + end + end +end diff --git a/spec/integration/shared_examples/hypervisor_manager/update.rb b/spec/integration/shared_examples/hypervisor_manager/update.rb new file mode 100644 index 000000000..7bd7c3f2b --- /dev/null +++ b/spec/integration/shared_examples/hypervisor_manager/update.rb @@ -0,0 +1,27 @@ +# (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. + +RSpec.shared_examples 'HypervisorManagerUpdateExample' do |context_name| + include_context context_name + + describe '#update' do + it 'updates the hypervisor manager name' do + item = described_class.new(current_client, name: HYPERVISOR_MGR_NAME) + item.retrieve! + item.update(name: HYPERVISOR_MGR_NAME) + item.refresh + expect(item[:name]).to eq(HYPERVISOR_MGR_NAME) + item.update(name: HYPERVISOR_MGR_NAME) # Put it back to normal + item.refresh + expect(item[:name]).to eq(HYPERVISOR_MGR_NAME) + end + end +end diff --git a/spec/support/fixtures/integration/hypervisor_manager.json b/spec/support/fixtures/integration/hypervisor_manager.json new file mode 100644 index 000000000..bd99b70ff --- /dev/null +++ b/spec/support/fixtures/integration/hypervisor_manager.json @@ -0,0 +1,9 @@ +{ + "data": { + "name": "172.18.13.11", + "username": "dcs", + "password": "dcs", + "hypervisorType": "Vmware", + "type": "HypervisorManagerV2" + } +} diff --git a/spec/unit/resource/api800/c7000/hypervisor_manager_spec.rb b/spec/unit/resource/api800/c7000/hypervisor_manager_spec.rb new file mode 100644 index 000000000..942e2d232 --- /dev/null +++ b/spec/unit/resource/api800/c7000/hypervisor_manager_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +RSpec.describe OneviewSDK::API800::C7000::HypervisorManager do + include_context 'shared context' + + describe '#initialize' do + it 'sets the defaults correctly' do + item = OneviewSDK::API800::C7000::HypervisorManager.new(@client_800) + expect(item[:type]).to eq('HypervisorManagerV2') + expect(item[:hypervisorType]).to eq('Vmware') + end + end +end diff --git a/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb b/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb new file mode 100644 index 000000000..4c001a3ce --- /dev/null +++ b/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +RSpec.describe OneviewSDK::API800::Synergy::HypervisorManager do + include_context 'shared context' + + describe '#initialize' do + it 'sets the defaults correctly' do + item = OneviewSDK::API800::Synergy::HypervisorManager.new(@client_800) + expect(item[:type]).to eq('HypervisorManagerV2') + expect(item[:hypervisorType]).to eq('Vmware') + end + end +end From 3e5ec6ad0dedfaad896f8079ed29391b9fca430c Mon Sep 17 00:00:00 2001 From: soodpr Date: Mon, 26 Mar 2018 15:19:18 +0530 Subject: [PATCH 2/6] Adding documentation for Hypervisor Manager to support API800 --- CHANGELOG.md | 1 + endpoints-support.md | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 640ec9cbc..a1f323142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Extends support of the SDK to OneView Rest API version 800 (OneView v4.10). #### Features Supported This release adds support to OneView Rest API version 800 for the hardware variants C7000 and Synergy to the already existing features: + - Hypervisor Manager - Server Profile Template ## v5.4.0(Unreleased) diff --git a/endpoints-support.md b/endpoints-support.md index 6b6bba3a9..cc0665725 100644 --- a/endpoints-support.md +++ b/endpoints-support.md @@ -139,6 +139,12 @@ OneviewSDK::Datacenter.find_by(@client, width: 11000).map(&:remove) |/rest/firmware-drivers | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/firmware-drivers/{id} | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/firmware-drivers/{id} | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| **Hypervisor Managers** | +|/rest/hypervisor-managers | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | PUT | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | DELETE | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | | **ID Pools** | |/rest/id-pools/{poolType} | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/id-pools/{poolType} | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | From f44fdab4376aadf5dcef6fcd0abbbb0d4748a18b Mon Sep 17 00:00:00 2001 From: soodpr Date: Mon, 26 Mar 2018 15:23:09 +0530 Subject: [PATCH 3/6] Editing endpoints-support.md for Hypervisor Manager --- endpoints-support.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/endpoints-support.md b/endpoints-support.md index cc0665725..24035af2f 100644 --- a/endpoints-support.md +++ b/endpoints-support.md @@ -140,11 +140,11 @@ OneviewSDK::Datacenter.find_by(@client, width: 11000).map(&:remove) |/rest/firmware-drivers/{id} | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/firmware-drivers/{id} | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | | **Hypervisor Managers** | -|/rest/hypervisor-managers | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | -|/rest/hypervisor-managers | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | -|/rest/hypervisor-managers/{id} | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | -|/rest/hypervisor-managers/{id} | PUT | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | -|/rest/hypervisor-managers/{id} | DELETE | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | PUT | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | +|/rest/hypervisor-managers/{id} | DELETE | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | | **ID Pools** | |/rest/id-pools/{poolType} | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | |/rest/id-pools/{poolType} | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | From abcb99ee047c14642b66634f0de149110f220088 Mon Sep 17 00:00:00 2001 From: soodpr Date: Mon, 26 Mar 2018 15:33:14 +0530 Subject: [PATCH 4/6] Adding hypervisor manager in client.rb and removing whitespace from delete spec --- examples/_client.rb.example | 3 +++ spec/integration/shared_examples/hypervisor_manager/delete.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/_client.rb.example b/examples/_client.rb.example index 688b0bb5c..9c2181ea8 100644 --- a/examples/_client.rb.example +++ b/examples/_client.rb.example @@ -54,3 +54,6 @@ puts "Connected to OneView appliance at #{@client.url}\n\n" # @logical_switch_ssh_password = "dcs" # @logical_switch_community_string = "public" # @logical_interconnect_name = 'Encl1-LogicalInterconnectGroup_1' +# @hypervisor_manager_ip = '172.18.13.11' +# @hypervisor_manager_username ='dcs' +# @hypervisor_manager_password ='dcs' diff --git a/spec/integration/shared_examples/hypervisor_manager/delete.rb b/spec/integration/shared_examples/hypervisor_manager/delete.rb index aa12ca1bf..8039d3252 100644 --- a/spec/integration/shared_examples/hypervisor_manager/delete.rb +++ b/spec/integration/shared_examples/hypervisor_manager/delete.rb @@ -14,7 +14,7 @@ describe '#delete' do it 'deletes the resource' do - item = described_class.new(current_client, name: HYPERVISOR_MGR_NAME) + item = described_class.new(current_client, name: HYPERVISOR_MGR_NAME) expect(item.retrieve!).to eq(true) From 8e8c06b4576d2b30f20bacb959130dde171315a0 Mon Sep 17 00:00:00 2001 From: soodpr Date: Tue, 27 Mar 2018 21:20:38 +0530 Subject: [PATCH 5/6] Removing resource.rb file from both variants for API800 --- .../api800/c7000/hypervisor_manager.rb | 4 ++-- .../resource/api800/c7000/resource.rb | 21 ------------------- .../resource/api800/synergy/resource.rb | 21 ------------------- 3 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 lib/oneview-sdk/resource/api800/c7000/resource.rb delete mode 100644 lib/oneview-sdk/resource/api800/synergy/resource.rb diff --git a/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb b/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb index 0720fd31c..b51f6fab8 100644 --- a/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb +++ b/lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb @@ -8,13 +8,13 @@ # 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 'resource' +require_relative '../../../resource' module OneviewSDK module API800 module C7000 # Hypervisor Manager resource implementation - class HypervisorManager < Resource + class HypervisorManager < OneviewSDK::Resource BASE_URI = '/rest/hypervisor-managers'.freeze # Create a resource object, associate it with a client, and set its properties. diff --git a/lib/oneview-sdk/resource/api800/c7000/resource.rb b/lib/oneview-sdk/resource/api800/c7000/resource.rb deleted file mode 100644 index 5f714c7da..000000000 --- a/lib/oneview-sdk/resource/api800/c7000/resource.rb +++ /dev/null @@ -1,21 +0,0 @@ -# (c) Copyright 2018 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 '../../../resource' - -module OneviewSDK - module API800 - module C7000 - # Base Resource implementation for API200 resources - class Resource < OneviewSDK::Resource - end - end - end -end diff --git a/lib/oneview-sdk/resource/api800/synergy/resource.rb b/lib/oneview-sdk/resource/api800/synergy/resource.rb deleted file mode 100644 index 15f9038e6..000000000 --- a/lib/oneview-sdk/resource/api800/synergy/resource.rb +++ /dev/null @@ -1,21 +0,0 @@ -# (c) Copyright 2018 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 '../../../resource' - -module OneviewSDK - module API800 - module Synergy - class Resource < OneviewSDK::Resource - end - end - end -end From 34b1ff1d1bc10f2b866b935a90151641b2a1dbf2 Mon Sep 17 00:00:00 2001 From: soodpr Date: Tue, 27 Mar 2018 22:33:39 +0530 Subject: [PATCH 6/6] Modifying documentation for hypervisor manager --- examples/shared_samples/hypervisor_manager.rb | 11 +++++------ .../resource/api800/synergy/hypervisor_manager.rb | 11 ----------- .../shared_examples/hypervisor_manager/create.rb | 2 +- .../shared_examples/hypervisor_manager/delete.rb | 2 +- .../shared_examples/hypervisor_manager/update.rb | 2 +- .../api800/synergy/hypervisor_manager_spec.rb | 8 ++------ 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/examples/shared_samples/hypervisor_manager.rb b/examples/shared_samples/hypervisor_manager.rb index ebd05e599..968a3215d 100644 --- a/examples/shared_samples/hypervisor_manager.rb +++ b/examples/shared_samples/hypervisor_manager.rb @@ -13,7 +13,6 @@ # Example: Create/Update/Delete hypervisor manager # NOTE: This will create a hypervisor manager named 'vcenter.corp.com', update it and then delete it. -# It will create a bulk of hypervisor managers and then delete them. # # Supported APIs: # - API800 for C7000 @@ -23,9 +22,9 @@ # api_version = 800 & variant = C7000 to OneviewSDK::API800::C7000::HypervisorManager # api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::HypervisorManager -raise 'ERROR: Must set @storage_system_ip in _client.rb' unless @hypervisor_manager_ip -raise 'ERROR: Must set @storage_system_username in _client.rb' unless @hypervisor_manager_username -raise 'ERROR: Must set @storage_system_password in _client.rb' unless @hypervisor_manager_password +raise 'ERROR: Must set @hypervisor_manager_ip in _client.rb' unless @hypervisor_manager_ip +raise 'ERROR: Must set @hypervisor_manager_username in _client.rb' unless @hypervisor_manager_username +raise 'ERROR: Must set @hypervisor_manager_password in _client.rb' unless @hypervisor_manager_password # Resource Class used in this sample hypervisor_manager_class = OneviewSDK.resource_named('HypervisorManager', @client.api_version) @@ -45,7 +44,7 @@ hm2 = matches.first puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" -# Retrieve recently created network +# Retrieve recently created hypervisor manager hm3 = hypervisor_manager_class.new(@client, name: hm[:name]) hm3.retrieve! puts "\nRetrieved hypervisor-manager data by name: '#{hm3[:name]}'.\n uri = '#{hm3[:uri]}'" @@ -63,6 +62,6 @@ puts " #{hypervisor_manager[:name]}" end -# Delete this network +# Delete this hypervisor manager hm.delete puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." diff --git a/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb b/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb index ef2dceea0..cc2da8fc9 100644 --- a/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb +++ b/lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb @@ -16,17 +16,6 @@ module API800 module Synergy # Hypervisor Manager resource implementation class HypervisorManager < OneviewSDK::API800::C7000::HypervisorManager - # 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['hypervisorType'] ||= 'Vmware' - @data['type'] ||= 'HypervisorManagerV2' - super - end end end end diff --git a/spec/integration/shared_examples/hypervisor_manager/create.rb b/spec/integration/shared_examples/hypervisor_manager/create.rb index ec7453463..6ea49c733 100644 --- a/spec/integration/shared_examples/hypervisor_manager/create.rb +++ b/spec/integration/shared_examples/hypervisor_manager/create.rb @@ -1,4 +1,4 @@ -# (C) Copyright 2017 Hewlett Packard Enterprise Development LP +# (C) Copyright 2018 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. diff --git a/spec/integration/shared_examples/hypervisor_manager/delete.rb b/spec/integration/shared_examples/hypervisor_manager/delete.rb index 8039d3252..3114087fa 100644 --- a/spec/integration/shared_examples/hypervisor_manager/delete.rb +++ b/spec/integration/shared_examples/hypervisor_manager/delete.rb @@ -1,4 +1,4 @@ -# (C) Copyright 2017 Hewlett Packard Enterprise Development LP +# (C) Copyright 2018 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. diff --git a/spec/integration/shared_examples/hypervisor_manager/update.rb b/spec/integration/shared_examples/hypervisor_manager/update.rb index 7bd7c3f2b..c0c3952b4 100644 --- a/spec/integration/shared_examples/hypervisor_manager/update.rb +++ b/spec/integration/shared_examples/hypervisor_manager/update.rb @@ -1,4 +1,4 @@ -# (C) Copyright 2017 Hewlett Packard Enterprise Development LP +# (C) Copyright 2018 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. diff --git a/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb b/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb index 4c001a3ce..d65d91f0c 100644 --- a/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb +++ b/spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb @@ -3,11 +3,7 @@ RSpec.describe OneviewSDK::API800::Synergy::HypervisorManager do include_context 'shared context' - describe '#initialize' do - it 'sets the defaults correctly' do - item = OneviewSDK::API800::Synergy::HypervisorManager.new(@client_800) - expect(item[:type]).to eq('HypervisorManagerV2') - expect(item[:hypervisorType]).to eq('Vmware') - end + it 'inherits from OneviewSDK::API800::C7000::HypervisorManager' do + expect(described_class).to be < OneviewSDK::API800::C7000::HypervisorManager end end