Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/i3s_structure
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexmonteiro committed Jan 10, 2017
2 parents 72ac680 + 7db6b42 commit b4897c2
Show file tree
Hide file tree
Showing 47 changed files with 1,962 additions and 138 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,8 +1,10 @@
# v3.1.0
1. Added full support to OneView Rest API version 300 for the hardware variants C7000 and Synergy to the already existing features:
- Interconnect
- Logical Interconnect
- Uplink Set
- Volume attachment
- Unmanaged devices

### Features supported
- Connection template
Expand All @@ -14,6 +16,7 @@
- FCoE network
- Firmware bundles
- Firmware drivers
- Interconnect
- Logical downlink
- Logical enclosure
- Logical interconnect
Expand Down Expand Up @@ -45,6 +48,7 @@
- SAS Logical Interconnect Group
- SAS Logical JBOD Attachments
- SAS Logical JBODs
- Unmanaged devices

2. Design changes:
- Architecture for future Image Streamer support.
Expand Down Expand Up @@ -134,7 +138,6 @@
- Power devices
- Racks
- Server hardware types
- Unmanaged devices
3. New exceptions to address the most common issues (Check them in *lib/oneview-sdk/resource/exceptions.rb*)

### Breaking changes
Expand Down
80 changes: 76 additions & 4 deletions Rakefile
Expand Up @@ -58,32 +58,104 @@ end

desc 'Run System tests'
RSpec::Core::RakeTask.new('spec:system') do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.pattern = spec_pattern
spec.rspec_opts = def_int_spec_options
spec.rspec_opts << ' --tag system'
end

desc 'Run System tests for specified model & API. Defaults to model C7000 and API 300.'
task 'spec:system:api_version_model', [:api, :model] do |_t, spec|
args = {}
args['model'] = spec['model'] || 'c7000'
args['api'] = spec['api'] || 300
spec_pattern = "spec/system/**/api#{args['api']}/#{args['model']}/*_spec.rb"
spec_pattern = 'spec/system/**/api200/*_spec.rb' if args['api'] == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests for specified API. Defaults to API 300.'
task 'spec:system:api_version', [:api] do |_t, spec|
args = spec['api'] || 300
spec_pattern = "spec/system/**/api#{args}/**/*_spec.rb"
spec_pattern = 'spec/system/**/api200/*_spec.rb' if args == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Light Profile'
RSpec::Core::RakeTask.new('spec:system:light') do |spec|
spec.pattern = 'spec/system/light_profile/*_spec.rb'
spec.pattern = 'spec/system/light_profile/**/*_spec.rb'
spec.rspec_opts = def_int_spec_options
spec.rspec_opts << ' --tag system'
end

desc 'Run System tests Light Profile for specified model & API. Defaults to model C7000 and API 300.'
task 'spec:system:light:api_version_model', [:api, :model] do |_t, spec|
args = {}
args['model'] = spec['model'] || 'c7000'
args['api'] = spec['api'] || 300
spec_pattern = "spec/system/light_profile/api#{args['api']}/#{args['model']}/*_spec.rb"
spec_pattern = 'spec/system/light_profile/api200/*_spec.rb' if args['api'] == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Light Profile for specified API. Defaults to API 300.'
task 'spec:system:light:api_version', [:api] do |_t, spec|
args = spec['api'] || 300
spec_pattern = "spec/system/light_profile/api#{args}/**/*_spec.rb"
spec_pattern = 'spec/system/light_profile/api200/*_spec.rb' if args == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Medium Profile'
RSpec::Core::RakeTask.new('spec:system:medium') do |spec|
spec.pattern = 'spec/system/medium_profile/*_spec.rb'
spec.pattern = 'spec/system/medium_profile/**/*_spec.rb'
spec.rspec_opts = def_int_spec_options
spec.rspec_opts << ' --tag system'
end

desc 'Run System tests Medium Profile for specified model & API. Defaults to model C7000 and API 300.'
task 'spec:system:medium:api_version_model', [:api, :model] do |_t, spec|
args = {}
args['model'] = spec['model'] || 'c7000'
args['api'] = spec['api'] || 300
spec_pattern = "spec/system/medium_profile/api#{args['api']}/#{args['model']}/*_spec.rb"
spec_pattern = 'spec/system/medium_profile/api200/*_spec.rb' if args['api'] == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Medium Profile for specified API. Defaults to API 300.'
task 'spec:system:medium:api_version', [:api] do |_t, spec|
args = spec['api'] || 300
spec_pattern = "spec/system/medium_profile/api#{args}/**/*_spec.rb"
spec_pattern = 'spec/system/medium_profile/api200/*_spec.rb' if args == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Heavy Profile'
RSpec::Core::RakeTask.new('spec:system:heavy') do |spec|
spec.pattern = 'spec/system/heavy_profile/*_spec.rb'
spec.pattern = 'spec/system/heavy_profile/**/*_spec.rb'
spec.rspec_opts = def_int_spec_options
spec.rspec_opts << ' --tag system'
end

