vagrant-guests-photon 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78a2f47f2f4da91108b4e1a202da0f3006f6f08b
4
- data.tar.gz: 0085fd4d34bdda428f9129adc791b2af45dee6a6
3
+ metadata.gz: 3cc5901eaae4d0c91b67bc09621fe9628c680aea
4
+ data.tar.gz: c6d18e3a9af68b16b564745d2938a3218034311f
5
5
  SHA512:
6
- metadata.gz: d628f32f1edb4319b9246090a1e1c7590b6188a1faab21bf83e9327779846424dfdabfcbea4c2e743ae6b0e91bbe56b0c8e69469e6c4d6ec5aa942d2b617e82f
7
- data.tar.gz: 721336c56c357163a9ca5b7a05af9d31def65f32057561f2ec5ca127e1fe780c3fbebea760d7adcb89193f68658d99a21ecfc2926ff1ea39ca2570b1b4db2dd5
6
+ metadata.gz: 9ba90e444742d70440478f3c65610dae9267f5aefcfd57d787821b3661360d7bc65d89c8fbb4a3183da03f378ac91d03105de99c2ddc250c0e36b3b1ee3d1ded
7
+ data.tar.gz: c004a45dfbe535f77eb1f034952c6835c8fb150cfa553acb01e68b778b112ba9f4420784c373306dd9c39cd4b4403b1f572d8b7c0e3d5070e7b44aea9b0b4df2
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p645
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gemspec
7
7
 
8
8
  group :development do
9
9
  gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
10
+ gem 'coveralls', require: false
10
11
  end
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # vagrant-guests-photon
2
-
1
+ # vagrant-guests-photon [![Build Status](https://travis-ci.org/vmware/vagrant-guests-photon.svg)](https://travis-ci.org/vmware/vagrant-guests-photon) [![Coverage Status](https://coveralls.io/repos/vmware/vagrant-guests-photon/badge.svg?branch=master&service=github)](https://coveralls.io/github/vmware/vagrant-guests-photon?branch=master)
3
2
  This is a [Vagrant](http://www.vagrantup.com/) [plugin](http://docs.vagrantup.com/v2/plugins/index.html) that adds VMware Photon guest support.
4
3
 
5
4
  ## Installation
@@ -9,7 +8,6 @@ $ vagrant plugin install vagrant-guests-photon
9
8
  ```
10
9
 
11
10
  ## Development
12
-
13
11
  To build and install the plugin directly from this repo:
14
12
 
15
13
  ```
@@ -20,5 +18,6 @@ $ vagrant plugin install pkg/vagrant-guests-photon-1.0.1.gem
20
18
  You can run RSpec with:
21
19
 
22
20
  ```
23
- $ rake
21
+ $ bundle install
22
+ $ bundle exec rake
24
23
  ```
@@ -36,11 +36,10 @@ module VagrantPlugins
36
36
 
37
37
  def self.configure_networks(machine, networks)
38
38
  machine.communicate.tap do |comm|
39
- comm.sudo("rm -f /etc/systemd/network/50-vagrant-*.network")
40
39
 
41
40
  # Read network interface names
42
41
  interfaces = []
43
- comm.sudo("ifconfig -a | grep '^eth' | cut -f1 -d' '") do |_, result|
42
+ comm.sudo("ifconfig -a | grep -E '^enp|^eth' | cut -f1 -d' '") do |_, result|
44
43
  interfaces = result.split("\n")
45
44
  end
46
45
 
@@ -54,9 +53,10 @@ module VagrantPlugins
54
53
  next
55
54
  end
56
55
 
57
- unit_name = "50-vagrant-%s.network" % [iface]
58
-
59
- if network[:type] == :static
56
+ unit_name = find_network_file comm, iface
57
+ comm.sudo("rm -f /etc/systemd/network/#{unit_name}")
58
+
59
+ if network[:type] == :static
60
60
  cidr = IPAddr.new(network[:netmask]).to_cidr
61
61
  address = "%s/%s" % [network[:ip], cidr]
62
62
  unit_file = STATIC_NETWORK % [iface, address]
@@ -78,6 +78,14 @@ module VagrantPlugins
78
78
  comm.sudo("systemctl restart systemd-networkd.service")
79
79
  end
80
80
  end
81
+
82
+ def self.find_network_file(comm, iface)
83
+ comm.sudo("grep #{iface} /etc/systemd/network/* | awk -F\: '{print $1}' | head -n1") do |_, result|
84
+ puts result
85
+ return File.basename(result.strip)
86
+ end
87
+ return "50-vagrant-%s.network" % [iface]
88
+ end
81
89
  end
82
90
  end
83
91
  end
@@ -4,6 +4,6 @@
4
4
  module VagrantPlugins
5
5
  # Set version for vagrant-guests-photon gem.
6
6
  module GuestPhoton
7
- VERSION = '1.0.1'
7
+ VERSION = '1.0.2'
8
8
  end
9
9
  end
@@ -46,31 +46,34 @@ describe VagrantPlugins::GuestPhoton::Cap::ConfigureNetworks do
46
46
  }
