smartdc 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/Gemfile +7 -7
  2. data/README.md +5 -5
  3. data/VERSION +1 -1
  4. data/bin/sdc-addmachinemetadata +2 -2
  5. data/bin/sdc-addmachinetag +2 -2
  6. data/bin/sdc-createinstrumentation +1 -2
  7. data/bin/sdc-createkey +1 -2
  8. data/bin/sdc-createmachine +5 -5
  9. data/bin/sdc-createmachinesnapshot +1 -2
  10. data/bin/sdc-deleteinstrumentation +4 -2
  11. data/bin/sdc-deletekey +4 -2
  12. data/bin/sdc-deletemachine +4 -2
  13. data/bin/sdc-deletemachinemetadata +4 -2
  14. data/bin/sdc-deletemachinesnapshot +4 -3
  15. data/bin/sdc-deletemachinetag +4 -2
  16. data/bin/sdc-describeanalytics +1 -2
  17. data/bin/sdc-getdatacenter +1 -2
  18. data/bin/sdc-getdataset +1 -2
  19. data/bin/sdc-getinstrumentation +1 -2
  20. data/bin/sdc-getkey +1 -2
  21. data/bin/sdc-getmachine +3 -2
  22. data/bin/sdc-getmachinemetadata +4 -3
  23. data/bin/sdc-getmachinesnapshot +1 -2
  24. data/bin/sdc-getmachinetag +1 -2
  25. data/bin/sdc-getpackage +1 -2
  26. data/bin/sdc-listdatacenters +1 -2
  27. data/bin/sdc-listdatasets +1 -2
  28. data/bin/sdc-listinstrumentations +1 -2
  29. data/bin/sdc-listkeys +1 -2
  30. data/bin/sdc-listmachines +1 -2
  31. data/bin/sdc-listmachinesnapshots +1 -2
  32. data/bin/sdc-listmachinetags +1 -2
  33. data/bin/sdc-listpackages +1 -2
  34. data/bin/sdc-rebootmachine +4 -2
  35. data/bin/sdc-resizemachine +5 -3
  36. data/bin/sdc-setup +7 -3
  37. data/bin/sdc-startmachine +4 -2
  38. data/bin/sdc-startmachinefromsnapshot +4 -3
  39. data/bin/sdc-stopmachine +4 -2
  40. data/lib/smartdc.rb +1 -0
  41. data/lib/smartdc/api/analytics/instrumentations.rb +1 -2
  42. data/lib/smartdc/api/keys.rb +0 -1
  43. data/lib/smartdc/api/machine/metadata.rb +1 -2
  44. data/lib/smartdc/api/machine/snapshots.rb +1 -3
  45. data/lib/smartdc/api/machine/tags.rb +1 -2
  46. data/lib/smartdc/api/machines.rb +0 -5
  47. data/lib/smartdc/client.rb +4 -0
  48. data/lib/smartdc/error.rb +35 -0
  49. data/lib/smartdc/request.rb +13 -10
  50. data/lib/smartdc/response/mashify.rb +29 -0
  51. data/lib/smartdc/response/parse_json.rb +26 -0
  52. data/lib/smartdc/response/raise_error.rb +38 -0
  53. data/smartdc.gemspec +25 -23
  54. data/spec/smartdc/api/analytics_spec.rb +1 -1
  55. data/spec/smartdc/api/keys_spec.rb +1 -1
  56. data/spec/smartdc/api/machine/metadata_spec.rb +21 -4
  57. data/spec/smartdc/api/machine/snapshots_spec.rb +17 -5
  58. data/spec/smartdc/api/machine/tags_spec.rb +21 -4
  59. data/spec/smartdc/api/machines_spec.rb +19 -23
  60. data/spec/smartdc/request_spec.rb +3 -2
  61. data/spec/spec_helper.rb +7 -1
  62. metadata +33 -31
  63. data/lib/faraday/response/mashify.rb +0 -26
  64. data/lib/faraday/response/parse_json.rb +0 -22
data/Gemfile CHANGED
@@ -1,16 +1,16 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem "rspec", "~> 2.7.0"
4
+ gem "rspec", "~> 2.8.0"
5
5
  gem "bundler", "~> 1.0.0"
6
- gem "jeweler", "~> 1.6.4"
7
- gem "rcov", ">= 0"
6
+ gem "jeweler", "~> 1.8.3"
7
+ gem "rcov", "~> 0.9.11"
8
8
  gem "uuid", "~> 2.3.4"
