Skip to content

Commit

Permalink
Removing example folder for build_plan
Browse files Browse the repository at this point in the history
  • Loading branch information
soodpr committed Apr 5, 2018
1 parent dccf93a commit 683f04a
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 33 deletions.
Expand Up @@ -10,6 +10,13 @@
# specific language governing permissions and limitations under the License.

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

# 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

# Example: Create a build plan for an API300 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 @@ -21,12 +28,13 @@
name: 'Build_Plan_1',
oeBuildPlanType: 'Deploy'
}

plan_script = OneviewSDK::ImageStreamer::API300::PlanScript.find_by(@client, name: @plan_script1_name).first
plan_script2 = OneviewSDK::ImageStreamer::API300::PlanScript.find_by(@client, name: @plan_script2_name).first
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_script2 = plan_script_class.find_by(@client, name: @plan_script2_name).first
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)
build_step = [
{
serialNumber: '1',
Expand Down Expand Up @@ -59,41 +67,41 @@
}

# Creating a build plan
item = OneviewSDK::ImageStreamer::API300::BuildPlan.new(@client, options)
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."

# Creating a build plan with build steps
item2 = OneviewSDK::ImageStreamer::API300::BuildPlan.new(@client, options2)
item2 = build_plan_class.new(@client, options2)

puts "\n#Creating a build plan with name #{options2[:name]}."
item2.create!
item2.retrieve!
puts "\n#Build plan with name #{item2['name']} and uri #{item2['uri']} created successfully."

# Creating a build plan with custom attributes
item3 = OneviewSDK::ImageStreamer::API300::BuildPlan.new(@client, options3)
item3 = build_plan_class.new(@client, options3)

puts "\n#Creating a build plan with name #{options3[:name]}."
item3.create!
item3.retrieve!
puts "\n#Build plan with name #{item3['name']} and uri #{item3['uri']} created successfully."

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

id = list.first['uri']
# Gets a build plan by id
puts "\n#Gets a build plan by id #{id}:"
item4 = OneviewSDK::ImageStreamer::API300::BuildPlan.find_by(@client, uri: id).first
item4 = build_plan_class.find_by(@client, uri: id).first
puts "\n#Build Plan with id #{item4['uri']} was found."

# Updates a build plan
item5 = OneviewSDK::ImageStreamer::API300::BuildPlan.find_by(@client, name: 'Build_Plan_1').first
item5 = build_plan_class.find_by(@client, name: 'Build_Plan_1').first
puts "\n#Updating a build plan with id #{item5['uri']} and name #{item5['name']}:"
item5['name'] = 'Build_Plan_Updated'
item5.update
Expand Down
@@ -1,4 +1,4 @@
# (C) Copyright 2017 Hewlett Packard Enterprise Development LP
# (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.
Expand All @@ -10,15 +10,25 @@
# specific language governing permissions and limitations under the License.

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

# Example: Create a deployment plan for an API300 Image Streamer
# 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

# Example: Create a deployment plan for an Image Streamer
# NOTE: This will create a deployment plan named 'Deployment_Plan_1', then delete it.
# NOTE: You'll need to add the following instance variables to the _client_i3s.rb file with valid URIs for your environment:
# @build_plan_name
# @golden_image_name
build_plan_class = OneviewSDK::ImageStreamer.resource_named('BuildPlan', @client.api_version)
build_plan = build_plan_class.find_by(@client, name: @build_plan_name).first
golden_image_class = OneviewSDK::ImageStreamer.resource_named('GoldenImage', @client.api_version)
golden_image = golden_image_class.find_by(@client, name: @golden_image_name).first

build_plan = OneviewSDK::ImageStreamer::API300::BuildPlan.find_by(@client, name: @build_plan_name).first
golden_image = OneviewSDK::ImageStreamer::API300::GoldenImage.find_by(@client, name: @golden_image_name).first

deployment_plan_class = OneviewSDK::ImageStreamer.resource_named('DeploymentPlan', @client.api_version)
options = {
name: 'Deployment_Plan_1',
description: 'AnyDescription',
Expand All @@ -35,33 +45,33 @@
}

# Creating a deployment plan
item = OneviewSDK::ImageStreamer::API300::DeploymentPlan.new(@client, options)
item = deployment_plan_class.new(@client, options)
puts "\n#Creating a deployment plan with name #{options[:name]}."
item.create!
item.retrieve!
puts "\n#Deployment plan with name #{item['name']} and uri #{item['uri']} created successfully."

# Creating a deployment plan with a golden image
item2 = OneviewSDK::ImageStreamer::API300::DeploymentPlan.new(@client, options2)
item2 = deployment_plan_class.new(@client, options2)
puts "\n#Creating a deployment plan with a golden image and name #{options2[:name]}."
item2.create!
item2.retrieve!
puts "\n#Deployment plan with name #{item2['name']} and golden image with uri #{item2['goldenImageURI']} created successfully."

# List all deployments
list = OneviewSDK::ImageStreamer::API300::DeploymentPlan.get_all(@client)
list = deployment_plan_class.get_all(@client)
puts "\n#Listing all:"
list.each { |p| puts " #{p['name']}" }

id = list.first['uri']
# Gets a deployment plan by id
puts "\n#Gets a deployment plan by id #{id}:"
item3 = OneviewSDK::ImageStreamer::API300::DeploymentPlan.find_by(@client, uri: id).first
item3 = deployment_plan_class.find_by(@client, uri: id).first
puts "\n#Deployment Plan with uri #{item3['uri']} was found."

# Gets a deployment plan by name
puts "\n#Gets a deployment plan by name #{options[:name]}:"
item4 = OneviewSDK::ImageStreamer::API300::DeploymentPlan.find_by(@client, name: options[:name]).first
item4 = deployment_plan_class.find_by(@client, name: options[:name]).first
puts "\n#Deployment Plan with name #{item4['uri']} was found."

# Updates a deployment plan
Expand Down
Expand Up @@ -10,16 +10,27 @@
# specific language governing permissions and limitations under the License.

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

# Example: Create a golden image for an API300 Image Streamer
# 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

# 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.
# NOTE: You'll need to add the following instance variables to the _client_i3s.rb file with valid URIs for your environment:
# @golden_image_download_path
# @golden_image_upload_path
# @golden_image_log_path
os_volume_class = OneviewSDK::ImageStreamer.resource_named('OSVolume', @client.api_version)
os_volume = os_volume_class.find_by(@client, {}).first

build_plan_class = OneviewSDK::ImageStreamer.resource_named('BuildPlan', @client.api_version)
build_plan = build_plan_class.find_by(@client, oeBuildPlanType: 'capture').first

os_volume = OneviewSDK::ImageStreamer::API300::OSVolume.find_by(@client, {}).first
build_plan = OneviewSDK::ImageStreamer::API300::BuildPlan.find_by(@client, oeBuildPlanType: 'capture').first
golden_image_class = OneviewSDK::ImageStreamer.resource_named('GoldenImage', @client.api_version)

options = {
type: 'GoldenImage',
Expand All @@ -29,7 +40,7 @@
}

# Creating a golden image
item = OneviewSDK::ImageStreamer::API300::GoldenImage.new(@client, options)
item = golden_image_class.new(@client, options)
item.set_os_volume(os_volume)
item.set_build_plan(build_plan)
puts "\n#Creating a golden image with name #{options[:name]}."
Expand All @@ -38,19 +49,19 @@
puts "\n#Golden Image with name #{item['name']} and uri #{item['uri']} created successfully."

# List all golden images
list = OneviewSDK::ImageStreamer::API300::GoldenImage.get_all(@client)
list = golden_image_class.get_all(@client)
puts "\n#Listing all:"
list.each { |p| puts " #{p['name']}" }

id = list.first['uri']
# Gets a golden image by id
puts "\n#Gets a golden image by id #{id}:"
item2 = OneviewSDK::ImageStreamer::API300::GoldenImage.find_by(@client, uri: id).first
item2 = golden_image_class.find_by(@client, uri: id).first
puts "\n#Golden Image with id #{item2['uri']} was found."

# Gets a golden image by name
puts "\n#Gets a golden image by name #{options[:name]}:"
item3 = OneviewSDK::ImageStreamer::API300::GoldenImage.find_by(@client, name: options[:name]).first
item3 = golden_image_class.find_by(@client, name: options[:name]).first
puts "\n#Golden Image with name #{item2['name']} was found."

# Updates a golden image
Expand All @@ -69,7 +80,7 @@
puts "\nAdds a golden image resource from the file that is uploaded from a local drive"
options2 = { name: 'Golden_Image_2', description: 'Any_Description' }
puts "\nAdding a golden image with name #{options2[:name]}."
item4 = OneviewSDK::ImageStreamer::API300::GoldenImage.add(@client, @golden_image_upload_path, options2)
item4 = golden_image_class.add(@client, @golden_image_upload_path, options2)
puts "\nGolden Image with uri #{item4['uri']} and name #{item4['name']} added successfully."

# Downloads the content of the selected golden image
Expand Down
Expand Up @@ -10,19 +10,26 @@
# specific language governing permissions and limitations under the License.

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

# Example: Os Volume for an API300 Image Streamer
# NOTE: You must have one os volume.
# 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

# Example: Os Volume for an Image Streamer
# NOTE: You must have one os volume.
os_volume_class = OneviewSDK::ImageStreamer.resource_named('OSVolume', @client.api_version)
# List all os volume
list = OneviewSDK::ImageStreamer::API300::OSVolume.get_all(@client)
list = os_volume_class.get_all(@client)
puts "\n#Listing all:"
list.each { |p| puts " #{p['name']}" }

id = list.first['uri']
# Gets an os volume by id
puts "\n#Gets an os volume by id #{id}:"
item2 = OneviewSDK::ImageStreamer::API300::OSVolume.find_by(@client, uri: id).first
item2 = os_volume_class.find_by(@client, uri: id).first
puts "\n#Os Volume with id #{item2['uri']} was found."


Expand Down
4 changes: 2 additions & 2 deletions examples/image-streamer/plan_script.rb
Expand Up @@ -16,8 +16,8 @@

# 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::API300::PlanScript
# api_version = 600 & 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

# 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
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api500/build_plan.rb
@@ -0,0 +1,22 @@
# (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 'resource'

module OneviewSDK
module ImageStreamer
module API500
# Build Plan resource implementation for Image Streamer
class BuildPlan < OneviewSDK::ImageStreamer::API300::BuildPlan
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/image-streamer/resource/api600/build_plan.rb
@@ -0,0 +1,22 @@
# (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 'resource'

module OneviewSDK
module ImageStreamer
module API600
# Build Plan resource implementation for Image Streamer
class BuildPlan < OneviewSDK::ImageStreamer::API500::BuildPlan
end
end
end
end

0 comments on commit 683f04a

Please sign in to comment.