47
47
  ]
48
48
 
49
- interfaces = "eth0\neth1\neth2\neth3\neth4\n"
49
+ interfaces = "enp0s3\nenp0s8\neth2\nenp1s5\nenp1s6\n"
50
50
 
51
51
  before do
52
- communicate.stub(:sudo).with("ifconfig -a | grep '^eth' | cut -f1 -d' '")
52
+ communicate.stub(:sudo).with("ifconfig -a | grep -E '^enp|^eth' | cut -f1 -d' '")
53
53
  .and_yield(nil, interfaces)
54
54
  end
55
55
 
56
56
  it 'should configure networks' do
57
- communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-*.network")
58
- communicate.should_receive(:sudo).with("ifconfig -a | grep '^eth' | cut -f1 -d' '")
57
+ communicate.should_receive(:sudo).with("ifconfig -a | grep -E '^enp|^eth' | cut -f1 -d' '")
59
58
 
60
- # eth1
59
+ # enp0s8
60
+ communicate.should_receive(:sudo).with("grep enp0s8 /etc/systemd/network/* | awk -F: '{print $1}' | head -n1")
61
+ communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-enp0s8.network")
61
62
  communicate.should_receive(:upload) do |src, dst|
62
63
  contents = (File.readlines src).join("")
63
- contents.should eq "[Match]\nName=eth1\n\n[Network]\nAddress=192.168.10.10/24\n"
64
- dst.should eq "/tmp/50-vagrant-eth1.network"
64
+ contents.should eq "[Match]\nName=enp0s8\n\n[Network]\nAddress=192.168.10.10/24\n"
65
+ dst.should eq "/tmp/50-vagrant-enp0s8.network"
65
66
  end
66
67
  communicate.should_receive(:sudo)
67
- .with("mv /tmp/50-vagrant-eth1.network /etc/systemd/network/")
68
+ .with("mv /tmp/50-vagrant-enp0s8.network /etc/systemd/network/")
68
69
  communicate.should_receive(:sudo)
69
- .with("chown root:root /etc/systemd/network/50-vagrant-eth1.network")
70
+ .with("chown root:root /etc/systemd/network/50-vagrant-enp0s8.network")
70
71
  communicate.should_receive(:sudo)
71
- .with("chmod +r /etc/systemd/network/50-vagrant-eth1.network")
72
+ .with("chmod +r /etc/systemd/network/50-vagrant-enp0s8.network")
72
73
 
73
74
  # eth2
75
+ communicate.should_receive(:sudo).with("grep eth2 /etc/systemd/network/* | awk -F: '{print $1}' | head -n1")
76
+ communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-eth2.network")
74
77
  communicate.should_receive(:upload) do |src, dst|
75
78
  contents = (File.readlines src).join("")
76
79
  contents.should eq "[Match]\nName=eth2\n\n[Network]\nDHCP=yes\n"
