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
@@ -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
-
7
-
8
- begin
9
- puts client.machines(ARGV[0]).metadata.find
10
- rescue => e
11
- puts e.inspect
12
- 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', '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
- puts client.machines(ARGV[0]).snapshots(options[:name]).read
25
- rescue => e
26
- puts e.inspect
27
- 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('-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
- puts client.machines(ARGV[0]).tags(options[:key]).read
25
- rescue => e
26
- puts e.inspect
27
- end
data/bin/sdc-getpackage 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.packages((ARGV[0])).read
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.find
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-listdatasets 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.find
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.analytics.instrumentations.find
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-listkeys 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.find
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-listmachines 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.machines.find
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.machines(ARGV[0]).snapshots.find
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.machines(ARGV[0]).tags.find
8
- rescue => e
9
- puts e.inspect
10
- end
data/bin/sdc-listpackages 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.packages.find
8
- rescue => e
9
- puts e.inspect
10
- 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]).reboot
8
- rescue => e
9
- puts e.inspect
10
- else
11
- puts "Success"
12
- end
@@ -1,34 +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('-p', '--package NAME', 'Name of the package to use on provisioning.') {|v| options[:package] = v }
10
- opts.on('-h','--help') do
11
- puts opts
12
- print "\n" + 'Packages(name):'
13
- fixture('packages').each do |packages|
14
- print ' ' + packages['name']
15
- end
16
- puts
17
- exit
18
- end
19
-
20
- begin
21
- opts.parse!(ARGV)
22
- rescue => e
23
- puts e.to_s << "\n" << opts.to_s
24
- exit
25
- end
26
- end
27
-
28
- begin
29
- client.machines(ARGV[0]).resize options
30
- rescue => e
31
- puts e.inspect
32
- else
33
- puts "Success"
34
- end
data/bin/sdc-setup DELETED
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'cli_helper'
5
- require 'pathname'
6
-
7
- CONFIG = File.join(File.dirname(__FILE__), '..', 'config/config.json')
8
- DATASETS = File.join(File.dirname(__FILE__), '..', 'config/fixtures/datasets.json')
9
- PACKAGES = File.join(File.dirname(__FILE__), '..', 'config/fixtures/packages.json')
10
- config = {}
11
-
12
- config[:url] = ARGV[0] if ARGV[0]
13
- unless config[:url]
14
- puts 'url is empty.'
15
- exit 1
16
- end
17
-
18
- print 'version:[~6.5] '
19
- config[:version] = STDIN.gets.chomp.to_s
20
- if config[:version].size == 0
21
- config[:version] = '~6.5'
22
- end
23
-
24
- print 'Username (login): '
25
- config[:username] = STDIN.gets.chomp.to_s
26
- if config[:username].size == 0
27
- puts 'Username is empty.'
28
- exit 1
29
- end
30
-
31
- print 'Password: '
32
- config[:password] = STDIN.gets.chomp.to_s
33
- if config[:password].size == 0
34
- puts 'Password is empty.'
35
- exit 1
36
- end
37
-
38
- config[:format] = 'json'
39
-
40
- Pathname.new(File.dirname(CONFIG)).mkpath unless File.exist?(File.dirname(CONFIG))
41
- File.open(CONFIG, 'w') do |file|
42
- file.write MultiJson.encode(config)
43
- end
44
-
45
- begin
46
- client.format = 'mash'
47
- datacenters = client.datacenters.find
48
- if client.datacenters.find.first[1] == config[:url]
49
- puts 'Successful configuration.'
50
-
51
- client.format = 'json'
52
- Pathname.new(File.dirname(DATASETS)).mkpath unless File.exist?(File.dirname(DATASETS))
53
- File.open(DATASETS, 'w') do |file|
54
- file.write client.datasets.find
55
- end
56
-
57
- Pathname.new(File.dirname(PACKAGES)).mkpath unless File.exist?(File.dirname(PACKAGES))
58
- File.open(PACKAGES, 'w') do |file|
59
- file.write client.packages.find
60
- end
61
- else
62
- puts 'Failed Configuration.'
63
- end
64
- rescue => e
65
- puts e.inspect
66
- puts 'Failed Setup.'
67
- end
data/bin/sdc-startmachine 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.machines(ARGV[0]).start
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('-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]).start
25
- rescue => e
26
- puts e.inspect
27
- else
28
- puts "Success"
29
- end
data/bin/sdc-stopmachine 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.machines(ARGV[0]).stop
8
- rescue => e
9
- puts e.inspect
10
- else
11
- puts "Success"
12
- end
@@ -1,4 +0,0 @@
1
- {
2
- "module": "syscall"
3
- , "stat": "syscalls"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "name": "sample",
3
- "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBnUxM+7a2f9K3PaKESQlf0YNg/UEXw4CxzLs4aHZciq2neHWeqD22uMIEkqIaYZYZAnbGCCPnz1h8ewk69D4/QVqG4Yw9wR0gEkHMu4xzSrQkCktftVnC0xv4tuxYBWKBu4q+t0R63oOPwzmfnSjcVXf+H6cDRzeBuQYjSaFcqCHIy1ehXfiesb+mdm/hlBA8u1WDZoLi/DELtpkwtX6mNySZCDTGrcua4Xc02ua2olpqj1UIYIZrs9Xyiz5RZP2lPzGMxP0k9lToZQHH1HprABDpEK7MckZbIDHHkoGlPhLEG40H0Wtq9hdgmCIw/rsUweFuwxDn/4BjEhSIBzqn"
4
- }
@@ -1,3 +0,0 @@
1
- {
2
- "name": "sample"
3
- }
@@ -1,44 +0,0 @@
1
- module Smartdc::Api
2
- class Analytics
3
- class Instrumentations
4
- attr_reader :request, :id
5
-
6
- def initialize(request, id)
7
- @request = request
8
- @id = id
9
- end
10
-
11
- def create(params={})
12
- request.post('my/analytics/instrumentations/', params)
13
- end
14
-
15
- def read
16
- raise ArgumentError unless id
17
- request.get('my/analytics/instrumentations/' + id.to_s)
18
- end
19
-
20
- def find(params={})
21
- request.get('my/analytics/instrumentations', params)
22
- end
23
-
24
- def delete
25
- request.delete('my/analytics/instrumentations/' + id.to_s)
26
- end
27
-
28
- def value
29
- raise ArgumentError unless id
30
- request.get('my/analytics/instrumentations/' + id.to_s + '/value/raw')
31
- end
32
-
33
- def heatmap(params={})
34
- raise ArgumentError unless id
35
- request.get('my/analytics/instrumentations/' + id.to_s + '/value/heatmap/image', params)
36
- end
37
-
38
- def heatmap_details(params={})
39
- raise ArgumentError unless id
40
- request.get('my/analytics/instrumentations/' + id.to_s + '/value/heatmap/details', params)
41
- end
42
- end
43
- end
44
- end
@@ -1,29 +0,0 @@
1
- require 'faraday'
2
-
3
- module Smartdc
4
- module Response
5
- class Mashify < Faraday::Response::Middleware
6
- class << self
7
- attr_accessor :mash_class
8
- end
9
-
10
- dependency do
11
- require 'hashie/mash'
12
- self.mash_class = ::Hashie::Mash
13
- end
14
-
15
- def parse(body)
16
- case body
17
- when Hash
18
- self.class.mash_class.new(body)
19
- when Array
20
- body.map { |item| item.is_a?(Hash) ? self.class.mash_class.new(item) : item }
21
- else
22
- body
23
- end
24
- rescue
25
- body
26
- end
27
- end
28
- end
29
- end