Skip to content

Commit

Permalink
Resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sijeesh committed Apr 20, 2018
2 parents 49ce2b8 + 34b1ff1 commit fcb5a06
Show file tree
Hide file tree
Showing 21 changed files with 319 additions and 1 deletion.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Extended support to Image Streamer Rest API version 500 and 600 to the already e
- Golden Image
- OS Volume


## v5.4.0

#### Notes
Expand Down
6 changes: 6 additions & 0 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ OneviewSDK::Datacenter.find_by(@client, width: 11000).map(&:remove)
|<sub>/rest/firmware-drivers</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Hypervisor Managers** |
|<sub>/rest/hypervisor-managers</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-managers</sub> | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-managers/{id}</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-managers/{id}</sub> | PUT | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-managers/{id}</sub> | DELETE | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
| **ID Pools** |
|<sub>/rest/id-pools/{poolType}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/id-pools/{poolType}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
3 changes: 3 additions & 0 deletions examples/_client.rb.example
Original file line number Diff line number Diff line change
Expand Up @@ -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'
67 changes: 67 additions & 0 deletions examples/shared_samples/hypervisor_manager.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# (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.
#
# 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 @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)

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 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]}'"

# 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 hypervisor manager
hm.delete
puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'."
33 changes: 33 additions & 0 deletions lib/oneview-sdk/resource/api800/c7000/hypervisor_manager.rb
Original file line number Diff line number Diff line change
@@ -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 < OneviewSDK::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
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api800/synergy/hypervisor_manager.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (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
end
end
end
end
3 changes: 3 additions & 0 deletions spec/integration/one_view_secrets.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions spec/integration/one_view_synergy_secrets.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions spec/integration/sequence_and_naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def tsort_each_child(node, &block)
FCoENetwork: [],
FirmwareBundle: [],
FirmwareDriver: [:FirmwareBundle],
HypervisorManager: [],
IDPool: [],
Interconnect: [:LogicalInterconnect],
LIGUplinkSet: [],
Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions spec/integration/shared_examples/hypervisor_manager/create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# (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.

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
27 changes: 27 additions & 0 deletions spec/integration/shared_examples/hypervisor_manager/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# (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.

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
27 changes: 27 additions & 0 deletions spec/integration/shared_examples/hypervisor_manager/update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# (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.

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
9 changes: 9 additions & 0 deletions spec/support/fixtures/integration/hypervisor_manager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"name": "172.18.13.11",
"username": "dcs",
"password": "dcs",
"hypervisorType": "Vmware",
"type": "HypervisorManagerV2"
}
}
13 changes: 13 additions & 0 deletions spec/unit/resource/api800/c7000/hypervisor_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions spec/unit/resource/api800/synergy/hypervisor_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'spec_helper'

RSpec.describe OneviewSDK::API800::Synergy::HypervisorManager do
include_context 'shared context'

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

0 comments on commit fcb5a06

Please sign in to comment.