specinfra 2.52.0 → 2.53.0

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: f646ff170ce099769c7f7d017c64f9539f8e2b26
4
- data.tar.gz: 12363501f793feb74be015aca6d9b544ecaae1a7
3
+ metadata.gz: b02d08de2e1a388e5dd42aa9ff31b33baa4f2ce2
4
+ data.tar.gz: 00fb96fe4dab29973dea33064f9c388917e3f7b9
5
5
  SHA512:
6
- metadata.gz: dae91ce7ac68a39d01832a207f6fb3a6e57b1bfb7b9e53c6936be485c432d2cf67e6e7a0058839b8ccfc8f516a94a5af2ae55b0abb5b2bd458107ded52a44b38
7
- data.tar.gz: c6ad4d292a0b14c6f66e206605163167d166798dcb66dfde82a10c4a5627cce6670befed1511cfbda185fe3c1b07b712b49473d29ba6999c46affd4a14cd2054
6
+ metadata.gz: 778e52d2d12eb06670a45da2ef3400021e733507e45cc4a316df84b7f46bbe9d71ecb164f63bf1e4be29450891d1d1850a6c1c6e5db5df97eac56d44d53ebe4b
7
+ data.tar.gz: 146a3c424c10225a18e8b828a0b12dbfc82a43269af8eb8871435deaff35dc423142d44376b782a394bacb556731bff074ee453c673d0dbe0fa98285d71e3c3d
@@ -32,6 +32,15 @@ class Specinfra::Command::Darwin::Base::Interface < Specinfra::Command::Base::In
32
32
  "ifconfig #{interface} inet6 | grep 'inet6 #{ip_address}'"
33
33
  end
34
34
 
35
+ def get_ipv4_address(interface)
36
+ "ifconfig #{interface} inet | grep inet | awk '{print $2}'"
37
+ end
38
+
39
+ def get_ipv6_address(interface)
40
+ # Awk refuses to print '/' even with using escapes or hex so workaround with sed employed here.
41
+ "ifconfig #{interface} inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit"
42
+ end
43
+
35
44
  def get_link_state(interface)
36
45
  # Checks if interfaces is administratively up with the -u arg.
37
46
  # L1 check via status. Virtual interfaces like tapX missing the status will report up.
@@ -1,4 +1,4 @@
1
- class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::Interface
1
+ class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::Interface
2
2
  class << self
3
3
  def check_exists(name)
4
4
  "ifconfig #{name}"
@@ -8,7 +8,7 @@ class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::I
8
8
  ip_address = ip_address.dup
9
9
  if ip_address =~ /\/\d+$/
10
10
  # remove the prefix - better would be to calculate the netmask
11
- ip_address.gsub!(/\/\d+$/, "")
11
+ ip_address.gsub!(/\/\d+$/, "")
12
12
  end
13
13
  ip_address << " "
14
14
  ip_address.gsub!(".", "\\.")
