vagrant-persistent-storage 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae11dde0a9a20e45403492d7f1d6de44699b5717
|
4
|
+
data.tar.gz: a9c1efd12626619b7a84c475d1cfbf6796ed68a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f5469c5e5c6c610072f94dbe5f89aa757cc4ed098cfce20704de38235a2b2aa9bef6befbce14874da285bb892b9733b1388a570b3a58caff4fc7cfbed80e87
|
7
|
+
data.tar.gz: 416335aee9c1e5e6b42cb5783e77d98388ea64ebcb1d46a6319e1853bb39c88e3592a05bcdf400fa3c5dc16be097ef4d22f325b0b162ac112694e5fe5fcff352
|
@@ -28,7 +28,7 @@ module VagrantPlugins
|
|
28
28
|
# check config to see if the disk should be created
|
29
29
|
return @app.call(env) unless env[:machine].config.persistent_storage.create?
|
30
30
|
|
31
|
-
if File.exists?(env[:machine].config.persistent_storage.location)
|
31
|
+
if File.exists?(File.expand_path(env[:machine].config.persistent_storage.location))
|
32
32
|
@logger.info '** Persistent Storage Volume exists, not creating **'
|
33
33
|
env[:ui].info I18n.t("vagrant_persistent_storage.action.not_creating")
|
34
34
|
@app.call(env)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "log4r"
|
1
2
|
require 'pathname'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
@@ -16,7 +17,7 @@ module VagrantPlugins
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def create_storage(location, size)
|
19
|
-
execute("createhd", "--filename", location, "--size", "#{size}")
|
20
|
+
execute("createhd", "--filename", File.expand_path(location), "--size", "#{size}")
|
20
21
|
end
|
21
22
|
|
22
23
|
def attach_storage(location)
|
@@ -25,30 +26,42 @@ module VagrantPlugins
|
|
25
26
|
controller_name = "SATA Controller"
|
26
27
|
end
|
27
28
|
|
29
|
+
location_realpath = File.expand_path(location)
|
30
|
+
|
28
31
|
if controller_name.start_with?("IDE")
|
29
|
-
execute("storageattach", @uuid, "--storagectl", get_controller_name, "--port", "
|
32
|
+
execute("storageattach", @uuid, "--storagectl", get_controller_name, "--port", "4", "--device", "0", "--type", "hdd", "--medium", "#{location_realpath}")
|
33
|
+
elsif controller_name.start_with?("SCSI")
|
34
|
+
execute("storageattach", @uuid, "--storagectl", get_controller_name, "--port", "15", "--device", "0", "--type", "hdd", "--medium", "#{location_realpath}")
|
30
35
|
else
|
31
|
-
execute("storageattach", @uuid, "--storagectl", get_controller_name, "--port", "
|
36
|
+
execute("storageattach", @uuid, "--storagectl", get_controller_name, "--port", "4", "--device", "0", "--type", "hdd", "--medium", "#{location_realpath}", "--hotpluggable", "on")
|
32
37
|
end
|
33
38
|
|
34
39
|
|
35
40
|
end
|
36
41
|
|
37
42
|
def detach_storage(location)
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
location_realpath = File.expand_path(location)
|
44
|
+
persistent_storage_data = read_persistent_storage(location_realpath)
|
45
|
+
if location and persistent_storage_data and identical_files(persistent_storage_data.location, location_realpath)
|
46
|
+
execute("storageattach", @uuid, "--storagectl", persistent_storage_data.controller, "--port", persistent_storage_data.port, "--device", "0", "--type", "hdd", "--medium", "none")
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
44
|
-
def read_persistent_storage()
|
50
|
+
def read_persistent_storage(location)
|
45
51
|
## Ensure previous operations are complete - bad practise yes, not sure how to avoid this:
|
46
52
|
sleep 3
|
53
|
+
storage_data = nil
|
54
|
+
controller_name = get_controller_name
|
47
55
|
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
48
56
|
info.split("\n").each do |line|
|
49
|
-
|
57
|
+
tmp_storage_data = nil
|
58
|
+
tmp_storage_data = PersistentStorageData.new(controller_name, $1, $3) if line =~ /^"#{controller_name}-(\d+)-(\d+)"="(.*)"/
|
59
|
+
|
60
|
+
if !tmp_storage_data.nil? and tmp_storage_data.location != 'none' and identical_files(File.expand_path(location), tmp_storage_data.location)
|
61
|
+
storage_data = tmp_storage_data
|
62
|
+
end
|
50
63
|
end
|
51
|
-
|
64
|
+
return storage_data
|
52
65
|
end
|
53
66
|
|
54
67
|
def identical_files(file1, file2)
|
@@ -61,7 +74,7 @@ module VagrantPlugins
|
|
61
74
|
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
|
62
75
|
info.split("\n").each do |line|
|
63
76
|
controllers[$1] = $2 if line =~ /^storagecontrollername(\d+)="(.*)"/
|
64
|
-
controller_number = $1 if line =~ /^storagecontrollertype(\d+)="(IntelAhci|PIIX4)"/
|
77
|
+
controller_number = $1 if line =~ /^storagecontrollertype(\d+)="(IntelAhci|PIIX4|LsiLogic)"/
|
65
78
|
end
|
66
79
|
|
67
80
|
if controller_number.nil?
|
@@ -71,6 +84,19 @@ module VagrantPlugins
|
|
71
84
|
return controllers[controller_number]
|
72
85
|
end
|
73
86
|
|
87
|
+
class PersistentStorageData
|
88
|
+
|
89
|
+
attr_accessor :controller
|
90
|
+
attr_accessor :port
|
91
|
+
attr_accessor :location
|
92
|
+
|
93
|
+
def initialize(controller,port,location)
|
94
|
+
@controller = controller
|
95
|
+
@port = port
|
96
|
+
@location = location
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
74
100
|
end
|
75
101
|
end
|
76
102
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-persistent-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Kusnier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.0.14
|
92
|
+
rubygems_version: 2.0.14.1
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: A Vagrant plugin that creates a persistent storage and attaches it to guest
|