Module: VagrantPlugins::Filoo::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant_filoo/action.rb,
lib/vagrant_filoo/action/get_images.rb,
lib/vagrant_filoo/action/is_created.rb,
lib/vagrant_filoo/action/is_stopped.rb,
lib/vagrant_filoo/action/read_state.rb,
lib/vagrant_filoo/action/create_server.rb,
lib/vagrant_filoo/action/read_ssh_info.rb,
lib/vagrant_filoo/action/stop_instance.rb,
lib/vagrant_filoo/action/start_instance.rb,
lib/vagrant_filoo/action/terminate_instance.rb,
lib/vagrant_filoo/action/message_not_created.rb,
lib/vagrant_filoo/action/message_already_created.rb

Defined Under Namespace

Classes: CreateServer, GetImages, IsCreated, IsStopped, MessageAlreadyCreated, MessageNotCreated, ReadSSHInfo, ReadState, StartInstance, StopInstance, TerminateInstance

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vagrant_filoo/action.rb', line 39

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, DestroyConfirm do |env, b2|
      if env[:result]
        b2.use ConfigValidate
        b2.use Call, IsCreated do |env2, b3|
          unless env2[:result]
            b3.use MessageNotCreated
            next
          end
          b3.use TerminateInstance
          b3.use ProvisionerCleanup if defined?(ProvisionerCleanup)
        end
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject

This action is called to halt the remote machine.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant_filoo/action.rb', line 25

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end
      b2.use StopInstance
    end
  end
end

.action_provisionObject

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vagrant_filoo/action.rb', line 60

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Provision
      # b2.use SyncedFolders
    end
  end
end

.action_read_ssh_infoObject

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



17
18
19
20
21
22
# File 'lib/vagrant_filoo/action.rb', line 17

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ReadSSHInfo
  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.



146
147
148
149
150
151
# File 'lib/vagrant_filoo/action.rb', line 146

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

.action_reloadObject



154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/vagrant_filoo/action.rb', line 154

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end
      b2.use action_halt
      b2.use action_up
    end
  end
end

.action_sshObject

This action is called to SSH into the machine.



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/vagrant_filoo/action.rb', line 114

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vagrant_filoo/action.rb', line 129

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHRun
    end
  end
end

.action_upObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vagrant_filoo/action.rb', line 78

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use BoxCheckOutdated
    b.use Call, IsCreated do |env1, b1|
      if env1[:result]
        b1.use Call, IsStopped do |env2, b1|
          if env2[:result]
            b1.use StartInstance # restart this instance  
          else
            b1.use MessageAlreadyCreated # TODO: write a better message
          end
        end
      else
        # b1.use Provision
        # b1.use SyncedFolders
        b1.use GetImages
        b1.use CreateServer do |env2, b2|
          if env2[:result]["vmstatus"] == "stopped"
            b2.use StartInstance # launch a new instance
          elseif env2[:result]["vmstatus"] != "running"
            raise VagrantPlugins::Filoo::Errors::UnexpectedStateError,
              resource: "/vserver/status",
              state: {"vmstatus" => env1[:result]["vmstatus"]},
              message: "Unexpected vmstatus after create Server done, vmstatus " + env1[:result]["vmstatus"],
              description: "Server with vmid  #{env1[:result]['vmid']} should be running or stopped "
          end
        end
        b1.use WaitForCommunicator
      end
    end
  end
end