smartdc 0.4.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/.document +0 -1
  2. data/.travis.yml +5 -0
  3. data/Gemfile +7 -10
  4. data/README.md +42 -69
  5. data/Rakefile +47 -0
  6. data/VERSION +1 -1
  7. data/bin/sdc +327 -0
  8. data/lib/cli_helper.rb +131 -8
  9. data/lib/configure.rb +73 -0
  10. data/lib/smartdc.rb +16 -1
  11. data/lib/smartdc/api/analytics.rb +29 -7
  12. data/lib/smartdc/api/analytics/heatmap.rb +20 -0
  13. data/lib/smartdc/api/datacenters.rb +6 -7
  14. data/lib/smartdc/api/datasets.rb +6 -7
  15. data/lib/smartdc/api/keys.rb +10 -11
  16. data/lib/smartdc/api/machine/metadata.rb +9 -15
  17. data/lib/smartdc/api/machine/snapshots.rb +16 -16
  18. data/lib/smartdc/api/machine/tags.rb +11 -12
  19. data/lib/smartdc/api/machines.rb +23 -23
  20. data/lib/smartdc/api/packages.rb +7 -8
  21. data/lib/smartdc/client.rb +14 -18
  22. data/lib/smartdc/request.rb +41 -51
  23. data/lib/smartdc/response.rb +24 -0
  24. data/lib/smartdc/response/raise_error.rb +1 -1
  25. data/smartdc.gemspec +51 -90
  26. data/spec/fixtures/analytics.json +26 -0
  27. data/spec/fixtures/datacenter.json +4 -0
  28. data/spec/fixtures/datacenters.json +3 -0
  29. data/spec/fixtures/datasets.json +38 -0
  30. data/spec/fixtures/keys.json +14 -0
  31. data/spec/fixtures/machines.json +36 -0
  32. data/spec/fixtures/packages.json +18 -0
  33. data/spec/fixtures/snapshots.json +8 -0
  34. data/spec/fixtures/tag.json +3 -0
  35. data/spec/spec_helper.rb +3 -12
  36. data/spec/unit/smartdc/api/analytics_spec.rb +53 -0
  37. data/spec/unit/smartdc/api/datacenters_spec.rb +31 -0
  38. data/spec/unit/smartdc/api/datasets_spec.rb +31 -0
  39. data/spec/unit/smartdc/api/keys_spec.rb +53 -0
  40. data/spec/unit/smartdc/api/machine/metadata_spec.rb +42 -0
  41. data/spec/unit/smartdc/api/machine/snapshots_spec.rb +132 -0
  42. data/spec/unit/smartdc/api/machine/tags_spec.rb +53 -0
  43. data/spec/unit/smartdc/api/machines_spec.rb +53 -0
  44. data/spec/unit/smartdc/api/packages_spec.rb +31 -0
  45. data/spec/{smartdc → unit/smartdc}/client_spec.rb +0 -6
  46. data/spec/{smartdc_spec.rb → unit/smartdc_spec.rb} +1 -1
  47. metadata +72 -140
  48. data/LICENSE.md +0 -20
  49. data/bin/sdc-addmachinemetadata +0 -29
  50. data/bin/sdc-addmachinetag +0 -29
  51. data/bin/sdc-createinstrumentation +0 -27
  52. data/bin/sdc-createkey +0 -32
  53. data/bin/sdc-createmachine +0 -39
  54. data/bin/sdc-createmachinesnapshot +0 -27
  55. data/bin/sdc-deleteinstrumentation +0 -12
  56. data/bin/sdc-deletekey +0 -12
  57. data/bin/sdc-deletemachine +0 -12
  58. data/bin/sdc-deletemachinemetadata +0 -29
  59. data/bin/sdc-deletemachinesnapshot +0 -29
  60. data/bin/sdc-deletemachinetag +0 -29
  61. data/bin/sdc-describeanalytics +0 -10
  62. data/bin/sdc-getdatacenter +0 -10
  63. data/bin/sdc-getdataset +0 -10
  64. data/bin/sdc-getinstrumentation +0 -31
  65. data/bin/sdc-getkey +0 -10
  66. data/bin/sdc-getmachine +0 -12
  67. data/bin/sdc-getmachinemetadata +0 -12
  68. data/bin/sdc-getmachinesnapshot +0 -27
  69. data/bin/sdc-getmachinetag +0 -27
  70. data/bin/sdc-getpackage +0 -10
  71. data/bin/sdc-listdatacenters +0 -10
  72. data/bin/sdc-listdatasets +0 -10
  73. data/bin/sdc-listinstrumentations +0 -10
  74. data/bin/sdc-listkeys +0 -10
  75. data/bin/sdc-listmachines +0 -10
  76. data/bin/sdc-listmachinesnapshots +0 -10
  77. data/bin/sdc-listmachinetags +0 -10
  78. data/bin/sdc-listpackages +0 -10
  79. data/bin/sdc-rebootmachine +0 -12
  80. data/bin/sdc-resizemachine +0 -34
  81. data/bin/sdc-setup +0 -67
  82. data/bin/sdc-startmachine +0 -12
  83. data/bin/sdc-startmachinefromsnapshot +0 -29
  84. data/bin/sdc-stopmachine +0 -12
  85. data/config/fixtures/instrumentation.json +0 -4
  86. data/config/fixtures/key.json +0 -4
  87. data/config/fixtures/tag.json +0 -3
  88. data/lib/smartdc/api/analytics/instrumentations.rb +0 -44
  89. data/lib/smartdc/response/mashify.rb +0 -29
  90. data/lib/smartdc/response/parse_json.rb +0 -26
  91. data/spec/smartdc/api/analytics_spec.rb +0 -32
  92. data/spec/smartdc/api/datacenters_spec.rb +0 -16
  93. data/spec/smartdc/api/datasets_spec.rb +0 -16
  94. data/spec/smartdc/api/keys_spec.rb +0 -32
  95. data/spec/smartdc/api/machine/metadata_spec.rb +0 -59
  96. data/spec/smartdc/api/machine/snapshots_spec.rb +0 -70
  97. data/spec/smartdc/api/machine/tags_spec.rb +0 -65
  98. data/spec/smartdc/api/machines_spec.rb +0 -92
  99. data/spec/smartdc/api/packages_spec.rb +0 -16
  100. data/spec/smartdc/request_spec.rb +0 -12
