smartdc 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/Gemfile +7 -7
  2. data/README.md +5 -5
  3. data/VERSION +1 -1
  4. data/bin/sdc-addmachinemetadata +2 -2
  5. data/bin/sdc-addmachinetag +2 -2
  6. data/bin/sdc-createinstrumentation +1 -2
  7. data/bin/sdc-createkey +1 -2
  8. data/bin/sdc-createmachine +5 -5
  9. data/bin/sdc-createmachinesnapshot +1 -2
  10. data/bin/sdc-deleteinstrumentation +4 -2
  11. data/bin/sdc-deletekey +4 -2
  12. data/bin/sdc-deletemachine +4 -2
  13. data/bin/sdc-deletemachinemetadata +4 -2
  14. data/bin/sdc-deletemachinesnapshot +4 -3
  15. data/bin/sdc-deletemachinetag +4 -2
  16. data/bin/sdc-describeanalytics +1 -2
  17. data/bin/sdc-getdatacenter +1 -2
  18. data/bin/sdc-getdataset +1 -2
  19. data/bin/sdc-getinstrumentation +1 -2
  20. data/bin/sdc-getkey +1 -2
  21. data/bin/sdc-getmachine +3 -2
  22. data/bin/sdc-getmachinemetadata +4 -3
  23. data/bin/sdc-getmachinesnapshot +1 -2
  24. data/bin/sdc-getmachinetag +1 -2
  25. data/bin/sdc-getpackage +1 -2
  26. data/bin/sdc-listdatacenters +1 -2
  27. data/bin/sdc-listdatasets +1 -2
  28. data/bin/sdc-listinstrumentations +1 -2
  29. data/bin/sdc-listkeys +1 -2
  30. data/bin/sdc-listmachines +1 -2
  31. data/bin/sdc-listmachinesnapshots +1 -2
  32. data/bin/sdc-listmachinetags +1 -2
  33. data/bin/sdc-listpackages +1 -2
  34. data/bin/sdc-rebootmachine +4 -2
  35. data/bin/sdc-resizemachine +5 -3
  36. data/bin/sdc-setup +7 -3
  37. data/bin/sdc-startmachine +4 -2
  38. data/bin/sdc-startmachinefromsnapshot +4 -3
  39. data/bin/sdc-stopmachine +4 -2
  40. data/lib/smartdc.rb +1 -0
  41. data/lib/smartdc/api/analytics/instrumentations.rb +1 -2
  42. data/lib/smartdc/api/keys.rb +0 -1
  43. data/lib/smartdc/api/machine/metadata.rb +1 -2
  44. data/lib/smartdc/api/machine/snapshots.rb +1 -3
  45. data/lib/smartdc/api/machine/tags.rb +1 -2
  46. data/lib/smartdc/api/machines.rb +0 -5
  47. data/lib/smartdc/client.rb +4 -0
  48. data/lib/smartdc/error.rb +35 -0
  49. data/lib/smartdc/request.rb +13 -10
  50. data/lib/smartdc/response/mashify.rb +29 -0
  51. data/lib/smartdc/response/parse_json.rb +26 -0
  52. data/lib/smartdc/response/raise_error.rb +38 -0
  53. data/smartdc.gemspec +25 -23
  54. data/spec/smartdc/api/analytics_spec.rb +1 -1
  55. data/spec/smartdc/api/keys_spec.rb +1 -1
  56. data/spec/smartdc/api/machine/metadata_spec.rb +21 -4
  57. data/spec/smartdc/api/machine/snapshots_spec.rb +17 -5
  58. data/spec/smartdc/api/machine/tags_spec.rb +21 -4
  59. data/spec/smartdc/api/machines_spec.rb +19 -23
  60. data/spec/smartdc/request_spec.rb +3 -2
  61. data/spec/spec_helper.rb +7 -1
  62. metadata +33 -31
  63. data/lib/faraday/response/mashify.rb +0 -26
  64. data/lib/faraday/response/parse_json.rb +0 -22
@@ -26,7 +26,7 @@ describe "Smartdc::Api::instrumentations" do
26
26
 
27
27
  describe ".delete" do