desc 'Run System tests Heavy Profile for specified model & API. Defaults to model C7000 and API 300.'
task 'spec:system:heavy:api_version_model', [:api, :model] do |_t, spec|
args = {}
args['model'] = spec['model'] || 'c7000'
args['api'] = spec['api'] || 300
spec_pattern = "spec/system/heavy_profile/api#{args['api']}/#{args['model']}/*_spec.rb"
spec_pattern = 'spec/system/heavy_profile/api200/*_spec.rb' if args['api'] == '200'
Rake::Task['spec:system'].invoke
end

desc 'Run System tests Heavy Profile for specified API. Defaults to API 300.'
task 'spec:system:heavy:api_version', [:api] do |_t, spec|
args = spec['api'] || 300
spec_pattern = "spec/system/heavy_profile/api#{args}/**/*_spec.rb"
spec_pattern = 'spec/system/heavy_profile/api200/*_spec.rb' if args == '200'
Rake::Task['spec:system'].invoke
end

RuboCop::RakeTask.new do |task|
task.options << '--display-cop-names'
end
Expand Down
55 changes: 47 additions & 8 deletions examples/api200/interconnect.rb
Expand Up @@ -11,18 +11,57 @@

require_relative '../_client'

# Example: Actions with interconnect
# NOTE: You'll need to add an interconnect with state Configured and a port linked.

# List of interconnects
puts "\nGets all interconnects"
OneviewSDK::Interconnect.find_by(@client, {}).each do |interconnect|
puts "Interconnect #{interconnect['name']} URI=#{interconnect['uri']}"
puts "Interconnect #{interconnect['name']} URI=#{interconnect['uri']} state #{interconnect['state']}"
end

# Retrieve name servers
puts " - Name servers: #{interconnect.nameServers}"
# Retrieves interconnect types
puts "\nRetrieving interconnect types"
OneviewSDK::Interconnect.get_types(@client).each do |type|
puts "Interconnect type #{type['name']} URI=#{type['uri']}"
end

# Retrieve interconnect
interconnect = OneviewSDK::Interconnect.new(@client, name: 'Encl2, interconnect 2')
interconnect.retrieve!
item = OneviewSDK::Interconnect.find_by(@client, state: 'Configured').first

# Retrieving the named servers for this interconnect
puts "\nRetrieving the named servers for interconnect #{item['name']}"
servers = item.name_servers
puts 'Server not found.' unless servers.empty?
puts servers

# Get statistics for an interconnect, for the specified port
port = item[:ports].last
puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}"
stats = item.statistics(port['name'])
puts "\nStatistics for the interconnect #{item['name']} and port #{port['name']}"
puts stats

# Resert Port Protection
puts "Reseting port protection for interconnect #{interconnect['name']}"
interconnect.resetportprotection
puts "\nReseting port protection for interconnect #{item['name']}"
item.reset_port_protection
puts 'Reset port protection successfully'

# Update port
ports = item['ports'].select { |k| k['portType'] == 'Uplink' }
port = ports.first
puts "\nUpdating port for interconnect #{item['name']}"
puts "and port #{port['name']} with status #{port['enabled']}"
puts "\nChanging the status"
item.update_port(port['name'], enabled: false)
item.retrieve!
ports_2 = item['ports'].select { |k| k['portType'] == 'Uplink' }
port_updated = ports_2.first
puts "Port updated successfully for interconnect #{item['name']}"
puts "Port #{port_updated['name']} with status #{port_updated['enabled']}"
# Returning for original state
puts "\nEnabling the port #{port['name']}"
item.update_port(port['name'], enabled: true)
item.retrieve!
ports_3 = item['ports'].select { |k| k['portType'] == 'Uplink' }
port_original_state = ports_3.first
puts "\nPort #{port_original_state['name']} with status #{port_original_state['enabled']}"
30 changes: 29 additions & 1 deletion examples/api200/unmanaged_device.rb
Expand Up @@ -11,5 +11,33 @@

require_relative '../_client' # Gives access to @client

puts "\nAdding first device ..."
device1 = OneviewSDK::UnmanagedDevice.new(@client, name: 'Unmanaged Device 1', model: 'Procurve 4200VL')
device1.add
puts 'Device added:'
puts "- \"#{device1['name']}\" with model \"#{device1['model']}\" and uri \"#{device1['uri']}\""

puts "\nAdding second device ..."
device2 = OneviewSDK::UnmanagedDevice.new(@client, name: 'Unmanaged Device 2', model: 'Unknown')
device2.add
puts 'Device added:'
puts "- \"#{device2['name']}\" with model \"#{device2['model']}\" and uri \"#{device2['uri']}\""

