cft_smartcloud 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/README.rdoc +4 -0
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/bin/cft_smartcloud +37 -0
  5. data/cft_smartcloud.gemspec +88 -7
  6. data/lib/smartcloud.rb +12 -2
  7. data/lib/smartcloud_logger.rb +1 -1
  8. data/rdoc/classes/ConfigTable/BoolItem.html +172 -0
  9. data/rdoc/classes/ConfigTable/ExecItem.html +252 -0
  10. data/rdoc/classes/ConfigTable/Item.html +308 -0
  11. data/rdoc/classes/ConfigTable/MetaConfigEnvironment.html +445 -0
  12. data/rdoc/classes/ConfigTable/PackageSelectionItem.html +188 -0
  13. data/rdoc/classes/ConfigTable/PathItem.html +148 -0
  14. data/rdoc/classes/ConfigTable/ProgramItem.html +148 -0
  15. data/rdoc/classes/ConfigTable/SelectItem.html +175 -0
  16. data/rdoc/classes/ConfigTable.html +724 -0
  17. data/rdoc/classes/Enumerable.html +157 -0
  18. data/rdoc/classes/Errno/ENOTEMPTY.html +111 -0
  19. data/rdoc/classes/Errno.html +111 -0
  20. data/rdoc/classes/File.html +197 -0
  21. data/rdoc/classes/FileOperations.html +600 -0
  22. data/rdoc/classes/Hash.html +163 -0
  23. data/rdoc/classes/HookScriptAPI.html +413 -0
  24. data/rdoc/classes/IBMSmartCloud.html +1484 -0
  25. data/rdoc/classes/Installer/Shebang.html +245 -0
  26. data/rdoc/classes/Installer.html +1660 -0
  27. data/rdoc/classes/MIME/InvalidContentType.html +119 -0
  28. data/rdoc/classes/MIME/Type.html +1366 -0
  29. data/rdoc/classes/MIME/Types.html +643 -0
  30. data/rdoc/classes/MIME.html +124 -0
  31. data/rdoc/classes/MockSmartCloud.html +376 -0
  32. data/rdoc/classes/Net/HTTP.html +164 -0
  33. data/rdoc/classes/Net.html +122 -0
  34. data/rdoc/classes/RestClient/AbstractResponse.html +417 -0
  35. data/rdoc/classes/RestClient/Exception.html +305 -0
  36. data/rdoc/classes/RestClient/ExceptionWithResponse.html +119 -0
  37. data/rdoc/classes/RestClient/Exceptions.html +130 -0
  38. data/rdoc/classes/RestClient/MaxRedirectsReached.html +113 -0
  39. data/rdoc/classes/RestClient/Payload/Base.html +422 -0
  40. data/rdoc/classes/RestClient/Payload/Multipart.html +372 -0
  41. data/rdoc/classes/RestClient/Payload/Streamed.html +191 -0
  42. data/rdoc/classes/RestClient/Payload/UrlEncoded.html +202 -0
  43. data/rdoc/classes/RestClient/Payload.html +192 -0
  44. data/rdoc/classes/RestClient/RawResponse.html +236 -0
  45. data/rdoc/classes/RestClient/Redirect.html +168 -0
  46. data/rdoc/classes/RestClient/Request.html +950 -0
  47. data/rdoc/classes/RestClient/RequestFailed.html +178 -0
  48. data/rdoc/classes/RestClient/Resource.html +607 -0
  49. data/rdoc/classes/RestClient/Response.html +208 -0
  50. data/rdoc/classes/RestClient/ResponseForException.html +152 -0
  51. data/rdoc/classes/RestClient/SSLCertificateNotVerified.html +149 -0
  52. data/rdoc/classes/RestClient/ServerBrokeConnection.html +157 -0
  53. data/rdoc/classes/RestClient.html +737 -0
  54. data/rdoc/classes/SetupError.html +111 -0
  55. data/rdoc/classes/SmartcloudLogger.html +162 -0
  56. data/rdoc/classes/TestMIME.html +109 -0
  57. data/rdoc/classes/ToplevelInstaller.html +987 -0
  58. data/rdoc/classes/ToplevelInstallerMulti.html +593 -0
  59. data/rdoc/classes/XmlSimple/Cache.html +372 -0
  60. data/rdoc/classes/XmlSimple.html +475 -0
  61. data/rdoc/created.rid +1 -0
  62. data/rdoc/files/README_rdoc.html +198 -0
  63. data/rdoc/files/lib/hash_fix_rb.html +115 -0
  64. data/rdoc/files/lib/mime-types-1_16/lib/mime/types_rb.html +107 -0
  65. data/rdoc/files/lib/mime-types-1_16/setup_rb.html +157 -0
  66. data/rdoc/files/lib/mime-types-1_16/test/test_mime_type_rb.html +109 -0
  67. data/rdoc/files/lib/mime-types-1_16/test/test_mime_types_rb.html +109 -0
  68. data/rdoc/files/lib/mock_smartcloud_rb.html +115 -0
  69. data/rdoc/files/lib/rest-client-1_6_3/lib/rest-client_rb.html +107 -0
  70. data/rdoc/files/lib/rest-client-1_6_3/lib/rest_client_rb.html +108 -0
  71. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/abstract_response_rb.html +108 -0
  72. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/exceptions_rb.html +101 -0
  73. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/net_http_ext_rb.html +113 -0
  74. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/payload_rb.html +110 -0
  75. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/raw_response_rb.html +101 -0
  76. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/request_rb.html +110 -0
  77. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/resource_rb.html +101 -0
  78. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/response_rb.html +101 -0
  79. data/rdoc/files/lib/rest-client-1_6_3/lib/restclient_rb.html +111 -0
  80. data/rdoc/files/lib/restclient_fix_rb.html +115 -0
  81. data/rdoc/files/lib/smartcloud_logger_rb.html +115 -0
  82. data/rdoc/files/lib/smartcloud_rb.html +143 -0
  83. data/rdoc/files/lib/xml-simple-1_0_12/lib/xmlsimple_rb.html +124 -0
  84. data/rdoc/fr_class_index.html +79 -0
  85. data/rdoc/fr_file_index.html +48 -0
  86. data/rdoc/fr_method_index.html +441 -0
  87. data/rdoc/index.html +26 -0
  88. data/rdoc/rdoc-style.css +208 -0
  89. metadata +90 -6