28
28
  it "should return true when success" do
29
- client.analytics.instrumentations(@instrumentation.id).delete.should be_true
29
+ client.analytics.instrumentations(@instrumentation.id).delete.should be_nil
30
30
  end
31
31
  end
32
32
  end
@@ -26,7 +26,7 @@ describe "Smartdc::Api::Keys" do
26
26
 
27
27
  describe ".delete" do
28
28
  it "should return true when success" do
29
- client.keys(@key['name']).delete.should be_true
29
+ client.keys(@key['name']).delete.should be_nil
30
30
  end
31
31
  end
32
32
  end
@@ -2,13 +2,29 @@ require 'spec_helper'
2
2
 
3
3
  describe "Smartdc::Api::Machine::Metadata" do
4
4
  before(:all) do
5
+ @fixture = fixture('tag')
5
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
+
6
14
  machine = {
7
15
  'name' => @name,
8
- 'dataset' => client.datasets.find[0].urn
16
+ 'dataset' => @dataset_urn
9
17
  }
10
18
  @machine = client.machines.create machine
11
- @fixture = fixture('tag')
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
12
28
  end
13
29
 
14
30
  describe ".create" do
@@ -26,14 +42,15 @@ describe "Smartdc::Api::Machine::Metadata" do
26
42
 
27
43
  describe ".delete" do
28
44
  it "should return true when success" do
29
- client.machines(@machine.id).metadata('name').delete.should be_true
45
+ client.machines(@machine.id).metadata('name').delete.should be_nil
30
46
  end
31
47
  end
32
48
 
33
49
  after(:all) do
50
+ sleep 8
34
51
  machine = client.machines(@machine.id)
35
52
  machine.stop
36
- 8.times do |i|
53
+ 88.times do |i|
37
54
  break if machine.read.state == 'stopped'
38
55
  sleep i
39
56
  end
@@ -4,18 +4,29 @@ describe "Smartdc::Api::Machine::Snapshots" do
4
4
  before(:all) do
5
5
  @fixture = fixture('tag')
6
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
+
7
14
  machine = {
8
15
  'name' => @name,
9
- 'dataset' => client.datasets.find[0].urn # this is smartmachine
16
+ 'dataset' => @dataset_urn
10
17
  }
11
18
  @machine = client.machines.create machine
12
19
  machine = client.machines(@machine.id)
13
- 8.times do |i|
20
+ 88.times do |i|
21
+ break if machine.read.state == 'running'
22
+ sleep i
23
+ end
24
+ 88.times do |i|
14
25
  break if machine.read.state == 'running'
15
26
  sleep i
16
27
  end
17
28
  machine.stop
18
- 8.times do |i|
29
+ 88.times do |i|
19
30
  break if machine.read.state == 'stopped'
20
31
  sleep i
21
32
  end
@@ -42,14 +53,15 @@ describe "Smartdc::Api::Machine::Snapshots" do
42
53
 
43
54
  describe ".delete" do
44
55
  it "should return true when success" do
45
- client.machines(@machine.id).snapshots('sample').delete.should be_true
56
+ client.machines(@machine.id).snapshots('sample').delete.should be_nil
46
57
  end
47
58
  end
48
59
 
49
60
  after(:all) do
61
+ sleep 8
50
62
  machine = client.machines(@machine.id)
51
63
  machine.stop
52
- 8.times do |i|
64
+ 88.times do |i|
53
65
  break if machine.read.state == 'stopped'
54
66
  sleep i
55
67
  end
@@ -2,13 +2,29 @@ require 'spec_helper'
2
2
 
3
3
  describe "Smartdc::Api::Machine::Tags" do
4
4
  before(:all) do
5
+ @fixture = fixture('tag')
5
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
+
6
14
  machine = {
7
15
  'name' => @name,
8
- 'dataset' => client.datasets.find[0].urn
16
+ 'dataset' => @dataset_urn
9
17
  }
10
18
  @machine = client.machines.create machine
11
- @fixture = fixture('tag')
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
12
28
  end
13
29
 
14
30
  describe ".create" do