9
9
  end
10
10
 
11
11
  group :runtime do
12
- gem "faraday", "~> 0.7.5"
12
+ gem "faraday", "~> 0.7.6"
13
13
  gem "hashie", "~> 1.2.0"
14
- gem "multi_json", "~> 1.0.3"
15
- gem "multipart-post", "~> 1.1.3"
16
- end
14
+ gem "multi_json", "~> 1.1.0"
15
+ gem "multipart-post", "~> 1.1.4"
16
+ end
data/README.md CHANGED
@@ -65,23 +65,23 @@ Connect and Machine find.
65
65
  end
66
66
 
67
67
 
68
- Return type of the variable.
68
+ Format of the return value.
69
69
 
70
70
  client = Smartdc.new(config)
71
71
 
72
72
  # Type of a variable to mash. (Default)
73
- client.request.return_variable = 'mash'
73
+ client.format = 'mash'
74
74
  puts client.datacenters.find #=> #<Hashie::Mash example="example.com">
75
75
 
76
76
  # Type of a variable to hash.
77
- client.request.return_variable = 'hash'
77
+ client.format = 'hash'
78
78
  puts client.datacenters.find #=> {"example"=>"https://example.com"}
79
79
 
80
80
  # Type of a variable to json.
81
- client.request.return_variable = 'json'
81
+ client.format = 'json'
82
82
  puts client.datacenters.find #=> {"example": "https://example.com"}
83
83
 
84
84
 
85
85
  ## Copyright
86
86
 
87
- Copyright (c) 2011 ogom. See LICENSE.md for further details.
87
+ Copyright (c) 2012 ogom. See LICENSE.md for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  begin
25
25
  metadata = {options[:key] => options[:value]}
26
- pp client.machines(ARGV[0]).metadata.create metadata
26
+ puts client.machines(ARGV[0]).metadata.create metadata
27
27
  rescue => e
28
- puts e
28
+ puts e.inspect
29
29
  end
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  begin
25
25
  tag = {options[:key] => options[:value]}
26
- pp client.machines(ARGV[0]).tags.create tag
26
+ puts client.machines(ARGV[0]).tags.create tag
27
27
  rescue => e
28
- puts e
28
+ puts e.inspect
29
29
  end
@@ -21,8 +21,7 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
24
  puts client.analytics.instrumentations.create options
26
25
  rescue => e
27
- puts e
26
+ puts e.inspect
28
27
  end
@@ -26,8 +26,7 @@ else
26
26
  end
27
27
 
28
28
  begin
29
- client.request.return_variable = 'json'
30
29
  puts client.keys.create key
31
30
  rescue => e
32
- puts e
31
+ puts e.inspect
33
32
  end
@@ -10,12 +10,11 @@ OptionParser.new do |opts|
10
10
  opts.on('-p', '--package NAME', 'Name of the package to use on provisioning.') {|v| options[:package] = v }
11
11
  opts.on('-h','--help') do
12
12
  puts opts
13
- print 'Datasets(urn):'
13
+ print "\n" + 'Datasets(urn):'
14
14
  fixture('datasets').each do |dataset|
15
15
  print ' ' + dataset['urn']
16
16
  end
17
- puts
18
- print 'Packages(name):'
17
+ print "\n\n" + 'Packages(name):'
19
18
  fixture('packages').each do |packages|
20
19
  print ' ' + packages['name']
21
20
  end
@@ -32,8 +31,9 @@ OptionParser.new do |opts|
32
31
  end
33
32
 
34
33
  begin
35
- client.request.return_variable = 'json'
36
34
  puts client.machines.create options
37
- rescue => e
35
+ rescue Smartdc::Error::Conflict => e
38
36
  puts e
37
+ rescue => e
38
+ puts e.inspect
39
39
  end
@@ -21,8 +21,7 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
24
  puts client.machines(ARGV[0]).snapshots.create options
26
25
  rescue => e
27
- puts e
26
+ puts e.inspect
28
27
  end
@@ -4,7 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- pp client.analytics.instrumentations(ARGV[0]).delete
7
+ client.analytics.instrumentations(ARGV[0]).delete
8
8
  rescue => e
9
- puts e
9
+ puts e.inspect
10
+ else
11
+ puts "Success"
10
12
  end
@@ -4,7 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- pp client.keys(ARGV[0]).delete
7
+ client.keys(ARGV[0]).delete
8
8
  rescue => e
