Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feature/i3s_structure
- Loading branch information
Showing
47 changed files
with
1,962 additions
and
138 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
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
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,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']}" |
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,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 |
Oops, something went wrong.