Skip to content

Commit

Permalink
API200 Deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed Aug 26, 2020
1 parent d3706de commit 52525f4
Show file tree
Hide file tree
Showing 164 changed files with 316 additions and 13,545 deletions.
2 changes: 1 addition & 1 deletion lib/oneview-sdk.rb
Expand Up @@ -26,7 +26,7 @@ module OneviewSDK
env_i3s = %w[I3S_URL I3S_SSL_ENABLED]
ENV_VARS = env_sdk.concat(env_i3s).freeze

SUPPORTED_API_VERSIONS = [200, 300, 500, 600, 800, 1000, 1200, 1600, 1800].freeze
SUPPORTED_API_VERSIONS = [300, 500, 600, 800, 1000, 1200, 1600, 1800].freeze
DEFAULT_API_VERSION = 200
@api_version = DEFAULT_API_VERSION
@api_version_updated = false # Whether or not the API version has been set by the user
Expand Down
4 changes: 2 additions & 2 deletions spec/support/fixtures/unit/cli/ethernet_network1.json
@@ -1,6 +1,6 @@
{
"type": "OneviewSDK::EthernetNetwork",
"api_version": 200,
"api_version": 600,
"data": {
"uri": "/rest/ethernet-networks/11111111-1111-1111-1111-111111111111",
"description": "Short Description",
Expand All @@ -10,4 +10,4 @@
"smartLink": false,
"privateNetwork": false
}
}
}
4 changes: 2 additions & 2 deletions spec/support/fixtures/unit/cli/ethernet_network1.yml
@@ -1,6 +1,6 @@
---
:type: OneviewSDK::EthernetNetwork
:api_version: 200
:type: OneviewSDK::API600::C7000::EthernetNetwork
:api_version: 600
:data:
name: My_Ethernet_Network
description: Short Description
Expand Down
8 changes: 8 additions & 0 deletions spec/support/fixtures/unit/cli/ethernet_network2.yml
@@ -0,0 +1,8 @@
---
:type: OneviewSDK::API600::C7000::EthernetNetwork
:api_version: 600
:data:
ethernetNetworkType: Tagged
type: ethernet-networkV4
name: Test
uri: "/rest/fake"
Expand Up @@ -2,7 +2,7 @@
"type": "NetworkCollectionV3",
"members": [
{
"type": "ethernet-networkV3",
"type": "ethernet-networkV4",
"vlanId": 28,
"ethernetNetworkType": "Tagged",
"smartLink": false,
Expand All @@ -21,7 +21,7 @@
"uri": "/rest/ethernet-networks/07a077d7-9454-407e-a2cd-78c940a1b703"
},
{
"type": "ethernet-networkV3",
"type": "ethernet-networkV4",
"vlanId": 26,
"ethernetNetworkType": "Tagged",
"smartLink": false,
Expand All @@ -40,7 +40,7 @@
"uri": "/rest/ethernet-networks/29ff37e6-ab56-4e4c-9d54-593ae04edfd8"
},
{
"type": "ethernet-networkV3",
"type": "ethernet-networkV4",
"vlanId": 27,
"ethernetNetworkType": "Tagged",
"smartLink": false,
Expand All @@ -59,7 +59,7 @@
"uri": "/rest/ethernet-networks/af25b11e-1326-4c76-a7f8-42098fea3532"
},
{
"type": "ethernet-networkV3",
"type": "ethernet-networkV4",
"vlanId": 0,
"ethernetNetworkType": "Untagged",
"smartLink": false,
Expand Down
@@ -1,6 +1,6 @@
{
"data" : {
"type": "logical-interconnectV3",
"type": "logical-interconnectV4",
"enclosureType": "C7000",
"enclosureUris": [
"/rest/enclosures/09SGH100X6J1"
Expand Down Expand Up @@ -94,7 +94,7 @@
"fcoeMode": "NotApplicable"
},
"ethernetSettings": {
"type": "EthernetInterconnectSettingsV3",
"type": "EthernetInterconnectSettingsV4",
"interconnectType": "Ethernet",
"enableIgmpSnooping": false,
"enableFastMacCacheFailover": true,
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/cli/create_from_file_spec.rb
Expand Up @@ -18,7 +18,7 @@
context 'with valid options' do
before :each do
@resource_data = { 'name' => 'My', 'uri' => '/rest/fake', 'description' => 'Blah' }
response = [OneviewSDK::EthernetNetwork.new(@client_200, @resource_data)]
response = [OneviewSDK::EthernetNetwork.new(@client_600, @resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
allow_any_instance_of(OneviewSDK::Resource).to receive(:create).and_return(true)
allow_any_instance_of(OneviewSDK::Resource).to receive(:update).and_return(true)
Expand All @@ -32,15 +32,15 @@

it 'updates a valid resource by name' do
resource_data = { 'name' => 'My_Ethernet_Network', 'description' => 'Blah' }
response = [OneviewSDK::EthernetNetwork.new(@client_200, resource_data)]
response = [OneviewSDK::EthernetNetwork.new(@client_600, resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
expect { OneviewSDK::Cli.start(['create_from_file', yaml_file]) }
.to output(/Updated Successfully!/).to_stdout_from_any_process
end

it 'makes no changes if the resource is up to date' do
resource_data = { 'name' => 'My_Ethernet_Network', 'description' => 'Short Description' }
response = [OneviewSDK::EthernetNetwork.new(@client_200, resource_data)]
response = [OneviewSDK::API600::C7000::EthernetNetwork.new(@client_600, resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
expect { OneviewSDK::Cli.start(['create_from_file', yaml_file]) }
.to output(/Skipped.*up to date/).to_stdout_from_any_process
Expand All @@ -58,15 +58,15 @@
end

it 'fails if the resource is a generic "Resource" type' do
resource = OneviewSDK::Resource.new(@client_200)
resource = OneviewSDK::Resource.new(@client_600)
allow(OneviewSDK::Resource).to receive(:from_file).and_return(resource)
expect(STDOUT).to receive(:puts).with(/Failed to determine resource type/)
expect { OneviewSDK::Cli.start(['create_from_file', yaml_file]) }
.to raise_error SystemExit
end

it 'fails if the file does not specify a unique identifier' do
resource = OneviewSDK::EthernetNetwork.new(@client_200)
resource = OneviewSDK::EthernetNetwork.new(@client_600)
allow(OneviewSDK::Resource).to receive(:from_file).and_return(resource)
expect(STDOUT).to receive(:puts).with(/Must set/)
expect { OneviewSDK::Cli.start(['create_from_file', yaml_file]) }
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/cli/delete_from_file_spec.rb
Expand Up @@ -18,7 +18,7 @@
context 'with valid options' do
before :each do
@resource_data = { 'name' => 'My', 'uri' => '/rest/fake', 'description' => 'Blah' }
response = [OneviewSDK::EthernetNetwork.new(@client_200, @resource_data)]
response = [OneviewSDK::EthernetNetwork.new(@client_600, @resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
allow_any_instance_of(OneviewSDK::Resource).to receive(:delete).and_return(true)
allow_any_instance_of(OneviewSDK::Resource).to receive(:retrieve!).and_return(true)
Expand Down Expand Up @@ -51,7 +51,7 @@
end

it 'fails if the file does not specify a name or uri' do
resource = OneviewSDK::Resource.new(@client_200)
resource = OneviewSDK::Resource.new(@client_600)
allow(OneviewSDK::Resource).to receive(:from_file).and_return(resource)
allow_any_instance_of(OneviewSDK::Resource).to receive(:retrieve!).and_call_original
expect(STDOUT).to receive(:puts).with(/Must set/)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/cli/delete_spec.rb
Expand Up @@ -25,7 +25,7 @@
context 'with valid options' do
before :each do
@resource_data = { 'name' => 'Profile1', 'uri' => '/rest/fake', 'description' => 'Blah' }
response = [OneviewSDK::ServerProfile.new(@client_200, @resource_data)]
response = [OneviewSDK::ServerProfile.new(@client_600, @resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
allow_any_instance_of(OneviewSDK::Resource).to receive(:delete).and_return(true)
allow_any_instance_of(HighLine).to receive(:agree).and_return(true)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/cli/env_spec.rb
Expand Up @@ -38,8 +38,8 @@
end

it 'shows ONEVIEWSDK_API_VERSION when set' do
ENV['ONEVIEWSDK_API_VERSION'] = '120'
expect { command }.to output(/ONEVIEWSDK_API_VERSION\s+=\s'120'/).to_stdout_from_any_process
ENV['ONEVIEWSDK_API_VERSION'] = '600'
expect { command }.to output(/ONEVIEWSDK_API_VERSION\s+=\s'600'/).to_stdout_from_any_process
end

it 'shows ONEVIEWSDK_VARIANT when set' do
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/cli/list_spec.rb
Expand Up @@ -73,7 +73,7 @@

it 'checks for a valid module api version' do
expect { OneviewSDK::Cli.start(%w[list ServerProfiles --api_version 291]) }
.to output(/API version 291 is not supported. Using 200+\sProfile1/).to_stdout_from_any_process
.to output(/API version 291 is not supported. Using 300+\sProfile1/).to_stdout_from_any_process
end

it 'rounds an invalid module api version down' do
Expand All @@ -84,7 +84,7 @@

it 'rounds an invalid module api version up if cannot round down' do
expect { OneviewSDK::Cli.start(%w[list ServerProfiles --api_version 0]) }
.to output(/API version 0 is not supported. Using 200+\sProfile1/).to_stdout_from_any_process
.to output(/API version 0 is not supported. Using 300+\sProfile1/).to_stdout_from_any_process
end

it 'handles a float type api version' do
Expand All @@ -94,16 +94,16 @@
end

it 'uses the api-version & variant params when looking for an API module' do
expect(OneviewSDK::API300::Synergy::ServerProfile).to receive(:get_all).and_return(@response)
expect { OneviewSDK::Cli.start(%w[list ServerProfiles --api_version 300 --variant Synergy]) }
expect(OneviewSDK::API600::Synergy::ServerProfile).to receive(:get_all).and_return(@response)
expect { OneviewSDK::Cli.start(%w[list ServerProfiles --api_version 600 --variant Synergy]) }
.to output.to_stdout_from_any_process
end
end

it 'uses the ONEVIEWSDK_API_VERSION & ONEVIEWSDK_VARIANT environment variables' do
ENV['ONEVIEWSDK_API_VERSION'] = '300'
ENV['ONEVIEWSDK_API_VERSION'] = '600'
ENV['ONEVIEWSDK_VARIANT'] = 'Synergy'
expect(OneviewSDK::API300::Synergy::ServerProfile).to receive(:get_all).and_return(@response)
expect(OneviewSDK::API600::Synergy::ServerProfile).to receive(:get_all).and_return(@response)
expect { OneviewSDK::Cli.start(%w[list ServerProfiles]) }
.to output.to_stdout_from_any_process
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/cli/search_spec.rb
Expand Up @@ -16,8 +16,8 @@

let(:response) do
[
OneviewSDK::ServerProfile.new(@client_200, resource_data),
OneviewSDK::ServerProfile.new(@client_200, resource_data2)
OneviewSDK::ServerProfile.new(@client_600, resource_data),
OneviewSDK::ServerProfile.new(@client_600, resource_data2)
]
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/cli/show_spec.rb
Expand Up @@ -25,7 +25,7 @@

before :each do
@resource_data = { 'name' => 'Profile1', 'uri' => '/rest/fake', 'description' => 'Blah', 'x' => { 'y' => 'z', 'a' => 'b' } }
response = [OneviewSDK::Resource.new(@client_200, @resource_data)]
response = [OneviewSDK::Resource.new(@client_600, @resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(response)
end

Expand Down
16 changes: 8 additions & 8 deletions spec/unit/cli/to_file_spec.rb
Expand Up @@ -41,7 +41,7 @@
context 'with valid options' do
before :each do
@resource_data = { 'name' => 'Test', 'uri' => '/rest/fake' }
@response = [OneviewSDK::EthernetNetwork.new(@client_200, @resource_data)]
@response = [OneviewSDK::EthernetNetwork.new(@client_600, @resource_data)]
allow(OneviewSDK::Resource).to receive(:find_by).and_return(@response)
end

Expand All @@ -59,17 +59,17 @@
.to output(/Output to/).to_stdout_from_any_process
end

it 'accepts an api-version parameter: 200' do
expect_any_instance_of(OneviewSDK::API200::EthernetNetwork).to receive(:to_file).and_return(true)
expect { OneviewSDK::Cli.start(['to_file', 'EthernetNetwork', 'Test', '-p', path, '--api-version', 200]) }
it 'accepts an api-version parameter: 300' do
expect_any_instance_of(OneviewSDK::API300::EthernetNetwork).to receive(:to_file).and_return(true)
expect { OneviewSDK::Cli.start(['to_file', 'EthernetNetwork', 'Test', '-p', path, '--api-version', 300]) }
.to output(/Output to/).to_stdout_from_any_process
end

it 'accepts an api-version parameter: 300' do
@response = [OneviewSDK::API300::EthernetNetwork.new(@client_200, @resource_data)]
it 'accepts an api-version parameter: 600' do
@response = [OneviewSDK::API600::EthernetNetwork.new(@client_600, @resource_data)]
expect(OneviewSDK::Resource).to receive(:find_by).and_return(@response)
expect_any_instance_of(OneviewSDK::API300::EthernetNetwork).to receive(:to_file).and_return(true)
expect { OneviewSDK::Cli.start(['to_file', 'EthernetNetwork', 'Test', '-p', path, '--api-version', 300]) }
expect_any_instance_of(OneviewSDK::API600::EthernetNetwork).to receive(:to_file).and_return(true)
expect { OneviewSDK::Cli.start(['to_file', 'EthernetNetwork', 'Test', '-p', path, '--api-version', 600]) }
.to output(/Output to/).to_stdout_from_any_process
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/cli/update_spec.rb
Expand Up @@ -15,7 +15,7 @@
end

let(:sp1) do
OneviewSDK::ServerProfile.new(@client_200, resource_data)
OneviewSDK::API600::C7000::ServerProfile.new(@client_600, resource_data)
end

let(:sp_list) do
Expand Down

0 comments on commit 52525f4

Please sign in to comment.