vagrant-guests-clearlinux 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/vagrant-guests-clearlinux/cap/configure_networks.rb +34 -35
- data/lib/vagrant-guests-clearlinux/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a0bf27d01315661bbd39dc82ba6c5bbaea3d8e21264be124ba4227184e68dd6
|
4
|
+
data.tar.gz: 3937c110ed621d7db7a1b74e618fac4f68ec62451d5a869e5386ac8bee7eb377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6af48e6b54266051c699c98e76121050d1cf2530cd5f14af523444b4d127f2c497e983b4194923ab7595b04502f55d74168f42338474a5c3c936648c45f4b605
|
7
|
+
data.tar.gz: 6070645fcefa9fed672be4bfb32c54ce9230a6491379b1a361d949bbc92b04980f8f341cc22c4af0975ea9a762fd55e43ce68993761851de6a5ab5ef434cdef1
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ To build and install the plugin directly from this repo:
|
|
17
17
|
```
|
18
18
|
$ bundle install
|
19
19
|
$ bundle exec rake build
|
20
|
-
$ vagrant plugin install pkg/vagrant-guests-clearlinux-1.0.
|
20
|
+
$ vagrant plugin install pkg/vagrant-guests-clearlinux-1.0.11.gem
|
21
21
|
```
|
22
22
|
|
23
23
|
You can run RSpec with:
|
@@ -41,47 +41,46 @@ module VagrantPlugins
|
|
41
41
|
@@logger = Log4r::Logger.new('vagrant::guest::clearlinux::configure_networks')
|
42
42
|
|
43
43
|
def self.configure_networks(machine, networks)
|
44
|
-
machine.communicate
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
44
|
+
comm = machine.communicate
|
45
|
+
# Read network interface names
|
46
|
+
interfaces = []
|
47
|
+
comm.sudo("ifconfig -a | grep -E '^en|^eth' | cut -f1 -d' '") do |_, result|
|
48
|
+
interfaces = result.split("\n")
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
# Configure interfaces
|
52
|
+
networks.each do |network|
|
53
|
+
interface = network[:interface].to_i
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
iface = interfaces[interface]
|
56
|
+
if iface.nil?
|
57
|
+
@@logger.warn("Could not find match rule for network #{network.inspect}")
|
58
|
+
next
|
59
|
+
end
|
60
|
+
comm.sudo("mkdir -p /etc/systemd/network/")
|
61
|
+
unit_name = find_network_file comm, iface
|
62
|
+
comm.sudo("rm -f /etc/systemd/network/#{unit_name}")
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
if network[:type] == :static
|
65
|
+
cidr = IPAddr.new(network[:netmask]).to_cidr
|
66
|
+
address = format('%s/%s', network[:ip], cidr)
|
67
|
+
unit_file = format(STATIC_NETWORK, iface, address)
|
68
|
+
elsif network[:type] == :dhcp
|
69
|
+
unit_file = format(DHCP_NETWORK, iface)
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
temp = Tempfile.new('vagrant')
|
73
|
+
temp.binmode
|
74
|
+
temp.write(unit_file)
|
75
|
+
temp.close
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
comm.sudo('systemctl restart systemd-networkd')
|
77
|
+
comm.upload(temp.path, "/tmp/#{unit_name}")
|
78
|
+
comm.sudo(["mv /tmp/#{unit_name} /etc/systemd/network/",
|
79
|
+
"chown root:root /etc/systemd/network/#{unit_name}",
|
80
|
+
"chmod a+r /etc/systemd/network/#{unit_name}"].join("\n"))
|
84
81
|
end
|
82
|
+
comm.sudo("systemctl restart systemd-networkd")
|
83
|
+
comm.wait_for_ready(30)
|
85
84
|
end
|
86
85
|
|
87
86
|
def self.find_network_file(comm, iface)
|