Skip to content

Commit

Permalink
Merge pull request #480 from HewlettPackard/I3schanges
Browse files Browse the repository at this point in the history
Config changes for I3S resources
  • Loading branch information
chebroluharika authored Nov 6, 2020
2 parents 47f50d8 + 4668a2e commit 7054042
Show file tree
Hide file tree
Showing 27 changed files with 311 additions and 61 deletions.
7 changes: 2 additions & 5 deletions examples/image-streamer/artifact_bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
require_relative '../_client_i3s' # Gives access to @client

# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020, 1600
# - 1000, 1020, 1600, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::ArtifactBundle
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::ArtifactBundle
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::ArtifactBundle
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::ArtifactBundle
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::ArtifactBundle
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::ArtifactBundle
# api_version = 1600 & variant = Synergy to OneviewSDK::ImageStreamer::API1600::ArtifactBundle
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::ArtifactBundle

# Example:
# - Create, update, download, upload, extract and delete an artifact bundle for an Image Streamer
Expand Down
24 changes: 14 additions & 10 deletions examples/image-streamer/build_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

require_relative '../_client_i3s' # Gives access to @client
# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020
# - 1000, 1020, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::BuildPlan
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::BuildPlan
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::BuildPlan
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::BuildPlan
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::BuildPlan
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::BuildPlan
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::BuildPlan

# Example: Create a build plan for an Image Streamer
# NOTE: This will create three build plans with the following names 'Build_Plan_1', 'Build_Plan_2' and 'Build_Plan_3', then delete them.
Expand All @@ -39,15 +36,15 @@
content: 'esxcli system hostname set --domain "@DomainName@"'
}
plan_script_class = OneviewSDK::ImageStreamer.resource_named('PlanScript', @client.api_version)
plan_script = plan_script_class.find_by(@client, name: @plan_script1_name).first
plan_script1 = plan_script_class.find_by(@client, name: @plan_script1_name).first
puts "\n#Found a plan script with name #{plan_script1[:name]} and uri #{plan_script1[:uri]}."
puts "\n#Creating a plan script with name #{options_plan_script[:name]}."
plan_script2 = plan_script_class.new(@client, options_plan_script)
plan_script2.create!
plan_script2.retrieve!
puts "\n#Plan script with name #{plan_script2['name']} and uri #{plan_script2['uri']} created successfully."

custom_attributes = JSON.parse(plan_script2['customAttributes'])

custom_attributes.replace([custom_attributes[0].merge('type' => 'String')])

build_plan_class = OneviewSDK::ImageStreamer.resource_named('BuildPlan', @client.api_version)
Expand All @@ -56,7 +53,7 @@
serialNumber: '1',
parameters: 'anystring',
planScriptName: @plan_script1_name,
planScriptUri: plan_script['uri']
planScriptUri: plan_script1['uri']
}
]

Expand Down Expand Up @@ -105,9 +102,9 @@
item3.retrieve!
puts "\n#Build plan with name #{item3['name']} and uri #{item3['uri']} created successfully."

# List all builds
# List all build plans
list = build_plan_class.get_all(@client)
puts "\n#Listing all:"
puts "\n#Listing all build plans:"
list.each { |p| puts " #{p['name']}" }

id = list.first['uri']
Expand Down Expand Up @@ -137,3 +134,10 @@
puts "\n#Removing a build plan with id #{item5['uri']} and name #{item5['name']}:"
item5.delete
puts "\n#Build plan with id #{item5['uri']} and name #{item5['name']} removed successfully."

# Creating a build plan to support automation
item = build_plan_class.new(@client, options)
puts "\n#Creating a build plan with name #{options[:name]}."
item.create!
item.retrieve!
puts "\n#Build plan with name #{item['name']} and uri #{item['uri']} created successfully."
7 changes: 2 additions & 5 deletions examples/image-streamer/deployment_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
require_relative '../_client_i3s' # Gives access to @client

# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020, 1600
# - 1000, 1020, 1600, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::DeploymentGroup
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::DeploymentGroup
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::DeploymentGroup
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::DeploymentGroup
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::DeploymentGroup
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::DeploymentGroup
# api_version = 1600 & variant = Synergy to OneviewSDK::ImageStreamer::API1600::DeploymentGroup
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::DeploymentGroup

# Example:
# - Gets the Deployment Groups
Expand Down
13 changes: 5 additions & 8 deletions examples/image-streamer/deployment_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@

require_relative '../_client_i3s' # Gives access to @client
# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020, 1600
# - 1000, 1020, 1600, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::DeploymentPlan
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::DeploymentPlan
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::DeploymentPlan
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::DeploymentPlan
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::DeploymentPlan
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::DeploymentPlan
# api_version = 1600 & variant = Synergy to OneviewSDK::ImageStreamer::API1600::DeploymentPlan
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::DeploymentPlan

# Example: Create a deployment plan for an Image Streamer
# NOTE: This will create a deployment plan named 'Deployment_Plan_1', then delete it.
Expand All @@ -36,15 +33,15 @@
name: 'Deployment_Plan_1',
description: 'AnyDescription',
hpProvided: false,
oeBuildPlanURI: build_plan.data['uri']
oeBuildPlanURI: build_plan['uri']
}

options2 = {
name: 'Deployment_Plan_2',
description: 'AnyDescription',
hpProvided: false,
oeBuildPlanURI: build_plan.data['uri'],
goldenImageURI: golden_image.data['uri']
oeBuildPlanURI: build_plan['uri'],
goldenImageURI: golden_image['uri']
}

# Creating a deployment plan
Expand Down
7 changes: 2 additions & 5 deletions examples/image-streamer/golden_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

