vagrant-persistent-storage 0.0.26 → 0.0.27

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: '09e3185b33a92af6417f243a9a97a9700454d6ec'
4
- data.tar.gz: af58114b16a94ef9cc42a31c4c5e722f19089bad
3
+ metadata.gz: 6c5cb664b3afdb9c69f0edbac2f802170c976a53
4
+ data.tar.gz: 0b638147e494cf69fbd22e3be9cee7115f2d7b69
5
5
  SHA512:
6
- metadata.gz: 8c9c5b44a06a81f037fd6ddfee6ecdf38a1537b195c8d114429fd79fc012d148b51f6976e235f27633fb277c2e27256e6f1a6f459d0d445e9340a74e964bfe91
7
- data.tar.gz: 15f09d640c8226735addf1be3d2cb91538755b5da577957ebef05297b966a21a54a631369c005e6f07cb793fad24046215fe0ebeb6445d24a39669f6aaac7d43
6
+ metadata.gz: 29768973693d388e28076d0e4553201843085a44c957225d2e4b46049fecc5a009b11a11284aea1fa27b85bb592f7af42c09e68cbeb6d65412bae41c719ea021
7
+ data.tar.gz: 789a035b9d325f30b0b0eb79a88cc2d2307af0e90c0353ff00d6b0a9b0a28759d50724b8f57ada8425501aafa38d50281bdf5f7555932bacf450ebba4cf27968
data/README.md CHANGED
@@ -34,29 +34,46 @@ 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
+
71
+ ## Optional settings
72
+
73
+ ```ruby
74
+ config.persistent_storage.part_type_code = '82'
75
+ ```
76
+
60
77
  ## Troubleshooting
61
78
 
62
79
  If your box are not using LVM you must set `config.persistent_storage.use_lvm = false`.