@@ -32,14 +48,15 @@ describe "Smartdc::Api::Machine::Tags" do
32
48
 
33
49
  describe ".delete" do
34
50
  it "should return true when success" do
35
- client.machines(@machine.id).tags('name').delete.should be_true
51
+ client.machines(@machine.id).tags('name').delete.should be_nil
36
52
  end
37
53
  end
38
54
 
39
55
  after(:all) do
56
+ sleep 8
40
57
  machine = client.machines(@machine.id)
41
58
  machine.stop
42
- 8.times do |i|
59
+ 88.times do |i|
43
60
  break if machine.read.state == 'stopped'
44
61
  sleep i
45
62
  end
@@ -3,9 +3,16 @@ require 'spec_helper'
3
3
  describe "Smartdc::Api::Machines" do
4
4
  before(:all) do
5
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
+
6
13
  machine = {
7
14
  'name' => @name,
8
- 'dataset' => client.datasets.find[0].urn
15
+ 'dataset' => @dataset_urn
9
16
  }
10
17
  @machine = client.machines.create machine
11
18
  end
@@ -23,7 +30,11 @@ describe "Smartdc::Api::Machines" do
23
30
 
24
31
  it "should return state at running when success" do
25
32
  machine = client.machines(@machine.id)
26
- 8.times do |i|
33
+ 88.times do |i|
34
+ break if machine.read.state == 'running'
35
+ sleep i
36
+ end
37
+ 88.times do |i|
27
38
  break if machine.read.state == 'running'
28
39
  sleep i
29
40
  end
@@ -39,12 +50,12 @@ describe "Smartdc::Api::Machines" do
39
50
 
40
51
  describe ".stop" do
41
52
  it "should return true when success" do
42
- client.machines(@machine.id).stop.should be_true
53
+ client.machines(@machine.id).stop.should be_nil
43
54
  end
44
55
 
45
56
  it "should return state at stopped when success" do
46
57
  machine = client.machines(@machine.id)
47
- 8.times do |i|
58
+ 88.times do |i|
48
59
  break if machine.read.state == 'stopped'
49
60
  sleep i
50
61
  end
@@ -54,27 +65,12 @@ describe "Smartdc::Api::Machines" do
54
65
 
55
66
  describe ".start" do
56
67
  it "should return true when success" do
57
- client.machines(@machine.id).start.should be_true
58
- end
59
-
60
- it "should return state at running when success" do
61
- machine = client.machines(@machine.id)
62
- 8.times do |i|
63
- break if machine.read.state == 'running'
64
- sleep i
65
- end
66
- machine.read.state.should eq 'running'
67
- end
68
- end
69
-
70
- describe ".reboot" do
71
- it "should return true when success" do
72
- client.machines(@machine.id).reboot.should be_true
68
+ client.machines(@machine.id).start.should be_nil
73
69
  end
74
70
 
75
71
  it "should return state at running when success" do
76
72
  machine = client.machines(@machine.id)
77
- 8.times do |i|
73
+ 88.times do |i|
78
74
  break if machine.read.state == 'running'
79
75
  sleep i
80
76
  end
@@ -86,11 +82,11 @@ describe "Smartdc::Api::Machines" do
86
82
  it "should return true when success" do
87
83
  machine = client.machines(@machine.id)
88
84
  machine.stop
89
- 8.times do |i|
85
+ 88.times do |i|
90
86
  break if machine.read.state == 'stopped'
91
87
  sleep i
92
88
  end
93
- client.machines(@machine.id).delete.should be_true
89
+ client.machines(@machine.id).delete.should be_nil
94
90
  end
95
91
  end
96
92
  end
@@ -4,8 +4,9 @@ describe "Smartdc::Request" do
4
4
  describe "http response status" do
5
5
  it "should return a response status" do
6
6
  request = Smartdc::Request.new(fixture('config', 'config'))
7
- request.get('/')
8
- request.response.status.should be(200)
7
+ expect{
8
+ request.get('smartdc/')
9
+ }.to raise_error(Smartdc::Error::NotFound)
9
10
  end
10
11
  end
11
12
  end
@@ -9,4 +9,10 @@ require 'cli_helper'
9
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
10
 
