smartdc 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.document +5 -0
  2. data/Gemfile +16 -0
  3. data/LICENSE.md +20 -0
  4. data/README.md +87 -0
  5. data/VERSION +1 -0
  6. data/bin/sdc-addmachinemetadata +29 -0
  7. data/bin/sdc-addmachinetag +29 -0
  8. data/bin/sdc-createinstrumentation +28 -0
  9. data/bin/sdc-createkey +33 -0
  10. data/bin/sdc-createmachine +39 -0
  11. data/bin/sdc-createmachinesnapshot +28 -0
  12. data/bin/sdc-deleteinstrumentation +10 -0
  13. data/bin/sdc-deletekey +10 -0
  14. data/bin/sdc-deletemachine +10 -0
  15. data/bin/sdc-deletemachinemetadata +27 -0
  16. data/bin/sdc-deletemachinesnapshot +28 -0
  17. data/bin/sdc-deletemachinetag +27 -0
  18. data/bin/sdc-describeanalytics +11 -0
  19. data/bin/sdc-getdatacenter +11 -0
  20. data/bin/sdc-getdataset +11 -0
  21. data/bin/sdc-getinstrumentation +32 -0
  22. data/bin/sdc-getkey +11 -0
  23. data/bin/sdc-getmachine +11 -0
  24. data/bin/sdc-getmachinemetadata +11 -0
  25. data/bin/sdc-getmachinesnapshot +28 -0
  26. data/bin/sdc-getmachinetag +28 -0
  27. data/bin/sdc-getpackage +11 -0
  28. data/bin/sdc-listdatacenters +11 -0
  29. data/bin/sdc-listdatasets +11 -0
  30. data/bin/sdc-listinstrumentations +11 -0
  31. data/bin/sdc-listkeys +11 -0
  32. data/bin/sdc-listmachines +11 -0
  33. data/bin/sdc-listmachinesnapshots +11 -0
  34. data/bin/sdc-listmachinetags +11 -0
  35. data/bin/sdc-listpackages +11 -0
  36. data/bin/sdc-rebootmachine +10 -0
  37. data/bin/sdc-resizemachine +32 -0
  38. data/bin/sdc-setup +63 -0
  39. data/bin/sdc-startmachine +10 -0
  40. data/bin/sdc-startmachinefromsnapshot +28 -0
  41. data/bin/sdc-stopmachine +10 -0
  42. data/config/fixtures/instrumentation.json +4 -0
  43. data/config/fixtures/key.json +4 -0
  44. data/config/fixtures/tag.json +3 -0
  45. data/lib/cli_helper.rb +12 -0
  46. data/lib/faraday/response/mashify.rb +26 -0
  47. data/lib/faraday/response/parse_json.rb +22 -0
  48. data/lib/smartdc.rb +8 -0
  49. data/lib/smartdc/api/analytics.rb +22 -0
  50. data/lib/smartdc/api/analytics/instrumentations.rb +45 -0
  51. data/lib/smartdc/api/datacenters.rb +21 -0
  52. data/lib/smartdc/api/datasets.rb +21 -0
  53. data/lib/smartdc/api/keys.rb +31 -0
  54. data/lib/smartdc/api/machine/metadata.rb +31 -0
  55. data/lib/smartdc/api/machine/snapshots.rb +37 -0
  56. data/lib/smartdc/api/machine/tags.rb +31 -0
  57. data/lib/smartdc/api/machines.rb +75 -0
  58. data/lib/smartdc/api/packages.rb +21 -0
  59. data/lib/smartdc/client.rb +40 -0
  60. data/lib/smartdc/request.rb +85 -0
  61. data/smartdc.gemspec +138 -0
  62. data/spec/smartdc/api/analytics_spec.rb +32 -0
  63. data/spec/smartdc/api/datacenters_spec.rb +16 -0
  64. data/spec/smartdc/api/datasets_spec.rb +16 -0
  65. data/spec/smartdc/api/keys_spec.rb +32 -0
  66. data/spec/smartdc/api/machine/metadata_spec.rb +42 -0
  67. data/spec/smartdc/api/machine/snapshots_spec.rb +58 -0
  68. data/spec/smartdc/api/machine/tags_spec.rb +48 -0
  69. data/spec/smartdc/api/machines_spec.rb +96 -0
  70. data/spec/smartdc/api/packages_spec.rb +16 -0
  71. data/spec/smartdc/client_spec.rb +45 -0
  72. data/spec/smartdc/request_spec.rb +11 -0
  73. data/spec/smartdc_spec.rb +9 -0
  74. data/spec/spec_helper.rb +12 -0
  75. metadata +259 -0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Smartdc::Api::Machine::Tags" do
