lib/bosh-bootstrap/cli.rb in bosh-bootstrap-0.9.0 vs lib/bosh-bootstrap/cli.rb in bosh-bootstrap-0.10.0

- old
+ new

@@ -26,10 +26,11 @@ desc "deploy", "Bootstrap Micro BOSH, and optionally an Inception VM" method_option :"edge-prebuilt", :type => :boolean, :desc => "Use AWS us-east-1 gems & prebuilt AMIs" method_option :"edge", :type => :boolean, :desc => "Use pre-built gems; create microbosh from source [temporary default]" method_option :fog, :type => :string, :desc => "fog config file (default: ~/.fog)" method_option :"upgrade-deps", :type => :boolean, :desc => "Force upgrade dependencies, packages & gems" + method_option :"create-inception", :type => :boolean, :desc => "Choose to create an inception VM" def deploy migrate_old_settings load_deploy_options # from method_options above deploy_stage_1_choose_infrastructure_provider @@ -37,12 +38,13 @@ deploy_stage_2_bosh_configuration deploy_stage_3_create_allocate_inception_vm deploy_stage_4_prepare_inception_vm deploy_stage_5_salted_password - deploy_stage_6_deploy_micro_bosh - deploy_stage_7_setup_new_bosh + deploy_stage_6_download_micro_bosh + deploy_stage_7_deploy_micro_bosh + deploy_stage_8_setup_new_bosh end desc "upgrade-inception", "Upgrade inception VM with latest packages, gems, security group ports" method_option :"edge-deployer", :type => :boolean, :desc => "Install bosh deployer from git instead of rubygems" def upgrade_inception @@ -100,10 +102,17 @@ no_tasks do DEFAULT_INCEPTION_VOLUME_SIZE = 32 # Gb DEFAULT_MICROBOSH_VOLUME_SIZE = 16 # Gb def deploy_stage_1_choose_infrastructure_provider + settings["git"] ||= {} + settings["git"]["name"] ||= `git config user.name`.strip + settings["git"]["email"] ||= `git config user.email`.strip + if settings["git"]["name"].empty? || settings["git"]["email"].empty? + error "Checking for git identity....Cannot find your git identity. Please set git user.name and user.email before deploying" + end + header "Stage 1: Choose infrastructure" unless settings[:fog_credentials] choose_fog_provider end @@ -296,34 +305,44 @@ else header "Stage 5: Generate salted password", skipping: "Already generated salted password" end end - def deploy_stage_6_deploy_micro_bosh - header "Stage 6: Deploying micro BOSH" + def deploy_stage_6_download_micro_bosh + header "Stage 6: Download micro BOSH" recreate_local_ssh_keys_for_inception_vm switch_to_prebuilt_microbosh_ami_if_available - unless run_server(Bosh::Bootstrap::Stages::MicroBoshDeploy.new(settings).commands) - error "Failed to complete Stage 6: Deploying micro BOSH" + unless run_server(Bosh::Bootstrap::Stages::MicroBoshDownload.new(settings).commands) + error "Failed to complete Stage 6: Downloading micro BOSH" end # Settings are updated by this stage - # it generates a salted password from settings.bosh.password - # and stores it in settings.bosh.salted_password + # It may update the micro_bosh_stemcell_name save_settings! confirm "Successfully built micro BOSH" end - def deploy_stage_7_setup_new_bosh + def deploy_stage_7_deploy_micro_bosh + header "Stage 7: Deploying micro BOSH" + recreate_local_ssh_keys_for_inception_vm + + unless run_server(Bosh::Bootstrap::Stages::MicroBoshDeploy.new(settings).commands) + error "Failed to complete Stage 7: Deploying micro BOSH" + end + + confirm "Successfully built micro BOSH" + end + + def deploy_stage_8_setup_new_bosh # TODO change to a polling test of director being available say "Pausing to wait for BOSH Director..." sleep 5 - header "Stage 7: Setup bosh" + header "Stage 8: Setup bosh" unless run_server(Bosh::Bootstrap::Stages::SetupNewBosh.new(settings).commands) - error "Failed to complete Stage 6: Setup bosh" + error "Failed to complete Stage 7: Setup bosh" end say "Locally targeting and login to new BOSH..." sh "bosh -u #{settings.bosh_username} -p #{settings.bosh_password} target #{settings.bosh.ip_address}" sh "bosh login #{settings.bosh_username} #{settings.bosh_password}" @@ -493,34 +512,29 @@ if options["upgrade-deps"] settings["upgrade_deps"] = options["upgrade-deps"] else settings.delete("upgrade_deps") end + + if options["create-inception"] + settings["inception"] = {"create_new" => true} + end save_settings! end def load_provider_specific_options # before deploy stage - need to change type => ami if AWS us-east-1? if options[:"edge-prebuilt"] || settings.delete("edge-prebuilt") - if aws? - settings["micro_bosh_stemcell_type"] = "edge-prebuilt" - settings["micro_bosh_stemcell_name"] = "edge-prebuilt" - else - error "Currently --edge-prebuilt is not available for #{bosh_provider} :(" - end + settings["micro_bosh_stemcell_type"] = "edge-prebuilt" + settings["micro_bosh_stemcell_name"] = "edge-prebuilt" elsif options[:"edge"] || settings.delete("edge") settings["micro_bosh_stemcell_type"] = "custom" settings["micro_bosh_stemcell_name"] = "custom" else - if settings["fog_credentials"] && aws? - # currently defaulting to latest prebuilt stemcells/amis until 1.5.0 is released - settings["micro_bosh_stemcell_type"] = "edge-prebuilt" - settings["micro_bosh_stemcell_name"] = "edge-prebuilt" - else - settings["micro_bosh_stemcell_type"] = "custom" - settings["micro_bosh_stemcell_name"] = "custom" - end + # currently defaulting to latest prebuilt stemcells/amis until 1.5.0 is released + settings["micro_bosh_stemcell_type"] = "edge-prebuilt" + settings["micro_bosh_stemcell_name"] = "edge-prebuilt" end end def prompt_git_user_information settings["git"] ||= {} @@ -655,12 +669,12 @@ creds[:aws_secret_access_key] = hl.ask("Secret key: ") end menu.choice("OpenStack") do creds[:provider] = "OpenStack" creds[:openstack_username] = hl.ask("Username: ") - creds[:openstack_api_key] = hl.ask("API key: ") + creds[:openstack_api_key] = hl.ask("Password: ") creds[:openstack_tenant] = hl.ask("Tenant: ") - creds[:openstack_auth_url] = hl.ask("Authorization URL: ") + creds[:openstack_auth_url] = hl.ask("Authorization Token URL: ") end end @fog_credentials = creds end