Module: VagrantPlugins::G5K::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-g5k/action.rb,
lib/vagrant-g5k/action/get_state.rb,
lib/vagrant-g5k/action/delete_job.rb,
lib/vagrant-g5k/action/is_created.rb,
lib/vagrant-g5k/action/read_state.rb,
lib/vagrant-g5k/action/connect_g5k.rb,
lib/vagrant-g5k/action/delete_disk.rb,
lib/vagrant-g5k/action/run_instance.rb,
lib/vagrant-g5k/action/read_ssh_info.rb,
lib/vagrant-g5k/action/wait_instance.rb,
lib/vagrant-g5k/action/message_not_created.rb,
lib/vagrant-g5k/action/message_not_running.rb,
lib/vagrant-g5k/action/message_already_running.rb,
lib/vagrant-g5k/action/create_local_working_dir.rb

Defined Under Namespace

Classes: ConnectG5K, CreateLocalWorkingDir, DeleteDisk, DeleteJob, GetState, IsCreated, MessageAlreadyRunning, MessageNotCreated, MessageNotRunning, ReadSSHInfo, ReadState, RunInstance, WaitInstance

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



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

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 ConnectG5K
        b2.use Call, GetState do |env2, b3|
          if [:Running, :Waiting].include?(env2[:result])
            b3.use DeleteJob
            b3.use DeleteDisk
            next
          elsif env2[:result] == :shutdown
            b3.use DeleteDisk
            next
          else
            b3.use MessageNotCreated
            next
          end
        end
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject

This action is called to shutdown the remote machine.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/vagrant-g5k/action.rb', line 115

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
      b.use ConfigValidate
      b.use ConnectG5K
      b.use Call, GetState do |env1, b2|
        if [:Running, :Waiting].include?(env1[:result])
          b2.use DeleteJob
          next
        else
          b2.use MessageNotCreated
          next
        end
    end
  end
end

.action_provisionObject

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



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/vagrant-g5k/action.rb', line 132

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, GetState do |env, b2|
      if env[:result] != :Running
        b2.use MessageNotRunning
        next
      end
      b2.use Provision
    end
  end
end

.action_read_ssh_infoObject

resulting state is expected to be put into the ‘:machine_ssh_info` key.



25
26
27
28
29
30
31
# File 'lib/vagrant-g5k/action.rb', line 25

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



14
15
16
17
18
19
20
# File 'lib/vagrant-g5k/action.rb', line 14

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

.action_sshObject

This action is called to SSH into the machine.



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

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    # read_state is hook by the call to machine.state.id
    # in GetState Middleware
    b.use Call, GetState do |env, b2|
      if env[:result] != :Running
        b2.use MessageNotRunning
        next
      end
      b2.use SSHExec
    end
  end
end

.action_ssh_runObject

This action is called when vagrant ssh -C “…” is used



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vagrant-g5k/action.rb', line 51

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, GetState do |env, b2|
      if env[:result] != :Running
        b2.use MessageNotRunning
        next
      end

      b2.use SSHRun
    end
  end
end

.action_upObject

This action is called to bring the box up from nothing.



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

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, GetState do |env1, b1|
      if env1[:result] == :Running then
        b1.use MessageAlreadyRunning
      elsif env1[:result] == :Waiting
        b1.use ConnectG5K
        b1.use WaitInstance
      else
        b1.use ConnectG5K
        b1.use CreateLocalWorkingDir
        b1.use RunInstance # launch a new instance
        b1.use WaitForCommunicator, [:Running]
        b1.use SyncedFolders
      end
    end
  end
end