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 fcb5a06 + 95a1cba commit dfe27a4
Show file tree
Hide file tree
Showing 19 changed files with 356 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Metrics/PerceivedComplexity:
Enabled: false

Style/GlobalVars:
AllowedVariables: [$config, $secrets, $client, $client_120, $client_300, $client_300_synergy, $config_synergy, $secrets_synergy, $config_i3s, $client_i3s_300, $client_500, $client_500_synergy, $client_600, $client_600_synergy, $client_800, $client_800_synergy]
AllowedVariables: [$config, $secrets, $client, $client_120, $client_300, $client_300_synergy, $config_synergy, $secrets_synergy, $config_i3s, $client_i3s_300, $client_500, $client_500_synergy, $client_i3s_500, $client_600, $client_600_synergy, $client_i3s_600, $client_800, $client_800_synergy]

Style/FrozenStringLiteralComment:
Enabled: false
Expand Down
7 changes: 7 additions & 0 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ OneviewSDK::Datacenter.find_by(@client, width: 11000).map(&:remove)
|<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: |
| **Hypervisor Cluster Profiles** |
|<sub>/rest/hypervisor-cluster-profiles</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles</sub> | POST | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles/{id}</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles/{id}</sub> | PUT | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles/{id}/compliance-preview</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles/{id}</sub> | DELETE | :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
9 changes: 9 additions & 0 deletions examples/_client.rb.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,12 @@ puts "Connected to OneView appliance at #{@client.url}\n\n"
# @hypervisor_manager_ip = '172.18.13.11'
# @hypervisor_manager_username ='dcs'
# @hypervisor_manager_password ='dcs'
# @hypervisor_cluster_profile_name = "Cluster5"
# @hypervisor_path = "DC2"
# @hypervisor_server_password = "dcs"
# @hypervisor_host_prefix = "Test-Cluster-host"
# @hypervisor_hypervisorType = "Vmware"
# @hypervisor_type = "HypervisorClusterProfileV3"
# @hypervisor_manager_uri = "/rest/hypervisor-managers/befc6bd9-0366-4fd9-a3fc-c92ab0df3603"
# @hypervisor_serverProfileTemplateUri = "/rest/server-profile-templates/c865a62c-8fd8-414c-8c16-3f7ca75ab2ba"
# @hypervisor_deploymentPlanUri = "/rest/os-deployment-plans/c54e1dab-cc14-48fa-92bf-d301671fb0cf"
71 changes: 71 additions & 0 deletions examples/shared_samples/hypervisor_cluster_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# (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 cluster profile
# NOTE: This will create a hypervisor cluster profile named 'cluster5', 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::HypervisorClusterProfile
# api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::HypervisorClusterProfile

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

options = {
type: @hypervisor_type,
name: @hypervisor_cluster_profile_name,
hypervisorManagerUri: @hypervisor_manager_uri,
path: @hypervisor_path,
hypervisorType: @hypervisor_hypervisorType,
hypervisorHostProfileTemplate: {
serverProfileTemplateUri: @hypervisor_serverProfileTemplateUri,
deploymentPlan: {
deploymentPlanUri: @hypervisor_deploymentPlanUri,
serverPassword: @hypervisor_server_password
},
hostprefix: @hypervisor_host_prefix
}
}

hcp = hypervisor_cluster_profile_class.new(@client, options)
hcp.create!
puts "\nCreated hypervisor-cluster_profile '#{hcp[:name]}' sucessfully.\n uri = '#{hcp[:uri]}'"

# Lists all the hypervisor cluster profiles present
puts "\nListing all the available cluster profiles\n"
hypervisor_cluster_profile_class.find_by(@client, {}).each do |profile|
puts "#{profile['name']} was found."
end

# Find cluster profile by name
hcp_by_name = hypervisor_cluster_profile_class.find_by(@client, name: hypervisor_cluster_profile_class.find_by(@client, {}).first[:name]).first
puts "\nFound hypervisor cluster profile by name: '#{hcp_by_name[:name]}'.\n uri : '#{hcp_by_name[:uri]}'"

# Update a hypervisor cluster profile
hcp2 = hypervisor_cluster_profile_class.find_by(@client, {}).first
data = { description: 'New Description' }
puts "\nCluster profile description before update : '#{hcp2[:description]}'"
hcp2.update(data)
puts "Cluster profile description after update : '#{hcp2[:description]}'\n"

# Listing compliance details of the previously updated cluster profile
cp = hcp2.compliance_preview
puts "\nCompliance preview details are :\n#{cp}\n"

# Deletes the created hypervisor cluster profile
hcp.delete
puts "\nSuccesfully deleted the cluster profile"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# (C) Copyright 2016 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 Cluster profile resource implementation
class HypervisorClusterProfile < OneviewSDK::Resource
BASE_URI = '/rest/hypervisor-cluster-profiles'.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['type'] ||= 'HypervisorClusterProfileListV3'
end

