vagrant-openvz 0.0.4 → 0.0.6
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.
- data/README.md +5 -4
- data/Vagrantfile +10 -9
- data/lib/vagrant-openvz/action/boot.rb +19 -13
- data/lib/vagrant-openvz/action/fetch_ip.rb +6 -2
- data/lib/vagrant-openvz/config.rb +2 -1
- data/lib/vagrant-openvz/driver/cli.rb +10 -0
- data/lib/vagrant-openvz/driver.rb +10 -0
- data/lib/vagrant-openvz/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
#### LINUX ONLY TECHNOLOGY.
|
6
6
|
|
7
|
-
This is provider plugin for vagrant. The provider integrates [OpenVZ](http://openvz.org/Main_Page) with the normal actions associated with vagrant including: up, ssh, halt, destroy.
|
7
|
+
This is a provider plugin for vagrant. The provider integrates [OpenVZ](http://openvz.org/Main_Page) with the normal actions associated with vagrant including: up, ssh, halt, destroy.
|
8
8
|
|
9
9
|
Successfully used in combination with the following vagrant plugins:
|
10
10
|
|
@@ -50,9 +50,10 @@ During development on Centos 6(.4), in order to use: "bundle exec vagrant box ad
|
|
50
50
|
|
51
51
|
## ROADMAP (Features not yet added).
|
52
52
|
|
53
|
-
*
|
54
|
-
*
|
55
|
-
*
|
53
|
+
* OpenVZ focused: [Virtual Ethernet devices](http://openvz.org/Virtual_Ethernet_device).
|
54
|
+
* Vagrant focused: Port Forwarding.
|
55
|
+
* Vagrant focuused: Improve usage of env[:ui] logging.
|
56
|
+
* Vagrant focused: Tokenize all hardcoded text.
|
56
57
|
|
57
58
|
## Credits
|
58
59
|
|
data/Vagrantfile
CHANGED
@@ -11,15 +11,16 @@ Vagrant.configure('2') do |config|
|
|
11
11
|
|
12
12
|
config.vm.define "vz1" do |vm_vz1|
|
13
13
|
vm_vz1.vm.provider :openvz do |openvz|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
openvz.vzctid="1"
|
15
|
+
openvz.physpages="0:1G"
|
16
|
+
openvz.hostname="vz1"
|
17
|
+
openvz.ipadd="192.168.101.1"
|
18
|
+
#openvz.netadapter="eth1" #Allow this line to give the container complete control over a network adapter.
|
19
|
+
openvz.nameserver="8.8.8.8"
|
20
|
+
openvz.diskspace="1000000:1100000"
|
21
|
+
openvz.diskinodes="100000:101000"
|
22
|
+
openvz.quotatime="600"
|
23
|
+
openvz.pubkey="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
|
23
24
|
end
|
24
25
|
|
25
26
|
vm_vz1.vm.provision "shell", inline: $script
|
@@ -1,21 +1,27 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Openvz
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Action
|
4
|
+
class Boot
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
def call(env)
|
10
|
+
@env = env
|
11
11
|
|
12
|
-
|
12
|
+
config = env[:machine].provider_config
|
13
13
|
|
14
|
-
|
14
|
+
env[:machine].provider.driver.start(config.vzctid,config.pubkey)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
if ! config.netadapter.nil?
|
17
|
+
env[:machine].provider.driver.set_netadapter(
|
18
|
+
config.vzctid,config.netadapter
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
@app.call env
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
@@ -8,8 +8,12 @@ module VagrantPlugins
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
config = env[:machine].provider_config
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
if config.netadapter.nil?
|
13
|
+
env[:machine_ip] ||= env[:machine].provider.driver.fetch_ip(config.vzctid)
|
14
|
+
else
|
15
|
+
env[:machine_ip] ||= env[:machine].provider.driver.fetch_ip_netadapter(config.vzctid)
|
16
|
+
end
|
13
17
|
|
14
18
|
@app.call(env)
|
15
19
|
end
|
@@ -6,6 +6,7 @@ module VagrantPlugins
|
|
6
6
|
attr_accessor :physpages
|
7
7
|
attr_accessor :hostname
|
8
8
|
attr_accessor :ipadd
|
9
|
+
attr_accessor :netadapter
|
9
10
|
attr_accessor :nameserver
|
10
11
|
attr_accessor :vzctid
|
11
12
|
attr_accessor :pubkey
|
@@ -32,7 +33,7 @@ module VagrantPlugins
|
|
32
33
|
|
33
34
|
errors << "config.physpages" if physpages.nil?
|
34
35
|
errors << "config.hostname" if hostname.nil?
|
35
|
-
errors << "config.ipadd" if ipadd.nil?
|
36
|
+
errors << "config.ipadd or config.netadapter" if ipadd.nil? && netadapter.nil?
|
36
37
|
errors << "config.nameserver" if nameserver.nil?
|
37
38
|
errors << "config.vzctid" if vzctid.nil?
|
38
39
|
errors << "config.pubkey" if pubkey.nil?
|
@@ -18,6 +18,10 @@ module VagrantPlugins
|
|
18
18
|
run(:vzlist,"-a","-H","-t","-o","ip","#{vzctlid}")
|
19
19
|
end
|
20
20
|
|
21
|
+
def fetch_ip_netadapter(vzctlid)
|
22
|
+
run(:vzctl,"exec","#{vzctlid}","ip -4 addr show eth1 | egrep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | grep -v 255")
|
23
|
+
end
|
24
|
+
|
21
25
|
def create(vzctlid,settings={})
|
22
26
|
|
23
27
|
# run :rsync, settings[:box_location],settings[:template_location]
|
@@ -34,6 +38,12 @@ module VagrantPlugins
|
|
34
38
|
|
35
39
|
end
|
36
40
|
|
41
|
+
def set_netadapter(vzctlid,netadapter)
|
42
|
+
run :vzctl,'set',vzctlid,"--netdev_add","#{netadapter}","--save"
|
43
|
+
run :vzctl,'exec',vzctlid,"ifconfig","#{netadapter}","up"
|
44
|
+
run :vzctl,'exec',vzctlid,"dhclient","#{netadapter}"
|
45
|
+
end
|
46
|
+
|
37
47
|
def start(vzctlid,pubkey)
|
38
48
|
run :vzctl, 'start', "#{vzctlid}"
|
39
49
|
add_vagrant_user(vzctlid,pubkey)
|
@@ -61,6 +61,11 @@ module VagrantPlugins
|
|
61
61
|
@cli.create vzctlid, settings
|
62
62
|
end
|
63
63
|
|
64
|
+
def set_netadapter(vzctlid,netadapter)
|
65
|
+
@logger.info("Adding network adapter: #{netadapter}")
|
66
|
+
@cli.set_netadapter(vzctlid,netadapter)
|
67
|
+
end
|
68
|
+
|
64
69
|
def start(vzctlid,pubkey)
|
65
70
|
@logger.info('Starting container...')
|
66
71
|
@cli.start(vzctlid,pubkey)
|
@@ -85,6 +90,11 @@ module VagrantPlugins
|
|
85
90
|
@cli.fetch_ip(vzctlid)
|
86
91
|
end
|
87
92
|
|
93
|
+
def fetch_ip_netadapter(vzctlid)
|
94
|
+
@cli.fetch_ip_netadapter(vzctlid)
|
95
|
+
end
|
96
|
+
|
97
|
+
|
88
98
|
end
|
89
99
|
end
|
90
100
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-openvz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|