Module: VagrantPlugins::ManagedServers::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-managed-servers/action.rb,
lib/vagrant-managed-servers/action/is_linked.rb,
lib/vagrant-managed-servers/action/read_state.rb,
lib/vagrant-managed-servers/action/link_server.rb,
lib/vagrant-managed-servers/action/is_reachable.rb,
lib/vagrant-managed-servers/action/sync_folders.rb,
lib/vagrant-managed-servers/action/reboot_server.rb,
lib/vagrant-managed-servers/action/unlink_server.rb,
lib/vagrant-managed-servers/action/warn_networks.rb,
lib/vagrant-managed-servers/action/message_not_linked.rb,
lib/vagrant-managed-servers/action/message_not_reachable.rb,
lib/vagrant-managed-servers/action/message_already_linked.rb

Defined Under Namespace

Classes: IsLinked, IsReachable, LinkServer, MessageAlreadyLinked, MessageNotLinked, MessageNotReachable, ReadState, RebootServer, SyncFolders, UnlinkServer, WarnNetworks

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to “unlink” vagrant from the managed server



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagrant-managed-servers/action.rb', line 33

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsLinked do |env, b2|
      if !env[:result]
        b2.use MessageNotLinked
        next
      end

      b2.use UnlinkServer
    end
  end
end

.action_provisionObject

This action is called when ‘vagrant provision` is called.



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
76
77
# File 'lib/vagrant-managed-servers/action.rb', line 48

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use WarnNetworks
    b.use Call, IsLinked do |env, b2|
      if !env[:result]
        b2.use MessageNotLinked
        next
      end

      b2.use Call, IsReachable do |env, b3|
        if !env[:result]
          b3.use MessageNotReachable
          next
        end

        b3.use Provision
        if env[:machine].config.vm.communicator == :winrm
          # Use the builtin vagrant folder sync for Windows target servers.
          # This gives us SMB folder sharing, which is much faster than the
          # WinRM uploader for any non-trivial number of files.
          b3.use Vagrant::Action::Builtin::SyncedFolders
        else
          # Vagrant managed servers custom implementation
          b3.use SyncFolders
        end
      end
    end
  end
end

.action_read_stateObject

This action is called to read the state of the machine. The resulting state is expected to be put into the ‘:machine_state_id` key.



82
83
84
85
86
87
# File 'lib/vagrant-managed-servers/action.rb', line 82

def self.action_read_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ReadState
  end
end

.action_reloadObject



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/vagrant-managed-servers/action.rb', line 134

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsLinked do |env, b2|
      if !env[:result]
        b2.use MessageNotLinked
        next
      end

      b2.use RebootServer
    end
  end
end

.action_sshObject

This action is called to SSH into the machine.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/vagrant-managed-servers/action.rb', line 90

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use WarnNetworks
    b.use Call, IsLinked do |env, b2|
      if !env[:result]
        b2.use MessageNotLinked
        next
      end

      b2.use Call, IsReachable do |env, b3|
        if !env[:result]
          b3.use MessageNotReachable
          next
        end

        b3.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/vagrant-managed-servers/action.rb', line 112

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use WarnNetworks
    b.use Call, IsLinked do |env, b2|
      if !env[:result]
        b2.use MessageNotLinked
        next
      end

      b2.use Call, IsReachable do |env, b3|
        if !env[:result]
          b3.use MessageNotReachable
          next
        end

        b3.use SSHRun
      end
    end
  end
end

.action_upObject

This action is called to establish linkage between vagrant and the managed server



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-managed-servers/action.rb', line 12

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    if Vagrant::VERSION < '1.5.0'
      b.use HandleBoxUrl
    else
      b.use HandleBox
    end
    b.use ConfigValidate
    b.use WarnNetworks
    b.use Call, IsLinked do |env, b2|
      if env[:result]
        b2.use MessageAlreadyLinked
        next
      end

      b2.use LinkServer
    end
  end
end