@@ -20,18 +20,27 @@ class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::I
20
20
  (ip_address, prefixlen) = ip_address.split(/\//)
21
21
  ip_address.downcase!
22
22
  if ip_address =~ /^fe80::/i
23
- # link local needs the scope (interface) appended
23
+ # link local needs the scope (interface) appended
24
24
  ip_address << "%#{interface}"
25
- end
26
- unless prefixlen.to_s.empty?
27
- # append prefixlen
25
+ end
26
+ unless prefixlen.to_s.empty?
27
+ # append prefixlen
28
28
  ip_address << " prefixlen #{prefixlen}"
29
- else
29
+ else
30
30
  ip_address << " "
31
31
  end
32
32
  "ifconfig #{interface} inet6 | grep 'inet6 #{ip_address}'"
33
33
  end
34
34
 
35
+ def get_ipv4_address(interface)
36
+ "ifconfig #{interface} inet | grep inet | awk '{print $2}'"
37
+ end
38
+
39
+ def get_ipv6_address(interface)
40
+ # Awk refuses to print '/' even with using escapes or hex so workaround with sed employed here.
41
+ "ifconfig #{interface} inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit"
42
+ end
43
+
35
44
  def get_link_state(interface)
36
45
  # Checks if interfaces is administratively up with the -u arg.
37
46
  # L1 check via status. Virtual interfaces like tapX missing the status will report up.
@@ -34,9 +34,16 @@ class Specinfra::Command::Linux::Base::Interface < Specinfra::Command::Base::Int
34
34
  "ip -6 addr show #{interface} | grep 'inet6 #{ip_address}'"
35
35
  end
36
36
 
37
+ def get_ipv4_address(interface)
38
+ "ip -4 addr show #{interface} | grep #{interface}$ | awk '{print $2}'"
39
+ end
40
+
41
+ def get_ipv6_address(interface)
42
+ "ip -6 addr show #{interface} | grep inet6 | awk '{print $2}'"
43
+ end
44
+
37
45
  def get_link_state(name)
38
46
  "cat /sys/class/net/#{name}/operstate"
39
47
  end
40
48
  end
41
49
  end
42
-
@@ -1,4 +1,4 @@
1
- class Specinfra::Command::Openbsd::Base::Interface < Specinfra::Command::Base::Interface
1
+ class Specinfra::Command::Openbsd::Base::Interface < Specinfra::Command::Base::Interface
2
2
  class << self
3
3
  def check_exists(name)
4
4
  "ifconfig #{name}"
@@ -12,7 +12,7 @@ class Specinfra::Command::Openbsd::Base::Interface < Specinfra::Command::Base::I
12
12
  ip_address = ip_address.dup
13
13
  if ip_address =~ /\/\d+$/
14
14
  # remove the prefix - better would be to calculate the netmask
15
- ip_address.gsub!(/\/\d+$/, "")
15
+ ip_address.gsub!(/\/\d+$/, "")
16
16
  end
17
17
  ip_address << " "
18
18
  ip_address.gsub!(".", "\\.")
@@ -24,22 +24,31 @@ class Specinfra::Command::Openbsd::Base::Interface < Specinfra::Command::Base::I
24
24
  (ip_address, prefixlen) = ip_address.split(/\//)
25
25
  ip_address.downcase!
26
26
  if ip_address =~ /^fe80::/i
27
- # link local needs the scope (interface) appended
27
+ # link local needs the scope (interface) appended
28
28
  ip_address << "%#{interface}"
29
- end
30
- unless prefixlen.to_s.empty?
31
- # append prefixlen
29
+ end
30
+ unless prefixlen.to_s.empty?
31
+ # append prefixlen
32
32
  ip_address << " prefixlen #{prefixlen}"
33
- else
33
+ else
34
34
  ip_address << " "
35
35
  end
36
36
  "ifconfig #{interface} inet6 | grep 'inet6 #{ip_address}'"
37
37
  end
38
38
 
39
+ def get_ipv4_address(interface)
40
+ "ifconfig #{interface} inet | grep inet | awk '{print $2}'"
41
+ end
42
+
43
+ def get_ipv6_address(interface)
44
+ # Awk refuses to print '/' even with using escapes or hex so workaround with sed employed here.
45
+ "ifconfig #{interface} inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit"
46
+ end
47
+
39
48
  def get_link_state(interface)
40
49
  # Checks if interfaces is administratively up by parsing the options.
41
50
  # L1 check via status. Virtual interfaces like tapX missing the status will report up.
42
- # Emulates operstate in linux with exception of the unknown status.
51
+ # Emulates operstate in linux with exception of the unknown status.
43
52
  %Q{ifconfig #{interface} 2>&1 | awk -v s=down -F '[:<>,]' } +
44
53
  %Q{'NR == 1 && $3 == "UP" { s="up" }; /status:/ && $2 != " active" { s="down" }; END{ print s }'}
45
54
  end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.52.0"
2
+ VERSION = "2.53.0"
3
3
  end
@@ -32,7 +32,14 @@ describe get_command(:check_interface_has_ipv4_address, 'en0', '192.168.0.123/24
32
32
  it { should eq "ifconfig en0 inet | grep 'inet 192\\.168\\.0\\.123 '" }
33
33
  end
34
34
 
35
+ describe get_command(:get_interface_ipv4_address, 'en0') do
36
+ it { should eq "ifconfig en0 inet | grep inet | awk '{print $2}'" }
37
+ end
38
+
39
+ describe get_command(:get_interface_ipv6_address, 'en0') do
40
+ it { should eq "ifconfig en0 inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit" }
41
+ end
42
+
35
43
  describe get_command(:get_interface_link_state, 'en0') do
36
44
  it { should eq %Q{ifconfig -u en0 2>&1 | awk -v s=up '/status:/ && $2 != "active" { s="down" }; END {print s}'} }
37
45
  end
38
-
@@ -27,6 +27,14 @@ describe get_command(:check_interface_has_ipv4_address, 'vtnet0', '192.168.0.123
27
27
  it { should eq "ifconfig vtnet0 inet | grep 'inet 192\\.168\\.0\\.123 '" }
28
28
  end
29
29
 
30
+ describe get_command(:get_interface_ipv4_address, 'vtnet0') do
31
+ it { should eq "ifconfig vtnet0 inet | grep inet | awk '{print $2}'" }
32
+ end
33
+
34
+ describe get_command(:get_interface_ipv6_address, 'vtnet0') do
35
+ it { should eq "ifconfig vtnet0 inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit" }
36
+ end
37
+
30
38
  describe get_command(:get_interface_link_state, 'vtnet0') do
31
39
  it { should eq %Q{ifconfig -u vtnet0 2>&1 | awk -v s=up '/status:/ && $2 != "active" { s="down" }; END {print s}'} }
32
40
  end
@@ -19,6 +19,14 @@ describe get_command(:check_interface_has_ipv4_address, 'eth0', '192.168.0.123/2
19
19
  it { should eq "ip -4 addr show eth0 | grep 'inet 192\\.168\\.0\\.123/24 '" }
20
20
  end
21
21
 
22
+ describe get_command(:get_interface_ipv4_address, 'eth0') do
23
+ it { should eq "ip -4 addr show eth0 | grep eth0$ | awk '{print $2}'" }
24
+ end
25
+
26
+ describe get_command(:get_interface_ipv6_address, 'eth0') do
27
+ it { should eq "ip -6 addr show eth0 | grep inet6 | awk '{print $2}'" }
28
+ end
29
+
22
30
  describe get_command(:get_interface_link_state, 'eth0') do
23
31
  it { should eq "cat /sys/class/net/eth0/operstate" }
24
32
  end
@@ -4,7 +4,7 @@ property[:os] = nil
4
4
  set :os, :family => 'openbsd'
5
5
 
6
6
  describe get_command(:get_interface_speed_of, 'vio0') do
7
- it { should eq "ifconfig vio0 | grep 'media\:' | perl -pe 's|.*media\:.*\\((.*?)\\)|\\1|'" }
7
+ it { should eq "ifconfig vio0 | grep 'media\:' | perl -pe 's|.*media\:.*\\((.*?)\\)|\\1|'" }
8
8
  end
9
9
 
10
10
  describe get_command(:check_interface_has_ipv6_address, 'vio0', '2001:0db8:bd05:01d2:288a:1fc0:0001:10ee') do
@@ -31,8 +31,16 @@ describe get_command(:check_interface_has_ipv4_address, 'vio0', '192.168.0.123/2
31
31
  it { should eq "ifconfig vio0 inet | grep 'inet 192\\.168\\.0\\.123 '" }
32
32
  end
33
33
 
34
+ describe get_command(:get_interface_ipv4_address, 'vio0') do
35
+ it { should eq "ifconfig vio0 inet | grep inet | awk '{print $2}'" }
36
+ end
37
+
38
+ describe get_command(:get_interface_ipv6_address, 'vio0') do
39
+ it { should eq "ifconfig vio0 inet6 | grep inet6 | awk '{print $2$3$4}' | sed 's/prefixlen/\//'; exit" }
40
+ end
41
+
34
42
  describe get_command(:get_interface_link_state, 'vio0') do
35
43
  it do should eq %Q{ifconfig vio0 2>&1 | awk -v s=down -F '[:<>,]' } +
36
44
  %Q{'NR == 1 && $3 == "UP" { s="up" }; /status:/ && $2 != " active" { s="down" }; END{ print s }'}
37
- end
45
+ end
38
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.52.0
4
+ version: 2.53.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp