vagrant-harddisk 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15eabdbdf1369e1404c61c74bf61ccf93cf6e323
4
+ data.tar.gz: 82a0f16f2d1de01c436e4d65255ab2f89aaa8e69
5
+ SHA512:
6
+ metadata.gz: 4618c1cc89b813a07a776de4c12e6d84ad6a1601639c5138e7c42c3fd535e23bf9623ddf8dce69676f5cc12ff8ab0322db3fccc16c455e2dcb4da469d1d174c4
7
+ data.tar.gz: 8dcf5ee536ec88c1c5fe736aaa5d67cf981d6034f9fe649c9bd2a537246e11f7ca23b66f61c3c2af8980e5f071238487de00130bbe7945826cdd16bac3eb311f
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /vendor/
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /.idea/
12
+ /.vagrant/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "vagrant-parallels"
11
+ gem "vagrant-harddisk", path: "."
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Martin Prebio, 25th-floor GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Vagrant Harddisk Plugin
2
+
3
+ This vagrant plugin creates and formats additional hard disks to use inside the machine.
4
+
5
+ Warning: At the moment this plugin just works with Parallels, and therefore with OS X.
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ $ vagrant plugin install vagrant-harddisk
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ After installing the plugin (see above), add the following code to configure an additional hard disk:
16
+
17
+ ```
18
+ config.harddisk.disks['database'] = {
19
+ :size => '20G',
20
+ :position => 2,
21
+ :interface_type => 'sata',
22
+ :mount_point => '/dbstorage',
23
+ }
24
+ ```
25
+
26
+ Note: mount_point is not used at the moment.
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rake spec` to run the tests.
31
+
32
+ If you want to try your changes with a sample Vagrantfile, just run `bundle exec vagrant up`.
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/25th-floor/vagrant-harddisk.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "rubygems"
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "bundler/setup"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+
10
+ Bundler::GemHelper.install_tasks
data/Vagrantfile ADDED
@@ -0,0 +1,15 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.box = "parallels/ubuntu-14.04"
3
+
4
+ config.harddisk.disks['database'] = {
5
+ :size => '10G',
6
+ :position => 4,
7
+ :interface_type => 'sata',
8
+ :mount_point => '/dbstorage',
9
+ }
10
+ config.harddisk.disks['noInterface'] = {
11
+ :size => '10G',
12
+ :position => 5,
13
+ :mount_point => '/foo',
14
+ }
15
+ end
@@ -0,0 +1,19 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-harddisk/plugin"
4
+ require "vagrant-harddisk/version"
5
+
6
+ module VagrantPlugins
7
+ module Harddisk
8
+ lib_path = Pathname.new(File.expand_path("../vagrant-harddisk", __FILE__))
9
+ autoload :Action, lib_path.join("action")
10
+ autoload :Errors, lib_path.join("errors")
11
+
12
+ # This returns the path to the source of this plugin.
13
+ #
14
+ # @return [Pathname]
15
+ def self.source_root
16
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,2 @@
1
+ module VagrantPlugins::Harddisk::Action
2
+ end
@@ -0,0 +1,30 @@
1
+ module VagrantPlugins
2
+ module Harddisk
3
+ module Action
4
+ class Creation
5
+ def initialize(app, env)
6
+ @app = app
7
+ @machine = env[:machine]
8
+ end
9
+
10
+ def call(env)
11
+ id = @machine.id
12
+
13
+ disks = @machine.config.harddisk.disks
14
+ unless disks.empty?
15
+ disks.each do |name, disk|
16
+ present = system("prlctl list --info #{id} | grep #{disk[:interface_type]}:#{disk[:position]} > /dev/null")
17
+ unless present
18
+ env[:ui].output("Installing hdd #{name}")
19
+ system("prlctl set #{id} --device-add hdd --type expand --size #{disk[:size]} --position #{disk[:position]} --iface #{disk[:interface_type]}")
20
+ end
21
+ end
22
+ end
23
+
24
+ # Continue provisioning
25
+ @app.call(env)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Harddisk
5
+ class Config < Vagrant.plugin("2", :config)
6
+ # A list of disk specifications.
7
+ #
8
+ # @return [???]
9
+ attr_accessor :disks
10
+
11
+ def initialize
12
+ @disks = Hash[]
13
+ end
14
+
15
+ def finalize!
16
+ @disks.each do |name, disk|
17
+ unless disk.key?(:size)
18
+ raise Vagrant::Errors::VagrantError.new, "Harddisk '#{name}' is missing required attribute: 'size'"
19
+ end
20
+ unless disk.key?(:position)
21
+ raise Vagrant::Errors::VagrantError.new, "Harddisk '#{name}' is missing required attribute: 'position'"
22
+ end
23
+ unless disk.key?(:mount_point)
24
+ raise Vagrant::Errors::VagrantError.new, "Harddisk '#{name}' is missing required attribute: 'mount_point'"
25
+ end
26
+ unless disk.key?(:interface_type)
27
+ disk[:interface_type] = 'sata'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant AWS plugin must be run within Vagrant."
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < "1.8.4"
10
+ raise "The Vagrant Compose plugin is only compatible with Vagrant 1.8.4+"
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module Harddisk
15
+ class Plugin < Vagrant.plugin("2")
16
+ name "Harddisk"
17
+ description <<-DESC
18
+ Creates additional harddisks in vagrant machines.
19
+ DESC
20
+
21
+ config "harddisk" do
22
+ require_relative "config"
23
+ Config
24
+ end
25
+
26
+ action_hook 'harddiskCreation' do |hook|
27
+ require_relative 'action/creation'
28
+ hook.before Vagrant::Action::Builtin::Provision, Action::Creation
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Harddisk
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-harddisk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-harddisk"
8
+ spec.version = VagrantPlugins::Harddisk::VERSION
9
+ spec.authors = ["Martin Prebio"]
10
+ spec.email = ["martin.prebio@gmail.com"]
11
+
12
+ spec.summary = "Creates additional harddisks in vagrant machines."
13
+ spec.description = "Creates additional harddisks in vagrant machines."
14
+ spec.homepage = "https://github.com/25th-floor/vagrant-harddisk"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 11.0"
24
+ spec.add_development_dependency "rspec", "~> 3.5"
25
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-harddisk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martin Prebio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ description: Creates additional harddisks in vagrant machines.
56
+ email:
57
+ - martin.prebio@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - Vagrantfile
70
+ - lib/vagrant-harddisk.rb
71
+ - lib/vagrant-harddisk/action.rb
72
+ - lib/vagrant-harddisk/action/creation.rb
73
+ - lib/vagrant-harddisk/config.rb
74
+ - lib/vagrant-harddisk/plugin.rb
75
+ - lib/vagrant-harddisk/version.rb
76
+ - vagrant-harddisk.gemspec
77
+ homepage: https://github.com/25th-floor/vagrant-harddisk
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.5.1
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Creates additional harddisks in vagrant machines.
101
+ test_files: []