@@ -83,31 +86,35 @@ describe VagrantPlugins::GuestPhoton::Cap::ConfigureNetworks do
83
86
  communicate.should_receive(:sudo)
84
87
  .with("chmod +r /etc/systemd/network/50-vagrant-eth2.network")
85
88
 
86
- # eth3
89
+ # enp1s5
90
+ communicate.should_receive(:sudo).with("grep enp1s5 /etc/systemd/network/* | awk -F: '{print $1}' | head -n1")
91
+ communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-enp1s5.network")
87
92
  communicate.should_receive(:upload) do |src, dst|
88
93
  contents = (File.readlines src).join("")
89
- contents.should eq "[Match]\nName=eth3\n\n[Network]\nDHCP=yes\n"
90
- dst.should eq "/tmp/50-vagrant-eth3.network"
94
+ contents.should eq "[Match]\nName=enp1s5\n\n[Network]\nDHCP=yes\n"
95
+ dst.should eq "/tmp/50-vagrant-enp1s5.network"
91
96
  end
92
97
  communicate.should_receive(:sudo)
93
- .with("mv /tmp/50-vagrant-eth3.network /etc/systemd/network/")
98
+ .with("mv /tmp/50-vagrant-enp1s5.network /etc/systemd/network/")
94
99
  communicate.should_receive(:sudo)
95
- .with("chown root:root /etc/systemd/network/50-vagrant-eth3.network")
100
+ .with("chown root:root /etc/systemd/network/50-vagrant-enp1s5.network")
96
101
  communicate.should_receive(:sudo)
97
- .with("chmod +r /etc/systemd/network/50-vagrant-eth3.network")
102
+ .with("chmod +r /etc/systemd/network/50-vagrant-enp1s5.network")
98
103
 
99
- # eth4
104
+ # enp1s6
105
+ communicate.should_receive(:sudo).with("grep enp1s6 /etc/systemd/network/* | awk -F: '{print $1}' | head -n1")
106
+ communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-enp1s6.network")
100
107
  communicate.should_receive(:upload) do |src, dst|
101
108
  contents = (File.readlines src).join("")
102
- contents.should eq "[Match]\nName=eth4\n\n[Network]\nAddress=192.168.1.201/24\n"
103
- dst.should eq "/tmp/50-vagrant-eth4.network"
109
+ contents.should eq "[Match]\nName=enp1s6\n\n[Network]\nAddress=192.168.1.201/24\n"
110
+ dst.should eq "/tmp/50-vagrant-enp1s6.network"
104
111
  end
105
112
  communicate.should_receive(:sudo)
106
- .with("mv /tmp/50-vagrant-eth4.network /etc/systemd/network/")
113
+ .with("mv /tmp/50-vagrant-enp1s6.network /etc/systemd/network/")
107
114
  communicate.should_receive(:sudo)
108
- .with("chown root:root /etc/systemd/network/50-vagrant-eth4.network")
115
+ .with("chown root:root /etc/systemd/network/50-vagrant-enp1s6.network")
109
116
  communicate.should_receive(:sudo)
110
- .with("chmod +r /etc/systemd/network/50-vagrant-eth4.network")
117
+ .with("chmod +r /etc/systemd/network/50-vagrant-enp1s6.network")
111
118
 
112
119
  communicate.should_receive(:sudo).with("systemctl restart systemd-networkd.service")
113
120
 
@@ -115,7 +122,7 @@ describe VagrantPlugins::GuestPhoton::Cap::ConfigureNetworks do
115
122
  end
116
123
  end
117
124
 
118
- context 'configure 2 kinds of networks without eth2' do
125
+ context 'configure 2 kinds of networks without enp0s8' do
119
126
  networks = [
120
127
  # config.vm.network :private_network, ip: "192.168.33.10"
121
128
  {
@@ -137,30 +144,31 @@ describe VagrantPlugins::GuestPhoton::Cap::ConfigureNetworks do
137
144
  }
138
145
  ]
139
146
 
140
- interfaces = "eth0\neth1\n"
147
+ interfaces = "enp0s3\nenp0s8\n"
141
148
 
