deltacloud-client-vm 1.1.4.2 → 1.1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +176 -0
  3. data/NOTICE +8 -0
  4. data/README.md +73 -0
  5. data/Rakefile +122 -0
  6. data/deltacloud-client-vm.gemspec +24 -0
  7. data/lib/deltacloud_vm/client.rb +79 -0
  8. data/lib/deltacloud_vm/client/base_error.rb +80 -0
  9. data/lib/deltacloud_vm/client/connection.rb +139 -0
  10. data/lib/deltacloud_vm/client/helpers/model_helper.rb +69 -0
  11. data/lib/deltacloud_vm/client/helpers/property_helper.rb +103 -0
  12. data/lib/deltacloud_vm/client/helpers/xml_helper.rb +33 -0
  13. data/lib/deltacloud_vm/client/methods.rb +33 -0
  14. data/lib/deltacloud_vm/client/methods/address.rb +67 -0
  15. data/lib/deltacloud_vm/client/methods/api.rb +96 -0
  16. data/lib/deltacloud_vm/client/methods/backward_compatiblity.rb +72 -0
  17. data/lib/deltacloud_vm/client/methods/blob.rb +91 -0
  18. data/lib/deltacloud_vm/client/methods/bucket.rb +55 -0
  19. data/lib/deltacloud_vm/client/methods/common.rb +46 -0
  20. data/lib/deltacloud_vm/client/methods/driver.rb +53 -0
  21. data/lib/deltacloud_vm/client/methods/firewall.rb +67 -0
  22. data/lib/deltacloud_vm/client/methods/hardware_profile.rb +41 -0
  23. data/lib/deltacloud_vm/client/methods/image.rb +61 -0
  24. data/lib/deltacloud_vm/client/methods/instance.rb +141 -0
  25. data/lib/deltacloud_vm/client/methods/instance_state.rb +41 -0
  26. data/lib/deltacloud_vm/client/methods/key.rb +58 -0
  27. data/lib/deltacloud_vm/client/methods/load_balancer.rb +96 -0
  28. data/lib/deltacloud_vm/client/methods/metric.rb +54 -0
  29. data/lib/deltacloud_vm/client/methods/realm.rb +42 -0
  30. data/lib/deltacloud_vm/client/methods/storage_snapshot.rb +61 -0
  31. data/lib/deltacloud_vm/client/methods/storage_volume.rb +94 -0
  32. data/lib/deltacloud_vm/client/models.rb +32 -0
  33. data/lib/deltacloud_vm/client/models/address.rb +57 -0
  34. data/lib/deltacloud_vm/client/models/base.rb +153 -0
  35. data/lib/deltacloud_vm/client/models/blob.rb +56 -0
  36. data/lib/deltacloud_vm/client/models/bucket.rb +65 -0
  37. data/lib/deltacloud_vm/client/models/driver.rb +87 -0
  38. data/lib/deltacloud_vm/client/models/firewall.rb +64 -0
  39. data/lib/deltacloud_vm/client/models/hardware_profile.rb +68 -0
  40. data/lib/deltacloud_vm/client/models/image.rb +60 -0
  41. data/lib/deltacloud_vm/client/models/instance.rb +142 -0
  42. data/lib/deltacloud_vm/client/models/instance_address.rb +40 -0
  43. data/lib/deltacloud_vm/client/models/instance_state.rb +52 -0
  44. data/lib/deltacloud_vm/client/models/key.rb +52 -0
  45. data/lib/deltacloud_vm/client/models/load_balancer.rb +55 -0
  46. data/lib/deltacloud_vm/client/models/metric.rb +72 -0
  47. data/lib/deltacloud_vm/client/models/realm.rb +29 -0
  48. data/lib/deltacloud_vm/client/models/storage_snapshot.rb +54 -0
  49. data/lib/deltacloud_vm/client/models/storage_volume.rb +96 -0
  50. data/lib/deltacloud_vm/core_ext.rb +19 -0
  51. data/lib/deltacloud_vm/core_ext/element.rb +32 -0
  52. data/lib/deltacloud_vm/core_ext/fixnum.rb +30 -0
  53. data/lib/deltacloud_vm/core_ext/nil.rb +22 -0
  54. data/lib/deltacloud_vm/core_ext/string.rb +49 -0
  55. data/lib/deltacloud_vm/error_response.rb +93 -0
  56. data/tests/client/client_test.rb +51 -0
  57. data/tests/client/connection_test.rb +77 -0
  58. data/tests/core_ext/element_test.rb +40 -0
  59. data/tests/core_ext/fixnum_test.rb +35 -0
  60. data/tests/core_ext/nil.rb +27 -0
  61. data/tests/core_ext/string_test.rb +47 -0
  62. data/tests/fixtures/instances_cleanup.yml +681 -0
  63. data/tests/fixtures/test_0001_connects_to_Deltacloud_API.yml +60 -0
  64. data/tests/fixtures/test_0001_support_cpu.yml +444 -0
  65. data/tests/fixtures/test_0001_support_original_body.yml +116 -0
  66. data/tests/fixtures/test_0001_supports_addresses.yml +178 -0
  67. data/tests/fixtures/test_0001_supports_api_host.yml +60 -0
  68. data/tests/fixtures/test_0001_supports_attached_.yml +282 -0
  69. data/tests/fixtures/test_0001_supports_blobs.yml +475 -0
  70. data/tests/fixtures/test_0001_supports_bucket.yml +200 -0
  71. data/tests/fixtures/test_0001_supports_buckets.yml +160 -0
  72. data/tests/fixtures/test_0001_supports_drivers.yml +202 -0
  73. data/tests/fixtures/test_0001_supports_firewalls.yml +399 -0
  74. data/tests/fixtures/test_0001_supports_hardware_profiles.yml +262 -0
  75. data/tests/fixtures/test_0001_supports_images.yml +224 -0
  76. data/tests/fixtures/test_0001_supports_instance_states.yml +156 -0
  77. data/tests/fixtures/test_0001_supports_instances.yml +486 -0
  78. data/tests/fixtures/test_0001_supports_keys.yml +198 -0
  79. data/tests/fixtures/test_0001_supports_path.yml +60 -0
  80. data/tests/fixtures/test_0001_supports_realms.yml +152 -0
  81. data/tests/fixtures/test_0001_supports_storage_snapshots.yml +164 -0
  82. data/tests/fixtures/test_0001_supports_storage_volumes.yml +176 -0
  83. data/tests/fixtures/test_0001_supports_to_get_providers.yml +410 -0
  84. data/tests/fixtures/test_0002_support_blob.yml +148 -0
  85. data/tests/fixtures/test_0002_support_instance_state.yml +204 -0
  86. data/tests/fixtures/test_0002_support_memory.yml +444 -0
  87. data/tests/fixtures/test_0002_support_on_Provider.yml +130 -0
  88. data/tests/fixtures/test_0002_supports_api_port.yml +60 -0
  89. data/tests/fixtures/test_0002_supports_api_uri.yml +60 -0
  90. data/tests/fixtures/test_0002_supports_driver.yml +219 -0
  91. data/tests/fixtures/test_0002_supports_extract_xml_body_using_faraday_connection.yml +117 -0
  92. data/tests/fixtures/test_0002_supports_filtering_addresses_by_id_param.yml +156 -0
  93. data/tests/fixtures/test_0002_supports_filtering_buckets_by_id_param.yml +156 -0
  94. data/tests/fixtures/test_0002_supports_filtering_firewalls_by_id_param.yml +207 -0
  95. data/tests/fixtures/test_0002_supports_filtering_hardware_profiles_by_id_param.yml +158 -0
  96. data/tests/fixtures/test_0002_supports_filtering_images_by_id_param.yml +165 -0
  97. data/tests/fixtures/test_0002_supports_filtering_instances_by_id_param.yml +164 -0
  98. data/tests/fixtures/test_0002_supports_filtering_keys_by_id_param.yml +178 -0
  99. data/tests/fixtures/test_0002_supports_filtering_realms_by_id.yml +104 -0
  100. data/tests/fixtures/test_0002_supports_filtering_storage_snapshots_by_id_param.yml +155 -0
  101. data/tests/fixtures/test_0002_supports_filtering_storage_volumes_by_id_param.yml +157 -0
  102. data/tests/fixtures/test_0002_supports_hardware_profiles.yml +262 -0
  103. data/tests/fixtures/test_0002_supports_is_compatible_.yml +116 -0
  104. data/tests/fixtures/test_0002_supports_snapshot_.yml +202 -0
  105. data/tests/fixtures/test_0002_supports_version.yml +60 -0
  106. data/tests/fixtures/test_0003_caches_the_API_entrypoint.yml +60 -0
  107. data/tests/fixtures/test_0003_support_address.yml +197 -0
  108. data/tests/fixtures/test_0003_support_bucket.yml +198 -0
  109. data/tests/fixtures/test_0003_support_create_blob.yml +105 -0
  110. data/tests/fixtures/test_0003_support_create_blob_and_destroy_blob.yml +138 -0
  111. data/tests/fixtures/test_0003_support_firewall.yml +768 -0
  112. data/tests/fixtures/test_0003_support_hardware_profile.yml +199 -0
  113. data/tests/fixtures/test_0003_support_image.yml +207 -0
  114. data/tests/fixtures/test_0003_support_instance.yml +206 -0
  115. data/tests/fixtures/test_0003_support_key.yml +220 -0
  116. data/tests/fixtures/test_0003_support_realm.yml +195 -0
  117. data/tests/fixtures/test_0003_support_storage.yml +444 -0
  118. data/tests/fixtures/test_0003_support_storage_snapshot.yml +196 -0
  119. data/tests/fixtures/test_0003_support_storage_volume.yml +197 -0
  120. data/tests/fixtures/test_0003_support_to_change_driver_with_Client.yml +72 -0
  121. data/tests/fixtures/test_0003_supports_connect.yml +60 -0
  122. data/tests/fixtures/test_0003_supports_extract_xml_body_using_nokogiri_document.yml +117 -0
  123. data/tests/fixtures/test_0003_supports_instance.yml +396 -0
  124. data/tests/fixtures/test_0003_supports_is_compatible_.yml +116 -0
  125. data/tests/fixtures/test_0003_supports_lunch_image.yml +367 -0
  126. data/tests/fixtures/test_0003_supports_providers.yml +102 -0
  127. data/tests/fixtures/test_0003_supports_version.yml +60 -0
  128. data/tests/fixtures/test_0004_support_architecture.yml +444 -0
  129. data/tests/fixtures/test_0004_support_create_address.yml +197 -0
  130. data/tests/fixtures/test_0004_support_create_blob_and_destroy_blob_with_meta_params.yml +139 -0
  131. data/tests/fixtures/test_0004_support_create_bucket.yml +180 -0
  132. data/tests/fixtures/test_0004_support_create_bucket_and_destroy_bucket.yml +180 -0
  133. data/tests/fixtures/test_0004_support_create_firewall_and_destroy_firewall.yml +496 -0
  134. data/tests/fixtures/test_0004_support_create_image_and_destroy_image.yml +1527 -0
  135. data/tests/fixtures/test_0004_support_create_instance.yml +115 -0
  136. data/tests/fixtures/test_0004_support_create_key_and_destroy_key.yml +206 -0
  137. data/tests/fixtures/test_0004_support_create_volume.yml +105 -0
  138. data/tests/fixtures/test_0004_support_create_volume_and_destroy_volume.yml +181 -0
  139. data/tests/fixtures/test_0004_support_to_test_of_valid_DC_connection.yml +60 -0
  140. data/tests/fixtures/test_0004_supports_current_driver.yml +60 -0
  141. data/tests/fixtures/test_0004_supports_extract_xml_body_using_nokogiri_element.yml +117 -0
  142. data/tests/fixtures/test_0004_supports_lunch_image.yml +312 -0
  143. data/tests/fixtures/test_0004_supports_valid_credentials_.yml +215 -0
  144. data/tests/fixtures/test_0004_supports_with_config.yml +129 -0
  145. data/tests/fixtures/test_0005_support_attach_storage_volume.yml +102 -0
  146. data/tests/fixtures/test_0005_support_attach_storage_volume_and_detach_storage_volume.yml +142 -0
  147. data/tests/fixtures/test_0005_support_create_instance_with_hwp_id.yml +115 -0
  148. data/tests/fixtures/test_0005_support_opaque_.yml +152 -0
  149. data/tests/fixtures/test_0005_supports_current_provider.yml +134 -0
  150. data/tests/fixtures/test_0005_supports_id.yml +116 -0
  151. data/tests/fixtures/test_0005_supports_switching_drivers_per_instance.yml +129 -0
  152. data/tests/fixtures/test_0005_supports_use_driver.yml +60 -0
  153. data/tests/fixtures/test_0006_support_create_instance_with_realm_id.yml +115 -0
  154. data/tests/fixtures/test_0006_supports_discovered_.yml +60 -0
  155. data/tests/fixtures/test_0006_supports_supported_collections.yml +60 -0
  156. data/tests/fixtures/test_0006_supports_switching_providers_per_instance.yml +208 -0
  157. data/tests/fixtures/test_0007_support_create_instance_with_name.yml +115 -0
  158. data/tests/fixtures/test_0007_support_switching_provider_without_credentials.yml +208 -0
  159. data/tests/fixtures/test_0007_supports_support_.yml +60 -0
  160. data/tests/fixtures/test_0007_supports_valid_credentials_on_class.yml +370 -0
  161. data/tests/fixtures/test_0008_support_stop_instance.yml +166 -0
  162. data/tests/fixtures/test_0008_supports_must_support_.yml +60 -0
  163. data/tests/fixtures/test_0009_support_start_instance.yml +217 -0
  164. data/tests/fixtures/test_0009_supports_features.yml +60 -0
  165. data/tests/fixtures/test_0010_support_reboot_instance.yml +166 -0
  166. data/tests/fixtures/test_0010_supports_feature_.yml +60 -0
  167. data/tests/helpers/model_test.rb +33 -0
  168. data/tests/helpers/xml_test.rb +56 -0
  169. data/tests/methods/address_test.rb +64 -0
  170. data/tests/methods/api_test.rb +97 -0
  171. data/tests/methods/backward_compatibility_test.rb +87 -0
  172. data/tests/methods/blob_test.rb +64 -0
  173. data/tests/methods/bucket_test.rb +62 -0
  174. data/tests/methods/driver_test.rb +48 -0
  175. data/tests/methods/firewall_test.rb +84 -0
  176. data/tests/methods/hardware_profile_test.rb +53 -0
  177. data/tests/methods/image_test.rb +64 -0
  178. data/tests/methods/instance_state_test.rb +43 -0
  179. data/tests/methods/instance_test.rb +126 -0
  180. data/tests/methods/key_test.rb +63 -0
  181. data/tests/methods/realm_test.rb +50 -0
  182. data/tests/methods/storage_snapshot_test.rb +53 -0
  183. data/tests/methods/storage_volume_test.rb +81 -0
  184. data/tests/models/blob_test.rb +40 -0
  185. data/tests/models/bucket_test.rb +37 -0
  186. data/tests/models/driver_test.rb +42 -0
  187. data/tests/models/hardware_profile_test.rb +80 -0
  188. data/tests/models/image_test.rb +65 -0
  189. data/tests/models/storage_volume_test.rb +52 -0
  190. data/tests/test_helper.rb +64 -0
  191. metadata +191 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1831df6aaaf51c6abb85d0c09756e7bbdce6ce8
