Module: VagrantPlugins::WinAzure::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-azure/action.rb,
lib/vagrant-azure/action/rdp.rb,
lib/vagrant-azure/action/os_type.rb,
lib/vagrant-azure/action/provision.rb,
lib/vagrant-azure/action/read_state.rb,
lib/vagrant-azure/action/restart_vm.rb,
lib/vagrant-azure/action/run_instance.rb,
lib/vagrant-azure/action/sync_folders.rb,
lib/vagrant-azure/action/connect_azure.rb,
lib/vagrant-azure/action/read_ssh_info.rb,
lib/vagrant-azure/action/stop_instance.rb,
lib/vagrant-azure/action/powershell_run.rb,
lib/vagrant-azure/action/start_instance.rb,
lib/vagrant-azure/action/wait_for_state.rb,
lib/vagrant-azure/action/read_winrm_info.rb,
lib/vagrant-azure/action/terminate_instance.rb,
lib/vagrant-azure/action/wait_for_communicate.rb,
lib/vagrant-azure/action/vagrant_azure_service.rb

Defined Under Namespace

Classes: ConnectAzure, OSType, PowerShellRun, Provision, Rdp, ReadSSHInfo, ReadState, ReadWinrmInfo, RestartVM, RunInstance, StartInstance, StopInstance, SyncFolders, TerminateInstance, VagrantAzureService, WaitForCommunicate, WaitForState

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vagrant-azure/action.rb', line 33

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, IsState, :NotCreated do |env2, b3|
          if env2[:result]
            b3.use Message, I18n.t('vagrant_azure.not_created')
            next
          end
        end

        b2.use ConnectAzure
        b2.use TerminateInstance
        b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
      else
        env[:machine].id =~ /@/
        b2.use Message, I18n.t(
            'vagrant_azure.will_not_destroy',
            :name => $`
        )
      end
    end
  end
end

.action_haltObject

This action is called to halt the remote machine.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-azure/action.rb', line 17

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use ConnectAzure
      b2.use StopInstance
    end
  end
end

.action_powershell_runObject



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

def self.action_powershell_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use action_read_winrm_info
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use PowerShellRun
    end
  end
end

.action_prepare_bootObject



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/vagrant-azure/action.rb', line 180

def self.action_prepare_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, WaitForState, :ReadyRole do |env, b1|
      if env[:result]
        env[:machine].id =~ /@/
        b1.use Message, I18n.t(
            'vagrant_azure.vm_started', :name => $`
        )
        b1.use action_read_winrm_info
        b1.use WaitForCommunicate
        b1.use action_provision
      end
    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
74
75
76
# File 'lib/vagrant-azure/action.rb', line 60

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectAzure
    b.use ConfigValidate
    b.use OSType
    b.use ReadWinrmInfo
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use Provision
      b2.use SyncFolders
    end
  end
end

.action_rdpObject



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

def self.action_rdp
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectAzure
    b.use ConfigValidate
    b.use Call, IsState, :NotCreated do |env1, b1|
      if env1[:result]
        b1.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b1.use Call, IsState, :ReadyRole do |env2, b2|
        if !env2[:result]
          b2.use Message, I18n.t('vagrant_azure.rdp_not_ready')
          next
        end

        b2.use Rdp
      end
    end
  end
end

.action_read_rdp_infoObject



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

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



80
81
82
83
84
85
86
# File 'lib/vagrant-azure/action.rb', line 80

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectAzure
    b.use ReadSSHInfo, 22
  end
end

.action_read_stateObject



105
106
107
108
109
110
111
# File 'lib/vagrant-azure/action.rb', line 105

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

.action_read_winrm_infoObject



96
97
98
99
100
101
102
103
# File 'lib/vagrant-azure/action.rb', line 96

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

.action_reloadObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/vagrant-azure/action.rb', line 223

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectAzure
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use action_halt
      b2.use Call, WaitForState, :StoppedDeallocated do |env2, b3|
        if env2[:result]
          env2[:machine].id =~ /@/
          b3.use Message, I18n.t('vagrant_azure.vm_stopped', name: $`)
          b3.use action_up
        else
          b3.use Message, 'Not able to stop the machine. Please retry.'
        end
      end
    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
127
# File 'lib/vagrant-azure/action.rb', line 114

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectAzure
    b.use ConfigValidate
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/vagrant-azure/action.rb', line 165

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectAzure
    b.use ConfigValidate
    b.use Call, IsState, :NotCreated do |env, b2|
      if env[:result]
        b2.use Message, I18n.t('vagrant_azure.not_created')
        next
      end

      b2.use SSHRun
    end
  end
end

.action_upObject

This action is called to bring the box up from nothing



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/vagrant-azure/action.rb', line 197

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectAzure
    b.use OSType
    b.use Call, IsState, :NotCreated do |env1, b1|
      if !env1[:result]
        b1.use Call, IsState, :StoppedDeallocated do |env2, b2|
          if env2[:result]
            b2.use StartInstance # start this instance again
            b2.use action_prepare_boot
          else
            b2.use Message, I18n.t(
                'vagrant_azure.already_status', :status => 'created'
            )
          end
        end
      else
        b1.use RunInstance # Launch a new instance
        b1.use action_prepare_boot
      end
    end
  end
end