smartdc 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -19
- data/.travis.yml +1 -1
- data/Gemfile +5 -11
- data/README.md +25 -40
- data/Rakefile +5 -5
- data/bin/sdc +4 -380
- data/config.ru +2 -0
- data/lib/smartdc.rb +23 -15
- data/lib/smartdc/api/analytics.rb +19 -36
- data/lib/smartdc/api/analytics/heatmap.rb +6 -15
- data/lib/smartdc/api/datacenters.rb +7 -16
- data/lib/smartdc/api/images.rb +11 -0
- data/lib/smartdc/api/keys.rb +13 -23
- data/lib/smartdc/api/machines.rb +26 -60
- data/lib/smartdc/api/machines/metadata.rb +15 -0
- data/lib/smartdc/api/machines/snapshots.rb +23 -0
- data/lib/smartdc/api/machines/tags.rb +19 -0
- data/lib/smartdc/api/packages.rb +7 -17
- data/lib/smartdc/auth.rb +39 -5
- data/lib/smartdc/cli.rb +65 -0
- data/lib/smartdc/cli/analytic.rb +52 -0
- data/lib/smartdc/cli/datacenter.rb +15 -0
- data/lib/smartdc/cli/image.rb +19 -0
- data/lib/smartdc/cli/key.rb +26 -0
- data/lib/smartdc/cli/machine.rb +79 -0
- data/lib/smartdc/cli/machine/metadata.rb +30 -0
- data/lib/smartdc/cli/machine/snapshot.rb +38 -0
- data/lib/smartdc/cli/machine/tag.rb +33 -0
- data/lib/smartdc/cli/package.rb +17 -0
- data/lib/smartdc/cli_configure.rb +81 -0
- data/lib/smartdc/cli_helper.rb +111 -0
- data/lib/smartdc/client.rb +33 -28
- data/lib/smartdc/configure.rb +30 -0
- data/lib/smartdc/default.rb +35 -0
- data/lib/smartdc/version.rb +1 -1
- data/smartdc.gemspec +20 -16
- data/spec/cassettes/analytics/create.yml +64 -0
- data/spec/cassettes/analytics/describe.yml +123 -0
- data/spec/cassettes/analytics/destroy.yml +56 -0
- data/spec/cassettes/analytics/index.yml +62 -0
- data/spec/cassettes/analytics/show.yml +62 -0
- data/spec/cassettes/analytics/value.yml +62 -0
- data/spec/cassettes/datacenters/index.yml +62 -0
- data/spec/cassettes/datacenters/show.yml +64 -0
- data/spec/cassettes/images/index.yml +519 -0
- data/spec/cassettes/images/show.yml +63 -0
- data/spec/cassettes/keys/create.yml +65 -0
- data/spec/cassettes/keys/destroy.yml +56 -0
- data/spec/cassettes/keys/index.yml +63 -0
- data/spec/cassettes/keys/show.yml +63 -0
- data/spec/cassettes/machines/create.yml +65 -0
- data/spec/cassettes/machines/destroy.yml +56 -0
- data/spec/cassettes/machines/index.yml +67 -0
- data/spec/cassettes/machines/metadata/destroy.yml +56 -0
- data/spec/cassettes/machines/metadata/index.yml +62 -0
- data/spec/cassettes/machines/metadata/update.yml +64 -0
- data/spec/cassettes/machines/reboot.yml +58 -0
- data/spec/cassettes/machines/show.yml +63 -0
- data/spec/cassettes/machines/snapshots/create.yml +62 -0
- data/spec/cassettes/machines/snapshots/destroy.yml +56 -0
- data/spec/cassettes/machines/snapshots/index.yml +62 -0
- data/spec/cassettes/machines/snapshots/show.yml +62 -0
- data/spec/cassettes/machines/snapshots/start.yml +58 -0
- data/spec/cassettes/machines/start.yml +58 -0
- data/spec/cassettes/machines/stop.yml +58 -0
- data/spec/cassettes/machines/tags/create.yml +64 -0
- data/spec/cassettes/machines/tags/destroy.yml +56 -0
- data/spec/cassettes/machines/tags/index.yml +62 -0
- data/spec/cassettes/machines/tags/show.yml +62 -0
- data/spec/cassettes/packages/index.yml +123 -0
- data/spec/cassettes/packages/show.yml +63 -0
- data/spec/fixtures/config/sdccfg +4 -0
- data/spec/fixtures/ssh/id_rsa +27 -0
- data/spec/fixtures/ssh/id_rsa.pub +1 -0
- data/spec/smartdc/api/analytics_spec.rb +47 -0
- data/spec/smartdc/api/datacenters_spec.rb +19 -0
- data/spec/smartdc/api/images_spec.rb +19 -0
- data/spec/smartdc/api/keys_spec.rb +34 -0
- data/spec/smartdc/api/machines/metadata_spec.rb +27 -0
- data/spec/smartdc/api/machines/snapshots_spec.rb +38 -0
- data/spec/smartdc/api/machines/tags_spec.rb +33 -0
- data/spec/smartdc/api/machines_spec.rb +59 -0
- data/spec/smartdc/api/packages_spec.rb +19 -0
- data/spec/smartdc/auth_spec.rb +25 -0
- data/spec/smartdc/cli_configure_spec.rb +32 -0
- data/spec/smartdc/client_spec.rb +11 -0
- data/spec/smartdc_spec.rb +44 -0
- data/spec/spec_helper.rb +25 -8
- metadata +176 -83
- data/lib/cli_helper.rb +0 -126
- data/lib/configure.rb +0 -125
- data/lib/smartdc/api/datasets.rb +0 -20
- data/lib/smartdc/api/machine/metadata.rb +0 -24
- data/lib/smartdc/api/machine/snapshots.rb +0 -35
- data/lib/smartdc/api/machine/tags.rb +0 -29
- data/lib/smartdc/error.rb +0 -35
- data/lib/smartdc/request.rb +0 -83
- data/lib/smartdc/response.rb +0 -25
- data/lib/smartdc/response/raise_error.rb +0 -38
- data/spec/fixtures/analytics.json +0 -26
- data/spec/fixtures/datacenter.json +0 -4
- data/spec/fixtures/datacenters.json +0 -3
- data/spec/fixtures/datasets.json +0 -38
- data/spec/fixtures/keys.json +0 -14
- data/spec/fixtures/machines.json +0 -36
- data/spec/fixtures/packages.json +0 -18
- data/spec/fixtures/snapshots.json +0 -8
- data/spec/fixtures/tag.json +0 -3
- data/spec/unit/smartdc/api/analytics_spec.rb +0 -48
- data/spec/unit/smartdc/api/datacenters_spec.rb +0 -28
- data/spec/unit/smartdc/api/datasets_spec.rb +0 -28
- data/spec/unit/smartdc/api/keys_spec.rb +0 -48
- data/spec/unit/smartdc/api/machine/metadata_spec.rb +0 -38
- data/spec/unit/smartdc/api/machine/snapshots_spec.rb +0 -48
- data/spec/unit/smartdc/api/machine/tags_spec.rb +0 -48
- data/spec/unit/smartdc/api/machines_spec.rb +0 -48
- data/spec/unit/smartdc/api/packages_spec.rb +0 -28
- data/spec/unit/smartdc/client_spec.rb +0 -40
- data/spec/unit/smartdc_spec.rb +0 -9
data/lib/smartdc/response.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Smartdc
|
2
|
-
class Response
|
3
|
-
attr_reader :status, :headers, :body, :content
|
4
|
-
|
5
|
-
def initialize(response)
|
6
|
-
@status = response.status
|
7
|
-
@headers = response.headers
|
8
|
-
@body = response.body
|
9
|
-
self.content = @body
|
10
|
-
end
|
11
|
-
|
12
|
-
def content=raw
|
13
|
-
case raw
|
14
|
-
when nil, ''
|
15
|
-
@content = nil
|
16
|
-
when 'true'
|
17
|
-
@content = true
|
18
|
-
when 'false'
|
19
|
-
@content = false
|
20
|
-
else
|
21
|
-
@content = JSON.parse(raw)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
module Smartdc
|
4
|
-
class Response
|
5
|
-
class RaiseError < Faraday::Response::Middleware
|
6
|
-
def on_complete(env)
|
7
|
-
case env[:status]
|
8
|
-
when 400
|
9
|
-
raise Smartdc::Error::BadRequest, response_values(env)
|
10
|
-
when 401
|
11
|
-
raise Smartdc::Error::Unauthorized, response_values(env)
|
12
|
-
when 403
|
13
|
-
raise Smartdc::Error::Forbidden, response_values(env)
|
14
|
-
when 404
|
15
|
-
raise Smartdc::Error::NotFound, response_values(env)
|
16
|
-
when 405
|
17
|
-
raise Smartdc::Error::MethodNotAllowed, response_values(env)
|
18
|
-
when 406
|
19
|
-
raise Smartdc::Error::NotAcceptable, response_values(env)
|
20
|
-
when 409
|
21
|
-
raise Smartdc::Error::Conflict, response_values(env)
|
22
|
-
when 500
|
23
|
-
raise Smartdc::Error::InternalServerError, response_values(env)
|
24
|
-
when 501
|
25
|
-
raise Smartdc::Error::NotImplemented, response_values(env)
|
26
|
-
when 502
|
27
|
-
raise Smartdc::Error::BadGateway, response_values(env)
|
28
|
-
when 503
|
29
|
-
raise Smartdc::Error::ServiceUnavailable, response_values(env)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def response_values(env)
|
34
|
-
{:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"module": "syscall",
|
4
|
-
"stat": "syscalls",
|
5
|
-
"predicate": {},
|
6
|
-
"decomposition": [],
|
7
|
-
"value-dimension": 1,
|
8
|
-
"value-arity": "scalar",
|
9
|
-
"enabled": true,
|
10
|
-
"retention-time": 600,
|
11
|
-
"idle-max": 3600,
|
12
|
-
"transformations": {},
|
13
|
-
"nsources": 1,
|
14
|
-
"granularity": 1,
|
15
|
-
"persist-data": false,
|
16
|
-
"crtime": 1355245051112,
|
17
|
-
"value-scope": "interval",
|
18
|
-
"id": "3",
|
19
|
-
"uris": [
|
20
|
-
{
|
21
|
-
"uri": "/ogom/analytics/instrumentations/3/value/raw",
|
22
|
-
"name": "value_raw"
|
23
|
-
}
|
24
|
-
]
|
25
|
-
}
|
26
|
-
]
|
data/spec/fixtures/datasets.json
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "141194fa-dd77-11e0-8539-27dd8d8264b8",
|
4
|
-
"urn": "sdc:sdc:smartos64:1.4.7",
|
5
|
-
"name": "smartos64",
|
6
|
-
"os": "smartos",
|
7
|
-
"type": "smartmachine",
|
8
|
-
"description": "Base template to build other templates on",
|
9
|
-
"default": false,
|
10
|
-
"requirements": {},
|
11
|
-
"version": "1.4.7",
|
12
|
-
"created": "2011-11-21T04:48:58+00:00"
|
13
|
-
},
|
14
|
-
{
|
15
|
-
"id": "f8ea0bb8-dd75-11e0-87c3-af5352ad3bd6",
|
16
|
-
"urn": "sdc:sdc:smartos:1.4.7",
|
17
|
-
"name": "smartos",
|
18
|
-
"os": "smartos",
|
19
|
-
"type": "smartmachine",
|
20
|
-
"description": "Base template to build other templates on",
|
21
|
-
"default": false,
|
22
|
-
"requirements": {},
|
23
|
-
"version": "1.4.7",
|
24
|
-
"created": "2011-10-22T07:23:19+00:00"
|
25
|
-
},
|
26
|
-
{
|
27
|
-
"id": "41da9c2e-7175-11e0-bb9f-536983f41cd8",
|
28
|
-
"urn": "sdc:sdc:nodejs:1.1.4",
|
29
|
-
"name": "nodejs",
|
30
|
-
"os": "smartos",
|
31
|
-
"type": "smartmachine",
|
32
|
-
"description": "Node.js git-deploy PaaS dataset",
|
33
|
-
"default": false,
|
34
|
-
"requirements": {},
|
35
|
-
"version": "1.1.4",
|
36
|
-
"created": "2011-09-26T01:42:34+00:00"
|
37
|
-
}
|
38
|
-
]
|
data/spec/fixtures/keys.json
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"name": "K001",
|
4
|
-
"key": "ssh-rsa AAA123 K001",
|
5
|
-
"created": "2012-12-12T23:59:01+00:00",
|
6
|
-
"updated": "2012-12-12T23:59:02+00:00"
|
7
|
-
},
|
8
|
-
{
|
9
|
-
"name": "K002",
|
10
|
-
"key": "ssh-rsa AAA456 K002",
|
11
|
-
"created": "2012-12-12T23:59:03+00:00",
|
12
|
-
"updated": "2012-12-12T23:59:04+00:00"
|
13
|
-
}
|
14
|
-
]
|
data/spec/fixtures/machines.json
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "abc",
|
4
|
-
"name": "M001",
|
5
|
-
"type": "smartmachine",
|
6
|
-
"state": "running",
|
7
|
-
"dataset": "sdc:sdc:smartos:1.5.1",
|
8
|
-
"ips": [
|
9
|
-
"192.168.1.2"
|
10
|
-
],
|
11
|
-
"memory": 512,
|
12
|
-
"disk": 10240,
|
13
|
-
"metadata": {},
|
14
|
-
"created": "2012-12-12T23:59:01+00:00",
|
15
|
-
"updated": "2012-12-12T23:59:02+00:00",
|
16
|
-
"primaryIp": "192.168.1.2"
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"id": "def",
|
20
|
-
"name": "M002",
|
21
|
-
"type": "virtualmachine",
|
22
|
-
"state": "running",
|
23
|
-
"dataset": "sdc:sdc:ubuntu10.04:0.1.0",
|
24
|
-
"ips": [
|
25
|
-
"192.168.1.3"
|
26
|
-
],
|
27
|
-
"memory": 256,
|
28
|
-
"disk": 10240,
|
29
|
-
"metadata": {
|
30
|
-
"root_authorized_keys": "ssh-rsa AAA123 K001\n"
|
31
|
-
},
|
32
|
-
"created": "2012-12-12T23:59:03+00:00",
|
33
|
-
"updated": "2012-12-12T23:59:04+00:00",
|
34
|
-
"primaryIp": "192.168.1.3"
|
35
|
-
}
|
36
|
-
]
|
data/spec/fixtures/packages.json
DELETED
data/spec/fixtures/tag.json
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Analytics do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:analytics) {Smartdc::Api::Analytics.new({})}
|
8
|
-
|
9
|
-
describe ".create" do
|
10
|
-
it "creates a instrumentation" do
|
11
|
-
object.stub(:content) {fixture('analytics')[0]}
|
12
|
-
analytic = object.content
|
13
|
-
request.stub_chain(:new, :post).with('my/analytics/instrumentations/', analytic) {object}
|
14
|
-
|
15
|
-
expect(analytics.create(analytic).content['id']).to eq(analytic['id'])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".read" do
|
20
|
-
it "returns a instrumentation" do
|
21
|
-
object.stub(:content) {fixture('analytics')[0]}
|
22
|
-
id = object.content['id']
|
23
|
-
request.stub_chain(:new, :get).with('my/analytics/instrumentations/' + id) {object}
|
24
|
-
|
25
|
-
expect(analytics.read(id).content['id']).to eq(id)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".all" do
|
30
|
-
it "returns some instrumentations" do
|
31
|
-
object.stub(:content) {fixture('analytics')}
|
32
|
-
request.stub_chain(:new, :get).with('my/analytics/instrumentations', {}) {object}
|
33
|
-
|
34
|
-
expect(analytics.all.content.count).to be > 0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe ".destroy" do
|
39
|
-
it "returns true when success" do
|
40
|
-
analytic = fixture('analytics')[0]
|
41
|
-
object.stub(:status) {204}
|
42
|
-
request.stub_chain(:new, :del).with('my/analytics/instrumentations/' + analytic['id']) {object}
|
43
|
-
|
44
|
-
expect(analytics.destroy(analytic['id']).status).to eq(204)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Datacenters do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:datacenters) {Smartdc::Api::Datacenters.new({})}
|
8
|
-
|
9
|
-
describe ".read" do
|
10
|
-
it "returns a datacenter" do
|
11
|
-
object.stub(:content) {fixture('datacenter')}
|
12
|
-
name = fixture('datacenters').first[0]
|
13
|
-
request.stub_chain(:new, :get).with('my/datacenters/' + name) {object}
|
14
|
-
|
15
|
-
expect(datacenters.read(name).content['message']).to match(/#{name}/)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".all" do
|
20
|
-
it "returns some datacenter" do
|
21
|
-
object.stub(:content) {fixture('datacenters')}
|
22
|
-
request.stub_chain(:new, :get).with('my/datacenters', {}) {object}
|
23
|
-
|
24
|
-
expect(datacenters.all.content.count).to be > 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Datasets do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:datasets) {Smartdc::Api::Datasets.new({})}
|
8
|
-
|
9
|
-
describe ".read" do
|
10
|
-
it "returns a dataset" do
|
11
|
-
object.stub(:content) {fixture('datasets')[0]}
|
12
|
-
id = object.content['id']
|
13
|
-
request.stub_chain(:new, :get).with('my/datasets/' + id) {object}
|
14
|
-
|
15
|
-
expect(datasets.read(id).content['id']).to eq(id)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".all" do
|
20
|
-
it "returns some datasets" do
|
21
|
-
object.stub(:content) {fixture('datasets')}
|
22
|
-
request.stub_chain(:new, :get).with('my/datasets', {}) {object}
|
23
|
-
|
24
|
-
expect(datasets.all.content.count).to be > 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Keys do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:keys) {Smartdc::Api::Keys.new({})}
|
8
|
-
|
9
|
-
describe ".create" do
|
10
|
-
it "creates a key" do
|
11
|
-
object.stub(:content) {fixture('keys')[0]}
|
12
|
-
key = object.content
|
13
|
-
request.stub_chain(:new, :post).with('my/keys/', key) {object}
|
14
|
-
|
15
|
-
expect(keys.create(key).content['name']).to eq(key['name'])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".read" do
|
20
|
-
it "returns a key" do
|
21
|
-
object.stub(:content) {fixture('keys')[0]}
|
22
|
-
name = object.content['name']
|
23
|
-
request.stub_chain(:new, :get).with('my/keys/' + name) {object}
|
24
|
-
|
25
|
-
expect(keys.read(name).content['name']).to eq(name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".all" do
|
30
|
-
it "returns some keys" do
|
31
|
-
object.stub(:content) {fixture('keys')}
|
32
|
-
request.stub_chain(:new, :get).with('my/keys', {}) {object}
|
33
|
-
|
34
|
-
expect(keys.all.content.count).to be > 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe ".destroy" do
|
39
|
-
it "returns true when success" do
|
40
|
-
key = fixture('keys')[0]
|
41
|
-
object.stub(:status) {204}
|
42
|
-
request.stub_chain(:new, :del).with('my/keys/' + key['name']) {object}
|
43
|
-
|
44
|
-
expect(keys.destroy(key['name']).status).to eq(204)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Machine::Metadata do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:metadata) {Smartdc::Api::Machine::Metadata.new('id', {})}
|
8
|
-
|
9
|
-
describe ".create" do
|
10
|
-
it "creates a metadata" do
|
11
|
-
object.stub(:content) {fixture('tag')}
|
12
|
-
tag = object.content
|
13
|
-
request.stub_chain(:new, :post).with('my/machines/id/metadata/', tag) {object}
|
14
|
-
|
15
|
-
expect(metadata.create(tag).content).to eq(tag)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".read" do
|
20
|
-
it "return some metadata" do
|
21
|
-
object.stub(:content) {fixture('tag')}
|
22
|
-
request.stub_chain(:new, :get).with('my/machines/id/metadata', {}) {object}
|
23
|
-
|
24
|
-
expect(metadata.read.content.count).to be > 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe ".destroy" do
|
29
|
-
it "return a metadata" do
|
30
|
-
object.stub(:status) {204}
|
31
|
-
key = fixture('tag').first[0]
|
32
|
-
request.stub_chain(:new, :del).with('my/machines/id/metadata/' + key) {object}
|
33
|
-
|
34
|
-
expect(metadata.destroy(key).status).to eq(204)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Smartdc::Api::Machine::Snapshots do
|
4
|
-
|
5
|
-
let(:object) {Object.new}
|
6
|
-
let(:request) {Smartdc::Request}
|
7
|
-
let(:snapshots) {Smartdc::Api::Machine::Snapshots.new('id', {})}
|
8
|
-
|
9
|
-
describe ".create" do
|
10
|
-
it "creates a snapshot" do
|
11
|
-
object.stub(:content) {fixture('snapshots')[0]}
|
12
|
-
snapshot = object.content
|
13
|
-
request.stub_chain(:new, :post).with('my/machines/id/snapshots/', snapshot) {object}
|
14
|
-
|
15
|
-
expect(snapshots.create(snapshot).content['name']).to eq(snapshot['name'])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".read" do
|
20
|
-
it "return a snapshot" do
|
21
|
-
object.stub(:content) {fixture('snapshots')[0]}
|
22
|
-
name = object.content['name']
|
23
|
-
request.stub_chain(:new, :get).with('my/machines/id/snapshots/' + name) {object}
|
24
|
-
|
25
|
-
expect(snapshots.read(name).content['name']).to eq(name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".all" do
|
30
|
-
it "return some snapshots" do
|
31
|
-
object.stub(:content) {fixture('snapshots')}
|
32
|
-
request.stub_chain(:new, :get).with('my/machines/id/snapshots', {}) {object}
|
33
|
-
|
34
|
-
expect(snapshots.all.content.count).to be > 0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe ".destroy" do
|
39
|
-
it "return a snapshot" do
|
40
|
-
object.stub(:status) {204}
|
41
|
-
name = fixture('snapshots')[0]['name']
|
42
|
-
request.stub_chain(:new, :del).with('my/machines/id/snapshots/' + name) {object}
|
43
|
-
|
44
|
-
expect(snapshots.destroy(name).status).to eq(204)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|