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
require 'rest-client' | |
require 'json' | |
def provisioning_parameters | |
{"version"=>"1.1", | |
"template_fields"=> | |
{"guid"=>"b420edc4-e6cd-11e5-b810-000a27020066", | |
"name"=>"gm-empty-template"}, | |
"vm_fields"=> | |
{"sysprep_server_license_mode"=>"perServer", |
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
# active_record model descendant walker | |
def model | |
(ARGV.first || 'ApplicationRecord').classify.safe_constantize.tap do |model| | |
raise "Provide valid model name. Argv: #{ARGV.first}" unless model | |
raise "Model must be a sub-class of ActiveRecord::Base Argv: #{ARGV.first}" unless model < ActiveRecord::Base || model == ActiveRecord::Base | |
end | |
end | |
def base_model(model) |
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
$dry_run = true | |
def clean_automation(klass) | |
puts "#{$dry_run ? 'DRY RUN' : 'Processing'} #{klass.name}" | |
klass.where(:state => %w[pending queued]).in_batches.each_with_index do |relation, batch_index| | |
ids = relation.pluck(:id) | |
queue_relation = MiqQueue.where(:class_name => klass.name, :instance_id => ids) | |
puts " Batch #{batch_index} Size #{ids.size} Queue Item Count: #{queue_relation.size}" |
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
def walk(start = ".", prefix = "") | |
Dir.foreach(start) do |x| | |
next if x[0] == "." | |
path = File.join(start, x) | |
next if File.symlink?(path) | |
print_directory(path, prefix) if File.directory?(path) | |
end | |
end |
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
def setup | |
app_name = ENV['OPENSHIFT_BUILD_NAME'].split('-')[0..-3].join('-') || ENV['APP_NAME'] | |
raise 'Missing ENV variable APP_NAME' unless app_name | |
@product_component = "#{app_name}:api" | |
# Prefix defined at https://pp.engineering.redhat.com/pp/ | |
@prefix = case app_name | |
when /catalog/, /approval/ then 'services-automation-services-catalog' | |
when /sources/ then 'services-sources' |
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
# Catalog UI manifest | |
jq --arg prefix services-automation-services-catalog/catalog:ui/ -r '[ [ .. | .resolved? | select(type == "string") ] | .[] | sub("^.*/";""+$prefix+"npmjs-") ] | unique | sort []' package-lock.json | |
| |
# Approval UI manifest | |
jq --arg prefix services-automation-services-catalog/approval:ui/ -r '[ [ .. | .resolved? | select(type == "string") ] | .[] | sub("^.*/";""+$prefix+"npmjs-") ] | unique | sort []' package-lock.json | |
| |
# Sources UI manifest | |
jq --arg prefix services-sources/sources:ui/ -r '[ [ .. | .resolved? | select(type == "string") ] | .[] | sub("^.*/";""+$prefix+"npmjs-") ] | unique | sort []' package-lock.json |