vagrant-libcloud-helper 0.0.1

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: 521337bb97a99df321e636a28da41573a23f233c
4
+ data.tar.gz: 83f91feb8cff450f4a06b85d7b6235a3a59c60c5
5
+ SHA512:
6
+ metadata.gz: 77178efe6e9d3953e111487f02f1daa617f78f44d45b35fcfc02f49e00153f2720b6e49be295f984f0f359b4717660edde4b5a5cbd269f2245044a36ff403c37
7
+ data.tar.gz: c4a8778c1cc0e4a44b0e835c649186128f6c5dcb1cb2c78125bdcc705986ebb494114fbb260c0cb2763db0b4189344a197c4f3e7bcd299a2aac669bf8d7a12c5
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .vagrant
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ gem "yard"
6
+ end
7
+
8
+ group :plugins do
9
+ gem "vagrant-libcloud-helper", path: "."
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Carlos Valiente
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # vagrant-libcloud-helper
2
+
3
+ A [Vagrant](http://www.vagrantup.com/) plugin used by
4
+ [libcloud-vagrant](https://github.com/carletes/libcloud-vagrant) to help
5
+ setting up VirtualBox instances.
6
+
7
+ At the moment only VirtualBox instances are supported.
8
+
9
+ `vagrant-libcloud-helper` does the following to your VirtualBox Vagrant
10
+ boxes:
11
+
12
+ * Allocate all SATA ports of the first SATA interface, so that disks may be
13
+ hot-plugged once the machine is up.
14
+
15
+ ## Installation
16
+
17
+ Like all Vagrant plugins:
18
+
19
+ ```sh
20
+ vagrant plugin install vagrant-libcloud-helper
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ If you want to use this plugin outside
26
+ [libcloud-vagrant](https://github.com/carletes/libcloud-vagrant), you just
27
+ need to enable the bits you want.
28
+
29
+ The following `Vagrantfile` snippet activates the allocation of all SATA
30
+ ports:
31
+
32
+ ```ruby
33
+ Vagrant.configure("2") do |config|
34
+
35
+ if Vagrant.has_plugin?("vagrant-libcloud-helper")
36
+ config.libcloud_helper.allocate_sata_ports = true
37
+ end
38
+
39
+ # [..]
40
+ end
41
+ ```
42
+
43
+ ## Compatibility
44
+
45
+ This plugin has been tested under 64-bit Linux with:
46
+
47
+ * Vagrant 1.6.3
48
+ * VirtualBox 4.3.14
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ Bundler::GemHelper.install_tasks
data/Vagrantfile ADDED
@@ -0,0 +1,25 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+
6
+ # This plugin must be explicitly enabled. Do it like this:
7
+ config.libcloud_helper.allocate_sata_ports = true
8
+
9
+ config.vm.define "precise64" do |n|
10
+ n.vm.hostname = "precise64"
11
+ n.vm.box = "hashicorp/precise64"
12
+ end
13
+
14
+ # Test on a non-Linux box. This one, for instance, has no SATA adapter.
15
+ config.vm.define "openbsd55" do |n|
16
+ n.vm.hostname = "openbsd55"
17
+ n.vm.box = "tmatilai/openbsd-5.5"
18
+
19
+ # This Vagrant box does not boot when the host is behind an HTTP/FTPs
20
+ # proxy, beacuse Vagrant tries to install the OpenBSD package ``rsync``
21
+ # in order to implement rsync shared folders, which are the default.
22
+ # We disable them anyway, since we do not need them for this demo.
23
+ n.vm.synced_folder ".", "/vagrant", disabled: true
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ module VagrantPlugins
2
+ module LibcloudHelper
3
+ module Action
4
+ class AllocateSataPorts
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ @machine = env[:machine]
9
+ end
10
+
11
+ def call(env)
12
+ return @app.call(env) if @machine.state.id != :poweroff && [:up].include?(env[:machine_action])
13
+
14
+ if env[:machine].config.libcloud_helper.allocate_sata_ports
15
+ env[:ui].info "Allocating SATA ports"
16
+ env[:machine].provider.driver.allocate_sata_ports
17
+ end
18
+
19
+ @app.call(env)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant/action/builder"
2
+ require "vagrant-libcloud-helper/action"
3
+
4
+ module VagrantPlugins
5
+ module LibcloudHelper
6
+ module Action
7
+ include Vagrant::Action::Builtin
8
+
9
+ autoload :AllocateSataPorts, File.expand_path("../action/allocate_sata_ports.rb", __FILE__)
10
+
11
+ def self.allocate_sata_ports
12
+ Vagrant::Action::Builder.new.tap do |builder|
13
+ builder.use ConfigValidate
14
+ builder.use AllocateSataPorts
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module VagrantPlugins
2
+ module LibcloudHelper
3
+ class Config < Vagrant.plugin("2", :config)
4
+
5
+ attr_accessor :allocate_sata_ports
6
+
7
+ alias_method :allocate_sata_ports?, :allocate_sata_ports
8
+
9
+ def initialize
10
+ @allocate_sata_ports = UNSET_VALUE
11
+ end
12
+
13
+ def finalize!
14
+ @allocate_sata_ports = false if @allocate_sata_ports == UNSET_VALUE
15
+ end
16
+
17
+ def validate(machine)
18
+ {}
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module LibcloudHelper
5
+ class Plugin < Vagrant.plugin("2")
6
+
7
+ include Vagrant::Action::Builtin
8
+
9
+ require_relative "action"
10
+ require_relative "providers/virtualbox/driver/base"
11
+ require_relative "providers/virtualbox/driver/meta"
12
+
13
+ name "libcloud_helper"
14
+
15
+ config "libcloud_helper" do
16
+ require_relative "config"
17
+ Config
18
+ end
19
+
20
+ action_hook(:libcloud_helper, :machine_action_up) do |hook|
21
+ hook.after VagrantPlugins::ProviderVirtualBox::Action::Customize,
22
+ VagrantPlugins::LibcloudHelper::Action.allocate_sata_ports
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ module VagrantPlugins
2
+ module ProviderVirtualBox
3
+ module Driver
4
+ class Base
5
+
6
+ def allocate_sata_ports
7
+ controller = get_sata_controller_name
8
+ portcount = 30
9
+ if controller.nil?
10
+ controller = "SATA Controller"
11
+ @logger.info("Creating SATA controller '#{controller}' with #{portcount} ports")
12
+ execute("storagectl", @uuid, "--name", controller, "--portcount", portcount.to_s,
13
+ "--add", "sata", "--bootable", "off")
14
+ else
15
+ @logger.info("Allocating #{portcount} ports in SATA controller '#{controller}'")
16
+ execute("storagectl", @uuid, "--name", controller, "--portcount", portcount.to_s)
17
+ end
18
+ end
19
+
20
+ def get_sata_controller_name
21
+ controllers = Hash.new
22
+ info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
23
+ info.split("\n").each do |line|
24
+ controllers[$1] = $2 if line =~ /^storagecontrollername(\d+)="(.*)"/
25
+ sata_controller_number = $1 if line =~ /^storagecontrollertype(\d+)="IntelAhci"/
26
+ return controllers[sata_controller_number] unless controllers[sata_controller_number].nil?
27
+ end
28
+ return nil
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module ProviderVirtualBox
3
+ module Driver
4
+
5
+ class Meta
6
+
7
+ def_delegators :@driver,
8
+ :allocate_sata_ports
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module LibcloudHelper
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "vagrant-libcloud-helper/plugin"
2
+ require "vagrant-libcloud-helper/version"
3
+
4
+ module VagrantPlugins
5
+ module LibcloudHelper
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-libcloud-helper/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "vagrant-libcloud-helper"
8
+ s.version = VagrantPlugins::LibcloudHelper::VERSION
9
+ s.authors = ["Carlos Valiente"]
10
+ s.email = ["carlos@pepelabs.net"]
11
+ s.description = "A Vagrant plugin used by libcloud-vagrant"
12
+ s.summary = "This plugins performs low-level changes to the life-cycle of Virtualbox guests"
13
+ s.homepage = "https://github.com/carletes/vagrant-libcloud-helper"
14
+ s.license = "MIT"
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_path = "lib"
20
+
21
+ s.add_development_dependency "bundler", "~> 1.3"
22
+ s.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-libcloud-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Valiente
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-11 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Vagrant plugin used by libcloud-vagrant
42
+ email:
43
+ - carlos@pepelabs.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - Vagrantfile
54
+ - lib/vagrant-libcloud-helper.rb
55
+ - lib/vagrant-libcloud-helper/action.rb
56
+ - lib/vagrant-libcloud-helper/action/allocate_sata_ports.rb
57
+ - lib/vagrant-libcloud-helper/config.rb
58
+ - lib/vagrant-libcloud-helper/plugin.rb
59
+ - lib/vagrant-libcloud-helper/providers/virtualbox/driver/base.rb
60
+ - lib/vagrant-libcloud-helper/providers/virtualbox/driver/meta.rb
61
+ - lib/vagrant-libcloud-helper/version.rb
62
+ - vagrant-libcloud-helper.gemspec
63
+ homepage: https://github.com/carletes/vagrant-libcloud-helper
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.3
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: This plugins performs low-level changes to the life-cycle of Virtualbox guests
87
+ test_files: []
88
+ has_rdoc: