Class: Bosh::AwsCliPlugin::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_cli_plugin_aws/migration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, receipt_bucket_name) ⇒ Migration

Returns a new instance of Migration.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 7

def initialize(config, receipt_bucket_name)
  @config = config
  @receipt_bucket_name = receipt_bucket_name
  aws_config = config['aws']
  @s3 = S3.new(aws_config)
  @elb = ELB.new(aws_config)
  @ec2 = EC2.new(aws_config)
  @rds = RDS.new(aws_config)
  @route53 = Route53.new(aws_config)
  @logger = Bosh::Clouds::Config.logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def config
  @config
end

#ec2Object (readonly)

Returns the value of attribute ec2.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def ec2
  @ec2
end

#elbObject (readonly)

Returns the value of attribute elb.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def elb
  @elb
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def logger
  @logger
end

#rdsObject (readonly)

Returns the value of attribute rds.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def rds
  @rds
end

#route53Object (readonly)

Returns the value of attribute route53.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def route53
  @route53
end

#s3Object (readonly)

Returns the value of attribute s3.



5
6
7
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 5

def s3
  @s3
end

Instance Method Details

#load_receipt(receipt_name) ⇒ Object



35
36
37
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 35

def load_receipt(receipt_name)
  YAML.load(s3.fetch_object_contents(@receipt_bucket_name, "receipts/#{receipt_name}.yml"))
end

#runObject



19
20
21
22
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 19

def run
  say "Executing migration #{self.class.name}"
  execute
end

#save_receipt(receipt_name, receipt) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/bosh_cli_plugin_aws/migration.rb', line 24

def save_receipt(receipt_name, receipt)
  receipt_yaml = YAML.dump(receipt)
  s3.upload_to_bucket(@receipt_bucket_name, "receipts/#{receipt_name}.yml", receipt_yaml)

  File.open("#{receipt_name}.yml", "w+") do |f|
    f.write(receipt_yaml)
  end

  say "details in S3 receipt: #{receipt_name} and file: #{receipt_name}.yml"
end