9
- puts e
9
+ puts e.inspect
10
+ else
11
+ puts "Success"
10
12
  end
@@ -4,7 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- pp client.machines(ARGV[0]).delete
7
+ client.machines(ARGV[0]).delete
8
8
  rescue => e
9
- puts e
9
+ puts e.inspect
10
+ else
11
+ puts "Success"
10
12
  end
@@ -21,7 +21,9 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- pp client.machines(ARGV[0]).metadata(options[:key]).delete
24
+ client.machines(ARGV[0]).metadata(options[:key]).delete
25
25
  rescue => e
26
- puts e
26
+ puts e.inspect
27
+ else
28
+ puts "Success"
27
29
  end
@@ -21,8 +21,9 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
- puts client.machines(ARGV[0]).snapshots(options[:name]).delete
24
+ client.machines(ARGV[0]).snapshots(options[:name]).delete
26
25
  rescue => e
27
- puts e
26
+ puts e.inspect
27
+ else
28
+ puts "Success"
28
29
  end
@@ -21,7 +21,9 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- pp client.machines(ARGV[0]).tags(options[:key]).delete
24
+ client.machines(ARGV[0]).tags(options[:key]).delete
25
25
  rescue => e
26
- puts e
26
+ puts e.inspect
27
+ else
28
+ puts "Success"
27
29
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.analytics.describe
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.datacenters(ARGV[0]).read
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.datasets(ARGV[0]).read
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -21,12 +21,11 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
24
  if options[:value]
26
25
  puts client.analytics.instrumentations(ARGV[0]).value
27
26
  else
28
27
  puts client.analytics.instrumentations(ARGV[0]).read
29
28
  end
30
29
  rescue => e
31
- puts e
30
+ puts e.inspect
32
31
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.keys(ARGV[0]).read
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.machines(ARGV[0]).read
9
- rescue => e
8
+ rescue Smartdc::Error::NotFound => e
10
9
  puts e
10
+ rescue => e
11
+ puts e.inspect
11
12
  end
@@ -3,9 +3,10 @@
3
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
+
7
+
6
8
  begin
7
- client.request.return_variable = 'json'
8
- puts client.machines(ARGV[0]).metadata.find
9
+ puts client.machines(ARGV[0]).metadata.find
9
10
  rescue => e
10
- puts e
11
+ puts e.inspect
11
12
  end
@@ -21,8 +21,7 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
24
  puts client.machines(ARGV[0]).snapshots(options[:name]).read
26
25
  rescue => e
27
- puts e
26
+ puts e.inspect
28
27
  end
@@ -21,8 +21,7 @@ OptionParser.new do |opts|
21
21
  end
22
22
 
23
23
  begin
24
- client.request.return_variable = 'json'
25
24
  puts client.machines(ARGV[0]).tags(options[:key]).read
26
25
  rescue => e
27
- puts e
26
+ puts e.inspect
28
27
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.packages((ARGV[0])).read
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.datacenters.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.datasets.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.analytics.instrumentations.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.keys.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.machines.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.machines(ARGV[0]).snapshots.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.machines(ARGV[0]).tags.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,8 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- client.request.return_variable = 'json'
8
7
  puts client.packages.find
9
8
  rescue => e
10
- puts e
9
+ puts e.inspect
11
10
  end
@@ -4,7 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'cli_helper'
5
5
 
6
6
  begin
7
- pp client.machines(ARGV[0]).reboot
7
+ client.machines(ARGV[0]).reboot
8
8
  rescue => e
9
- puts e
9
+ puts e.inspect
10
+ else
11
+ puts "Success"
10
12
  end
@@ -9,7 +9,7 @@ OptionParser.new do |opts|
9
9
  opts.on('-p', '--package NAME', 'Name of the package to use on provisioning.') {|v| options[:package] = v }
10
10
  opts.on('-h','--help') do
11
11
  puts opts
12
- print 'Packages(name):'
12
+ print "\n" + 'Packages(name):'
13
13
  fixture('packages').each do |packages|
14
14
  print ' ' + packages['name']
15
15
  end
@@ -26,7 +26,9 @@ OptionParser.new do |opts|
26
26
  end
27
27
 
28
28
  begin
29
- pp client.machines(ARGV[0]).resize options
29
+ client.machines(ARGV[0]).resize options
30
30
  rescue => e
31
- puts e
31
+ puts e.inspect
32
+ else
33
+ puts "Success"
32
34
  end