providers/docker: optimizing the action stacks...
This commit is contained in:
parent
c0f5095783
commit
4a59c5c522
|
@ -11,40 +11,7 @@ module VagrantPlugins
|
||||||
b.use ConfigValidate
|
b.use ConfigValidate
|
||||||
b.use HandleBox
|
b.use HandleBox
|
||||||
b.use HostMachine
|
b.use HostMachine
|
||||||
b.use HostMachineSyncFolders
|
b.use action_start
|
||||||
b.use Call, IsState, :not_created do |env, b2|
|
|
||||||
# If the VM is NOT created yet, then do the setup steps
|
|
||||||
if env[:result]
|
|
||||||
b2.use EnvSet, port_collision_repair: true
|
|
||||||
|
|
||||||
b2.use Call, HasSSH do |env2, b3|
|
|
||||||
if env2[:result]
|
|
||||||
b3.use Provision
|
|
||||||
else
|
|
||||||
b3.use Message,
|
|
||||||
I18n.t("docker_provider.messages.provision_no_ssh"),
|
|
||||||
post: true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
b2.use HostMachinePortWarning
|
|
||||||
b2.use HostMachinePortChecker
|
|
||||||
b2.use HandleForwardedPortCollisions
|
|
||||||
b2.use PrepareNFSValidIds
|
|
||||||
b2.use SyncedFolderCleanup
|
|
||||||
b2.use SyncedFolders
|
|
||||||
b2.use PrepareNFSSettings
|
|
||||||
b2.use Create
|
|
||||||
b2.use WaitForRunning
|
|
||||||
b2.use action_boot
|
|
||||||
else
|
|
||||||
b2.use PrepareNFSValidIds
|
|
||||||
b2.use SyncedFolderCleanup
|
|
||||||
b2.use SyncedFolders
|
|
||||||
b2.use PrepareNFSSettings
|
|
||||||
b2.use action_start
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,27 +156,55 @@ module VagrantPlugins
|
||||||
|
|
||||||
def self.action_start
|
def self.action_start
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Vagrant::Action::Builder.new.tap do |b|
|
||||||
b.use ConfigValidate
|
|
||||||
b.use Call, IsState, :running do |env, b2|
|
b.use Call, IsState, :running do |env, b2|
|
||||||
# If the container is running, then our work here is done, exit
|
# If the container is running, then our work here is done, exit
|
||||||
next if env[:result]
|
next if env[:result]
|
||||||
|
|
||||||
b2.use Provision
|
b2.use Call, HasSSH do |env2, b3|
|
||||||
b2.use Message, I18n.t("docker_provider.messages.starting")
|
if env2[:result]
|
||||||
b2.use action_boot
|
b3.use Provision
|
||||||
end
|
else
|
||||||
end
|
b3.use Message,
|
||||||
end
|
I18n.t("docker_provider.messages.provision_no_ssh"),
|
||||||
|
post: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.action_boot
|
# We only want to actually sync folder differences if
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
# we're not created.
|
||||||
# TODO: b.use SetHostname
|
b2.use Call, IsState, :not_created do |env2, b3|
|
||||||
b.use Start
|
if !env2[:result]
|
||||||
b.use WaitForRunning
|
b3.use EnvSet, host_machine_sync_folders: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
b.use Call, HasSSH do |env, b2|
|
b2.use HostMachineSyncFolders
|
||||||
if env[:result]
|
b2.use PrepareNFSValidIds
|
||||||
b2.use WaitForCommunicator
|
b2.use SyncedFolderCleanup
|
||||||
|
b2.use SyncedFolders
|
||||||
|
b2.use PrepareNFSSettings
|
||||||
|
|
||||||
|
# If the VM is NOT created yet, then do some setup steps
|
||||||
|
# necessary for creating it.
|
||||||
|
b2.use Call, IsState, :not_created do |env2, b3|
|
||||||
|
if env2[:result]
|
||||||
|
b3.use EnvSet, port_collision_repair: true
|
||||||
|
b3.use HostMachineSyncFolders
|
||||||
|
b3.use HostMachinePortWarning
|
||||||
|
b3.use HostMachinePortChecker
|
||||||
|
b3.use HandleForwardedPortCollisions
|
||||||
|
b3.use Create
|
||||||
|
b3.use WaitForRunning
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
b2.use Start
|
||||||
|
b2.use WaitForRunning
|
||||||
|
|
||||||
|
b2.use Call, HasSSH do |env2, b3|
|
||||||
|
if env2[:result]
|
||||||
|
b3.use WaitForCommunicator
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,10 @@ module VagrantPlugins
|
||||||
def call(env)
|
def call(env)
|
||||||
return @app.call(env) if !env[:machine].provider.host_vm?
|
return @app.call(env) if !env[:machine].provider.host_vm?
|
||||||
|
|
||||||
|
if !env.has_key?(:host_machine_sync_folders)
|
||||||
|
env[:host_machine_sync_folders] = true
|
||||||
|
end
|
||||||
|
|
||||||
host_machine = env[:machine].provider.host_vm
|
host_machine = env[:machine].provider.host_vm
|
||||||
|
|
||||||
# Lock while we make changes
|
# Lock while we make changes
|
||||||
|
@ -123,6 +127,11 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !env[:host_machine_sync_folders]
|
||||||
|
@logger.info("Not syncing folders because container created.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if !new_config.synced_folders.empty?
|
if !new_config.synced_folders.empty?
|
||||||
# Sync the folders!
|
# Sync the folders!
|
||||||
env[:machine].ui.output(I18n.t(
|
env[:machine].ui.output(I18n.t(
|
||||||
|
|
|
@ -9,9 +9,9 @@ module VagrantPlugins
|
||||||
def call(env)
|
def call(env)
|
||||||
machine = env[:machine]
|
machine = env[:machine]
|
||||||
driver = machine.provider.driver
|
driver = machine.provider.driver
|
||||||
driver.start(machine.id)
|
|
||||||
|
|
||||||
# TODO(mitchellh): Wait for container to go to "running" state.
|
machine.ui.output(I18n.t("docker_provider.messages.starting"))
|
||||||
|
driver.start(machine.id)
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue