Class: Bosh::Cli::Command::AWS
- Inherits:
-
Base
- Object
- Base
- Bosh::Cli::Command::AWS
- Defined in:
- lib/bosh/cli/commands/aws.rb
Constant Summary collapse
- DEFAULT_CIDR =
KILL
'10.0.0.0/16'
Instance Attribute Summary collapse
-
#config_dir ⇒ Object
readonly
Returns the value of attribute config_dir.
-
#ec2 ⇒ Object
readonly
Returns the value of attribute ec2.
-
#output_state ⇒ Object
readonly
Returns the value of attribute output_state.
-
#vpc ⇒ Object
Returns the value of attribute vpc.
Instance Method Summary collapse
- #bootstrap_bosh(config_file = nil) ⇒ Object
- #bootstrap_micro ⇒ Object
- #create(config_file = nil) ⇒ Object
- #create_bat_manifest(vpc_receipt_file, route53_receipt_file, stemcell_version, stemcell_name) ⇒ Object
- #create_bosh_manifest(vpc_receipt_file, route53_receipt_file, bosh_rds_receipt_file) ⇒ Object
- #create_key_pairs(config_file = nil) ⇒ Object
- #create_micro_bosh_manifest(vpc_receipt_file, route53_receipt_file) ⇒ Object
- #create_route53_records(config_file = nil) ⇒ Object
- #create_s3(config_file = nil) ⇒ Object
- #create_vpc(config_file = nil) ⇒ Object
- #destroy(config_file = nil) ⇒ Object
- #help ⇒ Object
-
#initialize(runner = []) ⇒ AWS
constructor
A new instance of AWS.
Constructor Details
#initialize(runner = []) ⇒ AWS
Returns a new instance of AWS.
15 16 17 18 |
# File 'lib/bosh/cli/commands/aws.rb', line 15 def initialize(runner = []) super(runner) @output_state = {} end |
Instance Attribute Details
#config_dir ⇒ Object (readonly)
Returns the value of attribute config_dir.
12 13 14 |
# File 'lib/bosh/cli/commands/aws.rb', line 12 def config_dir @config_dir end |
#ec2 ⇒ Object (readonly)
Returns the value of attribute ec2.
12 13 14 |
# File 'lib/bosh/cli/commands/aws.rb', line 12 def ec2 @ec2 end |
#output_state ⇒ Object (readonly)
Returns the value of attribute output_state.
12 13 14 |
# File 'lib/bosh/cli/commands/aws.rb', line 12 def output_state @output_state end |
#vpc ⇒ Object
Returns the value of attribute vpc.
13 14 15 |
# File 'lib/bosh/cli/commands/aws.rb', line 13 def vpc @vpc end |
Instance Method Details
#bootstrap_bosh(config_file = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/bosh/cli/commands/aws.rb', line 55 def bootstrap_bosh(config_file = nil) target_required err "To bootstrap BOSH, first log in to `#{config.target}'" unless logged_in? [:hm_director_user] ||= 'hm' [:hm_director_password] = SecureRandom.base64 bootstrap = Bosh::Aws::BoshBootstrap.new(director, s3(config_file), self.) bootstrap.start say 'For security purposes, please provide a username and password for BOSH Director' username = ask('Enter username: ') password = ask('Enter password: ') { |q| q.echo = '*' } bootstrap.create_user(username, password) say "BOSH deployed successfully. You are logged in as #{username}." bootstrap.create_user([:hm_director_user], [:hm_director_password]) rescue Bosh::Aws::BootstrapError => e err "Unable to bootstrap bosh: #{e.}" end |
#bootstrap_micro ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bosh/cli/commands/aws.rb', line 30 def bootstrap_micro [:hm_director_password] = SecureRandom.base64 [:hm_director_user] ||= 'hm' bootstrap = Bosh::Aws::MicroBoshBootstrap.new(runner, ) bootstrap.start bootstrap.create_user([:hm_director_user], [:hm_director_password]) if interactive? username = ask('Enter username: ') password = ask('Enter password: ') { |q| q.echo = '*' } if username.blank? || password.blank? err('Please enter username and password') end bootstrap.create_user(username, password) else bootstrap.create_user('admin', SecureRandom.base64) end end |
#create(config_file = nil) ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/bosh/cli/commands/aws.rb', line 124 def create(config_file = nil) if !![:trace] require 'logger' ::AWS.config(:logger => Logger.new($stdout), :http_wire_trace => true) end Bosh::Aws::Migrator.new(load_config(config_file)).migrate end |
#create_bat_manifest(vpc_receipt_file, route53_receipt_file, stemcell_version, stemcell_name) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/bosh/cli/commands/aws.rb', line 110 def create_bat_manifest(vpc_receipt_file, route53_receipt_file, stemcell_version, stemcell_name) target_required vpc_config = load_yaml_file(vpc_receipt_file) route53_config = load_yaml_file(route53_receipt_file) manifest = Bosh::Aws::BatManifest.new( vpc_config, route53_config, stemcell_version, director.uuid, stemcell_name) write_yaml(manifest, manifest.file_name) end |
#create_bosh_manifest(vpc_receipt_file, route53_receipt_file, bosh_rds_receipt_file) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bosh/cli/commands/aws.rb', line 94 def create_bosh_manifest(vpc_receipt_file, route53_receipt_file, bosh_rds_receipt_file) target_required [:hm_director_user] ||= 'hm' [:hm_director_password] = SecureRandom.base64 vpc_config = load_yaml_file(vpc_receipt_file) route53_config = load_yaml_file(route53_receipt_file) bosh_rds_config = load_yaml_file(bosh_rds_receipt_file) bosh_manifest = Bosh::Aws::BoshManifest.new(vpc_config, route53_config, director.uuid, bosh_rds_config, ) write_yaml(bosh_manifest, bosh_manifest.file_name) end |
#create_key_pairs(config_file = nil) ⇒ Object
141 142 143 |
# File 'lib/bosh/cli/commands/aws.rb', line 141 def create_key_pairs(config_file = nil) Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412000811') end |
#create_micro_bosh_manifest(vpc_receipt_file, route53_receipt_file) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/bosh/cli/commands/aws.rb', line 80 def create_micro_bosh_manifest(vpc_receipt_file, route53_receipt_file) vpc_config = load_yaml_file(vpc_receipt_file) route53_config = load_yaml_file(route53_receipt_file) [:hm_director_user] ||= 'hm' [:hm_director_password] = SecureRandom.base64 manifest = Bosh::Aws::MicroboshManifest.new(vpc_config, route53_config, ) write_yaml(manifest, manifest.file_name) end |
#create_route53_records(config_file = nil) ⇒ Object
147 148 149 |
# File 'lib/bosh/cli/commands/aws.rb', line 147 def create_route53_records(config_file = nil) Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412181302') end |
#create_s3(config_file = nil) ⇒ Object
135 136 137 |
# File 'lib/bosh/cli/commands/aws.rb', line 135 def create_s3(config_file = nil) Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412192351') end |
#create_vpc(config_file = nil) ⇒ Object
153 154 155 |
# File 'lib/bosh/cli/commands/aws.rb', line 153 def create_vpc(config_file = nil) Bosh::Aws::Migrator.new(load_config(config_file)).migrate_version('20130412004642') end |
#destroy(config_file = nil) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/bosh/cli/commands/aws.rb', line 159 def destroy(config_file = nil) config = load_config(config_file) rds_destroyer = Bosh::Aws::RdsDestroyer.new(self, config) vpc_destroyer = Bosh::Aws::VpcDestroyer.new(self, config) destroyer = Bosh::Aws::Destroyer.new(self, config, rds_destroyer, vpc_destroyer) destroyer.ensure_not_production! destroyer.delete_all_elbs destroyer.delete_all_ec2 destroyer.delete_all_ebs destroyer.delete_all_rds destroyer.delete_all_s3 destroyer.delete_all_vpcs destroyer.delete_all_key_pairs destroyer.delete_all_elastic_ips destroyer.delete_all_security_groups destroyer.delete_all_route53_records end |