11
11
  RSpec.configure do |config|
12
- end
12
+ end
13
+
14
+ def client
15
+ @client ||= Smartdc.new(fixture('config', 'config'))
16
+ @client.format = 'mash'
17
+ @client
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000 Z
12
+ date: 2012-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
- requirement: &70200344696400 !ruby/object:Gem::Requirement
16
+ requirement: &70117794072540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.5
21
+ version: 0.7.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70200344696400
24
+ version_requirements: *70117794072540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hashie
27
- requirement: &70200344695920 !ruby/object:Gem::Requirement
27
+ requirement: &70117794072060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,43 +32,43 @@ dependencies:
32
32
  version: 1.2.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70200344695920
35
+ version_requirements: *70117794072060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &70200344695440 !ruby/object:Gem::Requirement
38
+ requirement: &70117794071580 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.3
43
+ version: 1.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70200344695440
46
+ version_requirements: *70117794071580
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: multipart-post
49
- requirement: &70200344694960 !ruby/object:Gem::Requirement
49
+ requirement: &70117794071100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.3
54
+ version: 1.1.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70200344694960
57
+ version_requirements: *70117794071100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70200344694480 !ruby/object:Gem::Requirement
60
+ requirement: &70117794070620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 2.7.0
65
+ version: 2.8.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70200344694480
68
+ version_requirements: *70117794070620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70200344694000 !ruby/object:Gem::Requirement
71
+ requirement: &70117794070140 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,32 +76,32 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70200344694000
79
+ version_requirements: *70117794070140
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70200344693520 !ruby/object:Gem::Requirement
82
+ requirement: &70117794069660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
86
86
  - !ruby/object:Gem::Version
87
- version: 1.6.4
87
+ version: 1.8.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70200344693520
90
+ version_requirements: *70117794069660
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70200344725520 !ruby/object:Gem::Requirement
93
+ requirement: &70117794069180 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
- - - ! '>='
96
+ - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: '0'
98
+ version: 0.9.11
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70200344725520
101
+ version_requirements: *70117794069180
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: uuid
104
- requirement: &70200344725040 !ruby/object:Gem::Requirement
104
+ requirement: &70117794085080 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 2.3.4
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70200344725040
112
+ version_requirements: *70117794085080
113
113
  description: smartdc is SmartDataCenter Public API.
114
114
  email: ogom@hotmail.co.jp
115
115
  executables:
@@ -199,8 +199,6 @@ files:
199
199
  - config/fixtures/key.json
200
200
  - config/fixtures/tag.json
201
201
  - lib/cli_helper.rb
202
- - lib/faraday/response/mashify.rb
203
- - lib/faraday/response/parse_json.rb
204
202
  - lib/smartdc.rb
205
203
  - lib/smartdc/api/analytics.rb
206
204
  - lib/smartdc/api/analytics/instrumentations.rb
@@ -213,7 +211,11 @@ files:
213
211
  - lib/smartdc/api/machines.rb
214
212
  - lib/smartdc/api/packages.rb
215
213
  - lib/smartdc/client.rb
214
+ - lib/smartdc/error.rb
216
215
  - lib/smartdc/request.rb
216
+ - lib/smartdc/response/mashify.rb
217
+ - lib/smartdc/response/parse_json.rb
218
+ - lib/smartdc/response/raise_error.rb
217
219
  - smartdc.gemspec
218
220
  - spec/smartdc/api/analytics_spec.rb
219
221
  - spec/smartdc/api/datacenters_spec.rb
@@ -243,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
243
245
  version: '0'
244
246
  segments:
245
247
  - 0
246
- hash: 4559567800633525012
248
+ hash: -933495277461786696
247
249
  required_rubygems_version: !ruby/object:Gem::Requirement
248
250
  none: false
249
251
  requirements:
@@ -252,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
254
  version: '0'
253
255
  requirements: []
254
256
  rubyforge_project:
255
- rubygems_version: 1.8.10
257
+ rubygems_version: 1.8.15
256
258
  signing_key:
257
259
  specification_version: 3
258
260
  summary: SmartDataCenter CloudApi client by ruby.