Module: VagrantPlugins::Cloudstack::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-cloudstack/action.rb,
lib/vagrant-cloudstack/action/is_created.rb,
lib/vagrant-cloudstack/action/is_stopped.rb,
lib/vagrant-cloudstack/action/read_state.rb,
lib/vagrant-cloudstack/action/run_instance.rb,
lib/vagrant-cloudstack/action/read_rdp_info.rb,
lib/vagrant-cloudstack/action/read_ssh_info.rb,
lib/vagrant-cloudstack/action/stop_instance.rb,
lib/vagrant-cloudstack/action/warn_networks.rb,
lib/vagrant-cloudstack/action/start_instance.rb,
lib/vagrant-cloudstack/action/wait_for_state.rb,
lib/vagrant-cloudstack/action/read_winrm_info.rb,
lib/vagrant-cloudstack/action/timed_provision.rb,
lib/vagrant-cloudstack/action/connect_cloudstack.rb,
lib/vagrant-cloudstack/action/terminate_instance.rb,
lib/vagrant-cloudstack/action/message_not_created.rb,
lib/vagrant-cloudstack/action/read_transport_info.rb,
lib/vagrant-cloudstack/action/message_already_created.rb,
lib/vagrant-cloudstack/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: ConnectCloudstack, IsCreated, IsStopped, MessageAlreadyCreated, MessageNotCreated, MessageWillNotDestroy, ReadRdpInfo, ReadSSHInfo, ReadState, ReadTransportInfo, ReadWinrmInfo, RunInstance, StartInstance, StopInstance, TerminateInstance, TimedProvision, WaitForState, WarnNetworks

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagrant-cloudstack/action.rb', line 27

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

.action_haltObject

This action is called to halt the remote machine.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-cloudstack/action.rb', line 11

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

      b2.use ConnectCloudstack
      b2.use StopInstance
    end
  end
end

.action_prepare_bootObject



136
137
138
139
140
141
142
# File 'lib/vagrant-cloudstack/action.rb', line 136

def self.action_prepare_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use Provision
    b.use SyncedFolders
    b.use WarnNetworks
  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
# File 'lib/vagrant-cloudstack/action.rb', line 48

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

      b2.use Provision
      b2.use SyncedFolders
    end
  end
end

.action_read_rdp_infoObject

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



66
67
68
69
70
71
72
# File 'lib/vagrant-cloudstack/action.rb', line 66

def self.action_read_rdp_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectCloudstack
    b.use ReadRdpInfo
  end
end

.action_read_ssh_infoObject

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



88
89
90
91
92
93
94
# File 'lib/vagrant-cloudstack/action.rb', line 88

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



99
100
101
102
103
104
105
# File 'lib/vagrant-cloudstack/action.rb', line 99

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

.action_read_winrm_infoObject

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



77
78
79
80
81
82
83
# File 'lib/vagrant-cloudstack/action.rb', line 77

def self.action_read_winrm_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectCloudstack
    b.use ReadWinrmInfo
  end
end

.action_reloadObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/vagrant-cloudstack/action.rb', line 167

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

      b2.use action_halt
      b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
        if env2[:result]
          b3.use action_up
        else
          # TODO we couldn't reach :stopped, what now?
        end
      end
    end
  end
end

.action_sshObject

This action is called to SSH into the machine.



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/vagrant-cloudstack/action.rb', line 108

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

      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/vagrant-cloudstack/action.rb', line 122

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

      b2.use SSHRun
    end
  end
end

.action_upObject

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



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/vagrant-cloudstack/action.rb', line 145

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectCloudstack
    b.use Call, IsCreated do |env1, b1|
      if env1[:result]
        b1.use Call, IsStopped do |env2, b2|
          if env2[:result]
            b2.use action_prepare_boot
            b2.use StartInstance # restart this instance
          else
            b2.use MessageAlreadyCreated # TODO write a better message
          end
        end
      else
        b1.use action_prepare_boot
        b1.use RunInstance # launch a new instance
      end
    end
  end
end