@@ -0,0 +1,1484 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: IBMSmartCloud</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">IBMSmartCloud</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/smartcloud_rb.html">
59
+ lib/smartcloud.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ Encapsulates communications with IBM SmartCloud via REST
84
+ </p>
85
+
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+ <div id="method-list">
92
+ <h3 class="section-bar">Methods</h3>
93
+
94
+ <div class="name-list">
95
+ <a href="#M000125">address_state_is?</a>&nbsp;&nbsp;
96
+ <a href="#M000116">allocate_address</a>&nbsp;&nbsp;
97
+ <a href="#M000109">args</a>&nbsp;&nbsp;
98
+ <a href="#M000118">clone_image</a>&nbsp;&nbsp;
99
+ <a href="#M000119">clone_volume</a>&nbsp;&nbsp;
100
+ <a href="#M000113">create_instance</a>&nbsp;&nbsp;
101
+ <a href="#M000132">create_volume</a>&nbsp;&nbsp;
102
+ <a href="#M000151">delete</a>&nbsp;&nbsp;
103
+ <a href="#M000143">delete_instance</a>&nbsp;&nbsp;
104
+ <a href="#M000142">delete_instances</a>&nbsp;&nbsp;
105
+ <a href="#M000128">delete_unused_keys</a>&nbsp;&nbsp;
106
+ <a href="#M000120">delete_volume</a>&nbsp;&nbsp;
107
+ <a href="#M000117">describe_address</a>&nbsp;&nbsp;
108
+ <a href="#M000115">describe_address_offerings</a>&nbsp;&nbsp;
109
+ <a href="#M000124">describe_addresses</a>&nbsp;&nbsp;
110
+ <a href="#M000148">describe_image</a>&nbsp;&nbsp;
111
+ <a href="#M000149">describe_images</a>&nbsp;&nbsp;
112
+ <a href="#M000145">describe_instance</a>&nbsp;&nbsp;
113
+ <a href="#M000146">describe_instances</a>&nbsp;&nbsp;
114
+ <a href="#M000123">describe_key</a>&nbsp;&nbsp;
115
+ <a href="#M000126">describe_keys</a>&nbsp;&nbsp;
116
+ <a href="#M000111">describe_locations</a>&nbsp;&nbsp;
117
+ <a href="#M000133">describe_storage</a>&nbsp;&nbsp;
118
+ <a href="#M000127">describe_unused_keys</a>&nbsp;&nbsp;
119
+ <a href="#M000135">describe_volume</a>&nbsp;&nbsp;
120
+ <a href="#M000131">describe_volume_offerings</a>&nbsp;&nbsp;
121
+ <a href="#M000134">describe_volumes</a>&nbsp;&nbsp;
122
+ <a href="#M000150">display_images</a>&nbsp;&nbsp;
123
+ <a href="#M000147">display_instances</a>&nbsp;&nbsp;
124
+ <a href="#M000129">display_keys</a>&nbsp;&nbsp;
125
+ <a href="#M000112">display_locations</a>&nbsp;&nbsp;
126
+ <a href="#M000137">display_storage</a>&nbsp;&nbsp;
127
+ <a href="#M000136">display_volumes</a>&nbsp;&nbsp;
128
+ <a href="#M000121">generate_keypair</a>&nbsp;&nbsp;
129
+ <a href="#M000153">get</a>&nbsp;&nbsp;
130
+ <a href="#M000114">get_location_by_name</a>&nbsp;&nbsp;
131
+ <a href="#M000110">help</a>&nbsp;&nbsp;
132
+ <a href="#M000139">instance_state_is?</a>&nbsp;&nbsp;
133
+ <a href="#M000108">new</a>&nbsp;&nbsp;
134
+ <a href="#M000141">poll_for_instance_state</a>&nbsp;&nbsp;
135
+ <a href="#M000140">poll_for_volume_state</a>&nbsp;&nbsp;
136
+ <a href="#M000154">post</a>&nbsp;&nbsp;
137
+ <a href="#M000152">put</a>&nbsp;&nbsp;
138
+ <a href="#M000122">remove_keypair</a>&nbsp;&nbsp;
139
+ <a href="#M000144">restart_instance</a>&nbsp;&nbsp;
140
+ <a href="#M000138">storage_state_is?</a>&nbsp;&nbsp;
141
+ <a href="#M000130">supported_instance_types</a>&nbsp;&nbsp;
142
+ </div>
143
+ </div>
144
+
145
+ </div>
146
+
147
+
148
+ <!-- if includes -->
149
+
150
+ <div id="section">
151
+
152
+
153
+
154
+
155
+
156
+ <div id="attribute-list">
157
+ <h3 class="section-bar">Attributes</h3>
158
+
159
+ <div class="name-list">
160
+ <table>
161
+ <tr class="top-aligned-row context-row">
162
+ <td class="context-item-name">config</td>
163
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
164
+ <td class="context-item-desc"></td>
165
+ </tr>
166
+ <tr class="top-aligned-row context-row">
167
+ <td class="context-item-name">logger</td>
168
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
169
+ <td class="context-item-desc"></td>
170
+ </tr>
171
+ <tr class="top-aligned-row context-row">
172
+ <td class="context-item-name">method_help</td>
173
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
174
+ <td class="context-item-desc"></td>
175
+ </tr>
176
+ </table>
177
+ </div>
178
+ </div>
179
+
180
+
181
+
182
+ <!-- if method_list -->
183
+ <div id="methods">
184
+ <h3 class="section-bar">Public Class methods</h3>
185
+
186
+ <div id="method-M000109" class="method-detail">
187
+ <a name="M000109"></a>
188
+
189
+ <div class="method-heading">
190
+ <a href="#M000109" class="method-signature">
191
+ <span class="method-name">args</span><span class="method-args">(method, args)</span>
192
+ </a>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+ <p><a class="source-toggle" href="#"
197
+ onclick="toggleCode('M000109-source');return false;">[Source]</a></p>
198
+ <div class="method-source-code" id="M000109-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 55</span>
201
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">args</span>)
202
+ <span class="ruby-ivar">@method_help</span><span class="ruby-operator">||=</span>{}
203
+ <span class="ruby-ivar">@method_help</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">args</span>
204
+ <span class="ruby-keyword kw">end</span>
205
+ </pre>
206
+ </div>
207
+ </div>
208
+ </div>
209
+
210
+ <div id="method-M000108" class="method-detail">
211
+ <a name="M000108"></a>
212
+
213
+ <div class="method-heading">
214
+ <a href="#M000108" class="method-signature">
215
+ <span class="method-name">new</span><span class="method-args">(username, password, logger=nil, debug=false)</span>
216
+ </a>
217
+ </div>
218
+
219
+ <div class="method-description">
220
+ <p><a class="source-toggle" href="#"
221
+ onclick="toggleCode('M000108-source');return false;">[Source]</a></p>
222
+ <div class="method-source-code" id="M000108-source">
223
+ <pre>
224
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 33</span>
225
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">username</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">logger</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">debug</span>=<span class="ruby-keyword kw">false</span>)
226
+ <span class="ruby-ivar">@username</span> = <span class="ruby-identifier">username</span>
227
+ <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
228
+ <span class="ruby-ivar">@logger</span> = <span class="ruby-identifier">logger</span> <span class="ruby-operator">||</span> <span class="ruby-constant">SmartcloudLogger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">STDOUT</span>)
229
+ <span class="ruby-ivar">@debug</span> = <span class="ruby-identifier">debug</span>
230
+
231
+ <span class="ruby-ivar">@config</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>), <span class="ruby-value str">&quot;config/config.yml&quot;</span>))
232
+ <span class="ruby-ivar">@states</span> = <span class="ruby-ivar">@config</span>[<span class="ruby-value str">&quot;states&quot;</span>]
233
+
234
+ <span class="ruby-ivar">@api_url</span> = <span class="ruby-ivar">@config</span>[<span class="ruby-value str">&quot;api_url&quot;</span>]
235
+ <span class="ruby-ivar">@api_url</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot;https://&quot;</span>, <span class="ruby-node">&quot;https://#{CGI::escape(username)}:#{CGI::escape(password)}@&quot;</span>)
236
+
237
+ <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">timeout</span> = <span class="ruby-value">120</span> <span class="ruby-comment cmt"># ibm requests can be very slow</span>
238
+ <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> = <span class="ruby-ivar">@logger</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@debug</span>
239
+ <span class="ruby-keyword kw">end</span>
240
+ </pre>
241
+ </div>
242
+ </div>
243
+ </div>
244
+
245
+ <h3 class="section-bar">Public Instance methods</h3>
246
+
247
+ <div id="method-M000125" class="method-detail">
248
+ <a name="M000125"></a>
249
+
250
+ <div class="method-heading">
251
+ <a href="#M000125" class="method-signature">
252
+ <span class="method-name">address_state_is?</span><span class="method-args">(address_id, state_string)</span>
253
+ </a>
254
+ </div>
255
+
256
+ <div class="method-description">
257
+ <p><a class="source-toggle" href="#"
258
+ onclick="toggleCode('M000125-source');return false;">[Source]</a></p>
259
+ <div class="method-source-code" id="M000125-source">
260
+ <pre>
261
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 237</span>
262
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">address_state_is?</span>(<span class="ruby-identifier">address_id</span>, <span class="ruby-identifier">state_string</span>)
263
+ <span class="ruby-identifier">v</span> = <span class="ruby-identifier">describe_addresses</span>(<span class="ruby-identifier">address_id</span>)
264
+ <span class="ruby-identifier">v</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">state_string</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
265
+ <span class="ruby-keyword kw">end</span>
266
+ </pre>
267
+ </div>
268
+ </div>
269
+ </div>
270
+
271
+ <div id="method-M000116" class="method-detail">
272
+ <a name="M000116"></a>
273
+
274
+ <div class="method-heading">
275
+ <a href="#M000116" class="method-signature">
276
+ <span class="method-name">allocate_address</span><span class="method-args">(location, offering_id=nil)</span>
277
+ </a>
278
+ </div>
279
+
280
+ <div class="method-description">
281
+ <p><a class="source-toggle" href="#"
282
+ onclick="toggleCode('M000116-source');return false;">[Source]</a></p>
283
+ <div class="method-source-code" id="M000116-source">
284
+ <pre>
285
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 162</span>
286
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">allocate_address</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">offering_id</span>=<span class="ruby-keyword kw">nil</span>)
287
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">offering_id</span>.<span class="ruby-identifier">nil?</span>
288
+ <span class="ruby-identifier">offering_id</span> = <span class="ruby-identifier">describe_address_offerings</span>(<span class="ruby-identifier">location</span>).<span class="ruby-constant">ID</span>
289
+ <span class="ruby-keyword kw">end</span>
290
+ <span class="ruby-identifier">post</span>(<span class="ruby-value str">&quot;/addresses&quot;</span>, <span class="ruby-identifier">:offeringID</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">offering_id</span>, <span class="ruby-identifier">:location</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">location</span>).<span class="ruby-constant">Address</span>
291
+ <span class="ruby-keyword kw">end</span>
292
+ </pre>
293
+ </div>
294
+ </div>
295
+ </div>
296
+
297
+ <div id="method-M000118" class="method-detail">
298
+ <a name="M000118"></a>
299
+
300
+ <div class="method-heading">
301
+ <a href="#M000118" class="method-signature">
302
+ <span class="method-name">clone_image</span><span class="method-args">(name, description, image_id)</span>
303
+ </a>
304
+ </div>
305
+
306
+ <div class="method-description">
307
+ <p><a class="source-toggle" href="#"
308
+ onclick="toggleCode('M000118-source');return false;">[Source]</a></p>
309
+ <div class="method-source-code" id="M000118-source">
310
+ <pre>
311
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 179</span>
312
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clone_image</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">description</span>, <span class="ruby-identifier">image_id</span>)
313
+ <span class="ruby-identifier">post</span>(<span class="ruby-node">&quot;/offerings/image/#{image_id}&quot;</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">:description</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">description</span>).<span class="ruby-constant">ImageID</span>
314
+ <span class="ruby-keyword kw">end</span>
315
+ </pre>
316
+ </div>
317
+ </div>
318
+ </div>
319
+
320
+ <div id="method-M000119" class="method-detail">
321
+ <a name="M000119"></a>
322
+
323
+ <div class="method-heading">
324
+ <a href="#M000119" class="method-signature">
325
+ <span class="method-name">clone_volume</span><span class="method-args">(name, source_disk_id)</span>
326
+ </a>
327
+ </div>
328
+
329
+ <div class="method-description">
330
+ <p><a class="source-toggle" href="#"
331
+ onclick="toggleCode('M000119-source');return false;">[Source]</a></p>
332
+ <div class="method-source-code" id="M000119-source">
333
+ <pre>
334
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 186</span>
335
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clone_volume</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">source_disk_id</span>)
336
+ <span class="ruby-comment cmt"># result = post(&quot;/storage&quot;, :name =&gt; name, :SourceDiskID =&gt; source_disk_id)</span>
337
+ <span class="ruby-comment cmt"># result.Volume.ID</span>
338
+ <span class="ruby-identifier">create_password_file</span>
339
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">run_ibm_tool</span>(<span class="ruby-node">&quot;ic-clone-volume.sh -n #{name} -S #{source_disk_id}&quot;</span>)
340
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/ID : (.*)/</span>
341
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">$1</span> <span class="ruby-comment cmt"># grab the id of the created volume</span>
342
+ <span class="ruby-keyword kw">end</span>
343
+ </pre>
344
+ </div>
345
+ </div>
346
+ </div>
347
+
348
+ <div id="method-M000113" class="method-detail">
349
+ <a name="M000113"></a>
350
+
351
+ <div class="method-heading">
352
+ <a href="#M000113" class="method-signature">
353
+ <span class="method-name">create_instance</span><span class="method-args">(instance_params)</span>
354
+ </a>
355
+ </div>
356
+
357
+ <div class="method-description">
358
+ <p><a class="source-toggle" href="#"
359
+ onclick="toggleCode('M000113-source');return false;">[Source]</a></p>
360
+ <div class="method-source-code" id="M000113-source">
361
+ <pre>
362
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 106</span>
363
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_instance</span>(<span class="ruby-identifier">instance_params</span>)
364
+ <span class="ruby-identifier">param_remap</span> = { <span class="ruby-value str">&quot;name&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;name&quot;</span>,
365
+ <span class="ruby-value str">&quot;image-id&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;imageID&quot;</span>,
366
+ <span class="ruby-value str">&quot;instance-type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;instanceType&quot;</span>,
367
+ <span class="ruby-value str">&quot;data-center&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;location&quot;</span>,
368
+ <span class="ruby-value str">&quot;key-name&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;publicKey&quot;</span>,
369
+ <span class="ruby-value str">&quot;ip-address-id&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;ip&quot;</span>,
370
+ <span class="ruby-value str">&quot;volume-id&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;volumeID&quot;</span>,
371
+ <span class="ruby-value str">&quot;configuration&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;ConfigurationData&quot;</span>,
372
+ <span class="ruby-value str">&quot;vlan-id&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;vlanID&quot;</span>,
373
+ <span class="ruby-value str">&quot;antiCollocationInstance&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;antiCollocationInstance&quot;</span>,
374
+ <span class="ruby-value str">&quot;isMiniEphemeral&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;isMiniEphemeral&quot;</span>
375
+ }
376
+
377
+ <span class="ruby-comment cmt"># api does not take description</span>
378
+ <span class="ruby-identifier">instance_params</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;description&quot;</span>)
379
+
380
+ <span class="ruby-comment cmt"># configuration data has to be changed from a string like</span>
381
+ <span class="ruby-comment cmt"># &lt;configuration&gt;{contextmanager:baml-c3-master.cohesiveft.com,clustername:BAML_poc_pk0515,role:[nfs-client-setup|newyork_master_refdata_member|install-luci|rhel-openlikewise-client-setup|join-domain],hostname:r550n107}&lt;/configuration&gt; </span>
382
+ <span class="ruby-comment cmt"># to a standard list of POST params like</span>
383
+ <span class="ruby-comment cmt"># contextmanager=baml-c3-mager&amp;clustername=BAML...</span>
384
+ <span class="ruby-identifier">configuration_data</span> = <span class="ruby-identifier">instance_params</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;configuration&quot;</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">instance_params</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;ConfigurationData&quot;</span>)
385
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">configuration_data</span>
386
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">configuration_data</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\s+/</span>
387
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span> <span class="ruby-value str">&quot;&lt;configuration&gt; tag should not contain spaces! Correct format looks like: &lt;configuration&gt;{foo:bar,baz:quux}&lt;/configuration&gt;. Spaces will be removed.&quot;</span>
388
+ <span class="ruby-keyword kw">end</span>
389
+ <span class="ruby-identifier">configuration_data</span>.<span class="ruby-identifier">delete!</span>(<span class="ruby-value str">&quot;{}&quot;</span>) <span class="ruby-comment cmt"># get rid of curly braces</span>
390
+ <span class="ruby-identifier">config_data_params</span> = <span class="ruby-identifier">configuration_data</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;,&quot;</span>).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;:&quot;</span>)} <span class="ruby-comment cmt"># split each foo:bar into key and value</span>
391
+ <span class="ruby-identifier">config_data_params</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">instance_params</span>[<span class="ruby-identifier">k</span>]=<span class="ruby-identifier">v</span>} <span class="ruby-comment cmt"># add it into the standard instance params array</span>
392
+ <span class="ruby-keyword kw">end</span>
393
+
394
+ <span class="ruby-identifier">post</span> <span class="ruby-value str">&quot;/instances&quot;</span>, <span class="ruby-identifier">instance_params</span>, <span class="ruby-identifier">param_remap</span>
395
+ <span class="ruby-keyword kw">end</span>
396
+ </pre>
397
+ </div>
398
+ </div>
399
+ </div>
400
+
401
+ <div id="method-M000132" class="method-detail">
402
+ <a name="M000132"></a>
403
+
404
+ <div class="method-heading">
405
+ <a href="#M000132" class="method-signature">
406
+ <span class="method-name">create_volume</span><span class="method-args">(name, location, size, offering_id=nil, format=&quot;EXT3&quot;)</span>
407
+ </a>
408
+ </div>
409
+
410
+ <div class="method-description">
411
+ <p><a class="source-toggle" href="#"
412
+ onclick="toggleCode('M000132-source');return false;">[Source]</a></p>
413
+ <div class="method-source-code" id="M000132-source">
414
+ <pre>
415
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 304</span>
416
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_volume</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">location</span>, <span class="ruby-identifier">size</span>, <span class="ruby-identifier">offering_id</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">format</span>=<span class="ruby-value str">&quot;EXT3&quot;</span>)
417
+
418
+ <span class="ruby-comment cmt"># figure out the offering ID automatically based on location and size</span>
419
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">offering_id</span>.<span class="ruby-identifier">nil?</span>
420
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;Looking up volume offerings based on location: #{location} and size: #{size}&quot;</span>
421
+ <span class="ruby-identifier">offering_id</span> = <span class="ruby-identifier">describe_volume_offerings</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">size</span>).<span class="ruby-constant">ID</span>
422
+ <span class="ruby-keyword kw">end</span>
423
+
424
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-value str">&quot;Creating volume...please wait.&quot;</span>
425
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">post</span>(<span class="ruby-value str">&quot;/storage&quot;</span>, <span class="ruby-identifier">:format</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">format</span>, <span class="ruby-identifier">:location</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">location</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">:size</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>, <span class="ruby-identifier">:offeringID</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">offering_id</span>)
426
+ <span class="ruby-identifier">result</span>.<span class="ruby-constant">Volume</span>.<span class="ruby-constant">ID</span>
427
+ <span class="ruby-keyword kw">end</span>
428
+ </pre>
429
+ </div>
430
+ </div>
431
+ </div>
432
+
433
+ <div id="method-M000151" class="method-detail">
434
+ <a name="M000151"></a>
435
+
436
+ <div class="method-heading">
437
+ <a href="#M000151" class="method-signature">
438
+ <span class="method-name">delete</span><span class="method-args">(path)</span>
439
+ </a>
440
+ </div>
441
+
442
+ <div class="method-description">
443
+ <p><a class="source-toggle" href="#"
444
+ onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
445
+ <div class="method-source-code" id="M000151-source">
446
+ <pre>
447
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 497</span>
448
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
449
+ <span class="ruby-identifier">output</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">delete</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@api_url</span>, <span class="ruby-identifier">path</span>), <span class="ruby-identifier">:accept</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:response</span>
450
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">XmlSimple</span>.<span class="ruby-identifier">xml_in</span>(<span class="ruby-identifier">output</span>, {<span class="ruby-value str">'ForceArray'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>})
451
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
452
+ <span class="ruby-identifier">raise_restclient_error</span>(<span class="ruby-identifier">e</span>)
453
+ <span class="ruby-keyword kw">end</span>
454
+ </pre>
455
+ </div>
456
+ </div>
457
+ </div>
458
+
459
+ <div id="method-M000143" class="method-detail">
460
+ <a name="M000143"></a>
461
+
462
+ <div class="method-heading">
463
+ <a href="#M000143" class="method-signature">
464
+ <span class="method-name">delete_instance</span><span class="method-args">(instance_id)</span>
465
+ </a>
466
+ </div>
467
+
468
+ <div class="method-description">
469
+ <p><a class="source-toggle" href="#"
470
+ onclick="toggleCode('M000143-source');return false;">[Source]</a></p>
471
+ <div class="method-source-code" id="M000143-source">
472
+ <pre>
473
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 422</span>
474
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_instance</span>(<span class="ruby-identifier">instance_id</span>)
475
+ <span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;/instances/#{instance_id}&quot;</span>)
476
+ <span class="ruby-keyword kw">true</span>
477
+ <span class="ruby-keyword kw">end</span>
478
+ </pre>
479
+ </div>
480
+ </div>
481
+ </div>
482
+
483
+ <div id="method-M000142" class="method-detail">
484
+ <a name="M000142"></a>
485
+
486
+ <div class="method-heading">
487
+ <a href="#M000142" class="method-signature">
488
+ <span class="method-name">delete_instances</span><span class="method-args">(instance_ids)</span>
489
+ </a>
490
+ </div>
491
+
492
+ <div class="method-description">
493
+ <p><a class="source-toggle" href="#"
494
+ onclick="toggleCode('M000142-source');return false;">[Source]</a></p>
495
+ <div class="method-source-code" id="M000142-source">
496
+ <pre>
497
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 416</span>
498
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_instances</span>(<span class="ruby-identifier">instance_ids</span>)
499
+ <span class="ruby-identifier">instance_ids</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-identifier">delete_instance</span>(<span class="ruby-identifier">id</span>) }
500
+ <span class="ruby-keyword kw">end</span>
501
+ </pre>
502
+ </div>
503
+ </div>
504
+ </div>
505
+
506
+ <div id="method-M000128" class="method-detail">
507
+ <a name="M000128"></a>
508
+
509
+ <div class="method-heading">
510
+ <a href="#M000128" class="method-signature">
511
+ <span class="method-name">delete_unused_keys</span><span class="method-args">(auto=false)</span>
512
+ </a>
513
+ </div>
514
+
515
+ <div class="method-description">
516
+ <p><a class="source-toggle" href="#"
517
+ onclick="toggleCode('M000128-source');return false;">[Source]</a></p>
518
+ <div class="method-source-code" id="M000128-source">
519
+ <pre>
520
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 250</span>
521
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_unused_keys</span>(<span class="ruby-identifier">auto</span>=<span class="ruby-keyword kw">false</span>)
522
+ <span class="ruby-identifier">describe_unused_keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
523
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">auto</span>
524
+ <span class="ruby-identifier">remove_keypair</span>(<span class="ruby-identifier">key</span>.<span class="ruby-constant">KeyName</span>)
525
+ <span class="ruby-keyword kw">else</span>
526
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Remove key #{key.KeyName}? (type 'y' to continue): &quot;</span>
527
+ <span class="ruby-identifier">input</span> = <span class="ruby-identifier">gets</span>.<span class="ruby-identifier">strip</span>
528
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'y'</span>
529
+ <span class="ruby-identifier">remove_keypair</span>(<span class="ruby-identifier">key</span>.<span class="ruby-constant">KeyName</span>)
530
+ <span class="ruby-keyword kw">else</span>
531
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Not removing key #{key.KeyName}&quot;</span>
532
+ <span class="ruby-keyword kw">end</span>
533
+ <span class="ruby-keyword kw">end</span>
534
+ <span class="ruby-keyword kw">end</span>
535
+ <span class="ruby-keyword kw">end</span>
536
+ </pre>
537
+ </div>
538
+ </div>
539
+ </div>
540
+
541
+ <div id="method-M000120" class="method-detail">
542
+ <a name="M000120"></a>
543
+
544
+ <div class="method-heading">
545
+ <a href="#M000120" class="method-signature">
546
+ <span class="method-name">delete_volume</span><span class="method-args">(vol_id)</span>
547
+ </a>
548
+ </div>
549
+
550
+ <div class="method-description">
551
+ <p><a class="source-toggle" href="#"
552
+ onclick="toggleCode('M000120-source');return false;">[Source]</a></p>
553
+ <div class="method-source-code" id="M000120-source">
554
+ <pre>
555
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 197</span>
556
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_volume</span>(<span class="ruby-identifier">vol_id</span>)
557
+ <span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;/storage/#{vol_id}&quot;</span>)
558
+ <span class="ruby-keyword kw">true</span>
559
+ <span class="ruby-keyword kw">end</span>
560
+ </pre>
561
+ </div>
562
+ </div>
563
+ </div>
564
+
565
+ <div id="method-M000117" class="method-detail">
566
+ <a name="M000117"></a>
567
+
568
+ <div class="method-heading">
569
+ <a href="#M000117" class="method-signature">
570
+ <span class="method-name">describe_address</span><span class="method-args">(address_id)</span>
571
+ </a>
572
+ </div>
573
+
574
+ <div class="method-description">
575
+ <p><a class="source-toggle" href="#"
576
+ onclick="toggleCode('M000117-source');return false;">[Source]</a></p>
577
+ <div class="method-source-code" id="M000117-source">
578
+ <pre>
579
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 171</span>
580
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_address</span>(<span class="ruby-identifier">address_id</span>)
581
+ <span class="ruby-identifier">address</span> = <span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;/addresses/#{address_id}&quot;</span>).<span class="ruby-constant">Address</span>
582
+ <span class="ruby-identifier">address</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">states</span>.<span class="ruby-identifier">ip</span>[<span class="ruby-identifier">address</span>.<span class="ruby-constant">State</span>]
583
+ <span class="ruby-identifier">address</span>
584
+ <span class="ruby-keyword kw">end</span>
585
+ </pre>
586
+ </div>
587
+ </div>
588
+ </div>
589
+
590
+ <div id="method-M000115" class="method-detail">
591
+ <a name="M000115"></a>
592
+
593
+ <div class="method-heading">
594
+ <a href="#M000115" class="method-signature">
595
+ <span class="method-name">describe_address_offerings</span><span class="method-args">(location=nil)</span>
596
+ </a>
597
+ </div>
598
+
599
+ <div class="method-description">
600
+ <p><a class="source-toggle" href="#"
601
+ onclick="toggleCode('M000115-source');return false;">[Source]</a></p>
602
+ <div class="method-source-code" id="M000115-source">
603
+ <pre>
604
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 150</span>
605
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_address_offerings</span>(<span class="ruby-identifier">location</span>=<span class="ruby-keyword kw">nil</span>)
606
+ <span class="ruby-identifier">response</span>=<span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/offerings/address&quot;</span>).<span class="ruby-constant">Offerings</span>
607
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">location</span>
608
+ <span class="ruby-identifier">response</span>.<span class="ruby-identifier">detect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">offering</span><span class="ruby-operator">|</span> <span class="ruby-identifier">offering</span>.<span class="ruby-constant">Location</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">location</span>.<span class="ruby-identifier">to_s</span>}
609
+ <span class="ruby-keyword kw">else</span>
610
+ <span class="ruby-identifier">response</span>
611
+ <span class="ruby-keyword kw">end</span>
612
+ <span class="ruby-keyword kw">end</span>
613
+ </pre>
614
+ </div>
615
+ </div>
616
+ </div>
617
+
618
+ <div id="method-M000124" class="method-detail">
619
+ <a name="M000124"></a>
620
+
621
+ <div class="method-heading">
622
+ <a href="#M000124" class="method-signature">
623
+ <span class="method-name">describe_addresses</span><span class="method-args">(address_id=nil)</span>
624
+ </a>
625
+ </div>
626
+
627
+ <div class="method-description">
628
+ <p><a class="source-toggle" href="#"
629
+ onclick="toggleCode('M000124-source');return false;">[Source]</a></p>
630
+ <div class="method-source-code" id="M000124-source">
631
+ <pre>
632
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 222</span>
633
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_addresses</span>(<span class="ruby-identifier">address_id</span>=<span class="ruby-keyword kw">nil</span>)
634
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/addresses&quot;</span>).<span class="ruby-constant">Address</span>
635
+ <span class="ruby-identifier">response</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
636
+ <span class="ruby-identifier">a</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;ip&quot;</span>][<span class="ruby-identifier">a</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_i</span>]
637
+ <span class="ruby-keyword kw">end</span>
638
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">address_id</span>
639
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">detect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">address</span><span class="ruby-operator">|</span> <span class="ruby-identifier">address</span>.<span class="ruby-constant">ID</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">address_id</span>.<span class="ruby-identifier">to_s</span>}
640
+ <span class="ruby-keyword kw">end</span>
641
+ <span class="ruby-identifier">response</span>
642
+ <span class="ruby-keyword kw">end</span>
643
+ </pre>
644
+ </div>
645
+ </div>
646
+ </div>
647
+
648
+ <div id="method-M000148" class="method-detail">
649
+ <a name="M000148"></a>
650
+
651
+ <div class="method-heading">
652
+ <a href="#M000148" class="method-signature">
653
+ <span class="method-name">describe_image</span><span class="method-args">(image_id)</span>
654
+ </a>
655
+ </div>
656
+
657
+ <div class="method-description">
658
+ <p><a class="source-toggle" href="#"
659
+ onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
660
+ <div class="method-source-code" id="M000148-source">
661
+ <pre>
662
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 472</span>
663
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_image</span>(<span class="ruby-identifier">image_id</span>)
664
+ <span class="ruby-identifier">image</span> = <span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;offerings/image/#{image_id}&quot;</span>).<span class="ruby-constant">Image</span>
665
+ <span class="ruby-identifier">image</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;image&quot;</span>][<span class="ruby-identifier">image</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_i</span>]
666
+ <span class="ruby-identifier">image</span>
667
+ <span class="ruby-keyword kw">end</span>
668
+ </pre>
669
+ </div>
670
+ </div>
671
+ </div>
672
+
673
+ <div id="method-M000149" class="method-detail">
674
+ <a name="M000149"></a>
675
+
676
+ <div class="method-heading">
677
+ <a href="#M000149" class="method-signature">
678
+ <span class="method-name">describe_images</span><span class="method-args">(filters={})</span>
679
+ </a>
680
+ </div>
681
+
682
+ <div class="method-description">
683
+ <p><a class="source-toggle" href="#"
684
+ onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
685
+ <div class="method-source-code" id="M000149-source">
686
+ <pre>
687
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 479</span>
688
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_images</span>(<span class="ruby-identifier">filters</span>={})
689
+ <span class="ruby-identifier">images</span> = <span class="ruby-identifier">arrayize</span>(<span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;offerings/image/&quot;</span>).<span class="ruby-constant">Image</span>)
690
+ <span class="ruby-identifier">images</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">img</span><span class="ruby-operator">|</span> <span class="ruby-identifier">img</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;image&quot;</span>][<span class="ruby-identifier">img</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_i</span>]}
691
+ <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:order</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;Location&quot;</span>
692
+ <span class="ruby-identifier">images</span> = <span class="ruby-identifier">filter_and_sort</span>(<span class="ruby-identifier">images</span>, <span class="ruby-identifier">filters</span>)
693
+ <span class="ruby-keyword kw">end</span>
694
+ </pre>
695
+ </div>
696
+ </div>
697
+ </div>
698
+
699
+ <div id="method-M000145" class="method-detail">
700
+ <a name="M000145"></a>
701
+
702
+ <div class="method-heading">
703
+ <a href="#M000145" class="method-signature">
704
+ <span class="method-name">describe_instance</span><span class="method-args">(instance_id)</span>
705
+ </a>
706
+ </div>
707
+
708
+ <div class="method-description">
709
+ <p><a class="source-toggle" href="#"
710
+ onclick="toggleCode('M000145-source');return false;">[Source]</a></p>
711
+ <div class="method-source-code" id="M000145-source">
712
+ <pre>
713
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 434</span>
714
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_instance</span>(<span class="ruby-identifier">instance_id</span>)
715
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;instances/#{instance_id}&quot;</span>).<span class="ruby-constant">Instance</span>
716
+ <span class="ruby-identifier">response</span>[<span class="ruby-value str">&quot;Status&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;instance&quot;</span>][<span class="ruby-identifier">response</span>.<span class="ruby-constant">Status</span>.<span class="ruby-identifier">to_i</span>]
717
+ <span class="ruby-identifier">response</span>
718
+ <span class="ruby-keyword kw">end</span>
719
+ </pre>
720
+ </div>
721
+ </div>
722
+ </div>
723
+
724
+ <div id="method-M000146" class="method-detail">
725
+ <a name="M000146"></a>
726
+
727
+ <div class="method-heading">
728
+ <a href="#M000146" class="method-signature">
729
+ <span class="method-name">describe_instances</span><span class="method-args">(filters={})</span>
730
+ </a>
731
+ </div>
732
+
733
+ <div class="method-description">
734
+ <p><a class="source-toggle" href="#"
735
+ onclick="toggleCode('M000146-source');return false;">[Source]</a></p>
736
+ <div class="method-source-code" id="M000146-source">
737
+ <pre>
738
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 444</span>
739
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_instances</span>(<span class="ruby-identifier">filters</span>={})
740
+ <span class="ruby-identifier">instances</span> = <span class="ruby-identifier">arrayize</span>(<span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;instances&quot;</span>).<span class="ruby-constant">Instance</span>)
741
+
742
+ <span class="ruby-identifier">instances</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">instance</span><span class="ruby-operator">|</span>
743
+ <span class="ruby-identifier">instance</span>[<span class="ruby-value str">&quot;Status&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;instance&quot;</span>][<span class="ruby-identifier">instance</span>.<span class="ruby-constant">Status</span>.<span class="ruby-identifier">to_i</span>]
744
+ <span class="ruby-keyword kw">end</span>
745
+
746
+ <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:order</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;LaunchTime&quot;</span>
747
+ <span class="ruby-identifier">instances</span> = <span class="ruby-identifier">filter_and_sort</span>(<span class="ruby-identifier">instances</span>, <span class="ruby-identifier">filters</span>)
748
+ <span class="ruby-keyword kw">end</span>
749
+ </pre>
750
+ </div>
751
+ </div>
752
+ </div>
753
+
754
+ <div id="method-M000123" class="method-detail">
755
+ <a name="M000123"></a>
756
+
757
+ <div class="method-heading">
758
+ <a href="#M000123" class="method-signature">
759
+ <span class="method-name">describe_key</span><span class="method-args">(name)</span>
760
+ </a>
761
+ </div>
762
+
763
+ <div class="method-description">
764
+ <p><a class="source-toggle" href="#"
765
+ onclick="toggleCode('M000123-source');return false;">[Source]</a></p>
766
+ <div class="method-source-code" id="M000123-source">
767
+ <pre>
768
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 216</span>
769
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_key</span>(<span class="ruby-identifier">name</span>)
770
+ <span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;/keys/#{name}&quot;</span>).<span class="ruby-constant">PublicKey</span>
771
+ <span class="ruby-keyword kw">end</span>
772
+ </pre>
773
+ </div>
774
+ </div>
775
+ </div>
776
+
777
+ <div id="method-M000126" class="method-detail">
778
+ <a name="M000126"></a>
779
+
780
+ <div class="method-heading">
781
+ <a href="#M000126" class="method-signature">
782
+ <span class="method-name">describe_keys</span><span class="method-args">()</span>
783
+ </a>
784
+ </div>
785
+
786
+ <div class="method-description">
787
+ <p><a class="source-toggle" href="#"
788
+ onclick="toggleCode('M000126-source');return false;">[Source]</a></p>
789
+ <div class="method-source-code" id="M000126-source">
790
+ <pre>
791
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 242</span>
792
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_keys</span>
793
+ <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/keys&quot;</span>).<span class="ruby-constant">PublicKey</span>
794
+ <span class="ruby-keyword kw">end</span>
795
+ </pre>
796
+ </div>
797
+ </div>
798
+ </div>
799
+
800
+ <div id="method-M000111" class="method-detail">
801
+ <a name="M000111"></a>
802
+
803
+ <div class="method-heading">
804
+ <a href="#M000111" class="method-signature">
805
+ <span class="method-name">describe_locations</span><span class="method-args">()</span>
806
+ </a>
807
+ </div>
808
+
809
+ <div class="method-description">
810
+ <p>
811
+ Get a list of data centers
812
+ </p>
813
+ <p><a class="source-toggle" href="#"
814
+ onclick="toggleCode('M000111-source');return false;">[Source]</a></p>
815
+ <div class="method-source-code" id="M000111-source">
816
+ <pre>
817
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 92</span>
818
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_locations</span>
819
+ <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/locations&quot;</span>).<span class="ruby-constant">Location</span>
820
+ <span class="ruby-keyword kw">end</span>
821
+ </pre>
822
+ </div>
823
+ </div>
824
+ </div>
825
+
826
+ <div id="method-M000133" class="method-detail">
827
+ <a name="M000133"></a>
828
+
829
+ <div class="method-heading">
830
+ <a href="#M000133" class="method-signature">
831
+ <span class="method-name">describe_storage</span><span class="method-args">(volume_id=nil)</span>
832
+ </a>
833
+ </div>
834
+
835
+ <div class="method-description">
836
+ <p><a class="source-toggle" href="#"
837
+ onclick="toggleCode('M000133-source');return false;">[Source]</a></p>
838
+ <div class="method-source-code" id="M000133-source">
839
+ <pre>
840
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 319</span>
841
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_storage</span>(<span class="ruby-identifier">volume_id</span>=<span class="ruby-keyword kw">nil</span>)
842
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">volume_id</span> <span class="ruby-value">? </span><span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;/storage/#{volume_id}&quot;</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/storage&quot;</span>)
843
+
844
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
845
+ <span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
846
+ <span class="ruby-identifier">v</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;storage&quot;</span>][<span class="ruby-identifier">v</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_i</span>]
847
+ <span class="ruby-keyword kw">end</span>
848
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>
849
+ <span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>[<span class="ruby-value str">&quot;State&quot;</span>] = <span class="ruby-ivar">@states</span>[<span class="ruby-value str">&quot;storage&quot;</span>][<span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_i</span>]
850
+ <span class="ruby-keyword kw">else</span>
851
+ <span class="ruby-keyword kw">return</span> []
852
+ <span class="ruby-keyword kw">end</span>
853
+
854
+ <span class="ruby-identifier">response</span>.<span class="ruby-constant">Volume</span>
855
+ <span class="ruby-keyword kw">end</span>
856
+ </pre>
857
+ </div>
858
+ </div>
859
+ </div>
860
+
861
+ <div id="method-M000127" class="method-detail">
862
+ <a name="M000127"></a>
863
+
864
+ <div class="method-heading">
865
+ <a href="#M000127" class="method-signature">
866
+ <span class="method-name">describe_unused_keys</span><span class="method-args">()</span>
867
+ </a>
868
+ </div>
869
+
870
+ <div class="method-description">
871
+ <p><a class="source-toggle" href="#"
872
+ onclick="toggleCode('M000127-source');return false;">[Source]</a></p>
873
+ <div class="method-source-code" id="M000127-source">
874
+ <pre>
875
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 246</span>
876
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_unused_keys</span>
877
+ <span class="ruby-identifier">describe_keys</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-constant">Instances</span> <span class="ruby-operator">==</span> {}}
878
+ <span class="ruby-keyword kw">end</span>
879
+ </pre>
880
+ </div>
881
+ </div>
882
+ </div>
883
+
884
+ <div id="method-M000135" class="method-detail">
885
+ <a name="M000135"></a>
886
+
887
+ <div class="method-heading">
888
+ <span class="method-name">describe_volume</span><span class="method-args">(volume_id=nil)</span>
889
+ </div>
890
+
891
+ <div class="method-description">
892
+ <p>
893
+ Alias for <a href="IBMSmartCloud.html#M000133">describe_storage</a>
894
+ </p>
895
+ </div>
896
+ </div>
897
+
898
+ <div id="method-M000131" class="method-detail">
899
+ <a name="M000131"></a>
900
+
901
+ <div class="method-heading">
902
+ <a href="#M000131" class="method-signature">
903
+ <span class="method-name">describe_volume_offerings</span><span class="method-args">(location=nil, name=nil)</span>
904
+ </a>
905
+ </div>
906
+
907
+ <div class="method-description">
908
+ <p><a class="source-toggle" href="#"
909
+ onclick="toggleCode('M000131-source');return false;">[Source]</a></p>
910
+ <div class="method-source-code" id="M000131-source">
911
+ <pre>
912
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 283</span>
913
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe_volume_offerings</span>(<span class="ruby-identifier">location</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">name</span>=<span class="ruby-keyword kw">nil</span>)
914
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;/offerings/storage&quot;</span>)
915
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">location</span>
916
+ <span class="ruby-identifier">filtered_by_location</span> = <span class="ruby-identifier">response</span>.<span class="ruby-constant">Offerings</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-constant">Location</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">location</span>.<span class="ruby-identifier">to_s</span>}
917
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>
918
+ <span class="ruby-identifier">filtered_by_location</span>.<span class="ruby-identifier">detect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-constant">Name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>}
919
+ <span class="ruby-keyword kw">else</span>
920
+ <span class="ruby-identifier">filtered_by_location</span>
921
+ <span class="ruby-keyword kw">end</span>
922
+ <span class="ruby-keyword kw">else</span>
923
+ <span class="ruby-identifier">response</span>.<span class="ruby-constant">Offerings</span>
924
+ <span class="ruby-keyword kw">end</span>
925
+ <span class="ruby-keyword kw">end</span>
926
+ </pre>
927
+ </div>
928
+ </div>
929
+ </div>
930
+
931
+ <div id="method-M000134" class="method-detail">
932
+ <a name="M000134"></a>
933
+
934
+ <div class="method-heading">
935
+ <span class="method-name">describe_volumes</span><span class="method-args">(volume_id=nil)</span>
936
+ </div>
937
+
938
+ <div class="method-description">
939
+ <p>
940
+ Alias for <a href="IBMSmartCloud.html#M000133">describe_storage</a>
941
+ </p>
942
+ </div>
943
+ </div>
944
+
945
+ <div id="method-M000150" class="method-detail">
946
+ <a name="M000150"></a>
947
+
948
+ <div class="method-heading">
949
+ <a href="#M000150" class="method-signature">
950
+ <span class="method-name">display_images</span><span class="method-args">(filters={})</span>
951
+ </a>
952
+ </div>
953
+
954
+ <div class="method-description">
955
+ <p><a class="source-toggle" href="#"
956
+ onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
957
+ <div class="method-source-code" id="M000150-source">
958
+ <pre>
959
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 487</span>
960
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_images</span>(<span class="ruby-identifier">filters</span>={})
961
+ <span class="ruby-identifier">images</span> = <span class="ruby-identifier">describe_images</span>(<span class="ruby-identifier">filters</span>)
962
+
963
+ <span class="ruby-identifier">log</span> = <span class="ruby-identifier">images</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
964
+ <span class="ruby-identifier">types</span> = <span class="ruby-identifier">arrayize</span>(<span class="ruby-identifier">i</span>.<span class="ruby-constant">SupportedInstanceTypes</span>.<span class="ruby-constant">InstanceType</span>).<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:ID</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-value str">&quot;[INSTANCE TYPE UNKNOWN]&quot;</span>
965
+ <span class="ruby-node">&quot;#{i.ID} | #{i.Location} | #{i.Name} | #{types}&quot;</span>
966
+ <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
967
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">&quot;\n#{log}&quot;</span>
968
+ <span class="ruby-keyword kw">end</span>
969
+ </pre>
970
+ </div>
971
+ </div>
972
+ </div>
973
+
974
+ <div id="method-M000147" class="method-detail">
975
+ <a name="M000147"></a>
976
+
977
+ <div class="method-heading">
978
+ <a href="#M000147" class="method-signature">
979
+ <span class="method-name">display_instances</span><span class="method-args">(filters={})</span>
980
+ </a>
981
+ </div>
982
+
983
+ <div class="method-description">
984
+ <p><a class="source-toggle" href="#"
985
+ onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
986
+ <div class="method-source-code" id="M000147-source">
987
+ <pre>
988
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 460</span>
989
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_instances</span>(<span class="ruby-identifier">filters</span>={})
990
+ <span class="ruby-identifier">instances</span> = <span class="ruby-identifier">describe_instances</span>(<span class="ruby-identifier">filters</span>)
991
+
992
+ <span class="ruby-identifier">log</span> = <span class="ruby-node">%{#{&quot;Started&quot;.ljust(18)} | #{&quot;Instance&quot;.ljust(8)} | #{&quot;Image&quot;.ljust(9)} | #{&quot;Loc&quot;.ljust(3)} | #{&quot;Status&quot;.ljust(10)} | #{&quot;KeyName&quot;.ljust(15)} | #{&quot;IP&quot;.ljust(15)} | Name\n}</span>
993
+ <span class="ruby-identifier">log</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">instances</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ins</span><span class="ruby-operator">|</span>
994
+ <span class="ruby-node">&quot;#{DateTime.parse(ins.LaunchTime).strftime(&quot;%Y-%m-%d %I:%M%p&quot;)} | #{ins.ID.ljust(8)} | #{ins.ImageID.ljust(9)} | #{ins.Location.ljust(3)} | #{ins.Status[0..9].ljust(10)} | #{(ins.KeyName || &quot;&quot;).strip[0..14].ljust(15)} | #{(ins.IP.strip==&quot;&quot; ? '[NONE]' : ins.IP.strip).to_s.ljust(15)} | #{ins.Name}&quot;</span>
995
+ <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
996
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">&quot;\n#{log}&quot;</span>
997
+ <span class="ruby-keyword kw">end</span>
998
+ </pre>
999
+ </div>
1000
+ </div>
1001
+ </div>
1002
+
1003
+ <div id="method-M000129" class="method-detail">
1004
+ <a name="M000129"></a>
1005
+
1006
+ <div class="method-heading">
1007
+ <a href="#M000129" class="method-signature">
1008
+ <span class="method-name">display_keys</span><span class="method-args">()</span>
1009
+ </a>
1010
+ </div>
1011
+
1012
+ <div class="method-description">
1013
+ <p><a class="source-toggle" href="#"
1014
+ onclick="toggleCode('M000129-source');return false;">[Source]</a></p>
1015
+ <div class="method-source-code" id="M000129-source">
1016
+ <pre>
1017
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 266</span>
1018
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_keys</span>
1019
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-value str">&quot;\nKeyName&quot;</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">50</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; | Instance ID's\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">describe_keys</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">key</span>.<span class="ruby-constant">KeyName</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">50</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; | &quot;</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">key</span>.<span class="ruby-constant">Instances</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-value str">'[]'</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">key</span>.<span class="ruby-constant">Instances</span>.<span class="ruby-constant">InstanceID</span>.<span class="ruby-identifier">inspect</span> )}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
1020
+ <span class="ruby-keyword kw">end</span>
1021
+ </pre>
1022
+ </div>
1023
+ </div>
1024
+ </div>
1025
+
1026
+ <div id="method-M000112" class="method-detail">
1027
+ <a name="M000112"></a>
1028
+
1029
+ <div class="method-heading">
1030
+ <a href="#M000112" class="method-signature">
1031
+ <span class="method-name">display_locations</span><span class="method-args">()</span>
1032
+ </a>
1033
+ </div>
1034
+
1035
+ <div class="method-description">
1036
+ <p><a class="source-toggle" href="#"
1037
+ onclick="toggleCode('M000112-source');return false;">[Source]</a></p>
1038
+ <div class="method-source-code" id="M000112-source">
1039
+ <pre>
1040
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 96</span>
1041
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_locations</span>
1042
+ <span class="ruby-identifier">log</span> = <span class="ruby-identifier">describe_locations</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">loc</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{loc.ID.ljust(4)} | #{loc.Location.ljust(15)} | #{loc.Name}&quot;</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
1043
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">&quot;\n#{log}&quot;</span>
1044
+ <span class="ruby-keyword kw">end</span>
1045
+ </pre>
1046
+ </div>
1047
+ </div>
1048
+ </div>
1049
+
1050
+ <div id="method-M000137" class="method-detail">
1051
+ <a name="M000137"></a>
1052
+
1053
+ <div class="method-heading">
1054
+ <span class="method-name">display_storage</span><span class="method-args">(filter={})</span>
1055
+ </div>
1056
+
1057
+ <div class="method-description">
1058
+ <p>
1059
+ Alias for <a href="IBMSmartCloud.html#M000136">display_volumes</a>
1060
+ </p>
1061
+ </div>
1062
+ </div>
1063
+
1064
+ <div id="method-M000136" class="method-detail">
1065
+ <a name="M000136"></a>
1066
+
1067
+ <div class="method-heading">
1068
+ <a href="#M000136" class="method-signature">
1069
+ <span class="method-name">display_volumes</span><span class="method-args">(filter={})</span>
1070
+ </a>
1071
+ </div>
1072
+
1073
+ <div class="method-description">
1074
+ <p><a class="source-toggle" href="#"
1075
+ onclick="toggleCode('M000136-source');return false;">[Source]</a></p>
1076
+ <div class="method-source-code" id="M000136-source">
1077
+ <pre>
1078
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 341</span>
1079
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_volumes</span>(<span class="ruby-identifier">filter</span>={})
1080
+ <span class="ruby-identifier">vols</span> = <span class="ruby-identifier">describe_volumes</span>
1081
+ <span class="ruby-identifier">vols</span> = <span class="ruby-identifier">filter_and_sort</span>(<span class="ruby-identifier">vols</span>, <span class="ruby-identifier">filter</span>)
1082
+
1083
+ <span class="ruby-identifier">log</span> = <span class="ruby-value str">&quot;\nVolume | State | Loc | Name\n&quot;</span>
1084
+ <span class="ruby-identifier">volsz</span> = <span class="ruby-identifier">vols</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">vol</span><span class="ruby-operator">|</span> <span class="ruby-identifier">vol</span>.<span class="ruby-constant">ID</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">6</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; | &quot;</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">vol</span>.<span class="ruby-constant">State</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">9</span>].<span class="ruby-identifier">ljust</span>(<span class="ruby-value">10</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-value str">'?'</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">10</span>)) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; | &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vol</span>.<span class="ruby-constant">Location</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">4</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; | &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vol</span>.<span class="ruby-constant">Name</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
1085
+ <span class="ruby-identifier">log</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">volsz</span>
1086
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-identifier">log</span>
1087
+ <span class="ruby-keyword kw">true</span>
1088
+ <span class="ruby-keyword kw">end</span>
1089
+ </pre>
1090
+ </div>
1091
+ </div>
1092
+ </div>
1093
+
1094
+ <div id="method-M000121" class="method-detail">
1095
+ <a name="M000121"></a>
1096
+
1097
+ <div class="method-heading">
1098
+ <a href="#M000121" class="method-signature">
1099
+ <span class="method-name">generate_keypair</span><span class="method-args">(name)</span>
1100
+ </a>
1101
+ </div>
1102
+
1103
+ <div class="method-description">
1104
+ <p><a class="source-toggle" href="#"
1105
+ onclick="toggleCode('M000121-source');return false;">[Source]</a></p>
1106
+ <div class="method-source-code" id="M000121-source">
1107
+ <pre>
1108
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 204</span>
1109
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_keypair</span>(<span class="ruby-identifier">name</span>)
1110
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">post</span>(<span class="ruby-value str">&quot;/keys&quot;</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>)
1111
+ <span class="ruby-identifier">response</span>.<span class="ruby-constant">PrivateKey</span>.<span class="ruby-constant">KeyMaterial</span>
1112
+ <span class="ruby-keyword kw">end</span>
1113
+ </pre>
1114
+ </div>
1115
+ </div>
1116
+ </div>
1117
+
1118
+ <div id="method-M000153" class="method-detail">
1119
+ <a name="M000153"></a>
1120
+
1121
+ <div class="method-heading">
1122
+ <a href="#M000153" class="method-signature">
1123
+ <span class="method-name">get</span><span class="method-args">(path)</span>
1124
+ </a>
1125
+ </div>
1126
+
1127
+ <div class="method-description">
1128
+ <p><a class="source-toggle" href="#"
1129
+ onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
1130
+ <div class="method-source-code" id="M000153-source">
1131
+ <pre>
1132
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 512</span>
1133
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">path</span>)
1134
+ <span class="ruby-identifier">output</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">get</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@api_url</span>, <span class="ruby-identifier">path</span>), <span class="ruby-identifier">:accept</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:response</span>
1135
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">XmlSimple</span>.<span class="ruby-identifier">xml_in</span>(<span class="ruby-identifier">output</span>, {<span class="ruby-value str">'ForceArray'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>})
1136
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1137
+ <span class="ruby-identifier">raise_restclient_error</span>(<span class="ruby-identifier">e</span>)
1138
+ <span class="ruby-keyword kw">end</span>
1139
+ </pre>
1140
+ </div>
1141
+ </div>
1142
+ </div>
1143
+
1144
+ <div id="method-M000114" class="method-detail">
1145
+ <a name="M000114"></a>
1146
+
1147
+ <div class="method-heading">
1148
+ <a href="#M000114" class="method-signature">
1149
+ <span class="method-name">get_location_by_name</span><span class="method-args">(name)</span>
1150
+ </a>
1151
+ </div>
1152
+
1153
+ <div class="method-description">
1154
+ <p><a class="source-toggle" href="#"
1155
+ onclick="toggleCode('M000114-source');return false;">[Source]</a></p>
1156
+ <div class="method-source-code" id="M000114-source">
1157
+ <pre>
1158
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 142</span>
1159
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_location_by_name</span>(<span class="ruby-identifier">name</span>)
1160
+ <span class="ruby-identifier">locations</span> = <span class="ruby-identifier">describe_locations</span>
1161
+ <span class="ruby-identifier">locations</span>.<span class="ruby-identifier">detect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">loc</span><span class="ruby-operator">|</span> <span class="ruby-identifier">loc</span>.<span class="ruby-constant">Name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>}
1162
+ <span class="ruby-keyword kw">end</span>
1163
+ </pre>
1164
+ </div>
1165
+ </div>
1166
+ </div>
1167
+
1168
+ <div id="method-M000110" class="method-detail">
1169
+ <a name="M000110"></a>
1170
+
1171
+ <div class="method-heading">
1172
+ <a href="#M000110" class="method-signature">
1173
+ <span class="method-name">help</span><span class="method-args">(method=nil)</span>
1174
+ </a>
1175
+ </div>
1176
+
1177
+ <div class="method-description">
1178
+ <p><a class="source-toggle" href="#"
1179
+ onclick="toggleCode('M000110-source');return false;">[Source]</a></p>
1180
+ <div class="method-source-code" id="M000110-source">
1181
+ <pre>
1182
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 60</span>
1183
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">help</span>(<span class="ruby-identifier">method</span>=<span class="ruby-keyword kw">nil</span>)
1184
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method</span>
1185
+ <span class="ruby-identifier">args</span> = (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">method_help</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>])
1186
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
1187
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>
1188
+ <span class="ruby-keyword kw">else</span>
1189
+ <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
1190
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
1191
+ <span class="ruby-comment cmt"># If an argument is required, just list it</span>
1192
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span><span class="ruby-operator">==</span><span class="ruby-identifier">:req</span>
1193
+ <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_s</span>
1194
+ <span class="ruby-comment cmt"># If it's optional, list it in brackets</span>
1195
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span><span class="ruby-operator">==</span><span class="ruby-identifier">:opt</span>
1196
+ <span class="ruby-node">&quot;[#{arg.keys.first.to_s}]&quot;</span>
1197
+ <span class="ruby-comment cmt"># If there is an array of options, list them</span>
1198
+ <span class="ruby-keyword kw">else</span>
1199
+ <span class="ruby-node">&quot;#{arg.keys.first.to_s}=&gt;#{arg.values.first.inspect}&quot;</span>
1200
+ <span class="ruby-keyword kw">end</span>
1201
+ <span class="ruby-keyword kw">else</span>
1202
+ <span class="ruby-identifier">arg</span>
1203
+ <span class="ruby-keyword kw">end</span>
1204
+ <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)
1205
+
1206
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{method.to_s}(#{args})&quot;</span>
1207
+ <span class="ruby-keyword kw">end</span>
1208
+ <span class="ruby-keyword kw">else</span>
1209
+ <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">public_methods</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier">public_methods</span> <span class="ruby-operator">-</span> [<span class="ruby-value str">'post'</span>,<span class="ruby-value str">'get'</span>,<span class="ruby-value str">'put'</span>,<span class="ruby-value str">'delete'</span>,<span class="ruby-value str">'logger'</span>,<span class="ruby-value str">'logger='</span>,<span class="ruby-value str">'help'</span>]
1210
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
1211
+ <span class="ruby-keyword kw">end</span>
1212
+ <span class="ruby-keyword kw">end</span>
1213
+ </pre>
1214
+ </div>
1215
+ </div>
1216
+ </div>
1217
+
1218
+ <div id="method-M000139" class="method-detail">
1219
+ <a name="M000139"></a>
1220
+
1221
+ <div class="method-heading">
1222
+ <a href="#M000139" class="method-signature">
1223
+ <span class="method-name">instance_state_is?</span><span class="method-args">(instance_id, state_string)</span>
1224
+ </a>
1225
+ </div>
1226
+
1227
+ <div class="method-description">
1228
+ <p><a class="source-toggle" href="#"
1229
+ onclick="toggleCode('M000139-source');return false;">[Source]</a></p>
1230
+ <div class="method-source-code" id="M000139-source">
1231
+ <pre>
1232
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 376</span>
1233
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">instance_state_is?</span>(<span class="ruby-identifier">instance_id</span>, <span class="ruby-identifier">state_string</span>)
1234
+ <span class="ruby-identifier">v</span> = <span class="ruby-identifier">describe_instance</span>(<span class="ruby-identifier">instance_id</span>)
1235
+
1236
+ <span class="ruby-ivar">@last_instance_state</span><span class="ruby-operator">||=</span>{}
1237
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_instance_state</span>[<span class="ruby-identifier">instance_id</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-constant">Status</span>
1238
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;Instance: #{instance_id}; Current State: #{v.Status}; Waiting for: #{state_string.to_s.upcase}&quot;</span> <span class="ruby-comment cmt"># log it every time it changes</span>
1239
+ <span class="ruby-keyword kw">end</span>
1240
+ <span class="ruby-ivar">@last_instance_state</span>[<span class="ruby-identifier">instance_id</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-constant">Status</span>
1241
+
1242
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-constant">Status</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">state_string</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
1243
+ <span class="ruby-identifier">v</span>
1244
+ <span class="ruby-keyword kw">else</span>
1245
+ <span class="ruby-keyword kw">false</span>
1246
+ <span class="ruby-keyword kw">end</span>
1247
+ <span class="ruby-keyword kw">end</span>
1248
+ </pre>
1249
+ </div>
1250
+ </div>
1251
+ </div>
1252
+
1253
+ <div id="method-M000141" class="method-detail">
1254
+ <a name="M000141"></a>
1255
+
1256
+ <div class="method-heading">
1257
+ <a href="#M000141" class="method-signature">
1258
+ <span class="method-name">poll_for_instance_state</span><span class="method-args">(instance_id, state_string, polling_interval=5)</span>
1259
+ </a>
1260
+ </div>
1261
+
1262
+ <div class="method-description">
1263
+ <p><a class="source-toggle" href="#"
1264
+ onclick="toggleCode('M000141-source');return false;">[Source]</a></p>
1265
+ <div class="method-source-code" id="M000141-source">
1266
+ <pre>
1267
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 405</span>
1268
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">poll_for_instance_state</span>(<span class="ruby-identifier">instance_id</span>, <span class="ruby-identifier">state_string</span>, <span class="ruby-identifier">polling_interval</span>=<span class="ruby-value">5</span>)
1269
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;Polling for instance #{instance_id} to acquire state #{state_string} (interval: #{polling_interval})...&quot;</span>
1270
+ <span class="ruby-keyword kw">while</span>(<span class="ruby-keyword kw">true</span>)
1271
+ <span class="ruby-identifier">descriptor</span> = <span class="ruby-identifier">instance_state_is?</span>(<span class="ruby-identifier">instance_id</span>, <span class="ruby-identifier">state_string</span>)
1272
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">descriptor</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">descriptor</span>
1273
+ <span class="ruby-identifier">sleep</span>(<span class="ruby-identifier">polling_interval</span>)
1274
+ <span class="ruby-keyword kw">end</span>
1275
+ <span class="ruby-keyword kw">end</span>
1276
+ </pre>
1277
+ </div>
1278
+ </div>
1279
+ </div>
1280
+
1281
+ <div id="method-M000140" class="method-detail">
1282
+ <a name="M000140"></a>
1283
+
1284
+ <div class="method-heading">
1285
+ <a href="#M000140" class="method-signature">
1286
+ <span class="method-name">poll_for_volume_state</span><span class="method-args">(volume_id, state_string, polling_interval=5)</span>
1287
+ </a>
1288
+ </div>
1289
+
1290
+ <div class="method-description">
1291
+ <p><a class="source-toggle" href="#"
1292
+ onclick="toggleCode('M000140-source');return false;">[Source]</a></p>
1293
+ <div class="method-source-code" id="M000140-source">
1294
+ <pre>
1295
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 394</span>
1296
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">poll_for_volume_state</span>(<span class="ruby-identifier">volume_id</span>, <span class="ruby-identifier">state_string</span>, <span class="ruby-identifier">polling_interval</span>=<span class="ruby-value">5</span>)
1297
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;Polling for volume #{volume_id} to acquire state #{state_string} (interval: #{polling_interval})...&quot;</span>
1298
+ <span class="ruby-keyword kw">while</span>(<span class="ruby-keyword kw">true</span>)
1299
+ <span class="ruby-identifier">descriptor</span> = <span class="ruby-identifier">storage_state_is?</span>(<span class="ruby-identifier">volume_id</span>, <span class="ruby-identifier">state_string</span>)
1300
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">descriptor</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">descriptor</span>
1301
+ <span class="ruby-identifier">sleep</span>(<span class="ruby-identifier">polling_interval</span>)
1302
+ <span class="ruby-keyword kw">end</span>
1303
+ <span class="ruby-keyword kw">end</span>
1304
+ </pre>
1305
+ </div>
1306
+ </div>
1307
+ </div>
1308
+
1309
+ <div id="method-M000154" class="method-detail">
1310
+ <a name="M000154"></a>
1311
+
1312
+ <div class="method-heading">
1313
+ <a href="#M000154" class="method-signature">
1314
+ <span class="method-name">post</span><span class="method-args">(path, params={}, param_remap=nil)</span>
1315
+ </a>
1316
+ </div>
1317
+
1318
+ <div class="method-description">
1319
+ <p><a class="source-toggle" href="#"
1320
+ onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
1321
+ <div class="method-source-code" id="M000154-source">
1322
+ <pre>
1323
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 519</span>
1324
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>={}, <span class="ruby-identifier">param_remap</span>=<span class="ruby-keyword kw">nil</span>)
1325
+ <span class="ruby-identifier">param_string</span> = <span class="ruby-identifier">make_param_string</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">param_remap</span>)
1326
+ <span class="ruby-identifier">output</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">post</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@api_url</span>, <span class="ruby-identifier">path</span>), <span class="ruby-identifier">param_string</span>, <span class="ruby-identifier">:accept</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:response</span>
1327
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">XmlSimple</span>.<span class="ruby-identifier">xml_in</span>(<span class="ruby-identifier">output</span>, {<span class="ruby-value str">'ForceArray'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>})
1328
+ <span class="ruby-identifier">response</span>
1329
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1330
+ <span class="ruby-identifier">raise_restclient_error</span>(<span class="ruby-identifier">e</span>)
1331
+ <span class="ruby-keyword kw">end</span>
1332
+ </pre>
1333
+ </div>
1334
+ </div>
1335
+ </div>
1336
+
1337
+ <div id="method-M000152" class="method-detail">
1338
+ <a name="M000152"></a>
1339
+
1340
+ <div class="method-heading">
1341
+ <a href="#M000152" class="method-signature">
1342
+ <span class="method-name">put</span><span class="method-args">(path, params={}, param_remap={})</span>
1343
+ </a>
1344
+ </div>
1345
+
1346
+ <div class="method-description">
1347
+ <p><a class="source-toggle" href="#"
1348
+ onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
1349
+ <div class="method-source-code" id="M000152-source">
1350
+ <pre>
1351
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 504</span>
1352
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">params</span>={}, <span class="ruby-identifier">param_remap</span>={})
1353
+ <span class="ruby-identifier">param_string</span> = <span class="ruby-identifier">make_param_string</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">param_remap</span>)
1354
+ <span class="ruby-identifier">output</span> = <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">put</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@api_url</span>, <span class="ruby-identifier">path</span>), <span class="ruby-identifier">param_string</span>, <span class="ruby-identifier">:accept</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:response</span>
1355
+ <span class="ruby-identifier">response</span> = <span class="ruby-constant">XmlSimple</span>.<span class="ruby-identifier">xml_in</span>(<span class="ruby-identifier">output</span>, {<span class="ruby-value str">'ForceArray'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>})
1356
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1357
+ <span class="ruby-identifier">raise_restclient_error</span>(<span class="ruby-identifier">e</span>)
1358
+ <span class="ruby-keyword kw">end</span>
1359
+ </pre>
1360
+ </div>
1361
+ </div>
1362
+ </div>
1363
+
1364
+ <div id="method-M000122" class="method-detail">
1365
+ <a name="M000122"></a>
1366
+
1367
+ <div class="method-heading">
1368
+ <a href="#M000122" class="method-signature">
1369
+ <span class="method-name">remove_keypair</span><span class="method-args">(name)</span>
1370
+ </a>
1371
+ </div>
1372
+
1373
+ <div class="method-description">
1374
+ <p><a class="source-toggle" href="#"
1375
+ onclick="toggleCode('M000122-source');return false;">[Source]</a></p>
1376
+ <div class="method-source-code" id="M000122-source">
1377
+ <pre>
1378
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 210</span>
1379
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_keypair</span>(<span class="ruby-identifier">name</span>)
1380
+ <span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;/keys/#{name}&quot;</span>)
1381
+ <span class="ruby-keyword kw">true</span>
1382
+ <span class="ruby-keyword kw">end</span>
1383
+ </pre>
1384
+ </div>
1385
+ </div>
1386
+ </div>
1387
+
1388
+ <div id="method-M000144" class="method-detail">
1389
+ <a name="M000144"></a>
1390
+
1391
+ <div class="method-heading">
1392
+ <a href="#M000144" class="method-signature">
1393
+ <span class="method-name">restart_instance</span><span class="method-args">(instance_id)</span>
1394
+ </a>
1395
+ </div>
1396
+
1397
+ <div class="method-description">
1398
+ <p><a class="source-toggle" href="#"
1399
+ onclick="toggleCode('M000144-source');return false;">[Source]</a></p>
1400
+ <div class="method-source-code" id="M000144-source">
1401
+ <pre>
1402
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 428</span>
1403
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart_instance</span>(<span class="ruby-identifier">instance_id</span>)
1404
+ <span class="ruby-identifier">put</span>(<span class="ruby-node">&quot;/instances/#{instance_id}&quot;</span>, <span class="ruby-identifier">:state</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;restart&quot;</span>)
1405
+ <span class="ruby-keyword kw">true</span>
1406
+ <span class="ruby-keyword kw">end</span>
1407
+ </pre>
1408
+ </div>
1409
+ </div>
1410
+ </div>
1411
+
1412
+ <div id="method-M000138" class="method-detail">
1413
+ <a name="M000138"></a>
1414
+
1415
+ <div class="method-heading">
1416
+ <a href="#M000138" class="method-signature">
1417
+ <span class="method-name">storage_state_is?</span><span class="method-args">(volume_id, state_string)</span>
1418
+ </a>
1419
+ </div>
1420
+
1421
+ <div class="method-description">
1422
+ <p><a class="source-toggle" href="#"
1423
+ onclick="toggleCode('M000138-source');return false;">[Source]</a></p>
1424
+ <div class="method-source-code" id="M000138-source">
1425
+ <pre>
1426
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 358</span>
1427
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_state_is?</span>(<span class="ruby-identifier">volume_id</span>, <span class="ruby-identifier">state_string</span>)
1428
+ <span class="ruby-identifier">v</span> = <span class="ruby-identifier">describe_storage</span>(<span class="ruby-identifier">volume_id</span>)
1429
+
1430
+ <span class="ruby-ivar">@last_storage_state</span><span class="ruby-operator">||=</span>{}
1431
+ <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@last_storage_state</span>[<span class="ruby-identifier">volume_id</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-constant">State</span>
1432
+ <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;Volume: #{volume_id}; Current State: #{v.State}; Waiting for: #{state_string.to_s.upcase} &quot;</span> <span class="ruby-comment cmt"># log it every time it changes</span>
1433
+ <span class="ruby-keyword kw">end</span>
1434
+ <span class="ruby-ivar">@last_storage_state</span>[<span class="ruby-identifier">volume_id</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-constant">State</span>
1435
+
1436
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-constant">State</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">state_string</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
1437
+ <span class="ruby-identifier">v</span>
1438
+ <span class="ruby-keyword kw">else</span>
1439
+ <span class="ruby-keyword kw">false</span>
1440
+ <span class="ruby-keyword kw">end</span>
1441
+
1442
+ <span class="ruby-keyword kw">end</span>
1443
+ </pre>
1444
+ </div>
1445
+ </div>
1446
+ </div>
1447
+
1448
+ <div id="method-M000130" class="method-detail">
1449
+ <a name="M000130"></a>
1450
+
1451
+ <div class="method-heading">
1452
+ <a href="#M000130" class="method-signature">
1453
+ <span class="method-name">supported_instance_types</span><span class="method-args">(image_id)</span>
1454
+ </a>
1455
+ </div>
1456
+
1457
+ <div class="method-description">
1458
+ <p><a class="source-toggle" href="#"
1459
+ onclick="toggleCode('M000130-source');return false;">[Source]</a></p>
1460
+ <div class="method-source-code" id="M000130-source">
1461
+ <pre>
1462
+ <span class="ruby-comment cmt"># File lib/smartcloud.rb, line 271</span>
1463
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">supported_instance_types</span>(<span class="ruby-identifier">image_id</span>)
1464
+ <span class="ruby-identifier">img</span>=<span class="ruby-identifier">describe_image</span>(<span class="ruby-identifier">image_id</span>)
1465
+ <span class="ruby-identifier">arrayize</span>(<span class="ruby-identifier">img</span>.<span class="ruby-constant">SupportedInstanceTypes</span>.<span class="ruby-constant">InstanceType</span>).<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:ID</span>)
1466
+ <span class="ruby-keyword kw">end</span>
1467
+ </pre>
1468
+ </div>
1469
+ </div>
1470
+ </div>
1471
+
1472
+
1473
+ </div>
1474
+
1475
+
1476
+ </div>
1477
+
1478
+
1479
+ <div id="validator-badges">
1480
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1481
+ </div>
1482
+
1483
+ </body>
1484
+ </html>