@@ -82,6 +99,8 @@ If your box are not using LVM you must set `config.persistent_storage.use_lvm =
82
99
  * [Chen Yu Pao](https://github.com/windperson)
83
100
  * [Kris Reese](https://github.com/ktreese)
84
101
  * [Henry N.](https://github.com/HenryNe)
102
+ * [fredleger](https://github.com/fredleger)
103
+ * [Sebastian Wendel](https://github.com/sourceindex)
85
104
 
86
105
  ## TODO
87
106
 
@@ -15,16 +15,19 @@ 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
21
- attr_accessor :drive_letter
22
+ attr_accessor :drive_letter
23
+ attr_accessor :part_type_code
22
24
 
23
25
  alias_method :create?, :create
24
26
  alias_method :mount?, :mount
25
27
  alias_method :manage?, :manage
26
28
  alias_method :format?, :format
27
29
  alias_method :use_lvm?, :use_lvm
30
+ alias_method :partition?, :partition
28
31
  alias_method :enabled?, :enabled
29
32
 
30
33
  def initialize
@@ -35,6 +38,7 @@ module VagrantPlugins
35
38
  @format = true
36
39
  @use_lvm = true
37
40
  @enabled = false
41
+ @partition = true
38
42
  @location = UNSET_VALUE
39
43
  @mountname = UNSET_VALUE
40
44
  @mountpoint = UNSET_VALUE
@@ -42,7 +46,8 @@ module VagrantPlugins
42
46
  @diskdevice = UNSET_VALUE
43
47
  @filesystem = UNSET_VALUE
44
48
  @volgroupname = UNSET_VALUE
45
- @drive_letter = UNSET_VALUE
49
+ @drive_letter = UNSET_VALUE
50
+ @part_type_code = UNSET_VALUE
46
51
  end
47
52
 
48
53
  def finalize!
@@ -52,30 +57,33 @@ module VagrantPlugins
52
57
  @manage = true if @manage == UNSET_VALUE
53
58
  @format = true if @format == UNSET_VALUE
54
59
  @use_lvm = true if @use_lvm == UNSET_VALUE
60
+ @partition = true if @partition == UNSET_VALUE
55
61
  @enabled = false if @enabled == UNSET_VALUE
56
- @location = 0 if @location == UNSET_VALUE
57
- @mountname = 0 if @mountname == UNSET_VALUE
58
- @mountpoint = 0 if @mountpoint == UNSET_VALUE
59
- @mountoptions = 0 if @mountoptions == UNSET_VALUE
60
- @diskdevice = 0 if @diskdevice == UNSET_VALUE
61
- @filesystem = 0 if @filesystem == UNSET_VALUE
62
- @volgroupname = 0 if @volgroupname == UNSET_VALUE
63
- @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
70
+ @part_type_code = "8e" if @part_type_code == UNSET_VALUE
64
71
  end
65
72
 
66
73
  def validate(machine)
67
- errors = []
74
+ errors = _detected_errors
68
75
 
69
76
  errors << validate_bool('persistent_storage.create', @create)
70
77
  errors << validate_bool('persistent_storage.mount', @mount)
71
- errors << validate_bool('persistent_storage.mount', @manage)
72
- errors << validate_bool('persistent_storage.mount', @format)
73
- errors << validate_bool('persistent_storage.mount', @use_lvm)
74
- 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)
75
83
  errors.compact!
76
84
 
77
- if !machine.config.persistent_storage.size.kind_of?(String)
78
- 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', {
79
87
  :config_key => 'persistent_storage.size',
80
88
  :is_class => size.class.to_s,
81
89
  })
@@ -110,6 +118,12 @@ module VagrantPlugins
110
118
  :is_class => filesystem.class.to_s,
111
119
  })
112
120
  end
121
+ if !machine.config.persistent_storage.volgroupname.part_type_code?(String)
122
+ errors << I18n.t('vagrant_persistent_storage.config.not_a_string', {
123
+ :config_key => 'persistent_storage.part_type_code',
124
+ :is_class => volgroupname.class.to_s,
125
+ })
126
+ end
113
127
  if !machine.config.persistent_storage.volgroupname.kind_of?(String)
114
128
  errors << I18n.t('vagrant_persistent_storage.config.not_a_string', {
115
129
  :config_key => 'persistent_storage.volgroupname',
@@ -118,19 +132,21 @@ module VagrantPlugins
118
132
  end
119
133
 
120
134
  mount_point_path = Pathname.new("#{machine.config.persistent_storage.location}")
121
- if ! mount_point_path.absolute?
135
+ if ! (mount_point_path.absolute? || mount_point_path.relative?)
122
136
  errors << I18n.t('vagrant_persistent_storage.config.not_a_path', {
123
137
  :config_key => 'persistent_storage.location',
124
138
  :is_path => location.class.to_s,
125
139
  })
126
140
  end
127
141
 
128
- { 'Persistent Storage configuration' => errors }
129
-
130
142
  if ! File.exists?@location.to_s and ! @create == "true"
131
- return { "location" => ["file doesn't exist, and create set to false"] }
143
+ errors << I18n.t('vagrant_persistent_storage.config.no_create_and_missing', {
144
+ :config_key => 'persistent_storage.create',
145
+ :is_path => location.class.to_s,
146
+ })
132
147
  end
133
- {}
148
+
149
+ { 'Persistent Storage configuration' => errors }
134
150
  end
135
151
 
136
152
  private
@@ -14,8 +14,10 @@ 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
20
+ part_type_code = m.config.persistent_storage.part_type_code
19
21
 
20
22
  ## windows filesystem options
21
23
  drive_letter = m.config.persistent_storage.drive_letter
@@ -45,6 +47,7 @@ module VagrantPlugins
45
47
  if os == "windows"
46
48
  ## shell script for windows to create NTFS partition and assign drive letter
47
49
  disk_operations_template = ERB.new <<-EOF
50
+ <% if partition == true %>
48
51
  <% if format == true %>
49
52
  foreach ($disk in get-wmiobject Win32_DiskDrive -Filter "Partitions = 0"){
50
53
  $disk.DeviceID
@@ -52,26 +55,30 @@ module VagrantPlugins
52
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
53
56
  }
54
57
  <% end %>
58
+ <% end %>
55
59
  EOF
56
60
  else
57
61
  ## shell script to format disk, create/manage LVM, mount disk
58
62
  disk_operations_template = ERB.new <<-EOF
59
63
  #!/bin/bash
64
+ <% if partition == true %>
60
65
  # fdisk the disk if it's not a block device already:
61
66
  re='[0-9][.][0-9.]*[0-9.]*'; [[ $(sfdisk --version) =~ $re ]] && version="${BASH_REMATCH}"
62
67
  if ! awk -v ver="$version" 'BEGIN { if (ver < 2.26 ) exit 1; }'; then
63
- [ -b #{disk_dev}1 ] || echo 0,,8e | sfdisk #{disk_dev}
68
+ [ -b #{disk_dev}1 ] || echo 0,,#{part_type_code} | sfdisk #{disk_dev}
64
69
  else
65
- [ -b #{disk_dev}1 ] || echo ,,8e | sfdisk #{disk_dev}
70
+ [ -b #{disk_dev}1 ] || echo ,,#{part_type_code} | sfdisk #{disk_dev}
66
71
  fi
67
72
  echo "fdisk returned: $?" >> disk_operation_log.txt
73
+ disk_dev=#{disk_dev}1
74
+ <% end %>
68
75
 
69
76
  <% if use_lvm == true %>
70
77
  # Create the physical volume if it doesn't already exist:
71
- [[ `pvs #{disk_dev}1` ]] || pvcreate #{disk_dev}1
78
+ [[ `pvs #{disk_dev}` ]] || pvcreate #{disk_dev}
72
79
  echo "pvcreate returned: $?" >> disk_operation_log.txt
73
80
  # Create the volume group if it doesn't already exist:
74
- [[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}1
81
+ [[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}
75
82
  echo "vgcreate returned: $?" >> disk_operation_log.txt
76
83
  # Create the logical volume if it doesn't already exist:
77
84
  [[ `lvs #{vg_name} | grep #{mnt_name}` ]] || lvcreate -l 100%FREE -n #{mnt_name} #{vg_name}
@@ -83,7 +90,7 @@ echo "vg activation returned: $?" >> disk_operation_log.txt
83
90
 
84
91
  <% if format == true %>
85
92
  # Create the filesytem if it doesn't already exist
86
- MNT_NAME=#{mnt_name}
93
+ MNT_NAME=#{vg_name}-#{mnt_name}
87
94
  [[ `blkid | grep ${MNT_NAME:0:16} | grep #{fs_type}` ]] || mkfs.#{fs_type} -L #{mnt_name} #{device}
88
95
  echo "#{fs_type} creation return: $?" >> disk_operation_log.txt
89
96
  <% if mount == true %>
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module PersistentStorage
3
- VERSION = "0.0.26"
3
+ VERSION = "0.0.27"
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,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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Kusnier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-06-19 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.1
92
+ rubygems_version: 2.6.12
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