cft_smartcloud 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/README.md +106 -0
- data/VERSION +1 -1
- data/bin/cft_smartcloud +33 -7
- data/bin/smartcloud +33 -7
- data/cft_smartcloud.gemspec +84 -20
- data/lib/config/config.yml +2 -0
- data/lib/curl_client.rb +42 -0
- data/lib/rest-client-1.6.6-master/.gitignore +6 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/README.rdoc +10 -1
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/Rakefile +0 -0
- data/lib/rest-client-1.6.6-master/VERSION +1 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/bin/restclient +5 -4
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/history.md +22 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest-client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest_client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/abstract_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/exceptions.rb +0 -0
- data/lib/rest-client-1.6.6-master/lib/restclient/net_http_ext.rb +55 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/payload.rb +17 -2
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/raw_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/request.rb +21 -19
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/resource.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient.rb +0 -0
- data/lib/rest-client-1.6.6-master/rest-client.gemspec +76 -0
- data/lib/rest-client-1.6.6-master/spec/abstract_response_spec.rb +85 -0
- data/lib/rest-client-1.6.6-master/spec/base.rb +16 -0
- data/lib/rest-client-1.6.6-master/spec/exceptions_spec.rb +98 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/equifax.crt +19 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/verisign.crt +14 -0
- data/lib/rest-client-1.6.6-master/spec/integration/request_spec.rb +25 -0
- data/lib/rest-client-1.6.6-master/spec/integration_spec.rb +38 -0
- data/lib/rest-client-1.6.6-master/spec/master_shake.jpg +0 -0
- data/lib/rest-client-1.6.6-master/spec/payload_spec.rb +234 -0
- data/lib/rest-client-1.6.6-master/spec/raw_response_spec.rb +17 -0
- data/lib/rest-client-1.6.6-master/spec/request2_spec.rb +40 -0
- data/lib/rest-client-1.6.6-master/spec/request_spec.rb +536 -0
- data/lib/rest-client-1.6.6-master/spec/resource_spec.rb +134 -0
- data/lib/rest-client-1.6.6-master/spec/response_spec.rb +169 -0
- data/lib/rest-client-1.6.6-master/spec/restclient_spec.rb +73 -0
- data/lib/slop-2.3.1/.gemtest +0 -0
- data/lib/slop-2.3.1/.gitignore +6 -0
- data/lib/slop-2.3.1/.yardopts +6 -0
- data/lib/slop-2.3.1/CHANGES.md +137 -0
- data/lib/slop-2.3.1/LICENSE +20 -0
- data/lib/slop-2.3.1/README.md +293 -0
- data/lib/slop-2.3.1/Rakefile +6 -0
- data/lib/slop-2.3.1/lib/slop.rb +1022 -0
- data/lib/slop-2.3.1/slop.gemspec +11 -0
- data/lib/slop-2.3.1/test/commands_test.rb +151 -0
- data/lib/slop-2.3.1/test/helper.rb +13 -0
- data/lib/slop-2.3.1/test/option_test.rb +198 -0
- data/lib/slop-2.3.1/test/slop_test.rb +574 -0
- data/lib/smartcloud.rb +186 -116
- data/lib/terminal-table-1.4.4/History.rdoc +53 -0
- data/lib/terminal-table-1.4.4/Manifest +24 -0
- data/lib/terminal-table-1.4.4/README.rdoc +240 -0
- data/lib/terminal-table-1.4.4/Rakefile +15 -0
- data/lib/terminal-table-1.4.4/Todo.rdoc +14 -0
- data/lib/terminal-table-1.4.4/examples/examples.rb +80 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/cell.rb +88 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/core_ext.rb +8 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/import.rb +4 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/row.rb +48 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/separator.rb +14 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/style.rb +61 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table.rb +217 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table_helper.rb +9 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/version.rb +6 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table.rb +27 -0
- data/lib/terminal-table-1.4.4/spec/cell_spec.rb +54 -0
- data/lib/terminal-table-1.4.4/spec/core_ext_spec.rb +18 -0
- data/lib/terminal-table-1.4.4/spec/import_spec.rb +11 -0
- data/lib/terminal-table-1.4.4/spec/spec.opts +1 -0
- data/lib/terminal-table-1.4.4/spec/spec_helper.rb +8 -0
- data/lib/terminal-table-1.4.4/spec/table_spec.rb +525 -0
- data/lib/terminal-table-1.4.4/tasks/docs.rake +13 -0
- data/lib/terminal-table-1.4.4/tasks/gemspec.rake +3 -0
- data/lib/terminal-table-1.4.4/tasks/spec.rake +25 -0
- data/lib/terminal-table-1.4.4/terminal-table.gemspec +30 -0
- data/responses/addresses +26 -0
- data/responses/addresses.blank +2 -0
- data/responses/instances +74 -0
- data/responses/keys +33 -0
- data/responses/locations +142 -0
- data/responses/offerings_image +3780 -0
- data/responses/storage +379 -0
- metadata +86 -22
- data/README.rdoc +0 -75
- data/lib/rest-client-1.6.3/VERSION +0 -1
- data/lib/rest-client-1.6.3/lib/restclient/net_http_ext.rb +0 -21
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
2011-11-21 0.3.0:
|
2
|
+
* Support for smartcloud import/export api
|
3
|
+
* Ability to use -S to save responses and -R to play them back
|
4
|
+
for offline testing
|
5
|
+
* Cleaner output display using ascii tables
|
6
|
+
|
7
|
+
2011-11-16 0.2.5:
|
8
|
+
* Better help display
|
9
|
+
* Support for -u, -p, -U (username, password, api url)
|
10
|
+
* Removed delete_unused_keys method (was not working correctly / not needed)
|
11
|
+
|
1
12
|
2011-09-21 0.2.1:
|
2
13
|
* Added sleep/retry logic for intermittent 500 errors returned by cloud
|
3
14
|
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
smartcloud
|
2
|
+
===
|
3
|
+
|
4
|
+
Provides support for interacting with IBM SmartCloud API and CLI tools
|
5
|
+
|
6
|
+
installation
|
7
|
+
===
|
8
|
+
|
9
|
+
from rubygems.org:
|
10
|
+
|
11
|
+
gem install cft_smartcloud
|
12
|
+
|
13
|
+
locally:
|
14
|
+
|
15
|
+
rake build
|
16
|
+
gem install pkg/[name of generated gem]
|
17
|
+
|
18
|
+
setup
|
19
|
+
===
|
20
|
+
|
21
|
+
Please set up SMARTCLOUD_USERNAME and SMARTCLOUD_PASSWORD in your .bash_profile
|
22
|
+
|
23
|
+
export SMARTCLOUD_USERNAME=[your username]
|
24
|
+
export SMARTCLOUD_PASSWORD=[your password]
|
25
|
+
|
26
|
+
You can now also supply the username and password on the command line using -u and -p
|
27
|
+
Use `smartcloud help` to get a list of all optoins.
|
28
|
+
|
29
|
+
screencast
|
30
|
+
===
|
31
|
+
|
32
|
+
http://www.youtube.com/cohesiveft#p/u/0/-WdSHP2iwDM (somewhat outdated)
|
33
|
+
|
34
|
+
using the console
|
35
|
+
==
|
36
|
+
|
37
|
+
script/console
|
38
|
+
>> @smartcloud.display_instances
|
39
|
+
>> @smartcloud.display_volumes(:Location => 101)
|
40
|
+
>> @smartcloud.display_instances(:Location => 82, :Name => "namematch")
|
41
|
+
>> @smartcloud.poll_for_volume_state(12345, :unmounted)
|
42
|
+
|
43
|
+
The console predefines the @smartcloud instance variable that is set up
|
44
|
+
from the environment variables SMARTCLOUD_USERNAME and SMARTCLOUD_PASSWORD
|
45
|
+
automatically (it's created at the bottom of smartcloud.rb)
|
46
|
+
|
47
|
+
using the commandline helper
|
48
|
+
==
|
49
|
+
|
50
|
+
smartcloud [method of smartcloud.rb]
|
51
|
+
|
52
|
+
to see a list of methods:
|
53
|
+
|
54
|
+
smartcloud help
|
55
|
+
|
56
|
+
examples:
|
57
|
+
|
58
|
+
smartcloud display_volumes
|
59
|
+
smartcloud display_instances
|
60
|
+
smartcloud display_instance 12345
|
61
|
+
smartcloud delete_instances 12345 12346 12347
|
62
|
+
smartcloud "describe_instance('12345')"
|
63
|
+
smartcloud "display_instances(:Location => 82, :Name => 'match_this')"
|
64
|
+
|
65
|
+
smartcloud delete_unused_keys # this one will prompt for every key
|
66
|
+
|
67
|
+
The 'display_*' methods are intended to generate pretty human readable displays, while the describe methods
|
68
|
+
will return pretty-formatted hashes, or singular values.
|
69
|
+
|
70
|
+
smartcloud display_volumes
|
71
|
+
|
72
|
+
get a list of all available methods
|
73
|
+
===
|
74
|
+
|
75
|
+
console:
|
76
|
+
|
77
|
+
>> @smartcloud.help
|
78
|
+
|
79
|
+
commandline
|
80
|
+
|
81
|
+
> smartcloud help
|
82
|
+
|
83
|
+
These won't tell you the arguments, you have to look at smartcloud.rb for the args.
|
84
|
+
|
85
|
+
RestClient vs CurlHttpClient
|
86
|
+
===
|
87
|
+
Sometimes RestClient and friends have trouble communicating with certain API's such as
|
88
|
+
IBM SmartCloud, returning 500 errors. We found in some cases the only thing that truly
|
89
|
+
works is pure curl (not even libcurl ruby wrappers). Therefore there is a provided
|
90
|
+
simple CurlHttpClient library which emulates the RestClient interface, and wraps
|
91
|
+
command line calls to curl.
|
92
|
+
|
93
|
+
The choice of client is determined inside of config.yml
|
94
|
+
|
95
|
+
Versioning
|
96
|
+
==
|
97
|
+
|
98
|
+
This project uses the jeweler gem for packaging. See the tasks:
|
99
|
+
|
100
|
+
rake version:bump:...
|
101
|
+
rake build
|
102
|
+
|
103
|
+
Copyright
|
104
|
+
==
|
105
|
+
|
106
|
+
Copyright (c) 2011 CohesiveFT. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/cft_smartcloud
CHANGED
@@ -2,18 +2,44 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '../lib/smartcloud')
|
4
4
|
require 'pp'
|
5
|
+
require 'slop'
|
5
6
|
|
6
7
|
if !ENV['SMARTCLOUD_USERNAME'] || !ENV['SMARTCLOUD_PASSWORD']
|
7
8
|
puts "Please set environment variables SMARTCLOUD_PASSWORD and SMARTCLOUD_USERNAME in your environment."
|
8
9
|
exit(1)
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# These are the options we can pass in
|
13
|
+
opts = Slop.new do
|
14
|
+
on :u, :username=, :optional => true
|
15
|
+
on :p, :password=, :optional => true
|
16
|
+
on :r, :retries=, "How many retries if the server is down"
|
17
|
+
on :s, :sleep_interval=, "How long to sleep between retries (s)"
|
18
|
+
on :U, :api_url=, "URL of api endpoint"
|
19
|
+
on :d, :debug, "Enable debug logging"
|
20
|
+
on :R, :simulated_response_file=, "Pass in a file containing the response (do not hit cloud)"
|
21
|
+
on :S, :save_response, "Save the response in responses/ dir, for later use with -R response file"
|
22
|
+
end
|
23
|
+
|
24
|
+
# These are the actual commands appearing after the script name,
|
25
|
+
# such as "smartcloud display_instances ... "
|
26
|
+
commands = []
|
27
|
+
opts.parse do |nonarg|
|
28
|
+
commands << nonarg
|
29
|
+
end
|
30
|
+
@sc = IBMSmartCloud.new(opts)
|
31
|
+
|
32
|
+
if commands.size == 1
|
33
|
+
if commands[0] == 'help'
|
34
|
+
puts "#{opts.help}\n\nFunctions:\n"
|
35
|
+
end
|
36
|
+
@cmd=commands[0]
|
37
|
+
elsif commands.size == 2
|
38
|
+
@cmd="#{commands[0]}('#{commands[1]}')"
|
39
|
+
elsif commands.size == 0
|
16
40
|
puts %{
|
41
|
+
#{opts.help}
|
42
|
+
|
17
43
|
Usage:
|
18
44
|
smartcloud help
|
19
45
|
smartcloud help [command]
|
@@ -29,12 +55,12 @@ elsif ARGV.size == 0
|
|
29
55
|
}
|
30
56
|
exit(0)
|
31
57
|
else
|
32
|
-
@cmd="#{
|
58
|
+
@cmd="#{commands[0]}(#{commands[1..-1].map {|item| "'#{item}'"}.join(',')})"
|
33
59
|
end
|
34
60
|
|
35
61
|
# allows us to send arbitrary commands like
|
36
62
|
# smartcloud username password describe_instance("122345")
|
37
|
-
result = eval("@
|
63
|
+
result = eval("@sc.#{@cmd}")
|
38
64
|
|
39
65
|
if result == true || result.nil?
|
40
66
|
# do nothing, the command already logged
|
data/bin/smartcloud
CHANGED
@@ -2,18 +2,44 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '../lib/smartcloud')
|
4
4
|
require 'pp'
|
5
|
+
require 'slop'
|
5
6
|
|
6
7
|
if !ENV['SMARTCLOUD_USERNAME'] || !ENV['SMARTCLOUD_PASSWORD']
|
7
8
|
puts "Please set environment variables SMARTCLOUD_PASSWORD and SMARTCLOUD_USERNAME in your environment."
|
8
9
|
exit(1)
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# These are the options we can pass in
|
13
|
+
opts = Slop.new do
|
14
|
+
on :u, :username=, :optional => true
|
15
|
+
on :p, :password=, :optional => true
|
16
|
+
on :r, :retries=, "How many retries if the server is down"
|
17
|
+
on :s, :sleep_interval=, "How long to sleep between retries (s)"
|
18
|
+
on :U, :api_url=, "URL of api endpoint"
|
19
|
+
on :d, :debug, "Enable debug logging"
|
20
|
+
on :R, :simulated_response_file=, "Pass in a file containing the response (do not hit cloud)"
|
21
|
+
on :S, :save_response, "Save the response in responses/ dir, for later use with -R response file"
|
22
|
+
end
|
23
|
+
|
24
|
+
# These are the actual commands appearing after the script name,
|
25
|
+
# such as "smartcloud display_instances ... "
|
26
|
+
commands = []
|
27
|
+
opts.parse do |nonarg|
|
28
|
+
commands << nonarg
|
29
|
+
end
|
30
|
+
@sc = IBMSmartCloud.new(opts)
|
31
|
+
|
32
|
+
if commands.size == 1
|
33
|
+
if commands[0] == 'help'
|
34
|
+
puts "#{opts.help}\n\nFunctions:\n"
|
35
|
+
end
|
36
|
+
@cmd=commands[0]
|
37
|
+
elsif commands.size == 2
|
38
|
+
@cmd="#{commands[0]}('#{commands[1]}')"
|
39
|
+
elsif commands.size == 0
|
16
40
|
puts %{
|
41
|
+
#{opts.help}
|
42
|
+
|
17
43
|
Usage:
|
18
44
|
smartcloud help
|
19
45
|
smartcloud help [command]
|
@@ -29,12 +55,12 @@ elsif ARGV.size == 0
|
|
29
55
|
}
|
30
56
|
exit(0)
|
31
57
|
else
|
32
|
-
@cmd="#{
|
58
|
+
@cmd="#{commands[0]}(#{commands[1..-1].map {|item| "'#{item}'"}.join(',')})"
|
33
59
|
end
|
34
60
|
|
35
61
|
# allows us to send arbitrary commands like
|
36
62
|
# smartcloud username password describe_instance("122345")
|
37
|
-
result = eval("@
|
63
|
+
result = eval("@sc.#{@cmd}")
|
38
64
|
|
39
65
|
if result == true || result.nil?
|
40
66
|
# do nothing, the command already logged
|
data/cft_smartcloud.gemspec
CHANGED
@@ -5,29 +5,30 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cft_smartcloud}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["yan", "cohesive"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-11-21}
|
13
13
|
s.description = %q{CohesiveFT Ruby Interface for IBM SmartCloud and 'smartcloud' command line helper.}
|
14
14
|
s.email = %q{yan.pritzker@cohesiveft.com}
|
15
15
|
s.executables = ["cft_smartcloud", "smartcloud"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
|
-
"README.
|
18
|
+
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".gitignore",
|
22
22
|
"CHANGELOG",
|
23
23
|
"LICENSE",
|
24
|
-
"README.
|
24
|
+
"README.md",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"bin/cft_smartcloud",
|
28
28
|
"bin/smartcloud",
|
29
29
|
"cft_smartcloud.gemspec",
|
30
30
|
"lib/config/config.yml",
|
31
|
+
"lib/curl_client.rb",
|
31
32
|
"lib/hash_fix.rb",
|
32
33
|
"lib/mime-types-1.16/History.txt",
|
33
34
|
"lib/mime-types-1.16/Install.txt",
|
@@ -42,25 +43,81 @@ Gem::Specification.new do |s|
|
|
42
43
|
"lib/mime-types-1.16/test/test_mime_type.rb",
|
43
44
|
"lib/mime-types-1.16/test/test_mime_types.rb",
|
44
45
|
"lib/mock_smartcloud.rb",
|
45
|
-
"lib/rest-client-1.6.
|
46
|
-
"lib/rest-client-1.6.
|
47
|
-
"lib/rest-client-1.6.
|
48
|
-
"lib/rest-client-1.6.
|
49
|
-
"lib/rest-client-1.6.
|
50
|
-
"lib/rest-client-1.6.
|
51
|
-
"lib/rest-client-1.6.
|
52
|
-
"lib/rest-client-1.6.
|
53
|
-
"lib/rest-client-1.6.
|
54
|
-
"lib/rest-client-1.6.
|
55
|
-
"lib/rest-client-1.6.
|
56
|
-
"lib/rest-client-1.6.
|
57
|
-
"lib/rest-client-1.6.
|
58
|
-
"lib/rest-client-1.6.
|
59
|
-
"lib/rest-client-1.6.
|
60
|
-
"lib/rest-client-1.6.
|
46
|
+
"lib/rest-client-1.6.6-master/.gitignore",
|
47
|
+
"lib/rest-client-1.6.6-master/README.rdoc",
|
48
|
+
"lib/rest-client-1.6.6-master/Rakefile",
|
49
|
+
"lib/rest-client-1.6.6-master/VERSION",
|
50
|
+
"lib/rest-client-1.6.6-master/bin/restclient",
|
51
|
+
"lib/rest-client-1.6.6-master/history.md",
|
52
|
+
"lib/rest-client-1.6.6-master/lib/rest-client.rb",
|
53
|
+
"lib/rest-client-1.6.6-master/lib/rest_client.rb",
|
54
|
+
"lib/rest-client-1.6.6-master/lib/restclient.rb",
|
55
|
+
"lib/rest-client-1.6.6-master/lib/restclient/abstract_response.rb",
|
56
|
+
"lib/rest-client-1.6.6-master/lib/restclient/exceptions.rb",
|
57
|
+
"lib/rest-client-1.6.6-master/lib/restclient/net_http_ext.rb",
|
58
|
+
"lib/rest-client-1.6.6-master/lib/restclient/payload.rb",
|
59
|
+
"lib/rest-client-1.6.6-master/lib/restclient/raw_response.rb",
|
60
|
+
"lib/rest-client-1.6.6-master/lib/restclient/request.rb",
|
61
|
+
"lib/rest-client-1.6.6-master/lib/restclient/resource.rb",
|
62
|
+
"lib/rest-client-1.6.6-master/lib/restclient/response.rb",
|
63
|
+
"lib/rest-client-1.6.6-master/rest-client.gemspec",
|
64
|
+
"lib/rest-client-1.6.6-master/spec/abstract_response_spec.rb",
|
65
|
+
"lib/rest-client-1.6.6-master/spec/base.rb",
|
66
|
+
"lib/rest-client-1.6.6-master/spec/exceptions_spec.rb",
|
67
|
+
"lib/rest-client-1.6.6-master/spec/integration/certs/equifax.crt",
|
68
|
+
"lib/rest-client-1.6.6-master/spec/integration/certs/verisign.crt",
|
69
|
+
"lib/rest-client-1.6.6-master/spec/integration/request_spec.rb",
|
70
|
+
"lib/rest-client-1.6.6-master/spec/integration_spec.rb",
|
71
|
+
"lib/rest-client-1.6.6-master/spec/master_shake.jpg",
|
72
|
+
"lib/rest-client-1.6.6-master/spec/payload_spec.rb",
|
73
|
+
"lib/rest-client-1.6.6-master/spec/raw_response_spec.rb",
|
74
|
+
"lib/rest-client-1.6.6-master/spec/request2_spec.rb",
|
75
|
+
"lib/rest-client-1.6.6-master/spec/request_spec.rb",
|
76
|
+
"lib/rest-client-1.6.6-master/spec/resource_spec.rb",
|
77
|
+
"lib/rest-client-1.6.6-master/spec/response_spec.rb",
|
78
|
+
"lib/rest-client-1.6.6-master/spec/restclient_spec.rb",
|
61
79
|
"lib/restclient_fix.rb",
|
80
|
+
"lib/slop-2.3.1/.gemtest",
|
81
|
+
"lib/slop-2.3.1/.gitignore",
|
82
|
+
"lib/slop-2.3.1/.yardopts",
|
83
|
+
"lib/slop-2.3.1/CHANGES.md",
|
84
|
+
"lib/slop-2.3.1/LICENSE",
|
85
|
+
"lib/slop-2.3.1/README.md",
|
86
|
+
"lib/slop-2.3.1/Rakefile",
|
87
|
+
"lib/slop-2.3.1/lib/slop.rb",
|
88
|
+
"lib/slop-2.3.1/slop.gemspec",
|
89
|
+
"lib/slop-2.3.1/test/commands_test.rb",
|
90
|
+
"lib/slop-2.3.1/test/helper.rb",
|
91
|
+
"lib/slop-2.3.1/test/option_test.rb",
|
92
|
+
"lib/slop-2.3.1/test/slop_test.rb",
|
62
93
|
"lib/smartcloud.rb",
|
63
94
|
"lib/smartcloud_logger.rb",
|
95
|
+
"lib/terminal-table-1.4.4/History.rdoc",
|
96
|
+
"lib/terminal-table-1.4.4/Manifest",
|
97
|
+
"lib/terminal-table-1.4.4/README.rdoc",
|
98
|
+
"lib/terminal-table-1.4.4/Rakefile",
|
99
|
+
"lib/terminal-table-1.4.4/Todo.rdoc",
|
100
|
+
"lib/terminal-table-1.4.4/examples/examples.rb",
|
101
|
+
"lib/terminal-table-1.4.4/lib/terminal-table.rb",
|
102
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/cell.rb",
|
103
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/core_ext.rb",
|
104
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/import.rb",
|
105
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/row.rb",
|
106
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/separator.rb",
|
107
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/style.rb",
|
108
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/table.rb",
|
109
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/table_helper.rb",
|
110
|
+
"lib/terminal-table-1.4.4/lib/terminal-table/version.rb",
|
111
|
+
"lib/terminal-table-1.4.4/spec/cell_spec.rb",
|
112
|
+
"lib/terminal-table-1.4.4/spec/core_ext_spec.rb",
|
113
|
+
"lib/terminal-table-1.4.4/spec/import_spec.rb",
|
114
|
+
"lib/terminal-table-1.4.4/spec/spec.opts",
|
115
|
+
"lib/terminal-table-1.4.4/spec/spec_helper.rb",
|
116
|
+
"lib/terminal-table-1.4.4/spec/table_spec.rb",
|
117
|
+
"lib/terminal-table-1.4.4/tasks/docs.rake",
|
118
|
+
"lib/terminal-table-1.4.4/tasks/gemspec.rake",
|
119
|
+
"lib/terminal-table-1.4.4/tasks/spec.rake",
|
120
|
+
"lib/terminal-table-1.4.4/terminal-table.gemspec",
|
64
121
|
"lib/xml-simple-1.0.12/lib/xmlsimple.rb",
|
65
122
|
"rdoc/classes/ConfigTable.html",
|
66
123
|
"rdoc/classes/ConfigTable/BoolItem.html",
|
@@ -143,6 +200,13 @@ Gem::Specification.new do |s|
|
|
143
200
|
"rdoc/fr_method_index.html",
|
144
201
|
"rdoc/index.html",
|
145
202
|
"rdoc/rdoc-style.css",
|
203
|
+
"responses/addresses",
|
204
|
+
"responses/addresses.blank",
|
205
|
+
"responses/instances",
|
206
|
+
"responses/keys",
|
207
|
+
"responses/locations",
|
208
|
+
"responses/offerings_image",
|
209
|
+
"responses/storage",
|
146
210
|
"script/console",
|
147
211
|
"test/helper.rb"
|
148
212
|
]
|
data/lib/config/config.yml
CHANGED
data/lib/curl_client.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class CurlHttpClient
|
2
|
+
# For compatibility with RestClient
|
3
|
+
class << self
|
4
|
+
attr_accessor :timeout
|
5
|
+
attr_accessor :log
|
6
|
+
|
7
|
+
@timeout ||= 120
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.logger; @logger ||= Logger.new(STDOUT); end
|
11
|
+
|
12
|
+
def self.get(url)
|
13
|
+
handle_output(curl(url))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.post(url, data, options={})
|
17
|
+
handle_output(curl(%{ #{url} -d "#{data}" }))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.put(url, data, options={})
|
21
|
+
handle_output(curl(%{ #{url} -XPUT -d #{data} }))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.delete(url, options={})
|
25
|
+
handle_output(curl(%{ #{url} -XDELETE}))
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.curl(cmd)
|
29
|
+
cmd = "curl -s --insecure --connect-timeout #{@timeout} #{cmd} 2>&1"
|
30
|
+
@log.debug cmd if @log
|
31
|
+
`#{cmd}`
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.handle_output(output)
|
35
|
+
if output =~ /^Error/
|
36
|
+
logger.error output
|
37
|
+
raise output
|
38
|
+
else
|
39
|
+
output
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -57,7 +57,7 @@ This does two things for you:
|
|
57
57
|
|
58
58
|
If you are sending params that do not contain a File object but the payload needs to be multipart then:
|
59
59
|
|
60
|
-
RestClient.post '/data', :foo => 'bar', :multipart => true
|
60
|
+
RestClient.post '/data', {:foo => 'bar', :multipart => true}
|
61
61
|
|
62
62
|
== Usage: ActiveResource-Style
|
63
63
|
|
@@ -217,6 +217,15 @@ use whatever proxy the system is configured to use:
|
|
217
217
|
|
218
218
|
RestClient.proxy = ENV['http_proxy']
|
219
219
|
|
220
|
+
== Query parameters
|
221
|
+
|
222
|
+
Request objects know about query parameters and will automatically add them to
|
223
|
+
the url for GET, HEAD and DELETE requests and escape the keys and values as
|
224
|
+
needed:
|
225
|
+
|
226
|
+
RestClient.get 'http://example.com/resource', :params => {:foo => 'bar', :baz => 'qux'}
|
227
|
+
# will GET http://example.com/resource?foo=bar&baz=qux
|
228
|
+
|
220
229
|
== Cookies
|
221
230
|
|
222
231
|
Request and Response objects know about HTTP cookies, and will automatically
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
1.6.7
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
4
|
-
require 'restclient'
|
5
4
|
|
6
|
-
require
|
5
|
+
require 'rubygems'
|
6
|
+
require 'restclient'
|
7
|
+
require 'yaml'
|
7
8
|
|
8
9
|
def usage(why = nil)
|
9
10
|
puts "failed for reason: #{why}" if why
|
@@ -56,8 +57,8 @@ end
|
|
56
57
|
|
57
58
|
POSSIBLE_VERBS.each do |m|
|
58
59
|
eval <<-end_eval
|
59
|
-
def #{m}
|
60
|
-
r[path]
|
60
|
+
def #{m}(path, *args, &b)
|
61
|
+
r[path].#{m}(*args, &b)
|
61
62
|
end
|
62
63
|
end_eval
|
63
64
|
end
|
@@ -1,4 +1,26 @@
|
|
1
|
+
# 1.6.7
|
2
|
+
|
3
|
+
- rebuild with 1.8.7 to avoid https://github.com/rubygems/rubygems/pull/57
|
4
|
+
|
5
|
+
# 1.6.6
|
6
|
+
|
7
|
+
- 1.6.5 was yanked
|
8
|
+
|
9
|
+
# 1.6.5
|
10
|
+
|
11
|
+
- RFC6265 requires single SP after ';' for separating parameters pairs in the 'Cookie:' header (patch provided by Hiroshi Nakamura)
|
12
|
+
- enable url parameters for all actions
|
13
|
+
- detect file parameters in arrays
|
14
|
+
- allow disabling the timeouts by passing -1 (patch provided by Sven Böhm)
|
15
|
+
|
16
|
+
# 1.6.4
|
17
|
+
|
18
|
+
- fix restclient script compatibility with 1.9.2
|
19
|
+
- fix unlinking temp file (patch provided by Evan Smith)
|
20
|
+
- monkeypatching ruby for http patch method (patch provided by Syl Turner)
|
21
|
+
|
1
22
|
# 1.6.3
|
23
|
+
|
2
24
|
- 1.6.2 was yanked
|
3
25
|
|
4
26
|
# 1.6.2
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Net
|
2
|
+
class HTTP
|
3
|
+
|
4
|
+
# Adding the patch method if it doesn't exist (rest-client issue: https://github.com/archiloque/rest-client/issues/79)
|
5
|
+
if !defined?(Net::HTTP::Patch)
|
6
|
+
# Code taken from this commit: https://github.com/ruby/ruby/commit/ab70e53ac3b5102d4ecbe8f38d4f76afad29d37d#lib/net/http.rb
|
7
|
+
class Protocol
|
8
|
+
# Sends a PATCH request to the +path+ and gets a response,
|
9
|
+
# as an HTTPResponse object.
|
10
|
+
def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
|
11
|
+
send_entity(path, data, initheader, dest, Patch, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes a request which uses a representation
|
15
|
+
# and returns its body.
|
16
|
+
def send_entity(path, data, initheader, dest, type, &block)
|
17
|
+
res = nil
|
18
|
+
request(type.new(path, initheader), data) {|r|
|
19
|
+
r.read_body dest, &block
|
20
|
+
res = r
|
21
|
+
}
|
22
|
+
unless @newimpl
|
23
|
+
res.value
|
24
|
+
return res, res.body
|
25
|
+
end
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Patch < HTTPRequest
|
31
|
+
METHOD = 'PATCH'
|
32
|
+
REQUEST_HAS_BODY = true
|
33
|
+
RESPONSE_HAS_BODY = true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Replace the request method in Net::HTTP to sniff the body type
|
39
|
+
# and set the stream if appropriate
|
40
|
+
#
|
41
|
+
# Taken from:
|
42
|
+
# http://www.missiondata.com/blog/ruby/29/streaming-data-to-s3-with-ruby/
|
43
|
+
|
44
|
+
alias __request__ request
|
45
|
+
|
46
|
+
def request(req, body=nil, &block)
|
47
|
+
if body != nil && body.respond_to?(:read)
|
48
|
+
req.body_stream = body
|
49
|
+
return __request__(req, nil, &block)
|
50
|
+
else
|
51
|
+
return __request__(req, body, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -27,12 +27,27 @@ module RestClient
|
|
27
27
|
case v
|
28
28
|
when Hash
|
29
29
|
has_file?(v)
|
30
|
+
when Array
|
31
|
+
has_file_array?(v)
|
30
32
|
else
|
31
33
|
v.respond_to?(:path) && v.respond_to?(:read)
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
def has_file_array?(params)
|
39
|
+
params.any? do |v|
|
40
|
+
case v
|
41
|
+
when Hash
|
42
|
+
has_file?(v)
|
43
|
+
when Array
|
44
|
+
has_file_array?(v)
|
45
|
+
else
|
46
|
+
v.respond_to?(:path) && v.respond_to?(:read)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
36
51
|
class Base
|
37
52
|
def initialize(params)
|
38
53
|
build_stream(params)
|
@@ -70,7 +85,7 @@ module RestClient
|
|
70
85
|
result = []
|
71
86
|
value.each do |elem|
|
72
87
|
if elem.is_a? Hash
|
73
|
-
result +=
|
88
|
+
result += flatten_params(elem, calculated_key)
|
74
89
|
elsif elem.is_a? Array
|
75
90
|
result += flatten_params_array(elem, calculated_key)
|
76
91
|
else
|
@@ -91,7 +106,7 @@ module RestClient
|
|
91
106
|
alias :length :size
|
92
107
|
|
93
108
|
def close
|
94
|
-
@stream.close
|
109
|
+
@stream.close unless @stream.closed?
|
95
110
|
end
|
96
111
|
|
97
112
|
def inspect
|
File without changes
|