smartdc 0.4.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
module Smartdc
|
4
|
-
module Response
|
5
|
-
class ParseJson < Faraday::Response::Middleware
|
6
|
-
dependency do
|
7
|
-
require 'multi_json'
|
8
|
-
end
|
9
|
-
|
10
|
-
def parse(body)
|
11
|
-
case body
|
12
|
-
when ''
|
13
|
-
nil
|
14
|
-
when 'true'
|
15
|
-
true
|
16
|
-
when 'false'
|
17
|
-
false
|
18
|
-
else
|
19
|
-
::MultiJson.decode(body)
|
20
|
-
end
|
21
|
-
rescue
|
22
|
-
body
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::instrumentations" do
|
4
|
-
before(:all) do
|
5
|
-
@fixture = fixture('instrumentation')
|
6
|
-
@instrumentation = client.analytics.instrumentations.create @fixture
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".create" do
|
10
|
-
it "should return a instrumentation" do
|
11
|
-
@instrumentation.module.should eq @fixture['module']
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".read" do
|
16
|
-
it "should return a instrumentation" do
|
17
|
-
client.analytics.instrumentations(@instrumentation.id).read.module.should eq @fixture['module']
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe ".find" do
|
22
|
-
it "should return some instrumentations" do
|
23
|
-
client.analytics.instrumentations.find.count.should > 0
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".delete" do
|
28
|
-
it "should return true when success" do
|
29
|
-
client.analytics.instrumentations(@instrumentation.id).delete.should be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Datacenters" do
|
4
|
-
describe ".find" do
|
5
|
-
it "should return some datacenters" do
|
6
|
-
client.datacenters.find.count.should > 0
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ".read" do
|
11
|
-
it "should return a datacenter" do
|
12
|
-
datacenters = client.datacenters.find
|
13
|
-
client.datacenters(datacenters.first[0]).read[:message].should match(/#{datacenters.first[0]}/)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Datasets" do
|
4
|
-
describe ".find" do
|
5
|
-
it "should return some datasets" do
|
6
|
-
client.datasets.find.count.should > 0
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ".read" do
|
11
|
-
it "should return a dataset" do
|
12
|
-
datasets = client.datasets.find
|
13
|
-
client.datasets(datasets[0].id).read.id.should eq datasets[0].id
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Keys" do
|
4
|
-
before(:all) do
|
5
|
-
@key = fixture('key')
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ".create" do
|
9
|
-
it "should return a key" do
|
10
|
-
key = client.keys.create @key
|
11
|
-
key.name.should eq @key['name']
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".read" do
|
16
|
-
it "should return a key" do
|
17
|
-
client.keys(@key['name']).read.name.should eq @key['name']
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe ".find" do
|
22
|
-
it "should return some keys" do
|
23
|
-
client.keys.find.count.should > 0
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".delete" do
|
28
|
-
it "should return true when success" do
|
29
|
-
client.keys(@key['name']).delete.should be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Machine::Metadata" do
|
4
|
-
before(:all) do
|
5
|
-
@fixture = fixture('tag')
|
6
|
-
@name = UUID.new.generate
|
7
|
-
client.datasets.find.each do |dataset|
|
8
|
-
if dataset.type == "smartmachine"
|
9
|
-
@dataset_urn = dataset.urn
|
10
|
-
break
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
machine = {
|
15
|
-
'name' => @name,
|
16
|
-
'dataset' => @dataset_urn
|
17
|
-
}
|
18
|
-
@machine = client.machines.create machine
|
19
|
-
machine = client.machines(@machine.id)
|
20
|
-
88.times do |i|
|
21
|
-
break if machine.read.state == 'running'
|
22
|
-
sleep i
|
23
|
-
end
|
24
|
-
88.times do |i|
|
25
|
-
break if machine.read.state == 'running'
|
26
|
-
sleep i
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe ".create" do
|
31
|
-
it "should return a tag" do
|
32
|
-
tag = client.machines(@machine.id).metadata.create @fixture
|
33
|
-
tag.name.should eq @fixture['name']
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ".find" do
|
38
|
-
it "should return some metadata" do
|
39
|
-
client.machines(@machine.id).metadata.find.count.should > 0
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ".delete" do
|
44
|
-
it "should return true when success" do
|
45
|
-
client.machines(@machine.id).metadata('name').delete.should be_nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
after(:all) do
|
50
|
-
sleep 8
|
51
|
-
machine = client.machines(@machine.id)
|
52
|
-
machine.stop
|
53
|
-
88.times do |i|
|
54
|
-
break if machine.read.state == 'stopped'
|
55
|
-
sleep i
|
56
|
-
end
|
57
|
-
client.machines(@machine.id).delete
|
58
|
-
end
|
59
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Machine::Snapshots" do
|
4
|
-
before(:all) do
|
5
|
-
@fixture = fixture('tag')
|
6
|
-
@name = UUID.new.generate
|
7
|
-
client.datasets.find.each do |dataset|
|
8
|
-
if dataset.type == "smartmachine"
|
9
|
-
@dataset_urn = dataset.urn
|
10
|
-
break
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
machine = {
|
15
|
-
'name' => @name,
|
16
|
-
'dataset' => @dataset_urn
|
17
|
-
}
|
18
|
-
@machine = client.machines.create machine
|
19
|
-
machine = client.machines(@machine.id)
|
20
|
-
88.times do |i|
|
21
|
-
break if machine.read.state == 'running'
|
22
|
-
sleep i
|
23
|
-
end
|
24
|
-
88.times do |i|
|
25
|
-
break if machine.read.state == 'running'
|
26
|
-
sleep i
|
27
|
-
end
|
28
|
-
machine.stop
|
29
|
-
88.times do |i|
|
30
|
-
break if machine.read.state == 'stopped'
|
31
|
-
sleep i
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".create" do
|
36
|
-
it "should return a snapshot" do
|
37
|
-
snapshot = client.machines(@machine.id).snapshots.create @fixture
|
38
|
-
snapshot.name.should eq @fixture['name']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".read" do
|
43
|
-
it "should return a snapshot" do
|
44
|
-
client.machines(@machine.id).snapshots('sample').read.name.should eq @fixture['name']
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe ".find" do
|
49
|
-
it "should return some snapshots" do
|
50
|
-
client.machines(@machine.id).snapshots.find.count.should > 0
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe ".delete" do
|
55
|
-
it "should return true when success" do
|
56
|
-
client.machines(@machine.id).snapshots('sample').delete.should be_nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
after(:all) do
|
61
|
-
sleep 8
|
62
|
-
machine = client.machines(@machine.id)
|
63
|
-
machine.stop
|
64
|
-
88.times do |i|
|
65
|
-
break if machine.read.state == 'stopped'
|
66
|
-
sleep i
|
67
|
-
end
|
68
|
-
client.machines(@machine.id).delete
|
69
|
-
end
|
70
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Machine::Tags" do
|
4
|
-
before(:all) do
|
5
|
-
@fixture = fixture('tag')
|
6
|
-
@name = UUID.new.generate
|
7
|
-
client.datasets.find.each do |dataset|
|
8
|
-
if dataset.type == "smartmachine"
|
9
|
-
@dataset_urn = dataset.urn
|
10
|
-
break
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
machine = {
|
15
|
-
'name' => @name,
|
16
|
-
'dataset' => @dataset_urn
|
17
|
-
}
|
18
|
-
@machine = client.machines.create machine
|
19
|
-
machine = client.machines(@machine.id)
|
20
|
-
88.times do |i|
|
21
|
-
break if machine.read.state == 'running'
|
22
|
-
sleep i
|
23
|
-
end
|
24
|
-
88.times do |i|
|
25
|
-
break if machine.read.state == 'running'
|
26
|
-
sleep i
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe ".create" do
|
31
|
-
it "should return a tag" do
|
32
|
-
tag = client.machines(@machine.id).tags.create @fixture
|
33
|
-
tag.name.should eq @fixture['name']
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ".read" do
|
38
|
-
it "should return a tag" do
|
39
|
-
client.machines(@machine.id).tags('name').read.should eq @fixture['name']
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ".find" do
|
44
|
-
it "should return some tags" do
|
45
|
-
client.machines(@machine.id).tags.find.count.should > 0
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".delete" do
|
50
|
-
it "should return true when success" do
|
51
|
-
client.machines(@machine.id).tags('name').delete.should be_nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
after(:all) do
|
56
|
-
sleep 8
|
57
|
-
machine = client.machines(@machine.id)
|
58
|
-
machine.stop
|
59
|
-
88.times do |i|
|
60
|
-
break if machine.read.state == 'stopped'
|
61
|
-
sleep i
|
62
|
-
end
|
63
|
-
client.machines(@machine.id).delete
|
64
|
-
end
|
65
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Machines" do
|
4
|
-
before(:all) do
|
5
|
-
@name = UUID.new.generate
|
6
|
-
client.datasets.find.each do |dataset|
|
7
|
-
if dataset.type == "smartmachine"
|
8
|
-
@dataset_urn = dataset.urn
|
9
|
-
break
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
machine = {
|
14
|
-
'name' => @name,
|
15
|
-
'dataset' => @dataset_urn
|
16
|
-
}
|
17
|
-
@machine = client.machines.create machine
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".create" do
|
21
|
-
it "should return a machine" do
|
22
|
-
@machine.name.should eq @name
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".read" do
|
27
|
-
it "should return a machine" do
|
28
|
-
client.machines(@machine.id).read.name.should eq @name
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should return state at running when success" do
|
32
|
-
machine = client.machines(@machine.id)
|
33
|
-
88.times do |i|
|
34
|
-
break if machine.read.state == 'running'
|
35
|
-
sleep i
|
36
|
-
end
|
37
|
-
88.times do |i|
|
38
|
-
break if machine.read.state == 'running'
|
39
|
-
sleep i
|
40
|
-
end
|
41
|
-
machine.read.state.should eq 'running'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe ".find" do
|
46
|
-
it "should return some machines" do
|
47
|
-
client.machines.find.count.should > 0
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe ".stop" do
|
52
|
-
it "should return true when success" do
|
53
|
-
client.machines(@machine.id).stop.should be_nil
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should return state at stopped when success" do
|
57
|
-
machine = client.machines(@machine.id)
|
58
|
-
88.times do |i|
|
59
|
-
break if machine.read.state == 'stopped'
|
60
|
-
sleep i
|
61
|
-
end
|
62
|
-
machine.read.state.should eq 'stopped'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe ".start" do
|
67
|
-
it "should return true when success" do
|
68
|
-
client.machines(@machine.id).start.should be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should return state at running when success" do
|
72
|
-
machine = client.machines(@machine.id)
|
73
|
-
88.times do |i|
|
74
|
-
break if machine.read.state == 'running'
|
75
|
-
sleep i
|
76
|
-
end
|
77
|
-
machine.read.state.should eq 'running'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe ".delete" do
|
82
|
-
it "should return true when success" do
|
83
|
-
machine = client.machines(@machine.id)
|
84
|
-
machine.stop
|
85
|
-
88.times do |i|
|
86
|
-
break if machine.read.state == 'stopped'
|
87
|
-
sleep i
|
88
|
-
end
|
89
|
-
client.machines(@machine.id).delete.should be_nil
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Api::Packages" do
|
4
|
-
describe ".find" do
|
5
|
-
it "should return some packages" do
|
6
|
-
client.packages.find.count.should > 0
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe ".read" do
|
11
|
-
it "should return a dataset" do
|
12
|
-
packages = client.packages.find
|
13
|
-
client.packages(packages[0].name).read.name.should eq packages[0].name
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Smartdc::Request" do
|
4
|
-
describe "http response status" do
|
5
|
-
it "should return a response status" do
|
6
|
-
request = Smartdc::Request.new(fixture('config', 'config'))
|
7
|
-
expect{
|
8
|
-
request.get('smartdc/')
|
9
|
-
}.to raise_error(Smartdc::Error::NotFound)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|