vagrant-persistent-storage 0.0.31 → 0.0.32
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 +4 -4
- data/README.md +4 -15
- data/lib/vagrant-persistent-storage/config.rb +20 -27
- data/lib/vagrant-persistent-storage/manage_storage.rb +3 -9
- data/lib/vagrant-persistent-storage/version.rb +1 -1
- data/locales/en.yml +1 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbc1d980eb4bca46f4323c4ee32c75cee63dca50
|
|
4
|
+
data.tar.gz: 9738ed07cd4c02c730bf7d03e1a3df78ffd93490
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecd1adcf9d29b82d893849c60aa838ac839d937b8d122ee57df7cf83a4bf67cc373bcff7357550481ce3cfa363030f69586df372a8a4d4022684758f2129c2be
|
|
7
|
+
data.tar.gz: 7c0450d8de1d2a139c6d0e93c06d0f70fb564ed89308a9c4ebc8f4f5f85632e87d87302dfdd8dd153396df98f590d7aa3ccb560579889811e76ea709015ca336
|
data/README.md
CHANGED
|
@@ -34,40 +34,29 @@ config.persistent_storage.mountoptions = ['defaults', 'prjquota']
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Device defaults to `/dev/sdb`. For boxes with multiple disks, make sure you increment the drive:
|
|
37
|
-
```ruby
|
|
38
|
-
config.persistent_storage.diskdevice = '/dev/sdc'
|
|
39
37
|
```
|
|
40
|
-
|
|
41
|
-
If you are using LVM and you would prefer to use the disk rather than a partition, you can set the following configuration:
|
|
42
|
-
```ruby
|
|
43
|
-
config.persistent_storage.partition = false
|
|
38
|
+
config.persistent_storage.diskdevice = '/dev/sdc'
|
|
44
39
|
```
|
|
45
40
|
|
|
46
41
|
Every `vagrant up` will attach this file as hard disk to the guest machine.
|
|
47
|
-
|
|
42
|
+
An `vagrant destroy` will detach the storage to avoid deletion of the storage by vagrant.
|
|
48
43
|
A `vagrant destroy` generally destroys all attached drives. See [VBoxMange unregistervm --delete option][vboxmanage_delete].
|
|
49
44
|
|
|
50
45
|
The disk is initialized and added to it's own volume group as specfied in the config;
|
|
51
46
|
this defaults to 'vagrant'. An ext4 filesystem is created and the disk mounted appropriately,
|
|
52
|
-
with entries added to fstab ... subsequent runs will mount this disk with the options specified
|
|
47
|
+
with entries added to fstab ... subsequent runs will mount this disk with the options specified
|
|
53
48
|
|
|
54
49
|
## Windows Guests
|
|
55
50
|
|
|
56
51
|
Windows Guests must use the WinRM communicator by setting `vm.communicator = 'winrm'`. An additional option is provided to
|
|
57
52
|
allow you to set the drive letter using:
|
|
58
53
|
|
|
59
|
-
```
|
|
54
|
+
```
|
|
60
55
|
config.persistent_storage.drive_letter = 'Z'
|
|
61
56
|
```
|
|
62
57
|
|
|
63
58
|
Options that are irrelevent to Windows are ignored, such as `mountname`, `filesystem`, `mountpoint` and `volgroupname`.
|
|
64
59
|
|
|
65
|
-
## How Is The Storage Created?
|
|
66
|
-
|
|
67
|
-
Based on the configuration provided, during a `vagrant up` a bash script is generated and uploaded to `/tmp/disk_operations_#{mnt_name}.sh` (Linux) or `disk_operations_#{mnt_name}.ps1` (Windows). If the box has not been previously provisioned the script is executed on a `vagrant up`. To force the scrip to be executed again you can run `vagrant provision` or if you have halted the box, `vagrant up --provision`.
|
|
68
|
-
|
|
69
|
-
The outcome of the script being run is placed in the home drive of the vagrant user in a file called `disk_operation_log.txt`.
|
|
70
|
-
|
|
71
60
|
## Optional settings
|
|
72
61
|
|
|
73
62
|
```ruby
|
|
@@ -15,7 +15,6 @@ module VagrantPlugins
|
|
|
15
15
|
attr_accessor :mountname
|
|
16
16
|
attr_accessor :mountpoint
|
|
17
17
|
attr_accessor :mountoptions
|
|
18
|
-
attr_accessor :partition
|
|
19
18
|
attr_accessor :diskdevice
|
|
20
19
|
attr_accessor :filesystem
|
|
21
20
|
attr_accessor :volgroupname
|
|
@@ -27,7 +26,6 @@ module VagrantPlugins
|
|
|
27
26
|
alias_method :manage?, :manage
|
|
28
27
|
alias_method :format?, :format
|
|
29
28
|
alias_method :use_lvm?, :use_lvm
|
|
30
|
-
alias_method :partition?, :partition
|
|
31
29
|
alias_method :enabled?, :enabled
|
|
32
30
|
|
|
33
31
|
def initialize
|
|
@@ -38,7 +36,6 @@ module VagrantPlugins
|
|
|
38
36
|
@format = true
|
|
39
37
|
@use_lvm = true
|
|
40
38
|
@enabled = false
|
|
41
|
-
@partition = true
|
|
42
39
|
@location = UNSET_VALUE
|
|
43
40
|
@mountname = UNSET_VALUE
|
|
44
41
|
@mountpoint = UNSET_VALUE
|
|
@@ -57,33 +54,31 @@ module VagrantPlugins
|
|
|
57
54
|
@manage = true if @manage == UNSET_VALUE
|
|
58
55
|
@format = true if @format == UNSET_VALUE
|
|
59
56
|
@use_lvm = true if @use_lvm == UNSET_VALUE
|
|
60
|
-
@partition = true if @partition == UNSET_VALUE
|
|
61
57
|
@enabled = false if @enabled == UNSET_VALUE
|
|
62
|
-
@location =
|
|
63
|
-
@mountname =
|
|
64
|
-
@mountpoint =
|
|
65
|
-
@mountoptions =
|
|
66
|
-
@diskdevice =
|
|
67
|
-
@filesystem =
|
|
68
|
-
@volgroupname =
|
|
69
|
-
|
|
58
|
+
@location = 0 if @location == UNSET_VALUE
|
|
59
|
+
@mountname = 0 if @mountname == UNSET_VALUE
|
|
60
|
+
@mountpoint = 0 if @mountpoint == UNSET_VALUE
|
|
61
|
+
@mountoptions = 0 if @mountoptions == UNSET_VALUE
|
|
62
|
+
@diskdevice = 0 if @diskdevice == UNSET_VALUE
|
|
63
|
+
@filesystem = 0 if @filesystem == UNSET_VALUE
|
|
64
|
+
@volgroupname = 0 if @volgroupname == UNSET_VALUE
|
|
65
|
+
@drive_letter = 0 if @drive_letter == UNSET_VALUE
|
|
70
66
|
@part_type_code = "8e" if @part_type_code == UNSET_VALUE
|
|
71
67
|
end
|
|
72
68
|
|
|
73
69
|
def validate(machine)
|
|
74
|
-
errors =
|
|
70
|
+
errors = []
|
|
75
71
|
|
|
76
72
|
errors << validate_bool('persistent_storage.create', @create)
|
|
77
73
|
errors << validate_bool('persistent_storage.mount', @mount)
|
|
78
|
-
errors << validate_bool('persistent_storage.
|
|
79
|
-
errors << validate_bool('persistent_storage.
|
|
80
|
-
errors << validate_bool('persistent_storage.
|
|
81
|
-
errors << validate_bool('persistent_storage.
|
|
82
|
-
errors << validate_bool('persistent_storage.partition', @partition)
|
|
74
|
+
errors << validate_bool('persistent_storage.mount', @manage)
|
|
75
|
+
errors << validate_bool('persistent_storage.mount', @format)
|
|
76
|
+
errors << validate_bool('persistent_storage.mount', @use_lvm)
|
|
77
|
+
errors << validate_bool('persistent_storage.mount', @enabled)
|
|
83
78
|
errors.compact!
|
|
84
79
|
|
|
85
|
-
if !machine.config.persistent_storage.size.kind_of?(
|
|
86
|
-
errors << I18n.t('vagrant_persistent_storage.config.
|
|
80
|
+
if !machine.config.persistent_storage.size.kind_of?(String)
|
|
81
|
+
errors << I18n.t('vagrant_persistent_storage.config.not_a_string', {
|
|
87
82
|
:config_key => 'persistent_storage.size',
|
|
88
83
|
:is_class => size.class.to_s,
|
|
89
84
|
})
|
|
@@ -126,21 +121,19 @@ module VagrantPlugins
|
|
|
126
121
|
end
|
|
127
122
|
|
|
128
123
|
mount_point_path = Pathname.new("#{machine.config.persistent_storage.location}")
|
|
129
|
-
if !
|
|
124
|
+
if ! mount_point_path.absolute?
|
|
130
125
|
errors << I18n.t('vagrant_persistent_storage.config.not_a_path', {
|
|
131
126
|
:config_key => 'persistent_storage.location',
|
|
132
127
|
:is_path => location.class.to_s,
|
|
133
128
|
})
|
|
134
129
|
end
|
|
135
130
|
|
|
131
|
+
{ 'Persistent Storage configuration' => errors }
|
|
132
|
+
|
|
136
133
|
if ! File.exists?@location.to_s and ! @create == "true"
|
|
137
|
-
|
|
138
|
-
:config_key => 'persistent_storage.create',
|
|
139
|
-
:is_path => location.class.to_s,
|
|
140
|
-
})
|
|
134
|
+
return { "location" => ["file doesn't exist, and create set to false"] }
|
|
141
135
|
end
|
|
142
|
-
|
|
143
|
-
{ 'Persistent Storage configuration' => errors }
|
|
136
|
+
{}
|
|
144
137
|
end
|
|
145
138
|
|
|
146
139
|
private
|
|
@@ -14,7 +14,6 @@ module VagrantPlugins
|
|
|
14
14
|
fs_type = m.config.persistent_storage.filesystem
|
|
15
15
|
manage = m.config.persistent_storage.manage
|
|
16
16
|
use_lvm = m.config.persistent_storage.use_lvm
|
|
17
|
-
partition = m.config.persistent_storage.partition
|
|
18
17
|
mount = m.config.persistent_storage.mount
|
|
19
18
|
format = m.config.persistent_storage.format
|
|
20
19
|
part_type_code = m.config.persistent_storage.part_type_code
|
|
@@ -47,7 +46,6 @@ module VagrantPlugins
|
|
|
47
46
|
if os == "windows"
|
|
48
47
|
## shell script for windows to create NTFS partition and assign drive letter
|
|
49
48
|
disk_operations_template = ERB.new <<-EOF
|
|
50
|
-
<% if partition == true %>
|
|
51
49
|
<% if format == true %>
|
|
52
50
|
foreach ($disk in get-wmiobject Win32_DiskDrive -Filter "Partitions = 0"){
|
|
53
51
|
$disk.DeviceID
|
|
@@ -55,13 +53,11 @@ module VagrantPlugins
|
|
|
55
53
|
"select disk "+$disk.Index+"`r clean`r create partition primary`r format fs=ntfs unit=65536 quick`r active`r assign #{drive_letter}" | diskpart >> disk_operation_log.txt
|
|
56
54
|
}
|
|
57
55
|
<% end %>
|
|
58
|
-
<% end %>
|
|
59
56
|
EOF
|
|
60
57
|
else
|
|
61
58
|
## shell script to format disk, create/manage LVM, mount disk
|
|
62
59
|
disk_operations_template = ERB.new <<-EOF
|
|
63
60
|
#!/bin/bash
|
|
64
|
-
<% if partition == true %>
|
|
65
61
|
# fdisk the disk if it's not a block device already:
|
|
66
62
|
re='[0-9][.][0-9.]*[0-9.]*'; [[ $(sfdisk --version) =~ $re ]] && version="${BASH_REMATCH}"
|
|
67
63
|
if ! awk -v ver="$version" 'BEGIN { if (ver < 2.26 ) exit 1; }'; then
|
|
@@ -70,15 +66,13 @@ else
|
|
|
70
66
|
[ -b #{disk_dev}1 ] || echo ,,#{part_type_code} | sfdisk #{disk_dev}
|
|
71
67
|
fi
|
|
72
68
|
echo "fdisk returned: $?" >> disk_operation_log.txt
|
|
73
|
-
disk_dev=#{disk_dev}1
|
|
74
|
-
<% end %>
|
|
75
69
|
|
|
76
70
|
<% if use_lvm == true %>
|
|
77
71
|
# Create the physical volume if it doesn't already exist:
|
|
78
|
-
[[ `pvs #{disk_dev}` ]] || pvcreate #{disk_dev}
|
|
72
|
+
[[ `pvs #{disk_dev}1` ]] || pvcreate #{disk_dev}1
|
|
79
73
|
echo "pvcreate returned: $?" >> disk_operation_log.txt
|
|
80
74
|
# Create the volume group if it doesn't already exist:
|
|
81
|
-
[[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}
|
|
75
|
+
[[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}1
|
|
82
76
|
echo "vgcreate returned: $?" >> disk_operation_log.txt
|
|
83
77
|
# Create the logical volume if it doesn't already exist:
|
|
84
78
|
[[ `lvs #{vg_name} | grep #{mnt_name}` ]] || lvcreate -l 100%FREE -n #{mnt_name} #{vg_name}
|
|
@@ -90,7 +84,7 @@ echo "vg activation returned: $?" >> disk_operation_log.txt
|
|
|
90
84
|
|
|
91
85
|
<% if format == true %>
|
|
92
86
|
# Create the filesytem if it doesn't already exist
|
|
93
|
-
MNT_NAME=#{
|
|
87
|
+
MNT_NAME=#{mnt_name}
|
|
94
88
|
[[ `blkid | grep ${MNT_NAME:0:16} | grep #{fs_type}` ]] || mkfs.#{fs_type} -L #{mnt_name} #{device}
|
|
95
89
|
echo "#{fs_type} creation return: $?" >> disk_operation_log.txt
|
|
96
90
|
<% if mount == true %>
|
data/locales/en.yml
CHANGED
|
@@ -9,7 +9,4 @@ en:
|
|
|
9
9
|
manage_storage: "** Managing persistent storage **"
|
|
10
10
|
config:
|
|
11
11
|
not_a_bool: "A value for %{config_key} can only be true or false, not type '%{value}'"
|
|
12
|
-
not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{
|
|
13
|
-
not_a_string: "A value for %{config_key} must be a String, not type '%{value}'"
|
|
14
|
-
not_a_path: "A value for %{config_key} must be resolveable as a path"
|
|
15
|
-
not_a_number: "A value for %{config_key} must be a number, not type '%{value}'"
|
|
12
|
+
not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{is_class}'"
|