bosh_cli_plugin_consul 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +3 -0
- data/ChangeLog.md +12 -0
- data/Gemfile +8 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +2 -0
- data/bosh_cli_plugin_consul.gemspec +28 -0
- data/lib/bosh/cli/commands/consul_commands.rb +150 -0
- data/lib/bosh/consul.rb +6 -0
- data/lib/bosh/consul/models.rb +8 -0
- data/lib/bosh/consul/models/cluster.rb +54 -0
- data/lib/bosh/consul/models/services.rb +20 -0
- data/lib/bosh_cli_plugin_consul.rb +5 -0
- data/lib/bosh_cli_plugin_consul/version.rb +3 -0
- data/spec/models/cluster_spec.rb +34 -0
- data/spec/models/services_spec.rb +11 -0
- data/spec/spec_helper.rb +59 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42103263896620cf47360b7b8d04ce61fa4e7ef6
|
4
|
+
data.tar.gz: 9d5dae269c4ac44c5f85edef7168117d668b1fb2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f841187931b50cc360de71ddccb606d28ad10bd959bf5c4634a71e4895162be883d66670c6c970bb8ca031e78d07629dcd3c096676d0afbc323e54d46df7d75f
|
7
|
+
data.tar.gz: bb806d0a74e4ac5fac650c080b45bec9594b2a61f1601d16274aac48730f55c9ee872afc3ee2e9ddca86e050041abbf024c14b1de9fa47bb1280affb45cea780
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/ChangeLog.md
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dr Nic Williams
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
BOSH CLI plugin for Consul
|
2
|
+
==========================
|
3
|
+
|
4
|
+
If you're using consul within your BOSH deployments (such as [redis-boshrelease](https://github.com/cloudfoundry-community/redis-boshrelease#consul-service-advertisement)), or running a cluster of consul servers ([consul-boshrelease](https://github.com/cloudfoundry-community/consul-boshrelease)), this BOSH CLI plugin is a very handy ops tool.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Install via RubyGems:
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install bosh_cli_plugin_consul
|
13
|
+
```
|
14
|
+
|
15
|
+
Usage
|
16
|
+
-----
|
17
|
+
|
18
|
+
To see the list of commands: `bosh consul`
|
19
|
+
|
20
|
+
To use the CLI plugin, first target the consul cluster (`bosh target consul`).
|
21
|
+
|
22
|
+
### Target consul
|
23
|
+
|
24
|
+
The CLI can discover the consul cluster from any BOSH deployment using consul. The consul cluster does not even have to be managed by BOSH.
|
25
|
+
|
26
|
+
```
|
27
|
+
$ bosh target consul
|
28
|
+
1. consul-warden
|
29
|
+
2. redis-warden
|
30
|
+
Choose a deployment: 2
|
31
|
+
Fetching consul cluster info from deployment 'redis-warden'...
|
32
|
+
|
33
|
+
Current consul cluster from deployment 'redis-warden' OK
|
34
|
+
Leader 10.244.4.6
|
35
|
+
Peers 10.244.4.14, 10.244.4.6, 10.244.4.10
|
36
|
+
```
|
37
|
+
|
38
|
+
### View services
|
39
|
+
|
40
|
+
```
|
41
|
+
$ bosh consul services
|
42
|
+
+--------------+--------------+-------------+------+--------+
|
43
|
+
| name | service id | ip | port | tags |
|
44
|
+
+--------------+--------------+-------------+------+--------+
|
45
|
+
| consul | consul | 10.244.4.6 | 8300 | |
|
46
|
+
| | | 10.244.4.10 | 8300 | |
|
47
|
+
| | | 10.244.4.14 | 8300 | |
|
48
|
+
+--------------+--------------+-------------+------+--------+
|
49
|
+
| redis-warden | redis-warden | 10.244.2.6 | 6379 | master |
|
50
|
+
| | | 10.244.2.14 | 6379 | slave |
|
51
|
+
| | | 10.244.2.10 | 6379 | slave |
|
52
|
+
+--------------+--------------+-------------+------+--------+
|
53
|
+
|
54
|
+
$ bosh consul services --dns
|
55
|
+
+--------------+--------------+-------------+------+--------+-----------------------------------------------------------------+
|
56
|
+
| name | service id | ip | port | tags | dns |
|
57
|
+
+--------------+--------------+-------------+------+--------+-----------------------------------------------------------------+
|
58
|
+
| consul | consul | 10.244.4.6 | 8300 | | consul.service.consul |
|
59
|
+
| | | 10.244.4.10 | 8300 | | consul.service.consul |
|
60
|
+
| | | 10.244.4.14 | 8300 | | consul.service.consul |
|
61
|
+
+--------------+--------------+-------------+------+--------+-----------------------------------------------------------------+
|
62
|
+
| redis-warden | redis-warden | 10.244.2.6 | 6379 | master | redis-warden.service.consul, master.redis-warden.service.consul |
|
63
|
+
| | | 10.244.2.14 | 6379 | slave | redis-warden.service.consul, slave.redis-warden.service.consul |
|
64
|
+
| | | 10.244.2.10 | 6379 | slave | redis-warden.service.consul, slave.redis-warden.service.consul |
|
65
|
+
+--------------+--------------+-------------+------+--------+-----------------------------------------------------------------+
|
66
|
+
```
|
67
|
+
|
68
|
+
Contributing
|
69
|
+
------------
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/[my-github-username]/bosh_cli_plugin_consul/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bosh_cli_plugin_consul/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bosh_cli_plugin_consul"
|
8
|
+
spec.version = BoshCliPluginConsul::VERSION
|
9
|
+
spec.authors = ["Dr Nic Williams"]
|
10
|
+
spec.email = ["drnicwilliams@gmail.com"]
|
11
|
+
spec.summary = %q{BOSH CLI plugin for access, visibility and status of deployments using Consul}
|
12
|
+
spec.description = %q{BOSH CLI plugin for access, visibility and status of deployments using Consul}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "bosh_cli"
|
22
|
+
spec.add_dependency "rest-client"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "rspec-fire"
|
28
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
$:.unshift(File.expand_path("../../../..", __FILE__))
|
2
|
+
|
3
|
+
module Bosh::Cli::Command
|
4
|
+
class ConsulCommands < Base
|
5
|
+
include Bosh::Cli::Validation
|
6
|
+
|
7
|
+
DEFAULT_CONFIG_PATH = File.expand_path('~/.bosh_consul_config')
|
8
|
+
|
9
|
+
def initialize(runner)
|
10
|
+
super(runner)
|
11
|
+
# options[:config] ||= DEFAULT_CONFIG_PATH # hijack Cli::Config
|
12
|
+
end
|
13
|
+
|
14
|
+
usage "consul"
|
15
|
+
desc "show consul commands"
|
16
|
+
def consul_help
|
17
|
+
say("bosh consul commands:")
|
18
|
+
nl
|
19
|
+
cmds = Bosh::Cli::Config.commands.values.find_all {|c|
|
20
|
+
c.usage =~ /consul/
|
21
|
+
}
|
22
|
+
Bosh::Cli::Command::Help.list_commands(cmds)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
usage "target consul"
|
27
|
+
desc "target a consul cluster"
|
28
|
+
def target_consul(deployment_name=nil)
|
29
|
+
require "bosh/consul"
|
30
|
+
|
31
|
+
unless deployment_name
|
32
|
+
deployment_name = prompt_for_deployment
|
33
|
+
end
|
34
|
+
|
35
|
+
say "Fetching consul cluster info from deployment '#{deployment_name}'..."
|
36
|
+
cluster = Bosh::Consul::Models::Cluster.new(director)
|
37
|
+
cluster.load_from_deployment_name(deployment_name)
|
38
|
+
step("Current consul cluster from deployment '#{deployment_name}'", "Cannot find consul cluster '#{deployment_name}'", :fatal) do
|
39
|
+
cluster.valid?
|
40
|
+
end
|
41
|
+
show_cluster(cluster)
|
42
|
+
|
43
|
+
consul_config = config.read("consul") || {}
|
44
|
+
consul_config[target] = { "leader" => cluster.leader, "peers" => cluster.peers, "domain" => cluster.domain }
|
45
|
+
config.write_global("consul", consul_config)
|
46
|
+
config.save
|
47
|
+
|
48
|
+
rescue Bosh::Cli::ValidationHalted
|
49
|
+
err errors.first
|
50
|
+
# rescue => e
|
51
|
+
# puts e.message
|
52
|
+
end
|
53
|
+
|
54
|
+
usage "consul status"
|
55
|
+
desc "display status of target consul cluster"
|
56
|
+
def display_status
|
57
|
+
require "bosh/consul"
|
58
|
+
|
59
|
+
verify_target_consul_config
|
60
|
+
cluster = load_cluster
|
61
|
+
show_cluster(cluster)
|
62
|
+
end
|
63
|
+
|
64
|
+
usage "consul services"
|
65
|
+
desc "display services advertises on consul"
|
66
|
+
option "--dns", "show dns hostnames"
|
67
|
+
def display_services
|
68
|
+
require "bosh/consul"
|
69
|
+
show_dns = options[:dns]
|
70
|
+
|
71
|
+
cluster = load_cluster
|
72
|
+
domain = cluster.domain
|
73
|
+
|
74
|
+
services = Bosh::Consul::Models::Services.new
|
75
|
+
require "pp"
|
76
|
+
items = services.load_from_ip(cluster.leader)
|
77
|
+
|
78
|
+
previous_name = nil
|
79
|
+
view = table(items) do |t|
|
80
|
+
t.headings = ["name", "service id", "ip", "port", "tags"]
|
81
|
+
t.headings << "dns" if show_dns
|
82
|
+
items.each do |item|
|
83
|
+
same_as_previous = (previous_name == item["ServiceName"])
|
84
|
+
if previous_name && !same_as_previous
|
85
|
+
t.add_separator
|
86
|
+
end
|
87
|
+
|
88
|
+
tags = item["ServiceTags"] || []
|
89
|
+
if show_dns
|
90
|
+
dns = ["#{item["ServiceName"]}.service.#{domain}"]
|
91
|
+
tags.each do |tag|
|
92
|
+
dns << "#{tag}.#{item["ServiceName"]}.service.#{domain}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
row = [
|
97
|
+
same_as_previous ? "" : item["ServiceName"],
|
98
|
+
same_as_previous ? "" : item["ServiceID"],
|
99
|
+
item["Address"],
|
100
|
+
item["ServicePort"],
|
101
|
+
tags.join(", ")
|
102
|
+
]
|
103
|
+
row << dns.join(", ") if show_dns
|
104
|
+
t << row
|
105
|
+
|
106
|
+
previous_name = item["ServiceName"]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
say(view)
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def prompt_for_deployment
|
115
|
+
names = director.list_deployments.map { |deployment| deployment["name"] }
|
116
|
+
return names.first if names.size == 1
|
117
|
+
|
118
|
+
choose do |menu|
|
119
|
+
menu.prompt = 'Choose a deployment: '
|
120
|
+
names.each do |name|
|
121
|
+
menu.choice(name) { name }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def show_cluster(cluster)
|
127
|
+
say('Leader'.ljust(10) + cluster.leader)
|
128
|
+
say('Peers'.ljust(10) + cluster.peers.join(", "))
|
129
|
+
end
|
130
|
+
|
131
|
+
# loads consul configuration for the target director
|
132
|
+
def target_consul_config
|
133
|
+
consul_config = config.read("consul") || {}
|
134
|
+
consul_config[target]
|
135
|
+
end
|
136
|
+
|
137
|
+
def verify_target_consul_config
|
138
|
+
unless target_consul_config
|
139
|
+
err "First target a consul deployment with 'bosh target consul'"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def load_cluster
|
144
|
+
leader_ip = target_consul_config["leader"]
|
145
|
+
cluster = Bosh::Consul::Models::Cluster.new(director)
|
146
|
+
cluster.load_from_agent(leader_ip)
|
147
|
+
cluster
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/lib/bosh/consul.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Bosh::Consul::Models::Cluster
|
2
|
+
attr_reader :director_client
|
3
|
+
attr_reader :leader, :peers, :domain
|
4
|
+
|
5
|
+
def initialize(director_client)
|
6
|
+
@director_client = director_client
|
7
|
+
|
8
|
+
# FIXME: waiting on an API endpoint to discover the domain
|
9
|
+
@domain = "consul"
|
10
|
+
end
|
11
|
+
|
12
|
+
# A [re-]initialization method to get IPs for a cluster
|
13
|
+
def load_from_deployment_name(deployment_name)
|
14
|
+
@leader = @peers = nil
|
15
|
+
|
16
|
+
# fetch_vm_state raises error if name invalid
|
17
|
+
vms = director_client.fetch_vm_state(deployment_name)
|
18
|
+
deployment_ips = vms.map {|vm| vm["ips"].first }
|
19
|
+
discover_from_ips(deployment_ips)
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_from_agent(leader_ip)
|
23
|
+
@leader = @peers = nil
|
24
|
+
discover_from_ips([leader_ip])
|
25
|
+
end
|
26
|
+
|
27
|
+
# Discover the consul cluster from the IPs of servers or clients to the cluster
|
28
|
+
# Setups up @leader & @peers IP addresses
|
29
|
+
def discover_from_ips(ips)
|
30
|
+
ip = ips.first
|
31
|
+
if @leader = get(ip, "/v1/status/leader")
|
32
|
+
@leader =~ /"(.*):(\d+)"/
|
33
|
+
@leader, @cluster_port = $1, $2
|
34
|
+
@peers = JSON.parse(get(ip, "/v1/status/peers"))
|
35
|
+
@peers.map! do |peer|
|
36
|
+
peer =~ /(.*):(\d+)/
|
37
|
+
$1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid?
|
43
|
+
@leader
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def get(ip, path)
|
48
|
+
consul_api(ip)[path].get
|
49
|
+
end
|
50
|
+
|
51
|
+
def consul_api(ip)
|
52
|
+
RestClient::Resource.new("http://#{ip}:8500")
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Bosh::Consul::Models::Services
|
2
|
+
def load_from_ip(ip)
|
3
|
+
nodes = []
|
4
|
+
services = JSON.parse(get(ip, "/v1/catalog/services"))
|
5
|
+
services.each do |name, tags|
|
6
|
+
service_nodes = JSON.parse(get(ip, "/v1/catalog/service/#{name}"))
|
7
|
+
nodes.push(*service_nodes)
|
8
|
+
end
|
9
|
+
nodes
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def get(ip, path)
|
14
|
+
consul_api(ip)[path].get
|
15
|
+
end
|
16
|
+
|
17
|
+
def consul_api(ip)
|
18
|
+
RestClient::Resource.new("http://#{ip}:8500")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
describe Bosh::Consul::Models::Cluster do
|
2
|
+
let(:director) { double("Bosh::Cli::Client::Director") }
|
3
|
+
|
4
|
+
subject { Bosh::Consul::Models::Cluster.new(director) }
|
5
|
+
|
6
|
+
it "initially does not represent a cluster" do
|
7
|
+
expect(subject.valid?).to be_false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can load consul cluster IPs from any deployment" do
|
11
|
+
expect(director).to receive(:fetch_vm_state).and_return([{"ips" => ["10.244.4.2"]}, {"ips" => ["10.244.4.6"]}])
|
12
|
+
expect(subject).to receive(:discover_from_ips).with(["10.244.4.2", "10.244.4.6"])
|
13
|
+
subject.load_from_deployment_name("foobar")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can load cluster from single IP of consul server or agent" do
|
17
|
+
expect(subject).to receive(:discover_from_ips).with(["10.244.4.2"])
|
18
|
+
subject.load_from_agent("10.244.4.2")
|
19
|
+
end
|
20
|
+
|
21
|
+
context "from any agent" do
|
22
|
+
let(:target_ip) { "10.244.10.10" }
|
23
|
+
let(:api) { RestClient::Resource.new("http://#{target_ip}:8500") }
|
24
|
+
|
25
|
+
it "can discover the leader & peers" do
|
26
|
+
expect(subject).to receive(:get).with("10.244.10.10", "/v1/status/leader").and_return('"10.244.4.2:8300"\n')
|
27
|
+
expect(subject).to receive(:get).with("10.244.10.10", "/v1/status/peers").and_return('["10.244.4.2:8300", "10.244.4.6:8300"]')
|
28
|
+
subject.discover_from_ips(["10.244.10.10"])
|
29
|
+
expect(subject.leader).to eq "10.244.4.2"
|
30
|
+
expect(subject.peers).to eq ["10.244.4.2", "10.244.4.6"]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
describe Bosh::Consul::Models::Services do
|
2
|
+
subject { Bosh::Consul::Models::Services.new }
|
3
|
+
|
4
|
+
it "fetches services" do
|
5
|
+
expect(subject).to receive(:get).with("10.244.4.2", "/v1/catalog/services").and_return('{"consul":[],"redis-warden":["master", "slave"]}')
|
6
|
+
expect(subject).to receive(:get).with("10.244.4.2", "/v1/catalog/service/consul").and_return('[{"Node":"consul-warden-consul_server_z1-0","Address":"10.244.4.6","ServiceID":"consul","ServiceName":"consul","ServiceTags":null,"ServicePort":8300},{"Node":"consul-warden-consul_server_z1-1","Address":"10.244.4.10","ServiceID":"consul","ServiceName":"consul","ServiceTags":null,"ServicePort":8300},{"Node":"consul-warden-consul_server_z1-2","Address":"10.244.4.14","ServiceID":"consul","ServiceName":"consul","ServiceTags":null,"ServicePort":8300}]')
|
7
|
+
expect(subject).to receive(:get).with("10.244.4.2", "/v1/catalog/service/redis-warden").and_return('[{"Node":"redis-warden-redis_leader_z1-0","Address":"10.244.2.6","ServiceID":"redis-warden","ServiceName":"redis-warden","ServiceTags":["master"],"ServicePort":6379},{"Node":"redis-warden-redis_z1-1","Address":"10.244.2.14","ServiceID":"redis-warden","ServiceName":"redis-warden","ServiceTags":["slave"],"ServicePort":6379},{"Node":"redis-warden-redis_z1-0","Address":"10.244.2.10","ServiceID":"redis-warden","ServiceName":"redis-warden","ServiceTags":["slave"],"ServicePort":6379}]')
|
8
|
+
|
9
|
+
subject.load_from_ip("10.244.4.2")
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2012-2013 Stark & Wayne, LLC
|
2
|
+
|
3
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "bundler"
|
7
|
+
Bundler.setup(:default, :test)
|
8
|
+
|
9
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
10
|
+
|
11
|
+
require "rspec/core"
|
12
|
+
require 'rspec/fire'
|
13
|
+
|
14
|
+
# for the #sh helper
|
15
|
+
require "rake"
|
16
|
+
require "rake/file_utils"
|
17
|
+
|
18
|
+
# bosh_cli
|
19
|
+
require "cli"
|
20
|
+
|
21
|
+
require "bosh/consul"
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include(RSpec::Fire)
|
25
|
+
end
|
26
|
+
|
27
|
+
# load all files in spec/support/* (but not lower down)
|
28
|
+
Dir[File.dirname(__FILE__) + '/support/*'].each do |path|
|
29
|
+
require path unless File.directory?(path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def spec_fixture(filename)
|
33
|
+
File.expand_path("../fixtures/#{filename}", __FILE__)
|
34
|
+
end
|
35
|
+
|
36
|
+
def setup_home_dir
|
37
|
+
home_dir = File.expand_path("../../tmp/home", __FILE__)
|
38
|
+
FileUtils.rm_rf(home_dir)
|
39
|
+
FileUtils.mkdir_p(home_dir)
|
40
|
+
ENV['HOME'] = home_dir
|
41
|
+
end
|
42
|
+
|
43
|
+
# returns the file path to a file
|
44
|
+
# in the fake $HOME folder
|
45
|
+
def home_file(*path)
|
46
|
+
File.join(ENV['HOME'], *path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def in_home_dir(&block)
|
50
|
+
FileUtils.chdir(home_file, &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_tmp_file_path(content)
|
54
|
+
tmp_file = File.open(File.join(Dir.mktmpdir, "tmp"), "w")
|
55
|
+
tmp_file.write(content)
|
56
|
+
tmp_file.close
|
57
|
+
|
58
|
+
tmp_file.path
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bosh_cli_plugin_consul
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dr Nic Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bosh_cli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-fire
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: BOSH CLI plugin for access, visibility and status of deployments using
|
98
|
+
Consul
|
99
|
+
email:
|
100
|
+
- drnicwilliams@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ChangeLog.md
|
108
|
+
- Gemfile
|
109
|
+
- Guardfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bosh_cli_plugin_consul.gemspec
|
114
|
+
- lib/bosh/cli/commands/consul_commands.rb
|
115
|
+
- lib/bosh/consul.rb
|
116
|
+
- lib/bosh/consul/models.rb
|
117
|
+
- lib/bosh/consul/models/cluster.rb
|
118
|
+
- lib/bosh/consul/models/services.rb
|
119
|
+
- lib/bosh_cli_plugin_consul.rb
|
120
|
+
- lib/bosh_cli_plugin_consul/version.rb
|
121
|
+
- spec/models/cluster_spec.rb
|
122
|
+
- spec/models/services_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: ''
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: BOSH CLI plugin for access, visibility and status of deployments using Consul
|
148
|
+
test_files:
|
149
|
+
- spec/models/cluster_spec.rb
|
150
|
+
- spec/models/services_spec.rb
|
151
|
+
- spec/spec_helper.rb
|