-
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 #369 from HewlettPackard/api800/support
Api800/support
- Loading branch information
Showing
79 changed files
with
1,449 additions
and
39 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
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,71 @@ | ||
# (C) Copyright 2018 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: Create/Update/Delete hypervisor cluster profile | ||
# NOTE: This will create a hypervisor cluster profile named 'cluster5', update it and then delete it. | ||
# | ||
# Supported APIs: | ||
# - API800 for C7000 | ||
# - API800 for Synergy | ||
|
||
# Resources that can be created according to parameters: | ||
# api_version = 800 & variant = C7000 to OneviewSDK::API800::C7000::HypervisorClusterProfile | ||
# api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::HypervisorClusterProfile | ||
|
||
# Resource Class used in this sample | ||
hypervisor_cluster_profile_class = OneviewSDK.resource_named('HypervisorClusterProfile', @client.api_version) | ||
|
||
options = { | ||
type: @hypervisor_type, | ||
name: @hypervisor_cluster_profile_name, | ||
hypervisorManagerUri: @hypervisor_manager_uri, | ||
path: @hypervisor_path, | ||
hypervisorType: @hypervisor_hypervisorType, | ||
hypervisorHostProfileTemplate: { | ||
serverProfileTemplateUri: @hypervisor_serverProfileTemplateUri, | ||
deploymentPlan: { | ||
deploymentPlanUri: @hypervisor_deploymentPlanUri, | ||
serverPassword: @hypervisor_server_password | ||
}, | ||
hostprefix: @hypervisor_host_prefix | ||
} | ||
} | ||
|
||
hcp = hypervisor_cluster_profile_class.new(@client, options) | ||
hcp.create! | ||
puts "\nCreated hypervisor-cluster_profile '#{hcp[:name]}' sucessfully.\n uri = '#{hcp[:uri]}'" | ||
|
||
# Lists all the hypervisor cluster profiles present | ||
puts "\nListing all the available cluster profiles\n" | ||
hypervisor_cluster_profile_class.find_by(@client, {}).each do |profile| | ||
puts "#{profile['name']} was found." | ||
end | ||
|
||
# Find cluster profile by name | ||
hcp_by_name = hypervisor_cluster_profile_class.find_by(@client, name: hypervisor_cluster_profile_class.find_by(@client, {}).first[:name]).first | ||
puts "\nFound hypervisor cluster profile by name: '#{hcp_by_name[:name]}'.\n uri : '#{hcp_by_name[:uri]}'" | ||
|
||
# Update a hypervisor cluster profile | ||
hcp2 = hypervisor_cluster_profile_class.find_by(@client, {}).first | ||
data = { description: 'New Description' } | ||
puts "\nCluster profile description before update : '#{hcp2[:description]}'" | ||
hcp2.update(data) | ||
puts "Cluster profile description after update : '#{hcp2[:description]}'\n" | ||
|
||
# Listing compliance details of the previously updated cluster profile | ||
cp = hcp2.compliance_preview | ||
puts "\nCompliance preview details are :\n#{cp}\n" | ||
|
||
# Deletes the created hypervisor cluster profile | ||
hcp.delete | ||
puts "\nSuccesfully deleted the cluster profile" |
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 2018 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: Create/Update/Delete hypervisor manager | ||
# NOTE: This will create a hypervisor manager named 'vcenter.corp.com', update it and then delete it. | ||
# | ||
# Supported APIs: | ||
# - API800 for C7000 | ||
# - API800 for Synergy | ||
|
||
# Resources that can be created according to parameters: | ||
# api_version = 800 & variant = C7000 to OneviewSDK::API800::C7000::HypervisorManager | ||
# api_version = 800 & variant = Synergy to OneviewSDK::API800::Synergy::HypervisorManager | ||
|
||
raise 'ERROR: Must set @hypervisor_manager_ip in _client.rb' unless @hypervisor_manager_ip | ||
raise 'ERROR: Must set @hypervisor_manager_username in _client.rb' unless @hypervisor_manager_username | ||
raise 'ERROR: Must set @hypervisor_manager_password in _client.rb' unless @hypervisor_manager_password | ||
|
||
# Resource Class used in this sample | ||
hypervisor_manager_class = OneviewSDK.resource_named('HypervisorManager', @client.api_version) | ||
|
||
options = { | ||
name: @hypervisor_manager_ip, | ||
username: @hypervisor_manager_username, | ||
password: @hypervisor_manager_password | ||
} | ||
|
||
hm = hypervisor_manager_class.new(@client, options) | ||
hm.create! | ||
puts "\nCreated hypervisor-manager '#{hm[:name]}' sucessfully.\n uri = '#{hm[:uri]}'" | ||
|
||
# Find recently created hypervisor manager by name | ||
matches = hypervisor_manager_class.find_by(@client, name: hm[:name]) | ||
hm2 = matches.first | ||
puts "\nFound hypervisor-manager by name: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" | ||
|
||
# Retrieve recently created hypervisor manager | ||
hm3 = hypervisor_manager_class.new(@client, name: hm[:name]) | ||
hm3.retrieve! | ||
puts "\nRetrieved hypervisor-manager data by name: '#{hm3[:name]}'.\n uri = '#{hm3[:uri]}'" | ||
|
||
# Update hypervisor manager registration | ||
attribute = { name: @hypervisor_manager_ip } | ||
hm2.update(attribute) | ||
puts "\nUpdated hypervisor-manager: '#{hm2[:name]}'.\n uri = '#{hm2[:uri]}'" | ||
puts "with attribute: #{attribute}" | ||
|
||
# Example: List all hypervisor managers certain attributes | ||
attributes = { name: @hypervisor_manager_ip } | ||
puts "\nHypervisor manager with #{attributes}" | ||
hypervisor_manager_class.find_by(@client, attributes).each do |hypervisor_manager| | ||
puts " #{hypervisor_manager[:name]}" | ||
end | ||
|
||
# Delete this hypervisor manager | ||
hm.delete | ||
puts "\nSucessfully deleted hypervisor-manager '#{hm[:name]}'." |
Oops, something went wrong.