data/LICENSE.md DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011 ogom
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-k', '--key [NAME]', 'Key Tag.') {|v| options[:key] = v }
10
- opts.on('-v', '--value [NAME]', 'Value Tag.') {|v| options[:value] = v }
11
- opts.on_tail('-h','--help') do
12
- puts opts
13
- exit
14
- end
15
-
16
- begin
17
- opts.parse!(ARGV)
18
- rescue => e
19
- puts e.to_s << "\n" << opts.to_s
20
- exit
21
- end
22
- end
23
-
24
- begin
25
- metadata = {options[:key] => options[:value]}
26
- puts client.machines(ARGV[0]).metadata.create metadata
27
- rescue => e
28
- puts e.inspect
29
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-k', '--key [NAME]', 'Key Tag.') {|v| options[:key] = v }
10
- opts.on('-v', '--value [NAME]', 'Value Tag.') {|v| options[:value] = v }
11
- opts.on_tail('-h','--help') do
12
- puts opts
13
- exit
14
- end
15
-
16
- begin
17
- opts.parse!(ARGV)
18
- rescue => e
19
- puts e.to_s << "\n" << opts.to_s
20
- exit
21
- end
22
- end
23
-
24
- begin
25
- tag = {options[:key] => options[:value]}
26
- puts client.machines(ARGV[0]).tags.create tag
27
- rescue => e
28
- puts e.inspect
29
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.on('-m', '--module NAME', 'The CA module.') {|v| options[:module] = v }
9
- opts.on('-s', '--stat NAME', 'The CA stat.') {|v| options[:stat] = v }
10
- opts.on('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- puts client.analytics.instrumentations.create options
25
- rescue => e
26
- puts e.inspect
27
- end
data/bin/sdc-createkey DELETED
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- key = {}
7
- name = ARGV[0]
8
- if name
9
- key[:name] = name
10
- else
11
- puts 'name is empty.'
12
- exit 1
13
- end
14
-
15
- key_file = ARGV[1]
16
- if key_file
17
- begin
18
- key[:key] = File.read(key_file)
19
- rescue => e
20
- puts e
21
- exit 1
22
- end
23
- else
24
- puts 'key file is empty.'
25
- exit 1
26
- end
27
-
28
- begin
29
- puts client.keys.create key
30
- rescue => e
31
- puts e.inspect
32
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.on('-n', '--name NAME', 'friendly name for this machine.') {|v| options[:name] = v }
9
- opts.on('-e', '--dataset URN', 'dataset URN.') {|v| options[:dataset] = v }
10
- opts.on('-p', '--package NAME', 'Name of the package to use on provisioning.') {|v| options[:package] = v }
11
- opts.on('-h','--help') do
12
- puts opts
13
- print "\n" + 'Datasets(urn):'
14
- fixture('datasets').each do |dataset|
15
- print ' ' + dataset['urn']
16
- end
17
- print "\n\n" + 'Packages(name):'
18
- fixture('packages').each do |packages|
19
- print ' ' + packages['name']
20
- end
21
- puts
22
- exit
23
- end
24
-
25
- begin
26
- opts.parse!(ARGV)
27
- rescue => e
28
- puts e.to_s << "\n" << opts.to_s
29
- exit
30
- end
31
- end
32
-
33
- begin
34
- puts client.machines.create options
35
- rescue Smartdc::Error::Conflict => e
36
- puts e
37
- rescue => e
38
- puts e.inspect
39
- end
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-n', '--name NAME', 'The name to assign to the new snapshot.') {|v| options[:name] = v }
10
- opts.on_tail('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- puts client.machines(ARGV[0]).snapshots.create options
25
- rescue => e
26
- puts e.inspect
27
- end
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- client.analytics.instrumentations(ARGV[0]).delete
8
- rescue => e
9
- puts e.inspect
10
- else
11
- puts "Success"
12
- end
data/bin/sdc-deletekey DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- client.keys(ARGV[0]).delete
8
- rescue => e
9
- puts e.inspect
10
- else
11
- puts "Success"
12
- end
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- client.machines(ARGV[0]).delete
8
- rescue => e
9
- puts e.inspect
10
- else
11
- puts "Success"
12
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-k', '--key [NAME]', 'Key Tag.') {|v| options[:key] = v }
10
- opts.on_tail('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- client.machines(ARGV[0]).metadata(options[:key]).delete
25
- rescue => e
26
- puts e.inspect
27
- else
28
- puts "Success"
29
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-n', '--name NAME', 'snapshot name.') {|v| options[:name] = v }
10
- opts.on_tail('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- client.machines(ARGV[0]).snapshots(options[:name]).delete
25
- rescue => e
26
- puts e.inspect
27
- else
28
- puts "Success"
29
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} machine.id [options]"
9
- opts.on('-k', '--key [NAME]', 'Key Tag.') {|v| options[:key] = v }
10
- opts.on_tail('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- client.machines(ARGV[0]).tags(options[:key]).delete
25
- rescue => e
26
- puts e.inspect
27
- else
28
- puts "Success"
29
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- puts client.analytics.describe
8
- rescue => e
9
- puts e.inspect
10
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- puts client.datacenters(ARGV[0]).read
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-getdataset DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- puts client.datasets(ARGV[0]).read
8
- rescue => e
9
- puts e.inspect
10
- end
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: #{File.basename($0)} instrumentation.id [options]"
9
- opts.on('-v', '--value', 'value raw') { options[:value] = true }
10
- opts.on_tail('-h','--help') do
11
- puts opts
12
- exit
13
- end
14
-
15
- begin
16
- opts.parse!(ARGV)
17
- rescue => e
18
- puts e.to_s << "\n" << opts.to_s
19
- exit
20
- end
21
- end
22
-
23
- begin
24
- if options[:value]
25
- puts client.analytics.instrumentations(ARGV[0]).value
26
- else
27
- puts client.analytics.instrumentations(ARGV[0]).read
28
- end
29
- rescue => e
30
- puts e.inspect
31
- end
data/bin/sdc-getkey DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- puts client.keys(ARGV[0]).read
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-getmachine DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
-
6
- begin
7
- puts client.machines(ARGV[0]).read
8
- rescue Smartdc::Error::NotFound => e
9
- puts e
10
- rescue => e
11
- puts e.inspect
12
- end