vagrant-1cloud 1.0.3 → 1.0.4
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 +4 -4
- data/lib/vagrant-1cloud/actions/private_network.rb +83 -83
- data/lib/vagrant-1cloud/config.rb +3 -6
- data/lib/vagrant-1cloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0856a59309590f13a7976777462fb3d33bbe2f7e
|
4
|
+
data.tar.gz: 036b7db899e06fc0bed1cf48d1ff7e9afdac239c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8572f8739a2403180ed09ebff71c7f73f2100d7fd4f85fd761a65fd1ea9dd0967da502b60f7c92852f92edead77ee6c54f0e93b2115374ff7cb0ce8931e46ea
|
7
|
+
data.tar.gz: e46a8ea7108ae23c0781ce3b265700bfb30df5004723b9917c55d3af093f812be5b1bf73d64624baf9c677968fa3eca88b093b5cab2deb2fcfd65a8c37589de3
|
@@ -17,93 +17,93 @@ module VagrantPlugins
|
|
17
17
|
|
18
18
|
def call(env)
|
19
19
|
# check if network name is set
|
20
|
-
return @app.call(env) unless @machine.provider_config.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
20
|
+
return @app.call(env) unless @machine.provider_config.private_net
|
21
|
+
|
22
|
+
@machine.provider_config.private_net.each do |net, ip|
|
23
|
+
lockfile = "/tmp/" + net.to_s + ".lock"
|
24
|
+
f = File.open(lockfile, "w+")
|
25
|
+
|
26
|
+
retryable(:tries => 120, :sleep => 10) do
|
27
|
+
next if env[:interrupted]
|
28
|
+
raise 'not ready' if check_file_locked?(lockfile)
|
29
|
+
end
|
30
|
+
|
31
|
+
f.flock(File::LOCK_EX)
|
32
|
+
|
33
|
+
# Getting private network by name
|
34
|
+
result = @client.request('/network')
|
35
|
+
private_network = result['body'].find { |network| network['Name'] == net.to_s }
|
36
|
+
|
37
|
+
# Creating private network if it doesn't exist
|
38
|
+
if !private_network
|
39
|
+
result = @client.post("/network", {
|
40
|
+
:Name => net,
|
41
|
+
:IsDHCP => false,
|
42
|
+
:DCLocation => @machine.provider_config.region
|
43
|
+
})
|
44
|
+
# Waiting for private network to create
|
45
|
+
env[:ui].info I18n.t('vagrant_1cloud.info.creating_private_network')
|
46
|
+
@client.wait_for_network(env, result['body']['ID'])
|
47
|
+
|
48
|
+
result = @client.request("/network/#{result['body']['ID']}")
|
49
|
+
private_network = result['body']
|
50
|
+
end
|
51
|
+
|
52
|
+
f.flock(File::LOCK_UN)
|
53
|
+
|
54
|
+
# Adding server to specified network
|
55
|
+
result = @client.post("/Server/#{@machine.id}/Action", {
|
56
|
+
:Type => "AddNetwork",
|
57
|
+
:NetworkID => private_network['ID']
|
42
58
|
})
|
43
|
-
# Waiting for private network to create
|
44
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.creating_private_network')
|
45
|
-
@client.wait_for_network(env, result['body']['ID'])
|
46
59
|
|
47
|
-
|
48
|
-
|
60
|
+
# Waiting for server to add to private network
|
61
|
+
env[:ui].info I18n.t('vagrant_1cloud.info.setting_private_network')
|
62
|
+
@client.wait_for_event(env, @machine.id, result['body']['ID'])
|
63
|
+
|
64
|
+
# refresh droplet state with provider
|
65
|
+
Provider.droplet(@machine, :refresh => true)
|
66
|
+
|
67
|
+
result = @client.request("/server/#{@machine.id}")
|
68
|
+
linked_network = result['body']['LinkedNetworks'].find { |network| network['NetworkID'] == private_network['ID'] }
|
69
|
+
|
70
|
+
if !ip
|
71
|
+
ip = linked_network['IP']
|
72
|
+
end
|
73
|
+
|
74
|
+
# override ssh username to root temporarily
|
75
|
+
user = @machine.config.ssh.username
|
76
|
+
@machine.config.ssh.username = 'root'
|
77
|
+
|
78
|
+
# set private and public network
|
79
|
+
@machine.communicate.execute(<<-BASH)
|
80
|
+
ifdown -a
|
81
|
+
|
82
|
+
export INTERFACE=eth0
|
83
|
+
export MATCHADDR=$(ifconfig -a | grep eth0 | awk '{print $NF}')
|
84
|
+
export MATCHID=$(udevadm info /sys/class/net/eth0 | grep P: | awk -F/ '{print $(NF-2)}')
|
85
|
+
/lib/udev/write_net_rules
|
86
|
+
|
87
|
+
export INTERFACE=$(ifconfig -a | grep #{linked_network['MAC']} | awk '{print $1}')
|
88
|
+
export MATCHADDR=#{linked_network['MAC']}
|
89
|
+
export MATCHID=$(ifconfig -a | grep #{linked_network['MAC']} | awk 'system("udevadm info /sys/class/net/" $1)' | grep P: | awk -F/ '{print $(NF-2)}')
|
90
|
+
/lib/udev/write_net_rules
|
91
|
+
|
92
|
+
udevadm control --reload-rules && udevadm trigger
|
93
|
+
|
94
|
+
echo >> /etc/network/interfaces
|
95
|
+
ifconfig -a | grep #{linked_network['MAC']} | awk '{print "auto " $1}' >> /etc/network/interfaces
|
96
|
+
ifconfig -a | grep #{linked_network['MAC']} | awk '{print "iface " $1 " inet static"}' >> /etc/network/interfaces
|
97
|
+
echo "address #{ip}" >> /etc/network/interfaces
|
98
|
+
echo "netmask #{private_network['Mask']}" >> /etc/network/interfaces
|
99
|
+
|
100
|
+
ifup -a
|
101
|
+
BASH
|
102
|
+
|
103
|
+
# reset username
|
104
|
+
@machine.config.ssh.username = user
|
49
105
|
end
|
50
106
|
|
51
|
-
f.flock(File::LOCK_UN)
|
52
|
-
|
53
|
-
# Adding server to specified network
|
54
|
-
result = @client.post("/Server/#{@machine.id}/Action", {
|
55
|
-
:Type => "AddNetwork",
|
56
|
-
:NetworkID => private_network['ID']
|
57
|
-
})
|
58
|
-
|
59
|
-
# Waiting for server to add to private network
|
60
|
-
env[:ui].info I18n.t('vagrant_1cloud.info.setting_private_network')
|
61
|
-
@client.wait_for_event(env, @machine.id, result['body']['ID'])
|
62
|
-
|
63
|
-
# refresh droplet state with provider
|
64
|
-
Provider.droplet(@machine, :refresh => true)
|
65
|
-
|
66
|
-
result = @client.request("/server/#{@machine.id}")
|
67
|
-
linked_network = result['body']['LinkedNetworks'].find { |network| network['NetworkID'] == private_network['ID'] }
|
68
|
-
|
69
|
-
if !@machine.provider_config.private_ip
|
70
|
-
@machine.provider_config.private_ip = linked_network['IP']
|
71
|
-
end
|
72
|
-
|
73
|
-
# override ssh username to root temporarily
|
74
|
-
user = @machine.config.ssh.username
|
75
|
-
@machine.config.ssh.username = 'root'
|
76
|
-
|
77
|
-
# set private and public network
|
78
|
-
@machine.communicate.execute(<<-BASH)
|
79
|
-
ifdown -a
|
80
|
-
|
81
|
-
export INTERFACE=eth0
|
82
|
-
export MATCHADDR=$(ifconfig -a | grep eth0 | awk '{print $NF}')
|
83
|
-
export MATCHID=$(udevadm info /sys/class/net/eth0 | grep P: | awk -F/ '{print $(NF-2)}')
|
84
|
-
/lib/udev/write_net_rules
|
85
|
-
|
86
|
-
export INTERFACE=$(ifconfig -a | grep #{linked_network['MAC']} | awk '{print $1}')
|
87
|
-
export MATCHADDR=#{linked_network['MAC']}
|
88
|
-
export MATCHID=$(ifconfig -a | grep #{linked_network['MAC']} | awk 'system("udevadm info /sys/class/net/" $1)' | grep P: | awk -F/ '{print $(NF-2)}')
|
89
|
-
/lib/udev/write_net_rules
|
90
|
-
|
91
|
-
udevadm control --reload-rules && udevadm trigger
|
92
|
-
|
93
|
-
ifconfig -a | grep eth0 | awk '{print "hwaddress ether " $5}' >> /etc/network/interfaces
|
94
|
-
echo >> /etc/network/interfaces
|
95
|
-
ifconfig -a | grep #{linked_network['MAC']} | awk '{print "auto " $1}' >> /etc/network/interfaces
|
96
|
-
ifconfig -a | grep #{linked_network['MAC']} | awk '{print "iface " $1 " inet static"}' >> /etc/network/interfaces
|
97
|
-
echo "address #{@machine.provider_config.private_ip}" >> /etc/network/interfaces
|
98
|
-
echo "netmask #{private_network['Mask']}" >> /etc/network/interfaces
|
99
|
-
echo "hwaddress ether #{linked_network['MAC']}" >> /etc/network/interfaces
|
100
|
-
|
101
|
-
ifup -a
|
102
|
-
BASH
|
103
|
-
|
104
|
-
# reset username
|
105
|
-
@machine.config.ssh.username = user
|
106
|
-
|
107
107
|
@app.call(env)
|
108
108
|
end
|
109
109
|
|
@@ -10,8 +10,7 @@ module VagrantPlugins
|
|
10
10
|
attr_accessor :ram
|
11
11
|
attr_accessor :hi_perf
|
12
12
|
attr_accessor :ca_path
|
13
|
-
attr_accessor :
|
14
|
-
attr_accessor :private_ip
|
13
|
+
attr_accessor :private_net
|
15
14
|
|
16
15
|
def initialize
|
17
16
|
@token = UNSET_VALUE
|
@@ -23,8 +22,7 @@ module VagrantPlugins
|
|
23
22
|
@ram = UNSET_VALUE
|
24
23
|
@hi_perf = UNSET_VALUE
|
25
24
|
@ca_path = UNSET_VALUE
|
26
|
-
@
|
27
|
-
@private_ip = UNSET_VALUE
|
25
|
+
@private_net = UNSET_VALUE
|
28
26
|
end
|
29
27
|
|
30
28
|
def finalize!
|
@@ -37,8 +35,7 @@ module VagrantPlugins
|
|
37
35
|
@ram = '512' if @ram == UNSET_VALUE
|
38
36
|
@hi_perf = false if @hi_perf == UNSET_VALUE
|
39
37
|
@ca_path = nil if @ca_path == UNSET_VALUE
|
40
|
-
@
|
41
|
-
@private_ip = nil if @private_ip == UNSET_VALUE
|
38
|
+
@private_net = nil if @private_net == UNSET_VALUE
|
42
39
|
end
|
43
40
|
|
44
41
|
def validate(machine)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-1cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bulat Yusupov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|