puts "\nListing all devices:"
unmanaged_devices = OneviewSDK::UnmanagedDevice.get_devices(@client)
unmanaged_devices.each { |device| puts device['name'] }
unmanaged_devices.each do |device|
puts "- \"#{device['name']}\" with model \"#{device['model']}\" and uri \"#{device['uri']}\""
end

[device1, device2].each do |device|
puts "\nUpdating device '#{device['name']}' ..."
device.update(name: device['name'] + ' (Updated)', model: device['model'] + ' (Updated)')
device.refresh
puts 'Device updated:'
puts "- \"#{device['name']}\" with model \"#{device['model']}\" and uri \"#{device['uri']}\""
end

[device1, device2].each do |device|
puts "\nRemoving device '#{device['name']}' ..."
puts 'Device removed with success!' if device.remove
end
67 changes: 67 additions & 0 deletions examples/api300/c7000/interconnect.rb
@@ -0,0 +1,67 @@
# (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 '../../_client'

# Example: Actions with interconnect
# NOTE: You'll need to add an interconnect with state Configured and a port linked.

# List of interconnects
puts "\nGets all interconnects"
OneviewSDK::API300::C7000::Interconnect.find_by(@client, {}).each do |interconnect|
puts "Interconnect #{interconnect['name']} URI=#{interconnect['uri']} state #{interconnect['state']}"
end

# Retrieves interconnect types
puts "\nRetrieving interconnect types"
OneviewSDK::API300::C7000::Interconnect.get_types(@client).each do |type|
puts "Interconnect type #{type['name']} URI=#{type['uri']}"
end

item = OneviewSDK::API300::C7000::Interconnect.find_by(@client, state: 'Configured').first

# Retrieving the named servers for this interconnect
puts "\nRetrieving the named servers for interconnect #{item['name']}"
servers = item.name_servers
puts 'Server not found.' unless servers.empty?
puts servers

# Get statistics for an interconnect, for the specified port
port = item[:ports].last
puts "\nGetting statistics for the interconnect #{item['name']} and port #{port['name']}"
stats = item.statistics(port['name'])
puts "\nStatistics for the interconnect #{item['name']} and port #{port['name']}"
puts stats

# Resert Port Protection
puts "\nReseting port protection for interconnect #{item['name']}"
item.reset_port_protection
puts 'Reset port protection successfully.'

# Update port
ports = item['ports'].select { |k| k['portType'] == 'Uplink' }
port = ports.first
puts "\nUpdating port for interconnect #{item['name']}"
puts "and port #{port['name']} with status #{port['enabled']}"
puts "\nChanging the status"
item.update_port(port['name'], enabled: false)
item.retrieve!
ports_2 = item['ports'].select { |k| k['portType'] == 'Uplink' }
port_updated = ports_2.first
puts "Port updated successfully for interconnect #{item['name']}"
puts "Port #{port_updated['name']} with status #{port_updated['enabled']}"
# Returning to original state
puts "\nEnabling the port #{port['name']}"
item.update_port(port['name'], enabled: true)
item.retrieve!
ports_3 = item['ports'].select { |k| k['portType'] == 'Uplink' }
port_original_state = ports_3.first
puts "\nPort #{port_original_state['name']} with status #{port_original_state['enabled']}"
43 changes: 43 additions & 0 deletions examples/api300/c7000/unmanaged_device.rb
@@ -0,0 +1,43 @@
# (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 '../../_client' # Gives access to @client

puts "\nAdding first device ..."
device1 = OneviewSDK::API300::C7000::UnmanagedDevice.new(@client, name: 'Unmanaged Device 1', model: 'Procurve 4200VL')
device1.add
puts 'Device added:'
puts "- \"#{device1['name']}\" with model \"#{device1['model']}\" and uri \"#{device1['uri']}\""

puts "\nAdding second device ..."
device2 = OneviewSDK::API300::C7000::UnmanagedDevice.new(@client, name: 'Unmanaged Device 2', model: 'Unknown')
device2.add
puts 'Device added:'
puts "- \"#{device2['name']}\" with model \"#{device2['model']}\" and uri \"#{device2['uri']}\""

puts "\nListing all devices:"
unmanaged_devices = OneviewSDK::API300::C7000::UnmanagedDevice.get_devices(@client)
unmanaged_devices.each do |device|
puts "- \"#{device['name']}\" with model \"#{device['model']}\" and uri \"#{device['uri']}\""
end

[device1, device2].each do |device|
puts "\nUpdating device '#{device['name']}' ..."
device.update(name: device['name'] + ' (Updated)', model: device['model'] + ' (Updated)')
device.refresh
puts 'Device updated:'
puts "- \"#{device['name']}\" with model \"#{device['model']}\" and uri \"#{device['uri']}\""
end

[device1, device2].each do |device|
puts "\nRemoving device '#{device['name']}' ..."
puts 'Device removed with success!' if device.remove
end

0 comments on commit b4897c2

Please sign in to comment.