vagrant-persistent-storage 0.0.30 → 0.0.31

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: e93eed001f93535a8e8069607d2b30abd21d861c
4
- data.tar.gz: 7346c8a8a43be4ec4467f3a49f7174f5a788f1f6
3
+ metadata.gz: 0d9d22a1bec8197414b406c3052a2d5116e6dd2e
4
+ data.tar.gz: 0c67c81eec1e5e7513ccd673ae139d5e719112aa
5
5
  SHA512:
6
- metadata.gz: ec37b18e0e91cf430e87c3de749f46aa91364002ac380eb8a11650c663af4cc238db9863546e9848d151a168d58c72e2e512678fc98ff37b681e5ad931dba54f
7
- data.tar.gz: 76082422fcf9f95bdefd6543f922b174a932745ea542d11f85f4b2ad01e8d4ed004736c0246429ba8e5df7f695522de08e5839b320386d81b3eb61ae97f1688d
6
+ metadata.gz: 6617e8ead133179367c0eca3d31f8f49dc0271d721f16fa3b80bed8e8d5a4d0e7080fe8c43d4cbe306734836a16944e87218d0fa67cc7db2f0f3d720eaee9b2c
7
+ data.tar.gz: bbef6c0ab85e08dc39b9fd94c2d30e5887af7af63b5bbd960b7b800d982acdcad8a093a3937d31e3d3e95726f22bde01511e3b7968ec3616443638f2c0e4b02f
data/README.md CHANGED
@@ -34,29 +34,40 @@ 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
- ```
37
+ ```ruby
38
38
  config.persistent_storage.diskdevice = '/dev/sdc'
39
39
  ```
40
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
44
+ ```
45
+
41
46
  Every `vagrant up` will attach this file as hard disk to the guest machine.
42
- An `vagrant destroy` will detach the storage to avoid deletion of the storage by vagrant.
47
+ A `vagrant destroy` will detach the storage to avoid deletion of the storage by vagrant.
43
48
  A `vagrant destroy` generally destroys all attached drives. See [VBoxMange unregistervm --delete option][vboxmanage_delete].
44
49
 
45
50
  The disk is initialized and added to it's own volume group as specfied in the config;
46
51
  this defaults to 'vagrant'. An ext4 filesystem is created and the disk mounted appropriately,
47
- with entries added to fstab ... subsequent runs will mount this disk with the options specified
52
+ with entries added to fstab ... subsequent runs will mount this disk with the options specified.
48
53
 
49
54
  ## Windows Guests
50
55
 
51
56
  Windows Guests must use the WinRM communicator by setting `vm.communicator = 'winrm'`. An additional option is provided to
52
57
  allow you to set the drive letter using:
53
58
 
54
- ```
59
+ ```ruby
55
60
  config.persistent_storage.drive_letter = 'Z'
56
61
  ```
57
62
 
58
63
  Options that are irrelevent to Windows are ignored, such as `mountname`, `filesystem`, `mountpoint` and `volgroupname`.
59
64
 
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
+
60
71
  ## Optional settings
61
72
 
62
73
  ```ruby
@@ -15,6 +15,7 @@ module VagrantPlugins
15
15
  attr_accessor :mountname
16
16
  attr_accessor :mountpoint
17
17
  attr_accessor :mountoptions
18
+ attr_accessor :partition
18
19
  attr_accessor :diskdevice
19
20
  attr_accessor :filesystem
20
21
  attr_accessor :volgroupname
@@ -26,6 +27,7 @@ module VagrantPlugins
26
27
  alias_method :manage?, :manage
27
28
  alias_method :format?, :format
28
29
  alias_method :use_lvm?, :use_lvm
30
+ alias_method :partition?, :partition
29
31
  alias_method :enabled?, :enabled
30
32
 
31
33
  def initialize
@@ -36,6 +38,7 @@ module VagrantPlugins
36
38
  @format = true
37
39
  @use_lvm = true
38
40
  @enabled = false
41
+ @partition = true
39
42
  @location = UNSET_VALUE
40
43
  @mountname = UNSET_VALUE
41
44
  @mountpoint = UNSET_VALUE
@@ -54,31 +57,33 @@ module VagrantPlugins
54
57
  @manage = true if @manage == UNSET_VALUE
55
58
  @format = true if @format == UNSET_VALUE
56
59
  @use_lvm = true if @use_lvm == UNSET_VALUE
60
+ @partition = true if @partition == UNSET_VALUE
57
61
  @enabled = false if @enabled == UNSET_VALUE
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
62
+ @location = "" if @location == UNSET_VALUE
63
+ @mountname = "" if @mountname == UNSET_VALUE
64
+ @mountpoint = "" if @mountpoint == UNSET_VALUE
65
+ @mountoptions = [] if @mountoptions == UNSET_VALUE
66
+ @diskdevice = "" if @diskdevice == UNSET_VALUE
67
+ @filesystem = "" if @filesystem == UNSET_VALUE
68
+ @volgroupname = "" if @volgroupname == UNSET_VALUE
69
+ @drive_letter = 0 if @drive_letter == UNSET_VALUE
66
70
  @part_type_code = "8e" if @part_type_code == UNSET_VALUE
67
71
  end
68
72
 
69
73
  def validate(machine)
70
- errors = []
74
+ errors = _detected_errors
71
75
 
72
76
  errors << validate_bool('persistent_storage.create', @create)
