cloudblocks 0.0.12g → 0.0.12h
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cb-agent +3 -8
- metadata +1 -3
- data/bin/chief +0 -143
data/bin/cb-agent
CHANGED
@@ -410,7 +410,7 @@ end
|
|
410
410
|
|
411
411
|
# still no api key, we need to get it
|
412
412
|
if @api_key.empty?
|
413
|
-
puts 'CloudBlocks Agent One-Time Setup'
|
413
|
+
puts 'CloudBlocks Agent One-Time Setup:'
|
414
414
|
@api_key = ask('Please enter your API key. (you can find it at https://cloudblocks.co/me): ')
|
415
415
|
if @api_key.length != 32
|
416
416
|
puts 'Invalid API key'
|
@@ -428,13 +428,8 @@ end
|
|
428
428
|
if @agent_id.empty?
|
429
429
|
@quartz = CloudQuartz.new(:api_key => @api_key, :url => @url, :secret_key => @secret_key)
|
430
430
|
register
|
431
|
-
|
432
|
-
|
433
|
-
@quartz = CloudQuartz.new(:api_key => @api_key, :url => @url, :agent_id => @agent_id, :secret_key => @secret_key)
|
434
|
-
start
|
435
|
-
else
|
436
|
-
exit 0
|
437
|
-
end
|
431
|
+
@quartz = CloudQuartz.new(:api_key => @api_key, :url => @url, :agent_id => @agent_id, :secret_key => @secret_key)
|
432
|
+
start
|
438
433
|
end
|
439
434
|
|
440
435
|
if command.nil? || command.empty?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudblocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12h
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -142,7 +142,6 @@ dependencies:
|
|
142
142
|
description: See http://cloudblocks.co for more info
|
143
143
|
email: hello@thecloudblocks.com
|
144
144
|
executables:
|
145
|
-
- chief
|
146
145
|
- cb-agent
|
147
146
|
extensions: []
|
148
147
|
extra_rdoc_files: []
|
@@ -160,7 +159,6 @@ files:
|
|
160
159
|
- lib/plugins/shell.rb
|
161
160
|
- lib/plugins/tester.rb
|
162
161
|
- lib/plugins/webget.rb
|
163
|
-
- bin/chief
|
164
162
|
- bin/cb-agent
|
165
163
|
homepage: http://cloudblocks.co
|
166
164
|
licenses: []
|
data/bin/chief
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require File.expand_path("../../lib/config-chief", __FILE__)
|
5
|
-
require 'optparse'
|
6
|
-
begin
|
7
|
-
gem 'eventmachine', '~>1.0.0.beta.4'
|
8
|
-
gem 'faye', '~>0.8.0'
|
9
|
-
|
10
|
-
require 'eventmachine'
|
11
|
-
require 'faye'
|
12
|
-
rescue LoadError => exc
|
13
|
-
warn "Cannot find required ruby gems needed to run this agent. Please install cloudblocks gem by running 'gem install cloudblocks'"
|
14
|
-
warn exc
|
15
|
-
exit -1
|
16
|
-
end
|
17
|
-
|
18
|
-
def stop
|
19
|
-
puts "Stopping"
|
20
|
-
EM.stop
|
21
|
-
exit 0
|
22
|
-
end
|
23
|
-
|
24
|
-
config_file = 'cloudblocks.yaml'
|
25
|
-
config_dir = File.join(Dir.home, '.cloudblocks')
|
26
|
-
config_full = File.join(config_dir, config_file)
|
27
|
-
|
28
|
-
api_key = ''
|
29
|
-
faye_url = 'https://sockets.cloudblocks.co/'
|
30
|
-
|
31
|
-
if File.exists?(config_full)
|
32
|
-
# config file present
|
33
|
-
config = YAML::load(File.open(config_full))
|
34
|
-
api_key = config['api_key']
|
35
|
-
else
|
36
|
-
# no config file
|
37
|
-
puts 'CloudBlocks ConfigChief'
|
38
|
-
puts 'Please enter your API key. (you can find it at https://cloudblocks.co/me):'
|
39
|
-
api_key = gets
|
40
|
-
api_key = api_key.chomp
|
41
|
-
if api_key.length != 32
|
42
|
-
puts 'Invalid API key'
|
43
|
-
exit -1
|
44
|
-
else
|
45
|
-
if !FileTest::directory?(config_dir)
|
46
|
-
Dir.mkdir(config_dir)
|
47
|
-
end
|
48
|
-
File.open(config_full, 'w+') { |out| YAML::dump({ 'api_key' => api_key }, out) }
|
49
|
-
puts 'Configuration Saved'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
@version = 1
|
54
|
-
str_version = "0.0.#{@version}"
|
55
|
-
workspace = nil
|
56
|
-
key = nil
|
57
|
-
is_test = false
|
58
|
-
parameters = {}
|
59
|
-
url = nil
|
60
|
-
id = nil
|
61
|
-
OptionParser.new do |opts|
|
62
|
-
opts.banner = <<-EOF
|
63
|
-
ConfigChief. v#{str_version} (c) 2012 CloudBlocks
|
64
|
-
For more information please visit http://cloudblocks.co
|
65
|
-
|
66
|
-
Usage: chief [options]
|
67
|
-
|
68
|
-
Options:
|
69
|
-
EOF
|
70
|
-
|
71
|
-
opts.on("-w", "--workspace WORKSPACE", "Workspace id") do |v|
|
72
|
-
workspace = v
|
73
|
-
end
|
74
|
-
|
75
|
-
opts.on('-u', '--url URL', 'Server URL') do |v|
|
76
|
-
url = v
|
77
|
-
end
|
78
|
-
url = url || 'https://api.cloudblocks.co'
|
79
|
-
|
80
|
-
opts.on('-k', '--key KEY', 'Config Key') do |v|
|
81
|
-
key = v
|
82
|
-
end
|
83
|
-
|
84
|
-
opts.on('--api-key APIKEY', 'API key') do |v|
|
85
|
-
api_key = v
|
86
|
-
end
|
87
|
-
|
88
|
-
opts.on('-i', '--id ID', 'Config Id') do |v|
|
89
|
-
id = v
|
90
|
-
end
|
91
|
-
|
92
|
-
opts.on('-p', '--parameters P1=V1,P2=V2,...', Array, 'Optional Parameters') do |v|
|
93
|
-
v.each do |p|
|
94
|
-
pv = p.split('=')
|
95
|
-
if pv.count != 2 || pv[0].nil? || pv[1].nil?
|
96
|
-
warn 'Invalid Parameters. Use -h for help'
|
97
|
-
exit -1
|
98
|
-
end
|
99
|
-
|
100
|
-
parameters = parameters.merge({pv[0].to_sym => pv[1]})
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
opts.on('-t', '--test', 'Test mode. Shows updates received from the server') do |v|
|
105
|
-
is_test = true
|
106
|
-
end
|
107
|
-
|
108
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
109
|
-
puts opts
|
110
|
-
exit 0
|
111
|
-
end
|
112
|
-
end.parse!
|
113
|
-
|
114
|
-
if workspace.nil?
|
115
|
-
warn 'No workspace specified. Use --help for more info'
|
116
|
-
exit -1
|
117
|
-
end
|
118
|
-
|
119
|
-
if key.nil? && id.nil? && !is_test
|
120
|
-
warn 'Either id (-i) or key (-k) have to be present'
|
121
|
-
exit -1
|
122
|
-
end
|
123
|
-
|
124
|
-
if is_test
|
125
|
-
EM.run {
|
126
|
-
Signal.trap('INT') { stop }
|
127
|
-
Signal.trap('TERM'){ stop }
|
128
|
-
|
129
|
-
puts "Listening for /chief/keys/#{workspace} now on #{faye_url}"
|
130
|
-
client = Faye::Client.new(faye_url)
|
131
|
-
client.subscribe("/chief/keys/#{workspace}") do |message|
|
132
|
-
puts message.inspect
|
133
|
-
end
|
134
|
-
}
|
135
|
-
else
|
136
|
-
chief = ConfigChief.new(:api_key => api_key, :workspace => workspace, :url => url)
|
137
|
-
if (key.nil?)
|
138
|
-
puts chief.get_by_id(id, {}, parameters)
|
139
|
-
else
|
140
|
-
# let's get to bussiness
|
141
|
-
puts chief.get_by_key(key, {}, parameters)
|
142
|
-
end
|
143
|
-
end
|