Class: Bosh::AwsCliPlugin::BoshBootstrap

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

Constant Summary

Constants inherited from Bootstrap

Bosh::AwsCliPlugin::Bootstrap::AWS_JENKINS_BUCKET

Instance Attribute Summary collapse

Attributes inherited from Bootstrap

#options, #runner

Instance Method Summary collapse

Methods inherited from Bootstrap

#create_user, #login

Constructor Details

#initialize(director, s3, options) ⇒ BoshBootstrap

Returns a new instance of BoshBootstrap.


14
15
16
17
18
19
20
# File 'lib/bosh_cli_plugin_aws/bosh_bootstrap.rb', line 14

def initialize(director, s3, options)
  self.options = options
  self.options[:non_interactive] = true
  self.director = director
  self.s3 = s3
  @env = ENV.to_hash
end

Instance Attribute Details

#directorObject

Returns the value of attribute director.


12
13
14
# File 'lib/bosh_cli_plugin_aws/bosh_bootstrap.rb', line 12

def director
  @director
end

#s3Object

Returns the value of attribute s3.


12
13
14
# File 'lib/bosh_cli_plugin_aws/bosh_bootstrap.rb', line 12

def s3
  @s3
end

Instance Method Details

#startObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bosh_cli_plugin_aws/bosh_bootstrap.rb', line 38

def start
  release_exist, first_stemcell = validate_requirements

  fetch_and_upload_release unless release_exist
  if first_stemcell
    manifest.stemcell_name = first_stemcell['name']
  else
    manifest.stemcell_name = Bosh::Stemcell::Archive.new(fetch_and_upload_stemcell).name
  end
  generate_manifest

  deploy

  
end

#validate_requirementsObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bosh_cli_plugin_aws/bosh_bootstrap.rb', line 22

def validate_requirements
  release_exist = director.list_releases.detect { |r| r['name'] == 'bosh' }
  first_stemcell = director.list_stemcells.first

  existing_deployments = director.list_deployments.map { |deployment| deployment['name'] }

  if existing_deployments.include? manifest.bosh_deployment_name
    raise BootstrapError, <<-MSG
Deployment '#{manifest.bosh_deployment_name}' already exists.
This command should be used for bootstrapping bosh from scratch.
    MSG
  end

  return release_exist, first_stemcell
end