Class: VagrantPlugins::Openstack::Action::CreateServer
- Inherits:
-
Object
- Object
- VagrantPlugins::Openstack::Action::CreateServer
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-openstack-provider/action/create_server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ CreateServer
constructor
A new instance of CreateServer.
Constructor Details
#initialize(app, _env) ⇒ CreateServer
Returns a new instance of CreateServer.
14 15 16 17 |
# File 'lib/vagrant-openstack-provider/action/create_server.rb', line 14 def initialize(app, _env) @app = app @logger = Log4r::Logger.new('vagrant_openstack::action::create_server') end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vagrant-openstack-provider/action/create_server.rb', line 19 def call(env) @logger.info 'Start create server action' config = env[:machine].provider_config fail Errors::MissingBootOption if config.image.nil? && config.volume_boot.nil? fail Errors::ConflictBootOption unless config.image.nil? || config.volume_boot.nil? nova = env[:openstack_client].nova = { flavor: resolve_flavor(env), image: resolve_image(env), volume_boot: resolve_volume_boot(env), networks: resolve_networks(env), volumes: resolve_volumes(env), keypair_name: resolve_keypair(env), availability_zone: env[:machine].provider_config.availability_zone, scheduler_hints: env[:machine].provider_config.scheduler_hints, security_groups: env[:machine].provider_config.security_groups, user_data: env[:machine].provider_config.user_data, metadata: env[:machine].provider_config. } server_id = create_server(env, ) # Store the ID right away so we can track it env[:machine].id = server_id waiting_for_server_to_be_build(env, server_id) floating_ip = resolve_floating_ip(env) if floating_ip && !floating_ip.empty? @logger.info "Using floating IP #{floating_ip}" env[:ui].info(I18n.t('vagrant_openstack.using_floating_ip', floating_ip: floating_ip)) nova.add_floating_ip(env, server_id, floating_ip) end attach_volumes(env, server_id, [:volumes]) unless [:volumes].empty? unless env[:interrupted] # Clear the line one more time so the progress is removed env[:ui].clear_line # Wait for SSH to become available ssh_timeout = env[:machine].provider_config.ssh_timeout unless port_open?(env, floating_ip, resolve_ssh_port(env), ssh_timeout) env[:ui].error(I18n.t('vagrant_openstack.timeout')) fail Errors::SshUnavailable, host: floating_ip, timeout: ssh_timeout end @logger.info 'The server is ready' env[:ui].info(I18n.t('vagrant_openstack.ready')) end @app.call(env) end |