smartdc 0.4.0 → 1.0.1
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.
- data/.document +0 -1
- data/.travis.yml +5 -0
- data/Gemfile +7 -10
- data/README.md +42 -69
- data/Rakefile +47 -0
- data/VERSION +1 -1
- data/bin/sdc +327 -0
- data/lib/cli_helper.rb +131 -8
- data/lib/configure.rb +73 -0
- data/lib/smartdc.rb +16 -1
- data/lib/smartdc/api/analytics.rb +29 -7
- data/lib/smartdc/api/analytics/heatmap.rb +20 -0
- data/lib/smartdc/api/datacenters.rb +6 -7
- data/lib/smartdc/api/datasets.rb +6 -7
- data/lib/smartdc/api/keys.rb +10 -11
- data/lib/smartdc/api/machine/metadata.rb +9 -15
- data/lib/smartdc/api/machine/snapshots.rb +16 -16
- data/lib/smartdc/api/machine/tags.rb +11 -12
- data/lib/smartdc/api/machines.rb +23 -23
- data/lib/smartdc/api/packages.rb +7 -8
- data/lib/smartdc/client.rb +14 -18
- data/lib/smartdc/request.rb +41 -51
- data/lib/smartdc/response.rb +24 -0
- data/lib/smartdc/response/raise_error.rb +1 -1
- data/smartdc.gemspec +51 -90
- data/spec/fixtures/analytics.json +26 -0
- data/spec/fixtures/datacenter.json +4 -0
- data/spec/fixtures/datacenters.json +3 -0
- data/spec/fixtures/datasets.json +38 -0
- data/spec/fixtures/keys.json +14 -0
- data/spec/fixtures/machines.json +36 -0
- data/spec/fixtures/packages.json +18 -0
- data/spec/fixtures/snapshots.json +8 -0
- data/spec/fixtures/tag.json +3 -0
- data/spec/spec_helper.rb +3 -12
- data/spec/unit/smartdc/api/analytics_spec.rb +53 -0
- data/spec/unit/smartdc/api/datacenters_spec.rb +31 -0
- data/spec/unit/smartdc/api/datasets_spec.rb +31 -0
- data/spec/unit/smartdc/api/keys_spec.rb +53 -0
- data/spec/unit/smartdc/api/machine/metadata_spec.rb +42 -0
- data/spec/unit/smartdc/api/machine/snapshots_spec.rb +132 -0
- data/spec/unit/smartdc/api/machine/tags_spec.rb +53 -0
- data/spec/unit/smartdc/api/machines_spec.rb +53 -0
- data/spec/unit/smartdc/api/packages_spec.rb +31 -0
- data/spec/{smartdc → unit/smartdc}/client_spec.rb +0 -6
- data/spec/{smartdc_spec.rb → unit/smartdc_spec.rb} +1 -1
- metadata +72 -140
- data/LICENSE.md +0 -20
- data/bin/sdc-addmachinemetadata +0 -29
- data/bin/sdc-addmachinetag +0 -29
- data/bin/sdc-createinstrumentation +0 -27
- data/bin/sdc-createkey +0 -32
- data/bin/sdc-createmachine +0 -39
- data/bin/sdc-createmachinesnapshot +0 -27
- data/bin/sdc-deleteinstrumentation +0 -12
- data/bin/sdc-deletekey +0 -12
- data/bin/sdc-deletemachine +0 -12
- data/bin/sdc-deletemachinemetadata +0 -29
- data/bin/sdc-deletemachinesnapshot +0 -29
- data/bin/sdc-deletemachinetag +0 -29
- data/bin/sdc-describeanalytics +0 -10
- data/bin/sdc-getdatacenter +0 -10
- data/bin/sdc-getdataset +0 -10
- data/bin/sdc-getinstrumentation +0 -31
- data/bin/sdc-getkey +0 -10
- data/bin/sdc-getmachine +0 -12
- data/bin/sdc-getmachinemetadata +0 -12
- data/bin/sdc-getmachinesnapshot +0 -27
- data/bin/sdc-getmachinetag +0 -27
- data/bin/sdc-getpackage +0 -10
- data/bin/sdc-listdatacenters +0 -10
- data/bin/sdc-listdatasets +0 -10
- data/bin/sdc-listinstrumentations +0 -10
- data/bin/sdc-listkeys +0 -10
- data/bin/sdc-listmachines +0 -10
- data/bin/sdc-listmachinesnapshots +0 -10
- data/bin/sdc-listmachinetags +0 -10
- data/bin/sdc-listpackages +0 -10
- data/bin/sdc-rebootmachine +0 -12
- data/bin/sdc-resizemachine +0 -34
- data/bin/sdc-setup +0 -67
- data/bin/sdc-startmachine +0 -12
- data/bin/sdc-startmachinefromsnapshot +0 -29
- data/bin/sdc-stopmachine +0 -12
- data/config/fixtures/instrumentation.json +0 -4
- data/config/fixtures/key.json +0 -4
- data/config/fixtures/tag.json +0 -3
- data/lib/smartdc/api/analytics/instrumentations.rb +0 -44
- data/lib/smartdc/response/mashify.rb +0 -29
- data/lib/smartdc/response/parse_json.rb +0 -26
- data/spec/smartdc/api/analytics_spec.rb +0 -32
- data/spec/smartdc/api/datacenters_spec.rb +0 -16
- data/spec/smartdc/api/datasets_spec.rb +0 -16
- data/spec/smartdc/api/keys_spec.rb +0 -32
- data/spec/smartdc/api/machine/metadata_spec.rb +0 -59
- data/spec/smartdc/api/machine/snapshots_spec.rb +0 -70
- data/spec/smartdc/api/machine/tags_spec.rb +0 -65
- data/spec/smartdc/api/machines_spec.rb +0 -92
- data/spec/smartdc/api/packages_spec.rb +0 -16
- data/spec/smartdc/request_spec.rb +0 -12
data/bin/sdc-getmachinemetadata
DELETED
data/bin/sdc-getmachinesnapshot
DELETED
|
@@ -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
|
data/bin/sdc-getmachinetag
DELETED
|
@@ -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
data/bin/sdc-listdatacenters
DELETED
data/bin/sdc-listdatasets
DELETED
data/bin/sdc-listkeys
DELETED
data/bin/sdc-listmachines
DELETED
data/bin/sdc-listmachinetags
DELETED
data/bin/sdc-listpackages
DELETED
data/bin/sdc-rebootmachine
DELETED
data/bin/sdc-resizemachine
DELETED
|
@@ -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,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
data/config/fixtures/key.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sample",
|
|
3
|
-
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBnUxM+7a2f9K3PaKESQlf0YNg/UEXw4CxzLs4aHZciq2neHWeqD22uMIEkqIaYZYZAnbGCCPnz1h8ewk69D4/QVqG4Yw9wR0gEkHMu4xzSrQkCktftVnC0xv4tuxYBWKBu4q+t0R63oOPwzmfnSjcVXf+H6cDRzeBuQYjSaFcqCHIy1ehXfiesb+mdm/hlBA8u1WDZoLi/DELtpkwtX6mNySZCDTGrcua4Xc02ua2olpqj1UIYIZrs9Xyiz5RZP2lPzGMxP0k9lToZQHH1HprABDpEK7MckZbIDHHkoGlPhLEG40H0Wtq9hdgmCIw/rsUweFuwxDn/4BjEhSIBzqn"
|
|
4
|
-
}
|
data/config/fixtures/tag.json
DELETED
|
@@ -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
|