Module: VagrantPlugins::XenServer::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-xenserver/action.rb,
lib/vagrant-xenserver/action/dummy.rb,
lib/vagrant-xenserver/action/halt_vm.rb,
lib/vagrant-xenserver/action/clone_vm.rb,
lib/vagrant-xenserver/action/start_vm.rb,
lib/vagrant-xenserver/action/create_vm.rb,
lib/vagrant-xenserver/action/resume_vm.rb,
lib/vagrant-xenserver/action/clone_disk.rb,
lib/vagrant-xenserver/action/connect_xs.rb,
lib/vagrant-xenserver/action/destroy_vm.rb,
lib/vagrant-xenserver/action/is_created.rb,
lib/vagrant-xenserver/action/is_running.rb,
lib/vagrant-xenserver/action/read_state.rb,
lib/vagrant-xenserver/action/suspend_vm.rb,
lib/vagrant-xenserver/action/upload_vhd.rb,
lib/vagrant-xenserver/action/upload_xva.rb,
lib/vagrant-xenserver/action/create_vifs.rb,
lib/vagrant-xenserver/action/download_xva.rb,
lib/vagrant-xenserver/action/is_suspended.rb,
lib/vagrant-xenserver/action/read_ssh_info.rb,
lib/vagrant-xenserver/action/set_vm_params.rb,
lib/vagrant-xenserver/action/create_template.rb,
lib/vagrant-xenserver/action/prepare_nfs_settings.rb,
lib/vagrant-xenserver/action/prepare_nfs_valid_ids.rb

Defined Under Namespace

Classes: CloneDisk, CloneVM, ConnectXS, CreateTemplate, CreateVIFs, CreateVM, DestroyVM, DownloadXVA, DummyMessage, HaltVM, IsCreated, IsRunning, IsSuspended, PrepareNFSSettings, PrepareNFSValidIds, ReadSSHInfo, ReadState, ResumeVM, SetVMParams, StartVM, SuspendVM, UploadVHD, UploadXVA

Class Method Summary collapse

Class Method Details

.action_bootObject



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

def self.action_boot
	Vagrant::Action::Builder.new.tap do |b| 
    b.use Provision
    b.use PrepareNFSValidIds
    b.use SyncedFolderCleanup
    b.use SyncedFolders
    b.use Call, IsRunning do |env, b2|
      if !env[:result]
        b2.use StartVM
      end
    end
    b.use WaitForCommunicator, ["Running"]
    b.use PrepareNFSSettings         
  end
end

.action_destroyObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/vagrant-xenserver/action.rb', line 112

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        @logger.info "MessageNotCreated"
        next
      end
      b2.use ConnectXS
      b2.use DestroyVM
      b2.use ProvisionerCleanup
      b2.use PrepareNFSValidIds
      b2.use SyncedFolderCleanup
    end
  end
end

.action_haltObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vagrant-xenserver/action.rb', line 52

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        @logger.info "MessageNotCreated"
        next
      end
      b2.use ConnectXS
      b2.use Call, IsRunning do |env, b3|
        if !env[:result]
          @logger.info "Not running"
          next
        end
        b3.use HaltVM            
      end
    end
  end
end

.action_provisionObject



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

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    @logger.info("XXXXX provision")
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        @logger.info("MessageNotCreated")
        next
      end

      b2.use ConnectXS
      b2.use Call, IsRunning do |env2, b3|
        if !env2[:result]
          @logger.info("MessageNotRunning")
          next
        end

        b3.use Provision
      end
    end
  end
end

.action_read_ssh_infoObject



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

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

.action_read_stateObject



129
130
131
132
133
134
135
# File 'lib/vagrant-xenserver/action.rb', line 129

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

.action_reloadObject



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/vagrant-xenserver/action.rb', line 220

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

      b2.use ConfigValidate
      b2.use action_halt
      b2.use action_boot
    end
  end
end

.action_resumeObject



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

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        @logger.info "MessageNotCreated"
        next
      end
      b2.use ConnectXS
      b2.use Call, IsSuspended do |env, b3|
        if !env[:result]
          @logger.info "Not suspended"
          next
        end
        b3.use ResumeVM
      end
    end
  end
end

.action_sshObject



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

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    @logger.info("XXXXX SSH")
    b.use ConfigValidate
    b.use Call, IsCreated do | env, b2|
      if !env[:result]
#              b2.use MessageNotCreated
        @logger.info("MessageNotCreate")
        next
      end

      b2.use ConnectXS
      b2.use Call, IsRunning do |env2, b3|
        if !env2[:result]
          #b3.use MessageNotRunning
          @logger.info("MessageNotCreate")
          next
        end

        b3.use SSHExec
        @logger.info("ssh run")
      end
    end
  end
end

.action_ssh_runObject



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/vagrant-xenserver/action.rb', line 171

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    @logger.info("XXXXX SSH")
    b.use ConfigValidate
    b.use Call, IsCreated do | env, b2|
      if !env[:result]
#              b2.use MessageNotCreated
        @logger.info("MessageNotCreate")
        next
      end

      b2.use ConnectXS
      b2.use Call, IsRunning do |env2, b3|
        if !env2[:result]
          #b3.use MessageNotRunning
          @logger.info("MessageNotCreate")
          next
        end

        b3.use SSHRun
        @logger.info("ssh run")
      end
    end
  end
end

.action_suspendObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/vagrant-xenserver/action.rb', line 72

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        @logger.info "MessageNotCreated"
        next
      end
      b2.use ConnectXS
      b2.use Call, IsRunning do |env, b3|
        if !env[:result]
          @logger.info "Not running"
          next
        end
        b3.use SuspendVM
      end
    end
  end
end

.action_upObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vagrant-xenserver/action.rb', line 31

def self.action_up
	Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectXS
    b.use Call, IsCreated do |env,b2|
      # Create the VM
      if !env[:result]
        b2.use UploadVHD
        b2.use UploadXVA
        b2.use DownloadXVA
        b2.use CreateTemplate
        b2.use CloneVM
        b2.use SetVMParams
        b2.use CreateVIFs
      end
      b2.use action_boot
    end
  end
end

.getlockObject



11
12
13
# File 'lib/vagrant-xenserver/action.rb', line 11

def self.getlock
  @xvalock
end