linux-ip-addr 0.0.5 → 0.0.6

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: 1c03c32da3c0b4a82328f9bdadc4da7adc3b285a
4
- data.tar.gz: f612a97925c22679d2dd489fedf4fa3a40b2fb02
3
+ metadata.gz: 88b9efd09118cb965dd704249f0925a455640c0f
4
+ data.tar.gz: b4da92670195977f8dc5baf4fb3889d79fe33f45
5
5
  SHA512:
6
- metadata.gz: 36e47776ae966d17479688661a8f4fcf9d02cbe7977fb523742f86d30df2a13259d2c5e757ef541809860e24ad7d775ac2a576de1113327a380562c71d8c3f59
7
- data.tar.gz: 08f4404429f46fea45b9213092daa39e298d93bc11cad606e293919a0d0dc18285696d84fe6d34a658b5b0ee9b59963aeae330ca82abeee816493c98610b0f33
6
+ metadata.gz: cf1f67a861b572dc648fb2418050174c0bc2cf8e10d3c7f90503719241929cb2deb0bd56d343d17e155f859ba57ce06c0a861f4a273e520f73617c3c9ee8f6cc
7
+ data.tar.gz: 9909d5e253ce1ce86b04b252e779f813b3ed008478d8aef4bb8cdb5ad99201e013931bd0ffc6e71c9e11986e43918e6c0387d987b5aefed352ae56290b0a9689
@@ -13,6 +13,12 @@ module Linux
13
13
  end
14
14
  def add_ip(ip)
15
15
  @ips << ip
16
+ self
17
+ end
18
+ def as_commands(direction)
19
+ @ips.map do |ip|
20
+ "ip addr #{direction} #{ip} dev #{name}"
21
+ end
16
22
  end
17
23
  end
18
24
 
@@ -28,8 +34,20 @@ module Linux
28
34
  def find(name)
29
35
  interfaces.find { |i| i.name == name }
30
36
  end
37
+ def as_commands(direction="add")
38
+ @interfaces.map do |interface|
39
+ interface.as_commands(direction)
40
+ end.flatten.compact
41
+ end
42
+ def execute_add
43
+ system as_commands("add")
44
+ end
45
+ def execute_del
46
+ system as_commands("del")
47
+ end
31
48
  end
32
49
 
50
+
33
51
  #23: br202: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
34
52
  # link/ether d0:27:88:d1:01:6d brd ff:ff:ff:ff:ff:ff
35
53
  # inet 10.10.103.11/22 brd 10.10.103.255 scope global br202
@@ -1,7 +1,7 @@
1
1
  module Linux
2
2
  module Ip
3
3
  module Addr
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
@@ -153,5 +153,17 @@ SAMPLE
153
153
  assert_equal "huhu", ret[:result]
154
154
  end
155
155
 
156
+ def test_as_commands
157
+ ip_addr = Linux::Ip::Addr.parse_from_lines(@ip_addr_show.lines)
158
+ assert ip_addr.as_commands("add").include?("ip addr add fe80::d227:88ff:fed1:16d/64 dev p1p1.402")
159
+ assert ip_addr.as_commands("del").include?("ip addr del 10.1.0.11/16 dev br110")
160
+ end
161
+
162
+ def test_from_scratch
163
+ ip_addr = Linux::Ip::Addr::IpAddr.new
164
+ ip_addr.interfaces << Linux::Ip::Addr::Interface.new("eth0").add_ip("47.11.1.1/26")
165
+ assert ip_addr.as_commands("del").include?("ip addr del 47.11.1.1/26 dev eth0")
166
+ end
167
+
156
168
  end
157
169
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux-ip-addr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meno Abels
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-09 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ipaddress