vagrant-xenserver 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/vagrant-xenserver/action/create_vm.rb +10 -2
- data/lib/vagrant-xenserver/action/halt_vm.rb +27 -0
- data/lib/vagrant-xenserver/action/prepare_nfs_settings.rb +51 -0
- data/lib/vagrant-xenserver/action/prepare_nfs_valid_ids.rb +17 -0
- data/lib/vagrant-xenserver/action.rb +36 -9
- data/lib/vagrant-xenserver/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911987b6727c2c821c643fbd857f82d7022c7f48
|
4
|
+
data.tar.gz: 31433e632ad1fafdedeb1a83c735b64825cc20b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b372c6454cad0ee1ad976d5d920b90e6f201955c6464cf2a304eedf3d9171c8665e9ca195b2a688388ea0c88041b5950e983ae40b53e5b669f75bae1cdff7f
|
7
|
+
data.tar.gz: a0ae80e01bbc30ed5299828007e51022e9a1b521eac72565e414bf02fd097919a8a744848823ce5ff627f12c9a1fad0d2d9669a31620cc8726336a660dcd2762
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,7 @@ require "xmlrpc/client"
|
|
3
3
|
require "vagrant-xenserver/util/uploader"
|
4
4
|
require "rexml/document"
|
5
5
|
require "json"
|
6
|
+
require "etc"
|
6
7
|
|
7
8
|
module VagrantPlugins
|
8
9
|
module XenServer
|
@@ -22,10 +23,17 @@ module VagrantPlugins
|
|
22
23
|
(himn_ref,himn_rec) = himn
|
23
24
|
|
24
25
|
@logger.info("himn_uuid="+himn_rec['uuid'])
|
25
|
-
|
26
|
+
|
27
|
+
username = Etc.getlogin
|
28
|
+
|
26
29
|
oim = env[:xc].call("VM.get_by_name_label",env[:session],"Other install media")['Value'][0]
|
27
30
|
|
28
|
-
|
31
|
+
box_name = env[:machine].box.name.to_s
|
32
|
+
box_version = env[:machine].box.version.to_s
|
33
|
+
|
34
|
+
vm_name = "#{username}/#{box_name}/#{box_version}"
|
35
|
+
|
36
|
+
vm_ref = env[:xc].call("VM.clone",env[:session],oim,vm_name)['Value']
|
29
37
|
|
30
38
|
vbd_record = {
|
31
39
|
'VM' => vm_ref,
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "xmlrpc/client"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module XenServer
|
6
|
+
module Action
|
7
|
+
class HaltVM
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
@logger = Log4r::Logger.new("vagrant::xenserver::actions::start_vm")
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
myvm = env[:machine].id
|
15
|
+
|
16
|
+
shutdown_result = env[:xc].call("VM.clean_shutdown",env[:session],myvm)
|
17
|
+
|
18
|
+
if shutdown_result["Status"] != "Success"
|
19
|
+
raise Errors::APIError
|
20
|
+
end
|
21
|
+
|
22
|
+
@app.call env
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module XenServer
|
6
|
+
module Action
|
7
|
+
class PrepareNFSSettings
|
8
|
+
include Vagrant::Action::Builtin::MixinSyncedFolders
|
9
|
+
|
10
|
+
def initialize(app,env)
|
11
|
+
@app = app
|
12
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::nfs")
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
@machine = env[:machine]
|
17
|
+
@app.call(env)
|
18
|
+
|
19
|
+
if using_nfs?
|
20
|
+
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
21
|
+
env[:nfs_host_ip] = read_host_ip(env[:machine],env)
|
22
|
+
env[:nfs_machine_ip] = env[:xs_host_ip]
|
23
|
+
|
24
|
+
@logger.info("host IP: #{env[:nfs_host_ip]} machine IP: #{env[:nfs_machine_ip]}")
|
25
|
+
|
26
|
+
raise Vagrant::Errors::NFSNoHostonlyNetwork if !env[:nfs_machine_ip] || !env[:nfs_host_ip]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# We're using NFS if we have any synced folder with NFS configured. If
|
31
|
+
# we are not using NFS we don't need to do the extra work to
|
32
|
+
# populate these fields in the environment.
|
33
|
+
def using_nfs?
|
34
|
+
!!synced_folders(@machine)[:nfs]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the IP address of the interface that will route to the xs_host
|
38
|
+
#
|
39
|
+
# @param [Machine] machine
|
40
|
+
# @return [String]
|
41
|
+
def read_host_ip(machine,env)
|
42
|
+
ip = Socket.getaddrinfo(env[:machine].provider_config.xs_host,nil)[0][2]
|
43
|
+
env[:xs_host_ip] = ip
|
44
|
+
re = /src ([0-9\.]+)/
|
45
|
+
match = `ip route get to #{ip} | head -n 1`.match re
|
46
|
+
match[1]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module XenServer
|
3
|
+
module Action
|
4
|
+
class PrepareNFSValidIds
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new("vagrant::xenserver::action::vm::nfs")
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
env[:nfs_valid_ids] = env[:xc].call("VM.get_all",env[:session])['Value']
|
12
|
+
@app.call(env)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -7,6 +7,18 @@ module VagrantPlugins
|
|
7
7
|
include Vagrant::Action::Builtin
|
8
8
|
@logger = Log4r::Logger.new('vagrant::xenserver::action')
|
9
9
|
|
10
|
+
def self.action_boot
|
11
|
+
Vagrant::Action::Builder.new.tap do |b|
|
12
|
+
b.use Provision
|
13
|
+
b.use PrepareNFSValidIds
|
14
|
+
b.use SyncedFolderCleanup
|
15
|
+
b.use SyncedFolders
|
16
|
+
b.use StartVM
|
17
|
+
b.use WaitForCommunicator, ["Running"]
|
18
|
+
b.use PrepareNFSSettings
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
def self.action_up
|
11
23
|
Vagrant::Action::Builder.new.tap do |b|
|
12
24
|
b.use HandleBox
|
@@ -18,14 +30,27 @@ module VagrantPlugins
|
|
18
30
|
b2.use UploadVHD
|
19
31
|
b2.use CloneDisk
|
20
32
|
b2.use CreateVM
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
end
|
34
|
+
b2.use action_boot
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.action_halt
|
40
|
+
Vagrant::Action::Builder.new.tap do |b|
|
41
|
+
b.use ConfigValidate
|
42
|
+
b.use Call, IsCreated do |env, b2|
|
43
|
+
if !env[:result]
|
44
|
+
@logger.info "MessageNotCreated"
|
45
|
+
next
|
46
|
+
end
|
47
|
+
b2.use ConnectXS
|
48
|
+
b2.use Call, IsRunning do |env, b3|
|
49
|
+
if !env[:result]
|
50
|
+
@logger.info "Not running"
|
51
|
+
next
|
52
|
+
end
|
53
|
+
b3.use HaltVM
|
29
54
|
end
|
30
55
|
end
|
31
56
|
end
|
@@ -39,7 +64,6 @@ module VagrantPlugins
|
|
39
64
|
@logger.info "MessageNotCreated"
|
40
65
|
next
|
41
66
|
end
|
42
|
-
|
43
67
|
b2.use ConnectXS
|
44
68
|
b2.use DestroyVM
|
45
69
|
end
|
@@ -149,7 +173,10 @@ module VagrantPlugins
|
|
149
173
|
autoload :CreateVM, action_root.join('create_vm')
|
150
174
|
autoload :DestroyVM, action_root.join('destroy_vm')
|
151
175
|
autoload :StartVM, action_root.join('start_vm')
|
176
|
+
autoload :HaltVM, action_root.join('halt_vm')
|
152
177
|
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
|
178
|
+
autoload :PrepareNFSSettings, action_root.join('prepare_nfs_settings')
|
179
|
+
autoload :PrepareNFSValidIds, action_root.join('prepare_nfs_valid_ids')
|
153
180
|
end
|
154
181
|
end
|
155
182
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-xenserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Ludlam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Enables Vagrant to manage XenServers.
|
@@ -43,9 +43,12 @@ files:
|
|
43
43
|
- lib/vagrant-xenserver/action/create_vm.rb
|
44
44
|
- lib/vagrant-xenserver/action/destroy_vm.rb
|
45
45
|
- lib/vagrant-xenserver/action/dummy.rb
|
46
|
+
- lib/vagrant-xenserver/action/halt_vm.rb
|
46
47
|
- lib/vagrant-xenserver/action/is_created.rb
|
47
48
|
- lib/vagrant-xenserver/action/is_running.rb
|
48
49
|
- lib/vagrant-xenserver/action/maybe_upload_disk.rb
|
50
|
+
- lib/vagrant-xenserver/action/prepare_nfs_settings.rb
|
51
|
+
- lib/vagrant-xenserver/action/prepare_nfs_valid_ids.rb
|
49
52
|
- lib/vagrant-xenserver/action/read_ssh_info.rb
|
50
53
|
- lib/vagrant-xenserver/action/read_state.rb
|
51
54
|
- lib/vagrant-xenserver/action/start_vm.rb
|
@@ -70,12 +73,12 @@ require_paths:
|
|
70
73
|
- lib
|
71
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
75
|
requirements:
|
73
|
-
- -
|
76
|
+
- - '>='
|
74
77
|
- !ruby/object:Gem::Version
|
75
78
|
version: '0'
|
76
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
80
|
requirements:
|
78
|
-
- -
|
81
|
+
- - '>='
|
79
82
|
- !ruby/object:Gem::Version
|
80
83
|
version: '0'
|
81
84
|
requirements: []
|