Skip to content

Commit

Permalink
Merge pull request #213 from HewlettPackard/fix/os_deployment_plan_re…
Browse files Browse the repository at this point in the history
…source

Created the resource 'OS Deployment Plan'
  • Loading branch information
ricardogpsf committed Mar 14, 2017
2 parents 745cdc9 + 9c763f4 commit cad8705
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
- [#201](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/201) Code to search the collection of resources (paginated search) is repeated in some resources
- [#119](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/112) VolumeAttachment::remove_extra_unmanaged_volume throw Unexpected Http Error
- [#202](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/202) The method #get_default_settings in LogicalInterconnectGroup is used on integration test
- [#212](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/212) Unable to create a Server Profile with Deployment Plan settings

#### Design changes:
- Architecture for future API500 support. Features for API500 are not yet supported.

#### New Resources:
- OS Deployment Plan

# v4.1.0

#### New Resources:
Expand Down
26 changes: 26 additions & 0 deletions examples/api300/synergy/os_deployment_plan.rb
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 lib/oneview-sdk/resource/api300/synergy/os_deployment_plan.rb
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
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
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
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
1 change: 1 addition & 0 deletions spec/integration/sequence_and_naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def tsort_each_child(node, &block)
LogicalSwitchGroup: [],
ManagedSAN: [:SANManager],
NetworkSet: [:EthernetNetwork, :FCNetwork, :FCoENetwork],
OSDeploymentPlan: [],
PowerDevice: [:ServerProfile, :Volume, :LogicalSwitch],
Rack: [:ServerProfile],
SANManager: [],
Expand Down
45 changes: 45 additions & 0 deletions spec/unit/resource/api300/synergy/os_deployment_plan_spec.rb
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

0 comments on commit cad8705

Please sign in to comment.