gaddygaddy 0.1.89 → 0.1.90
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 +4 -4
- data/lib/gaddygaddy-client/chef_files.rb +1 -1
- data/lib/gaddygaddy-client.rb +67 -9
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac28e968392ddf19b195494d719948429a4b6f9c
|
4
|
+
data.tar.gz: a931d37d21e00cd0cd6b9ea586f9d123d2644375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e443b7fcd600dec082a36e2c5dfb1bd3a56107d6a3a1991839b2a3428c2e196ac8b8e42936a439831e2eaabe2c6b91bafac3f2d3bb3cfde5581900233378a18
|
7
|
+
data.tar.gz: 8f61f0c74f560bae3acc390978a5a7f92687a860eda2e1618c37fdb3436cdd5d8e1af46b8cf2cec0ceb22197c72ba485115fa2852050febef2e19346e5081558
|
data/lib/gaddygaddy-client.rb
CHANGED
@@ -153,6 +153,9 @@ class GaddyGaddy_Client
|
|
153
153
|
opts.on("-p", "--password password", "Password") do |password|
|
154
154
|
@options[:password] = password
|
155
155
|
end
|
156
|
+
opts.on("-c", "--create", "Create new gaddy if it doesn't exist") do
|
157
|
+
@options[:create] = true
|
158
|
+
end
|
156
159
|
end
|
157
160
|
|
158
161
|
command :send_device_data do |opts|
|
@@ -264,25 +267,80 @@ class GaddyGaddy_Client
|
|
264
267
|
|
265
268
|
def get_gaddy_config(name, user, password)
|
266
269
|
path = URI.encode("/device/config_file/1/#{name}?user_name=#{user}&user_password=#{password}").gsub('+', '%2B')
|
267
|
-
puts path
|
268
270
|
response = Request.client_service_get get_host, path
|
269
271
|
logger.debug "Got config file: #{response}"
|
270
272
|
response
|
271
273
|
end
|
272
274
|
|
275
|
+
|
276
|
+
# Get the config file and return the response
|
277
|
+
def get_conf_file
|
278
|
+
name = @options[:gaddy_name]
|
279
|
+
conf_content = get_gaddy_config(name, @options[:user_name], @options[:password])
|
280
|
+
gaddy_file_name = "gaddy_#{name}.gcf"
|
281
|
+
conf_file_name = File.join(conf_dir, gaddy_file_name)
|
282
|
+
if conf_content['device_name'] && conf_content['device_name'] == name
|
283
|
+
begin
|
284
|
+
conf_file = File.open conf_file_name, "w"
|
285
|
+
conf_file.write conf_content.to_json
|
286
|
+
conf_file.close
|
287
|
+
logger.info "Have created the configuration file for the gaddy in #{conf_file_name}"
|
288
|
+
rescue
|
289
|
+
logger.error "Could not write configuration #{conf_file_name}"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
conf_content
|
293
|
+
end
|
294
|
+
|
295
|
+
def create_gaddy(gaddy_name, user_name, password)
|
296
|
+
url = Request.get_base_url(get_host) + "/installation/device/1"
|
297
|
+
params = {:device_name => gaddy_name,
|
298
|
+
:user_name => user_name,
|
299
|
+
:user_password => password
|
300
|
+
}
|
301
|
+
response = Request.client_service_post url, params
|
302
|
+
logger.debug "The response for the request is #{response} #{response.class}"
|
303
|
+
raise JCouldNotPostClientDataException.new({:message=> "Could not post data to the gaddygaddy service, error code is #{response.body}"}) unless response[:status].to_i == 0
|
304
|
+
end
|
305
|
+
|
306
|
+
def create_new(name)
|
307
|
+
inp = ''
|
308
|
+
unless @options[:create]
|
309
|
+
puts "Gaddy #{name} doesn't exist, would you like to create it (Y/N)"
|
310
|
+
answer = nil
|
311
|
+
while answer.nil?
|
312
|
+
inp = gets.chomp.upcase
|
313
|
+
if inp
|
314
|
+
answer = ['Y','N'].index(inp[0]) ? inp : nil
|
315
|
+
else
|
316
|
+
puts
|
317
|
+
puts "Gaddy #{name} doesn't exist, would you like to create it (Y/N)"
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
@options[:create] || (inp == 'Y')
|
322
|
+
end
|
323
|
+
|
273
324
|
# Get the gaddy configuration and place it in /conf named gaddy_NAME.gcf
|
274
|
-
def gaddy_config
|
325
|
+
def gaddy_config(gaddy_name, user_name, password)
|
326
|
+
raise "You need to pass name of gaddy, username and password as parameters, see gaddygaddy-client gaddy_file --help" unless gaddy_name && password && user_name
|
275
327
|
begin
|
276
328
|
FileUtils.mkdir_p conf_dir
|
277
329
|
rescue Exception => e
|
278
330
|
raise e.inspect
|
279
331
|
end
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
332
|
+
if get_conf_file['status'] == 12
|
333
|
+
if create_new(gaddy_name)
|
334
|
+
logger.info "Will create a new gaddy named #{gaddy_name}"
|
335
|
+
create_gaddy(gaddy_name, user_name, password)
|
336
|
+
if get_conf_file['status'] == 12
|
337
|
+
puts "Can't find gaddy with name #{name}"
|
338
|
+
end
|
339
|
+
else
|
340
|
+
puts "Can't find gaddy with name #{name}"
|
341
|
+
puts 'If you would like to create it add parameter --create to the command'
|
342
|
+
end
|
343
|
+
end
|
286
344
|
|
287
345
|
end
|
288
346
|
|
@@ -426,7 +484,7 @@ class GaddyGaddy_Client
|
|
426
484
|
when "chef_config"
|
427
485
|
get_chef_config
|
428
486
|
when 'gaddy_file'
|
429
|
-
gaddy_config
|
487
|
+
gaddy_config(@options[:gaddy_name], @options[:user_name], @options[:password])
|
430
488
|
when 'send_device_data'
|
431
489
|
send_device_data
|
432
490
|
when "verify_installation"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaddygaddy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.90
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GaddyGaddy
|
@@ -14,84 +14,84 @@ dependencies:
|
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
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: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: log4r
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
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: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rest-client
|
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: :runtime
|
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
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: stringex
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: subcommand
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: systemu
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: |-
|
@@ -144,17 +144,17 @@ require_paths:
|
|
144
144
|
- lib
|
145
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- -
|
147
|
+
- - '>='
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - '>='
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.2.2
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Client tools used for the Gaddygaddy service
|