Module: Vagrant::Notify::Action

Defined in:
lib/vagrant-notify/action.rb,
lib/vagrant-notify/action/stop_server.rb,
lib/vagrant-notify/action/prepare_data.rb,
lib/vagrant-notify/action/start_server.rb,
lib/vagrant-notify/action/check_provider.rb,
lib/vagrant-notify/action/install_command.rb,
lib/vagrant-notify/action/server_is_running.rb,
lib/vagrant-notify/action/set_shared_folder.rb,
lib/vagrant-notify/action/windows/process_info.rb,
lib/vagrant-notify/action/notify_provisioning_status.rb

Defined Under Namespace

Modules: Windows Classes: CheckProvider, InstallCommand, NotifyProvisioningStatus, PrepareData, ServerIsRunning, SetSharedFolder, StartServer, StopServer

Constant Summary collapse

Call =
Vagrant::Action::Builtin::Call

Class Method Summary collapse

Class Method Details

.action_start_serverObject



16
17
18
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
# File 'lib/vagrant-notify/action.rb', line 16

def action_start_server
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, CheckProvider do |env, b2|
      next if !env[:result]

      b2.use PrepareData
      b2.use Call, ServerIsRunning do |env2, b3|
        if env2[:result]
          env[:machine].ui.success("vagrant-notify-server pid: #{env2[:notify_data][:pid]}")
        else
          # TODO: b3.use CheckServerPortCollision
          b3.use StartServer

          b3.use PrepareData
          b3.use Call, ServerIsRunning do |env3, b4|
            if env3[:result]
              env3[:machine].ui.success("vagrant-notify-server pid: #{env3[:notify_data][:pid]}")
            else
              env3[:machine].ui.error("Unable to start notification server using #{env3[:machine].config.notify.bind_ip}")
            end
          end
        end
        # Always install the command to make sure we can fix stale ips
        # on the guest machine
        b3.use InstallCommand
      end
    end
  end
end

.action_status_serverObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/vagrant-notify/action.rb', line 64

def action_status_server
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, CheckProvider do |env, b2|
      next if !env[:result]

      b2.use PrepareData
      b2.use Call, ServerIsRunning do |env2, b3|
        if env2[:result]
          env[:machine].ui.success("vagrant-notify-server pid: #{env2[:notify_data][:pid]}")
        else
          if env[:machine].config.notify.enable == false
            env[:machine].ui.error("No vagrant-notify server detected. Disabled in Vagrantfile")
          else
            env[:machine].ui.error("No vagrant-notify server detected.")
          end
        end
      end
    end
  end
end

.action_stop_serverObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-notify/action.rb', line 46

def action_stop_server
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, CheckProvider do |env, b2|
      next if !env[:result]

      b2.use PrepareData
      b2.use Call, ServerIsRunning do |env2, b3|
        if env2[:result]
          b3.use StopServer
          # TODO: b3.use RestoreCommandBackup
        else
          # TODO: b3.use MessageServerStopped
        end
      end
    end
  end
end