73
77
  errors << validate_bool('persistent_storage.mount', @mount)
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)
78
+ errors << validate_bool('persistent_storage.manage', @manage)
79
+ errors << validate_bool('persistent_storage.format', @format)
80
+ errors << validate_bool('persistent_storage.use_lvm', @use_lvm)
81
+ errors << validate_bool('persistent_storage.enabled', @enabled)
82
+ errors << validate_bool('persistent_storage.partition', @partition)
78
83
  errors.compact!
79
84
 
80
- if !machine.config.persistent_storage.size.kind_of?(String)
81
- errors << I18n.t('vagrant_persistent_storage.config.not_a_string', {
85
+ if !machine.config.persistent_storage.size.kind_of?(Fixnum)
86
+ errors << I18n.t('vagrant_persistent_storage.config.not_a_number', {
82
87
  :config_key => 'persistent_storage.size',
83
88
  :is_class => size.class.to_s,
84
89
  })
@@ -121,19 +126,21 @@ module VagrantPlugins
121
126
  end
122
127
 
123
128
  mount_point_path = Pathname.new("#{machine.config.persistent_storage.location}")
124
- if ! mount_point_path.absolute?
129
+ if ! (mount_point_path.absolute? || mount_point_path.relative?)
125
130
  errors << I18n.t('vagrant_persistent_storage.config.not_a_path', {
126
131
  :config_key => 'persistent_storage.location',
127
132
  :is_path => location.class.to_s,
128
133
  })
129
134
  end
130
135
 
131
- { 'Persistent Storage configuration' => errors }
132
-
133
136
  if ! File.exists?@location.to_s and ! @create == "true"
134
- return { "location" => ["file doesn't exist, and create set to false"] }
137
+ errors << I18n.t('vagrant_persistent_storage.config.no_create_and_missing', {
138
+ :config_key => 'persistent_storage.create',
139
+ :is_path => location.class.to_s,
140
+ })
135
141
  end
136
- {}
142
+
143
+ { 'Persistent Storage configuration' => errors }
137
144
  end
138
145
 
139
146
  private
@@ -14,6 +14,7 @@ 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
17
18
  mount = m.config.persistent_storage.mount
18
19
  format = m.config.persistent_storage.format
19
20
  part_type_code = m.config.persistent_storage.part_type_code
@@ -46,6 +47,7 @@ module VagrantPlugins
46
47
  if os == "windows"
47
48
  ## shell script for windows to create NTFS partition and assign drive letter
48
49
  disk_operations_template = ERB.new <<-EOF
50
+ <% if partition == true %>
49
51
  <% if format == true %>
50
52
  foreach ($disk in get-wmiobject Win32_DiskDrive -Filter "Partitions = 0"){
51
53
  $disk.DeviceID
@@ -53,11 +55,13 @@ module VagrantPlugins
53
55
  "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
54
56
  }
55
57
  <% end %>
58
+ <% end %>
56
59
  EOF
57
60
  else
58
61
  ## shell script to format disk, create/manage LVM, mount disk
59
62
  disk_operations_template = ERB.new <<-EOF
60
63
  #!/bin/bash
64
+ <% if partition == true %>
61
65
  # fdisk the disk if it's not a block device already:
62
66
  re='[0-9][.][0-9.]*[0-9.]*'; [[ $(sfdisk --version) =~ $re ]] && version="${BASH_REMATCH}"
63
67
  if ! awk -v ver="$version" 'BEGIN { if (ver < 2.26 ) exit 1; }'; then
@@ -66,13 +70,15 @@ else
66
70
  [ -b #{disk_dev}1 ] || echo ,,#{part_type_code} | sfdisk #{disk_dev}
67
71
  fi
68
72
  echo "fdisk returned: $?" >> disk_operation_log.txt
73
+ disk_dev=#{disk_dev}1
74
+ <% end %>
69
75
 
70
76
  <% if use_lvm == true %>
71
77
  # Create the physical volume if it doesn't already exist:
72
- [[ `pvs #{disk_dev}1` ]] || pvcreate #{disk_dev}1
78
+ [[ `pvs #{disk_dev}` ]] || pvcreate #{disk_dev}
73
79
  echo "pvcreate returned: $?" >> disk_operation_log.txt
74
80
  # Create the volume group if it doesn't already exist:
75
- [[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}1
81
+ [[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}
76
82
  echo "vgcreate returned: $?" >> disk_operation_log.txt
77
83
  # Create the logical volume if it doesn't already exist:
78
84
  [[ `lvs #{vg_name} | grep #{mnt_name}` ]] || lvcreate -l 100%FREE -n #{mnt_name} #{vg_name}
@@ -84,7 +90,7 @@ echo "vg activation returned: $?" >> disk_operation_log.txt
84
90
 
85
91
  <% if format == true %>
86
92
  # Create the filesytem if it doesn't already exist
87
- MNT_NAME=#{mnt_name}
93
+ MNT_NAME=#{vg_name}-#{mnt_name}
88
94
  [[ `blkid | grep ${MNT_NAME:0:16} | grep #{fs_type}` ]] || mkfs.#{fs_type} -L #{mnt_name} #{device}
89
95
  echo "#{fs_type} creation return: $?" >> disk_operation_log.txt
90
96
  <% if mount == true %>
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module PersistentStorage
3
- VERSION = "0.0.30"
3
+ VERSION = "0.0.31"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -9,4 +9,7 @@ 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 '%{is_class}'"
12
+ not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{value}'"
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}'"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-persistent-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Kusnier