4
+ before(:all) do
5
+ @name = UUID.new.generate
6
+ machine = {
7
+ 'name' => @name,
8
+ 'dataset' => client.datasets.find[0].urn
9
+ }
10
+ @machine = client.machines.create machine
11
+ @fixture = fixture('tag')
12
+ end
13
+
14
+ describe ".create" do
15
+ it "should return a tag" do
16
+ tag = client.machines(@machine.id).tags.create @fixture
17
+ tag.name.should eq @fixture['name']
18
+ end
19
+ end
20
+
21
+ describe ".read" do
22
+ it "should return a tag" do
23
+ client.machines(@machine.id).tags('name').read.should eq @fixture['name']
24
+ end
25
+ end
26
+
27
+ describe ".find" do
28
+ it "should return some tags" do
29
+ client.machines(@machine.id).tags.find.count.should > 0
30
+ end
31
+ end
32
+
33
+ describe ".delete" do
34
+ it "should return true when success" do
35
+ client.machines(@machine.id).tags('name').delete.should be_true
36
+ end
37
+ end
38
+
39
+ after(:all) do
40
+ machine = client.machines(@machine.id)
41
+ machine.stop
42
+ 8.times do |i|
43
+ break if machine.read.state == 'stopped'
44
+ sleep i
45
+ end
46
+ client.machines(@machine.id).delete
47
+ end
48
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Smartdc::Api::Machines" do
4
+ before(:all) do
5
+ @name = UUID.new.generate
6
+ machine = {
7
+ 'name' => @name,
8
+ 'dataset' => client.datasets.find[0].urn
9
+ }
10
+ @machine = client.machines.create machine
11
+ end
12
+
13
+ describe ".create" do
14
+ it "should return a machine" do
15
+ @machine.name.should eq @name
16
+ end
17
+ end
18
+
19
+ describe ".read" do
20
+ it "should return a machine" do
21
+ client.machines(@machine.id).read.name.should eq @name
22
+ end
23
+
24
+ it "should return state at running when success" do
25
+ machine = client.machines(@machine.id)
26
+ 8.times do |i|
27
+ break if machine.read.state == 'running'
28
+ sleep i
29
+ end
30
+ machine.read.state.should eq 'running'
31
+ end
32
+ end
33
+
34
+ describe ".find" do
35
+ it "should return some machines" do
36
+ client.machines.find.count.should > 0
37
+ end
38
+ end
39
+
40
+ describe ".stop" do
41
+ it "should return true when success" do
42
+ client.machines(@machine.id).stop.should be_true
43
+ end
44
+
45
+ it "should return state at stopped when success" do
46
+ machine = client.machines(@machine.id)
47
+ 8.times do |i|
48
+ break if machine.read.state == 'stopped'
49
+ sleep i
50
+ end
51
+ machine.read.state.should eq 'stopped'
52
+ end
53
+ end
54
+
55
+ describe ".start" do
56
+ 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
73
+ end
74
+
75
+ it "should return state at running when success" do
76
+ machine = client.machines(@machine.id)
77
+ 8.times do |i|
78
+ break if machine.read.state == 'running'
79
+ sleep i
80
+ end
81
+ machine.read.state.should eq 'running'
82
+ end
83
+ end
84
+
85
+ describe ".delete" do
86
+ it "should return true when success" do
87
+ machine = client.machines(@machine.id)
88
+ machine.stop
89
+ 8.times do |i|
90
+ break if machine.read.state == 'stopped'
91
+ sleep i
92
+ end
93
+ client.machines(@machine.id).delete.should be_true
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Smartdc::Client" do
4
+ describe ".initialize" do
5
+ it "should return a Smartdc::Request" do
6
+ Smartdc::Client.new(fixture('config', 'config')).request.should be_a Smartdc::Request
7
+ end
8
+ end
9
+
10
+ describe ".keys" do
11
+ it "should return a Smartdc::Api::Keys" do
12
+ Smartdc::Client.new.keys.should be_a Smartdc::Api::Keys
13
+ end
14
+ end
15
+
16
+ describe ".datacenters" do
17
+ it "should return a Smartdc::Api::Datacenters" do
18
+ Smartdc::Client.new.datacenters.should be_a Smartdc::Api::Datacenters
19
+ end
20
+ end
21
+
22
+ describe ".datasets" do
23
+ it "should return a Smartdc::Api::Datasets" do
24
+ Smartdc::Client.new.datasets.should be_a Smartdc::Api::Datasets
25
+ end
26
+ end
27
+
28
+ describe ".packages" do
29
+ it "should return a Smartdc::Api::Packages" do
30
+ Smartdc::Client.new.packages.should be_a Smartdc::Api::Packages
31
+ end
32
+ end
33
+
34
+ describe ".machines" do
35
+ it "should return a Smartdc::Api::Machines" do
36
+ Smartdc::Client.new.machines.should be_a Smartdc::Api::Machines
37
+ end
38
+ end
39
+
40
+ describe ".analytics" do
41
+ it "should return a Smartdc::Api::Analytics" do
42
+ Smartdc::Client.new.analytics.should be_a Smartdc::Api::Analytics
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,11 @@
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
+ request.get('/')
8
+ request.response.status.should be(200)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Smartdc" do
4
+ describe ".new" do
5
+ it "should return a Smartdc::Client" do
6
+ Smartdc.new.should be_a Smartdc::Client
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'uuid'
5
+ require 'cli_helper'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ end
metadata ADDED
@@ -0,0 +1,259 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smartdc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ogom
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: &70200344696400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.7.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70200344696400
25
+ - !ruby/object:Gem::Dependency
26
+ name: hashie
27
+ requirement: &70200344695920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.2.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70200344695920
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &70200344695440 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.3
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70200344695440
47
+ - !ruby/object:Gem::Dependency
48
+ name: multipart-post
49
+ requirement: &70200344694960 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.3
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70200344694960
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70200344694480 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 2.7.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70200344694480
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: &70200344694000 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70200344694000
80
+ - !ruby/object:Gem::Dependency
81
+ name: jeweler
82
+ requirement: &70200344693520 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 1.6.4
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70200344693520
91
+ - !ruby/object:Gem::Dependency
92
+ name: rcov
93
+ requirement: &70200344725520 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70200344725520
102
+ - !ruby/object:Gem::Dependency
103
+ name: uuid
104
+ requirement: &70200344725040 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.3.4
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70200344725040
113
+ description: smartdc is SmartDataCenter Public API.
114
+ email: ogom@hotmail.co.jp
115
+ executables:
116
+ - sdc-addmachinemetadata
117
+ - sdc-addmachinetag
118
+ - sdc-createinstrumentation
119
+ - sdc-createkey
120
+ - sdc-createmachine
121
+ - sdc-createmachinesnapshot
122
+ - sdc-deleteinstrumentation
123
+ - sdc-deletekey
124
+ - sdc-deletemachine
125
+ - sdc-deletemachinemetadata
126
+ - sdc-deletemachinesnapshot
127
+ - sdc-deletemachinetag
128
+ - sdc-describeanalytics
129
+ - sdc-getdatacenter
130
+ - sdc-getdataset
131
+ - sdc-getinstrumentation
132
+ - sdc-getkey
133
+ - sdc-getmachine
134
+ - sdc-getmachinemetadata
135
+ - sdc-getmachinesnapshot
136
+ - sdc-getmachinetag
137
+ - sdc-getpackage
138
+ - sdc-listdatacenters
139
+ - sdc-listdatasets
140
+ - sdc-listinstrumentations
141
+ - sdc-listkeys
142
+ - sdc-listmachines
143
+ - sdc-listmachinesnapshots
144
+ - sdc-listmachinetags
145
+ - sdc-listpackages
146
+ - sdc-rebootmachine
147
+ - sdc-resizemachine
148
+ - sdc-setup
149
+ - sdc-startmachine
150
+ - sdc-startmachinefromsnapshot
151
+ - sdc-stopmachine
152
+ extensions: []
153
+ extra_rdoc_files:
154
+ - LICENSE.md
155
+ - README.md
156
+ files:
157
+ - .document
158
+ - Gemfile
159
+ - LICENSE.md
160
+ - README.md
161
+ - VERSION
162
+ - bin/sdc-addmachinemetadata
163
+ - bin/sdc-addmachinetag
164
+ - bin/sdc-createinstrumentation
165
+ - bin/sdc-createkey
166
+ - bin/sdc-createmachine
167
+ - bin/sdc-createmachinesnapshot
168
+ - bin/sdc-deleteinstrumentation
169
+ - bin/sdc-deletekey
170
+ - bin/sdc-deletemachine
171
+ - bin/sdc-deletemachinemetadata
172
+ - bin/sdc-deletemachinesnapshot
173
+ - bin/sdc-deletemachinetag
174
+ - bin/sdc-describeanalytics
175
+ - bin/sdc-getdatacenter
176
+ - bin/sdc-getdataset
177
+ - bin/sdc-getinstrumentation
178
+ - bin/sdc-getkey
179
+ - bin/sdc-getmachine
180
+ - bin/sdc-getmachinemetadata
181
+ - bin/sdc-getmachinesnapshot
182
+ - bin/sdc-getmachinetag
183
+ - bin/sdc-getpackage
184
+ - bin/sdc-listdatacenters
185
+ - bin/sdc-listdatasets
186
+ - bin/sdc-listinstrumentations
187
+ - bin/sdc-listkeys
188
+ - bin/sdc-listmachines
189
+ - bin/sdc-listmachinesnapshots
190
+ - bin/sdc-listmachinetags
191
+ - bin/sdc-listpackages
192
+ - bin/sdc-rebootmachine
193
+ - bin/sdc-resizemachine
194
+ - bin/sdc-setup
195
+ - bin/sdc-startmachine
196
+ - bin/sdc-startmachinefromsnapshot
197
+ - bin/sdc-stopmachine
198
+ - config/fixtures/instrumentation.json
199
+ - config/fixtures/key.json
200
+ - config/fixtures/tag.json
201
+ - lib/cli_helper.rb
202
+ - lib/faraday/response/mashify.rb
203
+ - lib/faraday/response/parse_json.rb
204
+ - lib/smartdc.rb
205
+ - lib/smartdc/api/analytics.rb
206
+ - lib/smartdc/api/analytics/instrumentations.rb
207
+ - lib/smartdc/api/datacenters.rb
208
+ - lib/smartdc/api/datasets.rb
209
+ - lib/smartdc/api/keys.rb
210
+ - lib/smartdc/api/machine/metadata.rb
211
+ - lib/smartdc/api/machine/snapshots.rb
212
+ - lib/smartdc/api/machine/tags.rb
213
+ - lib/smartdc/api/machines.rb
214
+ - lib/smartdc/api/packages.rb
215
+ - lib/smartdc/client.rb
216
+ - lib/smartdc/request.rb
217
+ - smartdc.gemspec
218
+ - spec/smartdc/api/analytics_spec.rb
219
+ - spec/smartdc/api/datacenters_spec.rb
220
+ - spec/smartdc/api/datasets_spec.rb
221
+ - spec/smartdc/api/keys_spec.rb
222
+ - spec/smartdc/api/machine/metadata_spec.rb
223
+ - spec/smartdc/api/machine/snapshots_spec.rb
224
+ - spec/smartdc/api/machine/tags_spec.rb
225
+ - spec/smartdc/api/machines_spec.rb
226
+ - spec/smartdc/api/packages_spec.rb
227
+ - spec/smartdc/client_spec.rb
228
+ - spec/smartdc/request_spec.rb
229
+ - spec/smartdc_spec.rb
230
+ - spec/spec_helper.rb
231
+ homepage: http://github.com/ogom/ruby-smartdc
232
+ licenses:
233
+ - MIT
234
+ post_install_message:
235
+ rdoc_options: []
236
+ require_paths:
237
+ - lib
238
+ required_ruby_version: !ruby/object:Gem::Requirement
239
+ none: false
240
+ requirements:
241
+ - - ! '>='
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ segments:
245
+ - 0
246
+ hash: 4559567800633525012
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ none: false
249
+ requirements:
250
+ - - ! '>='
251
+ - !ruby/object:Gem::Version
252
+ version: '0'
253
+ requirements: []
254
+ rubyforge_project:
255
+ rubygems_version: 1.8.10
256
+ signing_key:
257
+ specification_version: 3
258
+ summary: SmartDataCenter CloudApi client by ruby.
259
+ test_files: []