# Gets the preview of manual and automatic updates required to make the cluster profile consistent with its template.
def compliance_preview
ensure_client && ensure_uri
@client.response_handler(@client.rest_get(@data['uri'] + '/compliance-preview', {}, @api_version))
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (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 '../c7000/hypervisor_cluster_profile'

module OneviewSDK
module API800
module Synergy
# Hypervisor cluster profile resource implementation for API800 Synergy
class HypervisorClusterProfile < OneviewSDK::API800::C7000::HypervisorClusterProfile
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'

klass = OneviewSDK::API800::C7000::HypervisorClusterProfile
RSpec.describe klass, integration: true, type: CREATE, sequence: seq(klass) do
include_examples 'HypervisorClusterProfileCreateExample', '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::HypervisorClusterProfile
RSpec.describe klass, integration: true, type: DELETE, sequence: rseq(klass) do
include_examples 'HypervisorClusterProfileDeleteExample', '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::HypervisorClusterProfile, integration: true, type: UPDATE do
include_examples 'HypervisorClusterProfileUpdateExample', '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::HypervisorClusterProfile
RSpec.describe klass, integration: true, type: CREATE, sequence: seq(klass) do
include_examples 'HypervisorClusterProfileCreateExample', '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::HypervisorClusterProfile
RSpec.describe klass, integration: true, type: DELETE, sequence: rseq(klass) do
include_examples 'HypervisorClusterProfileDeleteExample', '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::HypervisorClusterProfile, integration: true, type: UPDATE do
include_examples 'HypervisorClusterProfileUpdateExample', 'integration api800 context' do
let(:current_client) { $client_800 }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# (C) Copyright 2017 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.
# 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 'HypervisorClusterProfileCreateExample' do |context_name|
include_context context_name

let(:file_path) { 'spec/support/fixtures/integration/hypervisor_cluster_profile.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(HYP_CLUSTER_PROF)
expect(item[:hypervisorType]).to eq(Vmware)
expect(item[:deploymentPlanUri]).not_to eq(nil)
expect(item[:type]).to eq('HypervisorClusterProfileV3')
end
end

describe '#retrieve!' do
it 'retrieves the resource' do
item = described_class.new(current_client, name: HYP_CLUSTER_PROF)
item.retrieve!
expect(item[:name]).to eq(HYP_CLUSTER_PROF)
expect(item[:hypervisorType]).to eq(Vmware)
expect(item[:deploymentPlanUri]).not_to eq(nil)
expect(item[:type]).to eq('HypervisorClusterProfileV3')
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(HYP_CLUSTER_PROF)
end
end

describe '#compliance_preview' do
it 'Gets the compliance preview' do
item = described_class.get_all(current_client).first
item.compliance_preview
expect { item.compliance_preview }.not_to raise_error
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# (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 'HypervisorClusterProfileDeleteExample' do |context_name|
include_context context_name

describe '#delete' do
it 'deletes the resource' do
item = described_class.new(current_client, name: HYP_CLUSTER_PROF)

expect(item.retrieve!).to eq(true)

expect { item.delete }.not_to raise_error

expect(item.retrieve!).to eq(false)
end
end
end
Original file line number Diff line number Diff line change
@@ -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 'HypervisorClusterProfileUpdateExample' do |context_name|
include_context context_name

describe '#update' do
it 'updates the network name' do
item = described_class.new(current_client, name: HYP_CLUSTER_PROF)
item.retrieve!
item.update(name: HYP_CLUSTER_PROF_UPDATED)
item.refresh
expect(item[:name]).to eq(HYP_CLUSTER_PROF_UPDATED)
item.update(name: HYP_CLUSTER_PROF) # Put it back to normal
item.refresh
expect(item[:name]).to eq(HYP_CLUSTER_PROF)
end
end
end
17 changes: 17 additions & 0 deletions spec/support/fixtures/integration/hypervisor_cluster_profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"data": {
"type":"HypervisorClusterProfileV3",
"name":"Cluster5",
"hypervisorManagerUri":"/rest/hypervisor-managers/befc6bd9-0366-4fd9-a3fc-c92ab0df3603",
"path":"DC2",
"hypervisorType":"Vmware",
"hypervisorHostProfileTemplate":{
"serverProfileTemplateUri":"/rest/server-profile-templates/c865a62c-8fd8-414c-8c16-3f7ca75ab2ba",
"deploymentPlan":{
"deploymentPlanUri":"/rest/os-deployment-plans/c54e1dab-cc14-48fa-92bf-d301671fb0cf",
"serverPassword":"dcs"
},
"hostprefix":"Test-Cluster-host"
}
}
}
2 changes: 0 additions & 2 deletions spec/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ These config files get loaded and create the following global variables:
- `$client_500_synergy`: Client object using API v500 Synergy
- `$client_800`: Client object using API v800 C7000
- `$client_800_synergy`: Client object using API v800 Synergy
- `$client_600`: Client object using API v600 C7000
- `$client_600_synergy`: Client object using API v600 Synergy

## Running the tests
The following command must run in your Ruby SDK root directory:
Expand Down
27 changes: 27 additions & 0 deletions spec/unit/resource/api800/c7000/hypervisor_cluster_profile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require_relative '../../../../spec_helper'

RSpec.describe OneviewSDK::API800::C7000::HypervisorClusterProfile do
include_context 'shared context'

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

before(:each) do
@item = OneviewSDK::API800::C7000::HypervisorClusterProfile.new(@client_800, uri: '/rest/fake')
end

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

describe '#compliance_preview' do
it 'Makes a GET call' do
expect(@client_800).to receive(:rest_get).with(@item['uri'] + '/compliance-preview', {}, @item.api_version)
.and_return(FakeResponse.new({}))
@item.compliance_preview
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'spec_helper'

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

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

0 comments on commit dfe27a4

Please sign in to comment.