Module: Bosh::AwsCliPlugin::MigrationHelper

Defined in:
lib/bosh_cli_plugin_aws/migration_helper.rb

Defined Under Namespace

Classes: RdsDb, Template

Class Method Summary collapse

Class Method Details

.all_rds_instances_available?(rds, opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


140
141
142
143
144
145
146
147
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 140

def self.all_rds_instances_available?(rds, opts = {})
  silent = opts[:silent]
  say("checking rds status...") unless silent
  rds.databases.all? do |db_instance|
    say("  #{db_instance.db_name} #{db_instance.db_instance_status} #{db_instance.endpoint_address}") unless silent
    !db_instance.endpoint_address.nil?
  end
end

.aws_migration_directoryObject



116
117
118
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 116

def self.aws_migration_directory
  File.expand_path("../../migrations", File.dirname(__FILE__))
end

.aws_spec_migration_directoryObject



120
121
122
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 120

def self.aws_spec_migration_directory
  File.expand_path("../../spec/migrations", File.dirname(__FILE__))
end

.generate_migration_file(name) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 124

def self.generate_migration_file(name)
  template = Template.new(name)

  filename = "#{aws_migration_directory}/#{template.file_prefix}.rb"
  spec_filename = "#{aws_spec_migration_directory}/#{template.file_prefix}_spec.rb"

  puts "Creating #{filename} and #{spec_filename}"

  File.open(filename, 'w+') { |f| f.write(template.render) }
  File.open(spec_filename, 'w+') { |f| f.write(template.render("aws_migration_spec")) }
end

.to_class_name(name) ⇒ Object



136
137
138
# File 'lib/bosh_cli_plugin_aws/migration_helper.rb', line 136

def self.to_class_name(name)
  name.split('_').map(&:capitalize).join('')
end