142
149
  before do
143
- communicate.stub(:sudo).with("ifconfig -a | grep '^eth' | cut -f1 -d' '")
150
+ communicate.stub(:sudo).with("ifconfig -a | grep -E '^enp|^eth' | cut -f1 -d' '")
144
151
  .and_yield(nil, interfaces)
145
152
  @@logger = Log4r::Logger.new("vagrant::guest::photon::configure_networks")
146
153
  end
147
154
 
148
- it 'should configure networks without eth2' do
149
- communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-*.network")
150
- communicate.should_receive(:sudo).with("ifconfig -a | grep '^eth' | cut -f1 -d' '")
155
+ it 'should configure networks without enp0s9' do
156
+ communicate.should_receive(:sudo).with("ifconfig -a | grep -E '^enp|^eth' | cut -f1 -d' '")
157
+ communicate.should_receive(:sudo).with("grep enp0s8 /etc/systemd/network/* | awk -F: '{print $1}' | head -n1")
158
+ communicate.should_receive(:sudo).with("rm -f /etc/systemd/network/50-vagrant-enp0s8.network")
151
159
 
152
- # eth1
160
+ # enp0s8
153
161
  communicate.should_receive(:upload) do |src, dst|
154
162
  contents = (File.readlines src).join("")
155
- contents.should eq "[Match]\nName=eth1\n\n[Network]\nAddress=192.168.10.10/24\n"
156
- dst.should eq "/tmp/50-vagrant-eth1.network"
163
+ contents.should eq "[Match]\nName=enp0s8\n\n[Network]\nAddress=192.168.10.10/24\n"
164
+ dst.should eq "/tmp/50-vagrant-enp0s8.network"
157
165
  end
158
166
  communicate.should_receive(:sudo)
159
- .with("mv /tmp/50-vagrant-eth1.network /etc/systemd/network/")
167
+ .with("mv /tmp/50-vagrant-enp0s8.network /etc/systemd/network/")
160
168
  communicate.should_receive(:sudo)
161
- .with("chown root:root /etc/systemd/network/50-vagrant-eth1.network")
169
+ .with("chown root:root /etc/systemd/network/50-vagrant-enp0s8.network")
162
170
  communicate.should_receive(:sudo)
163
- .with("chmod +r /etc/systemd/network/50-vagrant-eth1.network")
171
+ .with("chmod +r /etc/systemd/network/50-vagrant-enp0s8.network")
164
172
 
165
173
  # eth2
166
174
  @@logger.should_receive(:warn).with(
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  # Copyright (c) 2015 VMware, Inc. All Rights Reserved.
3
+ require 'coveralls'
4
+ Coveralls.wear!
3
5
 
4
6
  shared_context 'machine' do
5
7
  let(:communicate) {
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-guests-photon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rapposelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-05 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-expectations
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.14'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.14'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-mocks
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.14'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Enables Vagrant to manage VMware Photon machines.
@@ -100,9 +100,11 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
- - ".gitignore"
104
- - ".rspec"
105
- - ".rubocop.yml"
103
+ - .gitignore
104
+ - .rspec
105
+ - .rubocop.yml
106
+ - .ruby-version
107
+ - .travis.yml
106
108
  - Gemfile
107
109
  - LICENSE
108
110
  - README.md
@@ -131,17 +133,17 @@ require_paths:
131
133
  - lib
132
134
  required_ruby_version: !ruby/object:Gem::Requirement
133
135
  requirements:
134
- - - ">="
136
+ - - '>='
135
137
  - !ruby/object:Gem::Version
136
138
  version: '0'
137
139
  required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  requirements:
139
- - - ">="
141
+ - - '>='
140
142
  - !ruby/object:Gem::Version
141
143
  version: '0'
142
144
  requirements: []
143
145
  rubyforge_project:
144
- rubygems_version: 2.4.3
146
+ rubygems_version: 2.0.14
145
147
  signing_key:
146
148
  specification_version: 4
147
149
  summary: VMware Photon Guest Plugin for Vagrant