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
|
# File 'lib/vagrant-openstack-provider/action/create_server.rb', line 19
def call(env)
@logger.info 'Start create server action'
nova = env[:openstack_client].nova
options = {
flavor: resolve_flavor(env),
image: resolve_image(env),
networks: resolve_networks(env),
keypair_name: resolve_keypair(env),
availability_zone: env[:machine].provider_config.availability_zone
}
server_id = create_server(env, options)
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
unless env[:interrupted]
env[:ui].clear_line
ssh_timeout = env[:machine].provider_config.ssh_timeout
unless port_open?(env, floating_ip, 22, 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
|