4
- data.tar.gz: 0fb22d0f4d6d3264a2fef1c05b92b739c726101b
3
+ metadata.gz: 19753f475607b9f3d623d4517e52c4c505f1deab
4
+ data.tar.gz: 69526ec5e76064b9a5fd2dbca154b67631454aef
5
5
  SHA512:
6
- metadata.gz: 406c43b25b6287307fd22187af1afd401b459d5850e4aff5260f94f2d5d227cf2b1b8f5b5f78228341a63f6cc8f750017486c6f9ca71d67522cd76332b37ae5e
7
- data.tar.gz: 7bd358018ebf621ad88b10188ad5472b6c6d9fe445ecdc0d2f9245e2e3bb27ca2333fba6ad4d572f5d2919cd2b4057157a699e3328c5744c33f14a69efc467c5
6
+ metadata.gz: 5a5ceadd37dfb8afe815f26e88bd0ad06bf827fe3bc4172f0f006fc4647ccfbeb1a049cfc048f22a051729683523a792d9577ece5b8b9ea24f55780fd8f244fe
7
+ data.tar.gz: 5be68f6caf8b25c9c35cdc5fa0d2da383bd843bb11de61981f019952dbd177e894b02d7f66356b87395f4ff5d1361309063c9c8ad660473050acb28a623cdbc9
data/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
data/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ Apache DeltacloudVM
2
+ Copyright 2010-2012 The Apache Software Foundation
3
+
4
+ This product includes software developed at The Apache Software Foundation
5
+ (http://www.apache.org/).
6
+
7
+ This product includes software developed by Red Hat,
8
+ Inc. (http://www.redhat.com/)
@@ -0,0 +1,73 @@
1
+ # deltacloud-client
2
+
3
+ The DeltacloudVM project includes a Ruby client. Other language-bindings
4
+ are possible and will be supported soon. The client aims to insulate
5
+ users from having to deal with HTTP and REST directly.
6
+
7
+ Each resource type has an associated model to ease usage. Where
8
+ resource reference other resources, natural navigation across the
9
+ object model is possible.
10
+
11
+ This is a Ruby client library for the [DeltacloudVM API](http://deltacloud.apache.org).
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ require 'deltacloud/client'
17
+
18
+ API_URL = "http://localhost:3001/api" # DeltacloudVM API endpoint
19
+
20
+ # Simple use-cases
21
+ client = DeltacloudVM::Client(API_URL, 'mockuser', 'mockpassword')
22
+
23
+ pp client.instances # List all instances
24
+ pp client.instance('i-12345') # Get one instance
25
+
26
+ inst = client.create_instance 'ami-1234', :hwp_id => 'm1.small' # Create instance
27
+
28
+ inst.reboot! # Reboot instance
29
+
30
+ # Advanced usage
31
+
32
+ # DeltacloudVM API supports changing driver per-request:
33
+
34
+ client.use(:ec2, 'API_KEY', 'API_SECRET').instances # List EC2 instances
35
+ client.use(:openstack, 'admin@tenant', 'password', KEYSTONE_URL).instances # List Openstack instances
36
+
37
+ ```
38
+ # Want help?
39
+
40
+ ## Adding new DeltacloudVM collection to client
41
+
42
+ ```
43
+ $ rake generate[YOUR_COLLECTION] # eg. 'storage_snapshot'
44
+ # Hit Enter 2x
45
+ ```
46
+
47
+ - Edit `lib/deltacloud_vm/client/methods/YOUR_COLLECTION.rb` and add all
48
+ methods for manipulating your collection. The list/show methods
49
+ should already be generated for you, but double-check them.
50
+
51
+ - Edit `lib/deltacloud_vm/client/model/YOUR_COLLECTION.rb` and add model
52
+ methods. Model methods should really be just a syntax sugar and exercise
53
+ the *DeltacloudVM::Client::Methods* methods.
54
+ The purpose of *model* class life is to deserialize XML body received
55
+ from DeltacloudVM API to a Ruby class.
56
+
57
+ ## Debugging a nasty bug?
58
+
59
+ - You can easily debug deltacloud-client using powerful **pry**.
60
+
61
+ - `gem install deltacloud-core`
62
+ - optional: `rbenv rehash` ;-)
63
+ - `deltacloudd -i mock -p 3002`
64
+ - `rake console`
65
+
66
+ Console require **pry** gem installed. If you are not using this awesome
67
+ gem, you can fix it by `gem install pry`.
68
+
69
+ # License
70
+
71
+ Apache License
72
+ Version 2.0, January 2004
73
+ http://www.apache.org/licenses/
@@ -0,0 +1,122 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership. The
4
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the
6
+ # License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ require 'rubygems'
17
+ require 'rubygems/package_task'
18
+ require 'rake'
19
+ require 'rake/testtask'
20
+
21
+ spec = Gem::Specification.load('deltacloud-client.gemspec')
22
+
23
+ Gem::PackageTask.new(spec) do |pkg|
24
+ pkg.need_tar = true
25
+ end
26
+
27
+ desc "Re-install the deltacloud-client gem (used for development)"
28
+ task :reinstall do
29
+ puts %x{gem uninstall deltacloud-client --all -I -x}
30
+ puts %x{gem build deltacloud-client.gemspec}
31
+ puts %x{gem install deltacloud-client-*.gem --local}
32
+ end
33
+
34
+ desc 'Generate model/methods files for collection.'
35
+ task :generate, :name do |t, args|
36
+ require 'erb'
37
+ require_relative './lib/deltacloud_vm/core_ext'
38
+ model_tpl = ERB.new(File.read('support/model_template.erb'))
39
+ methods_tpl = ERB.new(File.read('support/methods_template.erb'))
40
+ name = args[:name]
41
+ model_file = "lib/deltacloud_vm/client/models/#{name}.rb"
42
+ methods_file = "lib/deltacloud_vm/client/methods/#{name}.rb"
43
+ puts model_body = model_tpl.result(binding)
44
+ print "Save model to '#{model_file}'? [Y/n]"
45
+ answer = $stdin.gets.chomp
46
+ if answer.empty? or answer == 'Y'
47
+ File.open(model_file, 'w') { |f|
48
+ f.write(model_body)
49
+ }
50
+ File.open('lib/deltacloud_vm/client/models.rb', 'a') { |f|
51
+ f.puts "require_relative './models/#{name}'"
52
+ }
53
+ end
54
+ puts methods_body = methods_tpl.result(binding)
55
+ print "Save methods to '#{methods_file}'? [Y/n]"
56
+ answer = $stdin.gets.chomp
57
+ if answer.empty? or answer == 'Y'
58
+ File.open(methods_file, 'w') { |f|
59
+ f.write(methods_body)
60
+ }
61
+ File.open('lib/deltacloud_vm/client/methods.rb', 'a') { |f|
62
+ f.puts "require_relative './methods/#{name}'"
63
+ }
64
+ end
65
+ puts
66
+ puts "Don't forget to add this line to 'lib/deltacloud_vm/client/connection.rb':"
67
+ puts
68
+ puts "include DeltacloudVM::Client::Methods::#{name.to_s.camelize}"
69
+ puts
70
+ end
71
+
72
+ desc 'Generate method test file'
73
+ task :test_generate, :name do |t, args|
74
+ require 'erb'
75
+ require_relative './lib/deltacloud_vm/core_ext'
76
+ method_tpl = ERB.new(File.read('support/method_test_template.erb'))
77
+ name = args[:name]
78
+ methods_file = "tests/methods/#{name}_test.rb"
79
+ puts method_body = method_tpl.result(binding)
80
+ print "Save method test to '#{methods_file}'? [Y/n]"
81
+ answer = $stdin.gets.chomp
82
+ if answer.empty? or answer == 'Y'
83
+ File.open(methods_file, 'w') { |f|
84
+ f.write(method_body)
85
+ }
86
+ end
87
+ end
88
+
89
+
90
+ desc "Open console with client connected to #{ENV['API_URL'] || 'localhost:3002/api'}"
91
+ task :console do
92
+ require 'pry'
93
+ unless binding.respond_to? :pry
94
+ puts 'To open a console, you need to have "pry" installed (gem install pry)'
95
+ exit(1)
96
+ end
97
+ require_relative './lib/deltacloud_vm/client'
98
+ client = DeltacloudVM::Client(
99
+ ENV['API_URL'] || 'http://localhost:3002/api',
100
+ ENV['API_USER'] || 'mockuser',
101
+ ENV['API_PASSWORD'] || 'mockpassword'
102
+ )
103
+ binding.pry
104
+ end
105
+
106
+ Rake::TestTask.new(:test) do |t|
107
+ t.test_files = FileList[
108
+ 'tests/*/*_test.rb'
109
+ ]
110
+ end
111
+
112
+ desc "Execute test against live DeltacloudVM API"
113
+ task :test_live do
114
+ ENV['NO_VCR'] = 'true'
115
+ Rake::Task[:test].invoke
116
+ end
117
+
118
+ desc "Generate test coverage report"
119
+ task :coverage do
120
+ ENV['COVERAGE'] = 'true'
121
+ Rake::Task[:test].invoke
122
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "deltacloud-client-vm"
6
+ s.version = '1.1.4.3'
7
+ s.authors = ["Jiri Kaipr"]
8
+ s.email = ["jiri.kaipr@gmail.com"]
9
+ s.homepage = "https://github.com/virtualmaster/virtualmaster-cli"
10
+ s.summary = %q{Virtualmaster version of deltacloud-client.}
11
+ s.description = %q{Deltacloud API ruby client.}
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_dependency "faraday", "~> 0.9"
18
+ s.add_dependency "minitest", "~> 5.8"
19
+ s.add_dependency "nokogiri", "~> 1.6"
20
+ s.add_dependency "pry", "~> 0.1"
21
+ s.add_dependency "rake", "~> 10.1"
22
+ s.add_dependency "simplecov", "~> 0.1"
23
+ s.add_dependency "vcr", "~> 2.9"
24
+ end
@@ -0,0 +1,79 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership. The
4
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the
6
+ # License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ module DeltacloudVM
17
+ module Client
18
+ require 'require_relative' if RUBY_VERSION < '1.9'
19
+ require 'ostruct'
20
+ require 'nokogiri'
21
+ require 'faraday'
22
+ require 'base64'
23
+
24
+ # Core extensions
25
+ require_relative './core_ext'
26
+
27
+ # Errors && Helpers
28
+ require_relative './client/helpers/model_helper'
29
+ require_relative './client/helpers/xml_helper'
30
+ require_relative './client/helpers/property_helper'
31
+
32
+ # Exceptions goes here
33
+ require_relative './client/base_error'
34
+
35
+ # Faraday Middleware for DeltacloudVM errors
36
+ require_relative './error_response'
37
+
38
+ # DeltacloudVM API methods
39
+ require_relative './client/methods/api'
40
+ require_relative './client/methods/backward_compatiblity'
41
+
42
+ # Extend Client module with methods that existed in old client
43
+ # that need to be kept.
44
+ # Deprecation warnings should be provided to users if they use something
45
+ # from these modules.
46
+ #
47
+ extend DeltacloudVM::Client::Methods::BackwardCompatibility::ClassMethods
48
+
49
+ # DeltacloudVM methods
50
+ require_relative './client/methods'
51
+
52
+ # DeltacloudVM models
53
+ require_relative './client/models'
54
+
55
+ require_relative './client/connection'
56
+
57
+ VERSION = '1.1.2'
58
+
59
+ # Check if the connection to DeltacloudVM API is valid
60
+ def self.valid_connection?(api_url)
61
+ begin
62
+ DeltacloudVM::Client(api_url, '', '') && true
63
+ rescue Faraday::Error::ConnectionFailed
64
+ false
65
+ rescue DeltacloudVM::Client::AuthenticationError
66
+ false
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ def self.Client(url, api_user, api_password, opts={})
73
+ Client::Connection.new({
74
+ :url => url,
75
+ :api_user => api_user,
76
+ :api_password => api_password
77
+ }.merge(opts))
78
+ end
79
+ end