profitbricks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/.autotest +23 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +3 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +53 -0
  7. data/Manifest.txt +106 -0
  8. data/README.md +70 -0
  9. data/Rakefile +31 -0
  10. data/bin/profitbricks +3 -0
  11. data/examples/create_datacenter.rb +57 -0
  12. data/lib/profitbricks/config.rb +16 -0
  13. data/lib/profitbricks/data_center.rb +100 -0
  14. data/lib/profitbricks/extensions.rb +9 -0
  15. data/lib/profitbricks/image.rb +47 -0
  16. data/lib/profitbricks/ip_block.rb +49 -0
  17. data/lib/profitbricks/model.rb +102 -0
  18. data/lib/profitbricks/nic.rb +103 -0
  19. data/lib/profitbricks/profitbricks.rb +86 -0
  20. data/lib/profitbricks/server.rb +83 -0
  21. data/lib/profitbricks/storage.rb +84 -0
  22. data/lib/profitbricks.rb +15 -0
  23. data/profitbricks.gemspec +34 -0
  24. data/spec/fixtures/add_public_ip_to_nic/success.json +10 -0
  25. data/spec/fixtures/add_public_ip_to_nic/success.xml +1 -0
  26. data/spec/fixtures/clear_data_center/success.json +10 -0
  27. data/spec/fixtures/clear_data_center/success.xml +1 -0
  28. data/spec/fixtures/connect_storage_to_server/success.json +10 -0
  29. data/spec/fixtures/connect_storage_to_server/success.xml +1 -0
  30. data/spec/fixtures/create_data_center/success.json +10 -0
  31. data/spec/fixtures/create_data_center/success.xml +1 -0
  32. data/spec/fixtures/create_nic/success.json +11 -0
  33. data/spec/fixtures/create_nic/success.xml +1 -0
  34. data/spec/fixtures/create_server/minimal.json +11 -0
  35. data/spec/fixtures/create_server/minimal.xml +1 -0
  36. data/spec/fixtures/create_storage/success.json +11 -0
  37. data/spec/fixtures/create_storage/success.xml +1 -0
  38. data/spec/fixtures/delete_data_center/success.json +8 -0
  39. data/spec/fixtures/delete_data_center/success.xml +1 -0
  40. data/spec/fixtures/delete_nic/success.json +10 -0
  41. data/spec/fixtures/delete_nic/success.xml +1 -0
  42. data/spec/fixtures/delete_server/success.json +10 -0
  43. data/spec/fixtures/delete_server/success.xml +1 -0
  44. data/spec/fixtures/delete_storage/failture.json +16 -0
  45. data/spec/fixtures/delete_storage/failture.xml +1 -0
  46. data/spec/fixtures/delete_storage/success.json +10 -0
  47. data/spec/fixtures/delete_storage/success.xml +1 -0
  48. data/spec/fixtures/disconnect_storage_from_server/failture.json +16 -0
  49. data/spec/fixtures/disconnect_storage_from_server/failture.xml +1 -0
  50. data/spec/fixtures/disconnect_storage_from_server/success.json +10 -0
  51. data/spec/fixtures/disconnect_storage_from_server/success.xml +1 -0
  52. data/spec/fixtures/get_all_data_centers/empty.json +1 -0
  53. data/spec/fixtures/get_all_data_centers/empty.xml +1 -0
  54. data/spec/fixtures/get_all_data_centers/test_datacenter.json +10 -0
  55. data/spec/fixtures/get_all_data_centers/test_datacenter.xml +1 -0
  56. data/spec/fixtures/get_all_images/success.json +100 -0
  57. data/spec/fixtures/get_all_images/success.xml +1 -0
  58. data/spec/fixtures/get_all_public_ip_blocks/success.json +16 -0
  59. data/spec/fixtures/get_all_public_ip_blocks/success.xml +1 -0
  60. data/spec/fixtures/get_data_center/create.json +147 -0
  61. data/spec/fixtures/get_data_center/create.xml +1 -0
  62. data/spec/fixtures/get_data_center/two_servers_with_storage.json +147 -0
  63. data/spec/fixtures/get_data_center/two_servers_with_storage.xml +1 -0
  64. data/spec/fixtures/get_data_center_state/in_process.json +1 -0
  65. data/spec/fixtures/get_data_center_state/in_process.xml +1 -0
  66. data/spec/fixtures/get_data_center_state/success.json +1 -0
  67. data/spec/fixtures/get_data_center_state/success.xml +1 -0
  68. data/spec/fixtures/get_image/success.json +15 -0
  69. data/spec/fixtures/get_image/success.xml +1 -0
  70. data/spec/fixtures/get_nic/success.json +16 -0
  71. data/spec/fixtures/get_nic/success.xml +1 -0
  72. data/spec/fixtures/get_nic/two_ips.json +19 -0
  73. data/spec/fixtures/get_nic/two_ips.xml +1 -0
  74. data/spec/fixtures/get_server/after_create.json +17 -0
  75. data/spec/fixtures/get_server/after_create.xml +1 -0
  76. data/spec/fixtures/get_server/connected_storage.json +26 -0
  77. data/spec/fixtures/get_server/connected_storage.xml +1 -0
  78. data/spec/fixtures/get_storage/success.json +14 -0
  79. data/spec/fixtures/get_storage/success.xml +1 -0
  80. data/spec/fixtures/reboot_server/success.json +1 -0
  81. data/spec/fixtures/reboot_server/success.xml +1 -0
  82. data/spec/fixtures/release_public_ip_block/success.json +1 -0
  83. data/spec/fixtures/release_public_ip_block/success.xml +1 -0
  84. data/spec/fixtures/remove_public_ip_from_nic/success.json +10 -0
  85. data/spec/fixtures/remove_public_ip_from_nic/success.xml +1 -0
  86. data/spec/fixtures/reserve_public_ip_block/success.json +13 -0
  87. data/spec/fixtures/reserve_public_ip_block/success.xml +1 -0
  88. data/spec/fixtures/set_image_os_type/success.json +1 -0
  89. data/spec/fixtures/set_image_os_type/success.xml +1 -0
  90. data/spec/fixtures/set_internet_access/success.json +10 -0
  91. data/spec/fixtures/set_internet_access/success.xml +1 -0
  92. data/spec/fixtures/update_data_center/success.json +10 -0
  93. data/spec/fixtures/update_data_center/success.xml +1 -0
  94. data/spec/fixtures/update_nic/success.json +10 -0
  95. data/spec/fixtures/update_nic/success.xml +1 -0
  96. data/spec/fixtures/update_server/basic.json +10 -0
  97. data/spec/fixtures/update_server/basic.xml +1 -0
  98. data/spec/fixtures/update_storage/success.json +10 -0
  99. data/spec/fixtures/update_storage/success.xml +1 -0
  100. data/spec/profitbricks/data_center_spec.rb +95 -0
  101. data/spec/profitbricks/image_spec.rb +23 -0
  102. data/spec/profitbricks/ip_block_spec.rb +26 -0
  103. data/spec/profitbricks/model_spec.rb +68 -0
  104. data/spec/profitbricks/nic_spec.rb +55 -0
  105. data/spec/profitbricks/server_spec.rb +41 -0
  106. data/spec/profitbricks/storage_spec.rb +47 -0
  107. data/spec/spec_helper.rb +45 -0
  108. metadata +193 -0
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Profitbricks::Storage do
4
+ include Savon::Spec::Macros
5
+
6
+ it "should create a new server with minimal arguments" do
7
+ savon.expects(:create_storage).with("<arg0><dataCenterId>b3eebede-5c78-417c-b1bc-ff5de01a0602</dataCenterId><size>5</size><storageName>Test Storage</storageName></arg0>").returns(:success)
8
+ savon.expects(:get_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
9
+ storage = Storage.create(:size => 5, :name => "Test Storage", :data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
10
+ storage.name.should == "Test Storage"
11
+ storage.size.should == 5
12
+ end
13
+
14
+ it "should be connectable to a server" do
15
+ savon.expects(:get_storage).returns(:success)
16
+ savon.expects(:connect_storage_to_server).returns(:success)
17
+ savon.expects(:get_server).returns(:connected_storage)
18
+ storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
19
+ storage.connect(:server_id => "4cb6550f-3777-4818-8f4c-51233162a980", :bus_type => "VIRTIO").should == true
20
+ s = Server.find(:id => "4cb6550f-3777-4818-8f4c-51233162a980")
21
+ # FIXME
22
+ s.connected_storages[:storage_name].should == "Test Storage"
23
+ end
24
+
25
+ it "should be disconnectable from a server" do
26
+ savon.expects(:get_storage).returns(:success)
27
+ savon.expects(:disconnect_storage_from_server).returns(:success)
28
+ storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
29
+ storage.disconnect(:server_id => "4cb6550f-3777-4818-8f4c-51233162a980").should == true
30
+ end
31
+
32
+ it "should be updated" do
33
+ savon.expects(:get_storage).returns(:success)
34
+ savon.expects(:update_storage).returns(:success)
35
+ storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
36
+ storage.update(:name => "Updated", :size => 10).should == true
37
+ storage.name.should == "Updated"
38
+ storage.size.should == 10
39
+ end
40
+
41
+ it "should be deleted" do
42
+ savon.expects(:get_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
43
+ savon.expects(:delete_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
44
+ storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
45
+ storage.delete.should == true
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require "bundler"
8
+ Bundler.require(:default, :development)
9
+
10
+ if ENV['COVERAGE']
11
+ require 'simplecov'
12
+ SimpleCov.start
13
+ end
14
+
15
+ Savon.configure do |config|
16
+ config.log = false
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.treat_symbols_as_metadata_keys_with_true_values = true
21
+ config.run_all_when_everything_filtered = true
22
+ config.filter_run :focus
23
+ config.include Savon::Spec::Macros
24
+ end
25
+
26
+
27
+ Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
28
+
29
+ require 'profitbricks'
30
+
31
+ Savon.configure do |config|
32
+ config.log = false
33
+ config.log_level = :error
34
+ end
35
+ HTTPI.log = false
36
+ client = Savon::Client.new do
37
+ wsdl.endpoint = "https://api.profitbricks.com/1.1"
38
+ wsdl.document = "https://api.profitbricks.com/1.1/wsdl"
39
+ end
40
+
41
+ Profitbricks.configure do |config|
42
+ config.username = "none"
43
+ config.password = "none"
44
+ end
45
+ Profitbricks.client = client
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: profitbricks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dominik Sander
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: &14979800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *14979800
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &14979200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.10'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *14979200
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ requirement: &14978640 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.14'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *14978640
47
+ description: ! 'A Ruby client for the ProfitBricks API.
48
+
49
+
50
+ BE AWARE: This software is in a very early state of development, the methods and
51
+ responses will very likely change over time.'
52
+ email:
53
+ - git@dsander.de
54
+ executables:
55
+ - profitbricks
56
+ extensions: []
57
+ extra_rdoc_files:
58
+ - Manifest.txt
59
+ files:
60
+ - .autotest
61
+ - .rspec
62
+ - CHANGELOG.md
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - Manifest.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/profitbricks
69
+ - examples/create_datacenter.rb
70
+ - lib/profitbricks.rb
71
+ - lib/profitbricks/config.rb
72
+ - lib/profitbricks/data_center.rb
73
+ - lib/profitbricks/extensions.rb
74
+ - lib/profitbricks/image.rb
75
+ - lib/profitbricks/ip_block.rb
76
+ - lib/profitbricks/model.rb
77
+ - lib/profitbricks/nic.rb
78
+ - lib/profitbricks/profitbricks.rb
79
+ - lib/profitbricks/server.rb
80
+ - lib/profitbricks/storage.rb
81
+ - profitbricks.gemspec
82
+ - spec/fixtures/add_public_ip_to_nic/success.json
83
+ - spec/fixtures/add_public_ip_to_nic/success.xml
84
+ - spec/fixtures/clear_data_center/success.json
85
+ - spec/fixtures/clear_data_center/success.xml
86
+ - spec/fixtures/connect_storage_to_server/success.json
87
+ - spec/fixtures/connect_storage_to_server/success.xml
88
+ - spec/fixtures/create_data_center/success.json
89
+ - spec/fixtures/create_data_center/success.xml
90
+ - spec/fixtures/create_nic/success.json
91
+ - spec/fixtures/create_nic/success.xml
92
+ - spec/fixtures/create_server/minimal.json
93
+ - spec/fixtures/create_server/minimal.xml
94
+ - spec/fixtures/create_storage/success.json
95
+ - spec/fixtures/create_storage/success.xml
96
+ - spec/fixtures/delete_data_center/success.json
97
+ - spec/fixtures/delete_data_center/success.xml
98
+ - spec/fixtures/delete_nic/success.json
99
+ - spec/fixtures/delete_nic/success.xml
100
+ - spec/fixtures/delete_server/success.json
101
+ - spec/fixtures/delete_server/success.xml
102
+ - spec/fixtures/delete_storage/failture.json
103
+ - spec/fixtures/delete_storage/failture.xml
104
+ - spec/fixtures/delete_storage/success.json
105
+ - spec/fixtures/delete_storage/success.xml
106
+ - spec/fixtures/disconnect_storage_from_server/failture.json
107
+ - spec/fixtures/disconnect_storage_from_server/failture.xml
108
+ - spec/fixtures/disconnect_storage_from_server/success.json
109
+ - spec/fixtures/disconnect_storage_from_server/success.xml
110
+ - spec/fixtures/get_all_data_centers/empty.json
111
+ - spec/fixtures/get_all_data_centers/empty.xml
112
+ - spec/fixtures/get_all_data_centers/test_datacenter.json
113
+ - spec/fixtures/get_all_data_centers/test_datacenter.xml
114
+ - spec/fixtures/get_all_images/success.json
115
+ - spec/fixtures/get_all_images/success.xml
116
+ - spec/fixtures/get_all_public_ip_blocks/success.json
117
+ - spec/fixtures/get_all_public_ip_blocks/success.xml
118
+ - spec/fixtures/get_data_center/create.json
119
+ - spec/fixtures/get_data_center/create.xml
120
+ - spec/fixtures/get_data_center/two_servers_with_storage.json
121
+ - spec/fixtures/get_data_center/two_servers_with_storage.xml
122
+ - spec/fixtures/get_data_center_state/in_process.json
123
+ - spec/fixtures/get_data_center_state/in_process.xml
124
+ - spec/fixtures/get_data_center_state/success.json
125
+ - spec/fixtures/get_data_center_state/success.xml
126
+ - spec/fixtures/get_image/success.json
127
+ - spec/fixtures/get_image/success.xml
128
+ - spec/fixtures/get_nic/success.json
129
+ - spec/fixtures/get_nic/success.xml
130
+ - spec/fixtures/get_nic/two_ips.json
131
+ - spec/fixtures/get_nic/two_ips.xml
132
+ - spec/fixtures/get_server/after_create.json
133
+ - spec/fixtures/get_server/after_create.xml
134
+ - spec/fixtures/get_server/connected_storage.json
135
+ - spec/fixtures/get_server/connected_storage.xml
136
+ - spec/fixtures/get_storage/success.json
137
+ - spec/fixtures/get_storage/success.xml
138
+ - spec/fixtures/reboot_server/success.json
139
+ - spec/fixtures/reboot_server/success.xml
140
+ - spec/fixtures/release_public_ip_block/success.json
141
+ - spec/fixtures/release_public_ip_block/success.xml
142
+ - spec/fixtures/remove_public_ip_from_nic/success.json
143
+ - spec/fixtures/remove_public_ip_from_nic/success.xml
144
+ - spec/fixtures/reserve_public_ip_block/success.json
145
+ - spec/fixtures/reserve_public_ip_block/success.xml
146
+ - spec/fixtures/set_image_os_type/success.json
147
+ - spec/fixtures/set_image_os_type/success.xml
148
+ - spec/fixtures/set_internet_access/success.json
149
+ - spec/fixtures/set_internet_access/success.xml
150
+ - spec/fixtures/update_data_center/success.json
151
+ - spec/fixtures/update_data_center/success.xml
152
+ - spec/fixtures/update_nic/success.json
153
+ - spec/fixtures/update_nic/success.xml
154
+ - spec/fixtures/update_server/basic.json
155
+ - spec/fixtures/update_server/basic.xml
156
+ - spec/fixtures/update_storage/success.json
157
+ - spec/fixtures/update_storage/success.xml
158
+ - spec/profitbricks/data_center_spec.rb
159
+ - spec/profitbricks/image_spec.rb
160
+ - spec/profitbricks/ip_block_spec.rb
161
+ - spec/profitbricks/model_spec.rb
162
+ - spec/profitbricks/nic_spec.rb
163
+ - spec/profitbricks/server_spec.rb
164
+ - spec/profitbricks/storage_spec.rb
165
+ - spec/spec_helper.rb
166
+ - .gemtest
167
+ homepage:
168
+ licenses: []
169
+ post_install_message:
170
+ rdoc_options:
171
+ - --main
172
+ - README.md
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project: profitbricks
189
+ rubygems_version: 1.8.11
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: A Ruby client for the ProfitBricks API
193
+ test_files: []