require_relative '../_client_i3s' # Gives access to @client
# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020
# - 1000, 1020, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::GoldenImage
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::GoldenImage
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::GoldenImage
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::GoldenImage
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::GoldenImage
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::GoldenImage
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::GoldenImage

# Example: Create a golden image for an Image Streamer
# NOTE: This will create a golden images named 'Golden_Image_1' and 'Golden_Image_2', and then, it will delete them.
Expand Down
7 changes: 2 additions & 5 deletions examples/image-streamer/os_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@

require_relative '../_client_i3s' # Gives access to @client
# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020
# - 1000, 1020, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::OSVolume
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::OSVolume
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::OSVolume
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::OSVolume
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::OSVolume
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::OSVolume
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::OSVolume

# Example: Os Volume for an Image Streamer
# NOTE: You must have one os volume.
Expand Down
21 changes: 9 additions & 12 deletions examples/image-streamer/plan_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
require_relative '../_client_i3s' # Gives access to @client

# Supported APIs:
# - 300, 500, 600, 800, 1000, 1020
# - 1000, 1020, 2000

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::ImageStreamer::API300::PlanScript
# api_version = 500 & variant = Synergy to OneviewSDK::ImageStreamer::API500::PlanScript
# api_version = 600 & variant = Synergy to OneviewSDK::ImageStreamer::API600::PlanScript
# api_version = 800 & variant = Synergy to OneviewSDK::ImageStreamer::API800::PlanScript
# api_version = 1000 & variant = Synergy to OneviewSDK::ImageStreamer::API1000::PlanScript
# api_version = 1020 & variant = Synergy to OneviewSDK::ImageStreamer::API1020::PlanScript
# api_version = 2000 & variant = Synergy to OneviewSDK::ImageStreamer::API2000::PlanScript

# Example: Create a plan script for an Image Streamer
# NOTE: This will create a plan script named 'Plan_Script_1', then delete it.
Expand Down Expand Up @@ -66,14 +63,14 @@
item2.retrieve!
puts "\n#Plan script updated successfully with id #{item2['uri']} and new name #{item2['name']}."

# Updates a plan script
puts "\n#Retrieves the modified contents of the selected Plan Script with id #{item2['uri']} and name #{item2['name']}:"
differences = item2.retrieve_differences
puts "\n#Differences retrieved:"
differences.each { |d| puts " #{d}" }
puts "\n#Plan script updated successfully with id #{item2['uri']} and new name #{item2['name']}."

# Removes a plan script
puts "\n#Removing a plan script with id #{item2['uri']} and name #{item2['name']}:"
item2.delete
puts "\n#Plan script with id #{item2['uri']} and name #{item2['name']} removed successfully."

# Creating a plan script to support automation
puts "\n#Creating a plan script with name #{options[:name]}."
plan_script = plan_script_class.new(@client, options)
plan_script.create!
plan_script.retrieve!
puts "\n#Plan script with name #{plan_script['name']} and uri #{plan_script['uri']} created successfully."
7 changes: 0 additions & 7 deletions examples/shared_samples/volume_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@

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

# All supported APIs for Volume Attachment:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000

# Supported Variants:
# C7000 and Synergy for all API versions

volume_attachment_class = OneviewSDK.resource_named('VolumeAttachment', @client.api_version)

# List volume attachments
Expand All @@ -43,4 +37,3 @@
puts "- #{path['initiatorName']}"
end
end
puts
39 changes: 39 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api2000.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# (c) Copyright 2020 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 Image Streamer
module ImageStreamer
# Module API 2000
module API2000
# Get resource class that matches the type given
# @param [String] type Name of the desired class type
# @param [String] variant There is only 1 variant for this module, so this is not used.
# It exists only so that the parameters match API modules that do have multiple variants.
# @return [Class] Resource class or nil if not found
def self.resource_named(type, _variant = nil)
new_type = type.to_s.downcase.gsub(/[ -_]/, '')
constants.each do |c|
klass = const_get(c)
next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
name = klass.name.split('::').last.downcase.delete('_').delete('-')
return klass if new_type =~ /^#{name}[s]?$/
end
nil
end
end
end
end

# Load all API-specific resources:
Dir[File.dirname(__FILE__) + '/api2000/*.rb'].each { |file| require file }
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api2000/artifact_bundle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 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 '../api1600/artifact_bundle'

module OneviewSDK
module ImageStreamer
module API2000
# Artifact Bundle resource implementation for Image Streamer
class ArtifactBundle < OneviewSDK::ImageStreamer::API1600::ArtifactBundle
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api2000/build_plan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 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 '../api1600/build_plan'

module OneviewSDK
module ImageStreamer
module API2000
# Build Plan resource implementation for Image Streamer
class BuildPlan < OneviewSDK::ImageStreamer::API1600::BuildPlan
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 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 '../api1600/deployment_group'

module OneviewSDK
module ImageStreamer
module API2000
# Deployment Group resource implementation for Image Streamer
class DeploymentGroup < OneviewSDK::ImageStreamer::API1600::DeploymentGroup
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api2000/deployment_plan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 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 '../api1600/deployment_plan'

module OneviewSDK
module ImageStreamer
module API2000
# Deployment Plan resource implementation for Image Streamer
class DeploymentPlan < OneviewSDK::ImageStreamer::API1600::DeploymentPlan
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api2000/golden_image.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 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 '../api1600/golden_image'

module OneviewSDK
module ImageStreamer
module API2000
# Golden Image resource implementation for Image Streamer
class GoldenImage < OneviewSDK::ImageStreamer::API1600::GoldenImage
end
end
end
end
Loading

0 comments on commit 7054042

Please sign in to comment.