-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from HewlettPackard/fix/os_deployment_plan_re…
…source Created the resource 'OS Deployment Plan'
- Loading branch information
Showing
8 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
require_relative '../../_client' # Gives access to @client | ||
|
||
# Example: Get OS Deployment Plans | ||
|
||
puts "\nListing all 'OS Deployment Plans':" | ||
all_deployments_plans = OneviewSDK::API300::Synergy::OSDeploymentPlan.get_all(@client) | ||
all_deployments_plans.each { |item| puts "- #{item['name']}" } | ||
|
||
puts "\nFinding items by name '#{all_deployments_plans.first['name']}'" | ||
items = OneviewSDK::API300::Synergy::OSDeploymentPlan.find_by(@client, name: all_deployments_plans.first['name']) | ||
puts "#{items.size} item found:", items.first.data | ||
|
||
puts "\nRetrieving by URI '#{all_deployments_plans.first['uri']}'" | ||
item = OneviewSDK::API300::Synergy::OSDeploymentPlan.new(@client, uri: all_deployments_plans.first['uri']) | ||
puts 'Item retrieved: ', item.data if item.retrieve! |
41 changes: 41 additions & 0 deletions
41
lib/oneview-sdk/resource/api300/synergy/os_deployment_plan.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# (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 'resource' | ||
|
||
module OneviewSDK | ||
module API300 | ||
module Synergy | ||
# Network set resource implementation for API300 Synergy | ||
class OSDeploymentPlan < OneviewSDK::API300::Synergy::Resource | ||
BASE_URI = '/rest/os-deployment-plans'.freeze | ||
|
||
# Method is not available | ||
# @raise [OneviewSDK::MethodUnavailable] method is not available | ||
def create(*) | ||
unavailable_method | ||
end | ||
|
||
# Method is not available | ||
# @raise [OneviewSDK::MethodUnavailable] method is not available | ||
def update(*) | ||
unavailable_method | ||
end | ||
|
||
# Method is not available | ||
# @raise [OneviewSDK::MethodUnavailable] method is not available | ||
def delete(*) | ||
unavailable_method | ||
end | ||
end | ||
end | ||
end | ||
end |
57 changes: 57 additions & 0 deletions
57
spec/integration/resource/api300/synergy/os_deployment_plan/create_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# (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 'spec_helper' | ||
|
||
klass = OneviewSDK::API300::Synergy::OSDeploymentPlan | ||
RSpec.describe klass, integration: true, type: CREATE, sequence: seq(klass) do | ||
include_context 'integration api300 context' | ||
|
||
describe '#create' do | ||
it 'should throw method unavailable exception' do | ||
item = klass.new($client_300) | ||
expect { item.create }.to raise_error(OneviewSDK::MethodUnavailable) | ||
end | ||
end | ||
|
||
describe '::get_all' do | ||
it 'should get all OS Deployment Plans' do | ||
items = klass.get_all($client_300) | ||
expect(items).not_to be_empty | ||
expect(items.first.class).to eq(OneviewSDK::API300::Synergy::OSDeploymentPlan) | ||
end | ||
end | ||
|
||
describe '::find_by' do | ||
it 'should get specific OS Deployment Plan' do | ||
item = klass.get_all($client_300).first | ||
items_searched = klass.find_by($client_300, name: item['name']) | ||
expect(items_searched.size).to eq(1) | ||
expect(items_searched.first['uri']).to eq(item['uri']) | ||
end | ||
|
||
context 'when there are not items for the paramater passed' do | ||
it 'should return an empty list' do | ||
items_searched = klass.find_by($client_300, name: 'some wrong name') | ||
expect(items_searched).to be_empty | ||
end | ||
end | ||
end | ||
|
||
describe '#retrieve!' do | ||
it 'should get specific OS Deployment Plan by URI' do | ||
item = klass.get_all($client_300).first | ||
item_retrieved = klass.new($client_300, uri: item['uri']) | ||
expect(item_retrieved.retrieve!).to eq(true) | ||
expect(item_retrieved['name']).to eq(item['name']) | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
spec/integration/resource/api300/synergy/os_deployment_plan/delete_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# (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 'spec_helper' | ||
|
||
klass = OneviewSDK::API300::Synergy::OSDeploymentPlan | ||
RSpec.describe klass, integration: true, type: DELETE, sequence: rseq(klass) do | ||
include_context 'integration api300 context' | ||
|
||
describe '#delete' do | ||
it 'should throw method unavailable exception' do | ||
item = klass.new($client_300) | ||
expect { item.delete }.to raise_error(OneviewSDK::MethodUnavailable) | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
spec/integration/resource/api300/synergy/os_deployment_plan/update_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# (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 'spec_helper' | ||
|
||
klass = OneviewSDK::API300::Synergy::OSDeploymentPlan | ||
RSpec.describe klass, integration: true, type: UPDATE do | ||
include_context 'integration api300 context' | ||
|
||
describe '#update' do | ||
it 'should throw method unavailable exception' do | ||
item = klass.new($client_300) | ||
expect { item.update }.to raise_error(OneviewSDK::MethodUnavailable) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
spec/unit/resource/api300/synergy/os_deployment_plan_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# (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 'spec_helper' | ||
|
||
RSpec.describe OneviewSDK::API300::Synergy::OSDeploymentPlan do | ||
include_context 'shared context' | ||
|
||
it 'BASE_URI should be the correct URI' do | ||
expect(described_class::BASE_URI).to eq('/rest/os-deployment-plans') | ||
end | ||
|
||
it 'inherits from Resource' do | ||
expect(described_class).to be < OneviewSDK::API300::Synergy::Resource | ||
end | ||
|
||
describe '#create' do | ||
it 'should throw unavailable method error' do | ||
item = described_class.new(@client_300) | ||
expect { item.create }.to raise_error(/The method #create is unavailable for this resource/) | ||
end | ||
end | ||
|
||
describe '#update' do | ||
it 'should throw unavailable method error' do | ||
item = described_class.new(@client_300) | ||
expect { item.update }.to raise_error(/The method #update is unavailable for this resource/) | ||
end | ||
end | ||
|
||
describe '#delete' do | ||
it 'should throw unavailable method error' do | ||
item = described_class.new(@client_300) | ||
expect { item.delete }.to raise_error(/The method #delete is unavailable for this resource/) | ||
end | ||
end | ||
end |