vagrant-clusterfuck 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: 4308db071ea87758e85c296b1d6384074f695b76
4
- data.tar.gz: 6813d15d675e7481b26eb5a6bdc2a817c6feb667
3
+ metadata.gz: c99bfd81a0935e4507ad2e97d7b11cb127846cdf
4
+ data.tar.gz: ee08c1f30fae807dbcc6066afb79051a26fac55f
5
5
  SHA512:
6
- metadata.gz: 7f4d2371ea0ca035ca0337e753200397ee5af4ba70c994c357eaf2207bcead0273f024a7b011af20733e9a05b8f95ee0ed8e4e5c5a2b693bef57fca11a26ca7e
7
- data.tar.gz: 5b27dfd4c05af27585323113504383f55d6ac2106ad2f172461adca5dce6f71a80a12ee22a57b2ce8714f1aa7059b9af05919c3ad3d86994d7ae1d0c6b84b816
6
+ metadata.gz: a4f16e7144db5a3800363beb09f236581f56e6c0a979c2d5a2a835b67f70a02926ba275ef9acb65a3aa7d4d8871d962775009ae3c991568f712c719b52a87d7c
7
+ data.tar.gz: 2c334a1df943f88cf762c1c215fb105f54157d0e792eb907eef329b3a23169efdf97cb7f1f955bdb715962ae19e5edc996fdf7ea60a0495520be1a1d0434b285
@@ -7,6 +7,7 @@ require_relative "clusterfuck/bgp_peer"
7
7
  require_relative "clusterfuck/exabgp_peer"
8
8
  require_relative "clusterfuck/quagga_bgp_router"
9
9
  require_relative "clusterfuck/core_ext/ipaddr"
10
+ require_relative "clusterfuck/test_helpers"
10
11
 
11
12
  module Clusterfuck
12
13
  end
@@ -0,0 +1,4 @@
1
+ module Clusterfuck::TestHelpers
2
+ end
3
+
4
+ require_relative "test_helpers/command_helpers"
@@ -0,0 +1,66 @@
1
+ module Clusterfuck::TestHelpers::CommandHelpers
2
+ def machine(host_name)
3
+ host_name = host_name.to_sym
4
+
5
+ Clusterfuck::Cluster.all.each do |cluster|
6
+ if machine = cluster[host_name]
7
+ return machine
8
+ end
9
+ end
10
+ end
11
+
12
+ def run_command(host, cmd)
13
+ cmd = "#{ssh_command(host)} -- #{cmd}"
14
+ `#{cmd}`
15
+ end
16
+
17
+ def ssh_command(host)
18
+ port = machine(host).ssh_port
19
+
20
+ cmd = <<-CMD
21
+ ssh vagrant@localhost
22
+ -p #{port}
23
+ -i ~/.vagrant.d/insecure_private_key
24
+ -o UserKnownHostsFile=/dev/null
25
+ -o StrictHostKeyChecking=no
26
+ -o PasswordAuthentication=no
27
+ -o IdentitiesOnly=yes
28
+ -o LogLevel=quiet
29
+ CMD
30
+
31
+ cmd.gsub("\n", ' ').squeeze(" ").strip
32
+ end
33
+
34
+ def iptables_drop_port(host, port, direction, action: "-D", device: "eth1")
35
+ @hosts_with_iptables ||= []
36
+ @hosts_with_iptables << host
37
+
38
+ ['tcp', 'udp'].each do |proto|
39
+ run_command(host,
40
+ "sudo iptables #{action} #{direction} -p #{proto} --dport #{port} -o #{device} -j DROP > /dev/null"
41
+ )
42
+ end
43
+ end
44
+
45
+ def flush_iptables(host)
46
+ run_command(host, "sudo iptables -F")
47
+ end
48
+
49
+ def block_traffic(host, port, direction = "INPUT")
50
+ iptables_drop_port(host, port, direction, action: "-A")
51
+ end
52
+
53
+ def unblock_traffic(host, port, direction = "INPUT")
54
+ iptables_drop_port(host, port, direction)
55
+ end
56
+
57
+ def sv(host, cmd, service)
58
+ if cmd == 'stop'
59
+ @hosts_with_stopped_services ||= {}
60
+ @hosts_with_stopped_services[host] ||= []
61
+ @hosts_with_stopped_services[host] << service
62
+ end
63
+
64
+ run_command(host, "sudo sv #{cmd} #{service}")
65
+ end
66
+ end
@@ -1,3 +1,3 @@
1
1
  module Clusterfuck
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-clusterfuck
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
  - Simon Eskildsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-04-21 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.7'
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.7'
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: '10.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: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
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: '0'
55
55
  description: Clusterfuck lets you fuck with clusters
@@ -59,7 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gitignore"
62
+ - .gitignore
63
63
  - Gemfile
64
64
  - LICENSE.txt
65
65
  - README.md
@@ -75,6 +75,8 @@ files:
75
75
  - lib/clusterfuck/machine.rb
76
76
  - lib/clusterfuck/quagga_bgp_router.rb
77
77
  - lib/clusterfuck/subnet_factory.rb
78
+ - lib/clusterfuck/test_helpers.rb
79
+ - lib/clusterfuck/test_helpers/command_helpers.rb
78
80
  - lib/clusterfuck/version.rb
79
81
  - templates/quagga.bgpd.conf.erb
80
82
  - templates/quagga.daemons
@@ -96,17 +98,17 @@ require_paths:
96
98
  - lib
97
99
  required_ruby_version: !ruby/object:Gem::Requirement
98
100
  requirements:
99
- - - ">="
101
+ - - '>='
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
- - - ">="
106
+ - - '>='
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.4.5
111
+ rubygems_version: 2.0.3
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: Clusterfuck lets you fuck with clusters