swift-manager 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +19 -0
- data/LICENSE +201 -0
- data/README.md +56 -0
- data/README.rdoc +8 -0
- data/Rakefile +38 -0
- data/bin/swift-manager +337 -0
- data/docs/examples.txt +407 -0
- data/html/CloudShell.html +308 -0
- data/html/CloudShell/Context.html +403 -0
- data/html/Configurator.html +270 -0
- data/html/Formatter.html +272 -0
- data/html/Object.html +165 -0
- data/html/Parser.html +291 -0
- data/html/README_rdoc.html +102 -0
- data/html/SwiftClient.html +656 -0
- data/html/SwiftManager.html +181 -0
- data/html/bin/swift-manager.html +103 -0
- data/html/created.rid +9 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +119 -0
- data/html/js/darkfish.js +116 -0
- data/html/js/jquery.js +32 -0
- data/html/js/quicksearch.js +114 -0
- data/html/js/thickbox-compressed.js +10 -0
- data/html/lib/cloud_shell_rb.html +75 -0
- data/html/lib/configurator_rb.html +75 -0
- data/html/lib/formatter_rb.html +75 -0
- data/html/lib/parser_rb.html +75 -0
- data/html/lib/swift-manager_version_rb.html +75 -0
- data/html/lib/swift_client_rb.html +75 -0
- data/html/rdoc.css +763 -0
- data/lib/cloud_shell.rb +127 -0
- data/lib/configurator.rb +69 -0
- data/lib/formatter.rb +42 -0
- data/lib/parser.rb +60 -0
- data/lib/swift-manager_version.rb +21 -0
- data/lib/swift_client.rb +172 -0
- data/swift-manager.gemspec +48 -0
- data/swift-manager.rdoc +2 -0
- data/test/tc_nothing.rb +14 -0
- metadata +174 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>File: README.rdoc [swift-manager]</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="./js/jquery.js" type="text/javascript"
|
14
|
+
charset="utf-8"></script>
|
15
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript"
|
16
|
+
charset="utf-8"></script>
|
17
|
+
<script src="./js/quicksearch.js" type="text/javascript"
|
18
|
+
charset="utf-8"></script>
|
19
|
+
<script src="./js/darkfish.js" type="text/javascript"
|
20
|
+
charset="utf-8"></script>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body class="file">
|
24
|
+
<div id="metadata">
|
25
|
+
<div id="home-metadata">
|
26
|
+
<div id="home-section" class="section">
|
27
|
+
<h3 class="section-header">
|
28
|
+
<a href="./index.html">Home</a>
|
29
|
+
<a href="./index.html#classes">Classes</a>
|
30
|
+
<a href="./index.html#methods">Methods</a>
|
31
|
+
</h3>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="project-metadata">
|
36
|
+
|
37
|
+
|
38
|
+
<div id="fileindex-section" class="section project-section">
|
39
|
+
<h3 class="section-header">Files</h3>
|
40
|
+
<ul>
|
41
|
+
|
42
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
43
|
+
|
44
|
+
</ul>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
|
48
|
+
<div id="classindex-section" class="section project-section">
|
49
|
+
<h3 class="section-header">Class Index
|
50
|
+
<span class="search-toggle"><img src="./images/find.png"
|
51
|
+
height="16" width="16" alt="[+]"
|
52
|
+
title="show/hide quicksearch" /></span></h3>
|
53
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
54
|
+
<fieldset>
|
55
|
+
<legend>Quicksearch</legend>
|
56
|
+
<input type="text" name="quicksearch" value=""
|
57
|
+
class="quicksearch-field" />
|
58
|
+
</fieldset>
|
59
|
+
</form>
|
60
|
+
|
61
|
+
<ul class="link-list">
|
62
|
+
|
63
|
+
<li><a href="./CloudShell.html">CloudShell</a></li>
|
64
|
+
|
65
|
+
<li><a href="./CloudShell/Context.html">CloudShell::Context</a></li>
|
66
|
+
|
67
|
+
<li><a href="./Configurator.html">Configurator</a></li>
|
68
|
+
|
69
|
+
<li><a href="./Formatter.html">Formatter</a></li>
|
70
|
+
|
71
|
+
<li><a href="./Object.html">Object</a></li>
|
72
|
+
|
73
|
+
<li><a href="./Parser.html">Parser</a></li>
|
74
|
+
|
75
|
+
<li><a href="./SwiftClient.html">SwiftClient</a></li>
|
76
|
+
|
77
|
+
<li><a href="./SwiftManager.html">SwiftManager</a></li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="documentation">
|
88
|
+
|
89
|
+
<h1>swift-manager</h1>
|
90
|
+
|
91
|
+
<p>A Ruby OpenStack Swift Client</p>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<div id="validator-badges">
|
96
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
97
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
98
|
+
Rdoc Generator</a> 2</small>.</p>
|
99
|
+
</div>
|
100
|
+
</body>
|
101
|
+
</html>
|
102
|
+
|
@@ -0,0 +1,656 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: SwiftClient</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="./index.html">Home</a>
|
25
|
+
<a href="./index.html#classes">Classes</a>
|
26
|
+
<a href="./index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="./lib/swift_client_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/swift_client.rb">lib/swift_client.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link"><a href="Object.html">Object</a></p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-new">::new</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-i-create_container_no_cdn">#create_container_no_cdn</a></li>
|
71
|
+
|
72
|
+
<li><a href="#method-i-create_containers_no_cdn">#create_containers_no_cdn</a></li>
|
73
|
+
|
74
|
+
<li><a href="#method-i-create_objects">#create_objects</a></li>
|
75
|
+
|
76
|
+
<li><a href="#method-i-delete_container">#delete_container</a></li>
|
77
|
+
|
78
|
+
<li><a href="#method-i-delete_containers">#delete_containers</a></li>
|
79
|
+
|
80
|
+
<li><a href="#method-i-delete_objects">#delete_objects</a></li>
|
81
|
+
|
82
|
+
<li><a href="#method-i-generate_json_output">#generate_json_output</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-list_containers">#list_containers</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-list_objects">#list_objects</a></li>
|
87
|
+
|
88
|
+
</ul>
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<div id="project-metadata">
|
96
|
+
|
97
|
+
|
98
|
+
<div id="fileindex-section" class="section project-section">
|
99
|
+
<h3 class="section-header">Files</h3>
|
100
|
+
<ul>
|
101
|
+
|
102
|
+
<li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
|
103
|
+
|
104
|
+
</ul>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<div id="classindex-section" class="section project-section">
|
109
|
+
<h3 class="section-header">Class/Module Index
|
110
|
+
<span class="search-toggle"><img src="./images/find.png"
|
111
|
+
height="16" width="16" alt="[+]"
|
112
|
+
title="show/hide quicksearch" /></span></h3>
|
113
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
114
|
+
<fieldset>
|
115
|
+
<legend>Quicksearch</legend>
|
116
|
+
<input type="text" name="quicksearch" value=""
|
117
|
+
class="quicksearch-field" />
|
118
|
+
</fieldset>
|
119
|
+
</form>
|
120
|
+
|
121
|
+
<ul class="link-list">
|
122
|
+
|
123
|
+
<li><a href="./CloudShell.html">CloudShell</a></li>
|
124
|
+
|
125
|
+
<li><a href="./CloudShell/Context.html">CloudShell::Context</a></li>
|
126
|
+
|
127
|
+
<li><a href="./Configurator.html">Configurator</a></li>
|
128
|
+
|
129
|
+
<li><a href="./Formatter.html">Formatter</a></li>
|
130
|
+
|
131
|
+
<li><a href="./Object.html">Object</a></li>
|
132
|
+
|
133
|
+
<li><a href="./Parser.html">Parser</a></li>
|
134
|
+
|
135
|
+
<li><a href="./SwiftClient.html">SwiftClient</a></li>
|
136
|
+
|
137
|
+
<li><a href="./SwiftManager.html">SwiftManager</a></li>
|
138
|
+
|
139
|
+
</ul>
|
140
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div id="documentation">
|
148
|
+
<h1 class="class">SwiftClient</h1>
|
149
|
+
|
150
|
+
<div id="description" class="description">
|
151
|
+
<table class="rdoc-list"><tr><td class="rdoc-term"><p>Author</p></td>
|
152
|
+
<td>
|
153
|
+
<p>Murali Raju (<murali.raju@appliv.com>)</p>
|
154
|
+
</td></tr><tr><td class="rdoc-term"><p>Copyright</p></td>
|
155
|
+
<td>
|
156
|
+
<p>Copyright © 2011 Murali Raju.</p>
|
157
|
+
</td></tr><tr><td class="rdoc-term"><p>License</p></td>
|
158
|
+
<td>
|
159
|
+
<p>Apache License, Version 2.0</p>
|
160
|
+
</td></tr></table>
|
161
|
+
|
162
|
+
<p>Licensed under the Apache License, Version 2.0 (the “License”); you may not
|
163
|
+
use this file except in compliance with the License. You may obtain a copy
|
164
|
+
of the License at</p>
|
165
|
+
|
166
|
+
<p><a
|
167
|
+
href="http://www.apache.org/licenses/LICENSE-2.0">www.apache.org/licenses/LICENSE-2.0</a></p>
|
168
|
+
|
169
|
+
<p>Unless required by applicable law or agreed to in writing, software
|
170
|
+
distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
|
171
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
172
|
+
License for the specific language governing permissions and limitations
|
173
|
+
under the License.</p>
|
174
|
+
|
175
|
+
</div><!-- description -->
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<!-- Methods -->
|
190
|
+
|
191
|
+
<div id="public-class-method-details" class="method-section section">
|
192
|
+
<h3 class="section-header">Public Class Methods</h3>
|
193
|
+
|
194
|
+
|
195
|
+
<div id="new-method" class="method-detail ">
|
196
|
+
<a name="method-c-new"></a>
|
197
|
+
|
198
|
+
|
199
|
+
<div class="method-heading">
|
200
|
+
<span class="method-name">new</span><span
|
201
|
+
class="method-args">(type, auth_json)</span>
|
202
|
+
<span class="method-click-advice">click to toggle source</span>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
<div class="method-description">
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
<div class="method-source-code" id="new-source">
|
213
|
+
<pre>
|
214
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 20</span>
|
215
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">auth_json</span>)
|
216
|
+
<span class="ruby-identifier">auth_config</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">home</span> <span class="ruby-operator">+</span> <span class="ruby-node">"/.swift-manager/authentication/#{auth_json}.json"</span>)
|
217
|
+
<span class="ruby-ivar">@auth_params</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">auth_config</span>)
|
218
|
+
|
219
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
|
220
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">'s3'</span>
|
221
|
+
<span class="ruby-identifier">provider</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"provider"</span>]
|
222
|
+
<span class="ruby-identifier">aws_secret_access_key</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"keys"</span>][<span class="ruby-string">"secret_access_key"</span>]
|
223
|
+
<span class="ruby-identifier">aws_access_key_id</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"keys"</span>][<span class="ruby-string">"access_key_id"</span>]
|
224
|
+
<span class="ruby-keyword">begin</span>
|
225
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'Connecting to OpenStack Swift: S3 middleware...'</span>.<span class="ruby-identifier">color</span>(<span class="ruby-value">:green</span>)
|
226
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
227
|
+
<span class="ruby-ivar">@connection</span> = <span class="ruby-constant">Fog</span><span class="ruby-operator">::</span><span class="ruby-constant">Storage</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value">:provider</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">provider</span>,
|
228
|
+
<span class="ruby-value">:aws_secret_access_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">aws_secret_access_key</span>,
|
229
|
+
<span class="ruby-value">:aws_access_key_id</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">aws_access_key_id</span> )
|
230
|
+
|
231
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
232
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">'Unable to connect to OpenStack Swift: S3 middleware. Check authentication information or if the service is running'</span>
|
233
|
+
<span class="ruby-keyword">end</span>
|
234
|
+
|
235
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">'swift'</span>
|
236
|
+
<span class="ruby-identifier">provider</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"provider"</span>]
|
237
|
+
<span class="ruby-identifier">swift_api_key</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"keys"</span>][<span class="ruby-string">"secret_access_key"</span>]
|
238
|
+
<span class="ruby-identifier">swift_username</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"keys"</span>][<span class="ruby-string">"access_key_id"</span>]
|
239
|
+
<span class="ruby-identifier">swift_auth_ip</span> = <span class="ruby-ivar">@auth_params</span>[<span class="ruby-string">"url_ip"</span>]
|
240
|
+
|
241
|
+
<span class="ruby-keyword">begin</span>
|
242
|
+
<span class="ruby-constant">Excon</span>.<span class="ruby-identifier">defaults</span>[<span class="ruby-value">:ssl_verify_peer</span>] = <span class="ruby-keyword">false</span> <span class="ruby-comment">#SSL verify error on Mac OS X </span>
|
243
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'Connecting to OpenStack Swift...'</span>.<span class="ruby-identifier">color</span>(<span class="ruby-value">:green</span>)
|
244
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
245
|
+
<span class="ruby-ivar">@connection</span> = <span class="ruby-constant">Fog</span><span class="ruby-operator">::</span><span class="ruby-constant">Storage</span>.<span class="ruby-identifier">new</span>({ <span class="ruby-value">:provider</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">provider</span>,
|
246
|
+
<span class="ruby-value">:rackspace_username</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">swift_username</span>,
|
247
|
+
<span class="ruby-value">:rackspace_api_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">swift_api_key</span>,
|
248
|
+
<span class="ruby-value">:rackspace_auth_url</span> =<span class="ruby-operator">></span> <span class="ruby-node">"#{swift_auth_ip}:8080/auth/v1.0"</span>})
|
249
|
+
|
250
|
+
<span class="ruby-ivar">@cdn_connection</span> = <span class="ruby-constant">Fog</span><span class="ruby-operator">::</span><span class="ruby-constant">CDN</span>.<span class="ruby-identifier">new</span>({ <span class="ruby-value">:provider</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">provider</span>,
|
251
|
+
<span class="ruby-value">:rackspace_username</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">swift_username</span>,
|
252
|
+
<span class="ruby-value">:rackspace_api_key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">swift_api_key</span>,
|
253
|
+
<span class="ruby-value">:rackspace_auth_url</span> =<span class="ruby-operator">></span> <span class="ruby-node">"#{swift_auth_ip}:8080/auth/v1.0"</span>})
|
254
|
+
|
255
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
256
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">'Unable to connect to OpenStack Swift. Check authentication information or if the service is running.'</span>
|
257
|
+
<span class="ruby-keyword">end</span>
|
258
|
+
<span class="ruby-keyword">end</span>
|
259
|
+
<span class="ruby-keyword">end</span></pre>
|
260
|
+
</div><!-- new-source -->
|
261
|
+
|
262
|
+
</div>
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
</div><!-- new-method -->
|
268
|
+
|
269
|
+
|
270
|
+
</div><!-- public-class-method-details -->
|
271
|
+
|
272
|
+
<div id="public-instance-method-details" class="method-section section">
|
273
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
274
|
+
|
275
|
+
|
276
|
+
<div id="create_container_no_cdn-method" class="method-detail ">
|
277
|
+
<a name="method-i-create_container_no_cdn"></a>
|
278
|
+
|
279
|
+
|
280
|
+
<div class="method-heading">
|
281
|
+
<span class="method-name">create_container_no_cdn</span><span
|
282
|
+
class="method-args">(prefix)</span>
|
283
|
+
<span class="method-click-advice">click to toggle source</span>
|
284
|
+
</div>
|
285
|
+
|
286
|
+
|
287
|
+
<div class="method-description">
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<div class="method-source-code" id="create_container_no_cdn-source">
|
294
|
+
<pre>
|
295
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 71</span>
|
296
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">create_container_no_cdn</span>(<span class="ruby-identifier">prefix</span>)
|
297
|
+
<span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">create</span>(
|
298
|
+
<span class="ruby-value">:key</span> =<span class="ruby-operator">></span> <span class="ruby-node">"#{prefix}-#{Time.now.to_i}"</span>, <span class="ruby-comment"># globally unique name</span>
|
299
|
+
<span class="ruby-value">:public</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">false</span>,
|
300
|
+
<span class="ruby-value">:cdn</span> =<span class="ruby-operator">></span> <span class="ruby-string">""</span>
|
301
|
+
)
|
302
|
+
<span class="ruby-identifier">sleep</span> <span class="ruby-value">1</span>
|
303
|
+
<span class="ruby-identifier">list_containers</span>
|
304
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
305
|
+
<span class="ruby-keyword">end</span></pre>
|
306
|
+
</div><!-- create_container_no_cdn-source -->
|
307
|
+
|
308
|
+
</div>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</div><!-- create_container_no_cdn-method -->
|
314
|
+
|
315
|
+
|
316
|
+
<div id="create_containers_no_cdn-method" class="method-detail ">
|
317
|
+
<a name="method-i-create_containers_no_cdn"></a>
|
318
|
+
|
319
|
+
|
320
|
+
<div class="method-heading">
|
321
|
+
<span class="method-name">create_containers_no_cdn</span><span
|
322
|
+
class="method-args">(prefix, number_of)</span>
|
323
|
+
<span class="method-click-advice">click to toggle source</span>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
|
327
|
+
<div class="method-description">
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
<div class="method-source-code" id="create_containers_no_cdn-source">
|
334
|
+
<pre>
|
335
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 82</span>
|
336
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">create_containers_no_cdn</span>(<span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">number_of</span>)
|
337
|
+
<span class="ruby-identifier">start_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span>
|
338
|
+
<span class="ruby-ivar">@count</span> = <span class="ruby-value">1</span>
|
339
|
+
<span class="ruby-identifier">number_of</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
|
340
|
+
<span class="ruby-identifier">create_container_no_cdn</span>(<span class="ruby-identifier">prefix</span>)
|
341
|
+
<span class="ruby-identifier">end_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span>
|
342
|
+
<span class="ruby-identifier">time_elapsed</span> = <span class="ruby-identifier">end_time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">start_time</span>
|
343
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Time elapsed to create #{@count} containers: #{time_elapsed} seconds"</span>.<span class="ruby-identifier">bright</span>
|
344
|
+
<span class="ruby-ivar">@count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
345
|
+
<span class="ruby-keyword">end</span>
|
346
|
+
<span class="ruby-keyword">end</span></pre>
|
347
|
+
</div><!-- create_containers_no_cdn-source -->
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
</div><!-- create_containers_no_cdn-method -->
|
355
|
+
|
356
|
+
|
357
|
+
<div id="create_objects-method" class="method-detail ">
|
358
|
+
<a name="method-i-create_objects"></a>
|
359
|
+
|
360
|
+
|
361
|
+
<div class="method-heading">
|
362
|
+
<span class="method-name">create_objects</span><span
|
363
|
+
class="method-args">(path_to_local_files, container)</span>
|
364
|
+
<span class="method-click-advice">click to toggle source</span>
|
365
|
+
</div>
|
366
|
+
|
367
|
+
|
368
|
+
<div class="method-description">
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
<div class="method-source-code" id="create_objects-source">
|
375
|
+
<pre>
|
376
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 125</span>
|
377
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">create_objects</span>(<span class="ruby-identifier">path_to_local_files</span>, <span class="ruby-identifier">container</span>)
|
378
|
+
<span class="ruby-identifier">directory</span> = <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">container</span>)
|
379
|
+
<span class="ruby-identifier">files</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-identifier">path_to_local_files</span>]
|
380
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">file</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">files</span> <span class="ruby-keyword">do</span>
|
381
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">file</span>)
|
382
|
+
<span class="ruby-keyword">begin</span>
|
383
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">directory</span>.<span class="ruby-identifier">files</span>.<span class="ruby-identifier">head</span>(<span class="ruby-identifier">name</span>)
|
384
|
+
<span class="ruby-identifier">directory</span>.<span class="ruby-identifier">files</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:key</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>, <span class="ruby-value">:body</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">open</span>(<span class="ruby-identifier">file</span>))
|
385
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Uploading file #{name} to #{container}"</span>.<span class="ruby-identifier">bright</span>
|
386
|
+
<span class="ruby-keyword">else</span>
|
387
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"File #{name} already exists. Please delete file and try again"</span>.<span class="ruby-identifier">bright</span>
|
388
|
+
<span class="ruby-keyword">end</span>
|
389
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
390
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Container #{container} does not exist. Please check and try again"</span>
|
391
|
+
<span class="ruby-keyword">end</span>
|
392
|
+
|
393
|
+
<span class="ruby-keyword">end</span>
|
394
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
395
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'Creating objects complete'</span>.<span class="ruby-identifier">color</span>(<span class="ruby-value">:green</span>)
|
396
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
397
|
+
<span class="ruby-keyword">end</span></pre>
|
398
|
+
</div><!-- create_objects-source -->
|
399
|
+
|
400
|
+
</div>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
</div><!-- create_objects-method -->
|
406
|
+
|
407
|
+
|
408
|
+
<div id="delete_container-method" class="method-detail ">
|
409
|
+
<a name="method-i-delete_container"></a>
|
410
|
+
|
411
|
+
|
412
|
+
<div class="method-heading">
|
413
|
+
<span class="method-name">delete_container</span><span
|
414
|
+
class="method-args">(prefix)</span>
|
415
|
+
<span class="method-click-advice">click to toggle source</span>
|
416
|
+
</div>
|
417
|
+
|
418
|
+
|
419
|
+
<div class="method-description">
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
<div class="method-source-code" id="delete_container-source">
|
426
|
+
<pre>
|
427
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 94</span>
|
428
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete_container</span>(<span class="ruby-identifier">prefix</span>)
|
429
|
+
<span class="ruby-keyword">begin</span>
|
430
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Deleting container #{prefix}..."</span>.<span class="ruby-identifier">color</span>(<span class="ruby-value">:green</span>)
|
431
|
+
<span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">prefix</span>).<span class="ruby-identifier">destroy</span>
|
432
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
433
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
434
|
+
<span class="ruby-comment">#Fog related bugs...tbd</span>
|
435
|
+
<span class="ruby-comment">#raise 'Delete files first or check if the container lists using \'swift-manager list storage -t swift -f <auth> -i container\''</span>
|
436
|
+
<span class="ruby-keyword">end</span>
|
437
|
+
<span class="ruby-keyword">end</span></pre>
|
438
|
+
</div><!-- delete_container-source -->
|
439
|
+
|
440
|
+
</div>
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
</div><!-- delete_container-method -->
|
446
|
+
|
447
|
+
|
448
|
+
<div id="delete_containers-method" class="method-detail ">
|
449
|
+
<a name="method-i-delete_containers"></a>
|
450
|
+
|
451
|
+
|
452
|
+
<div class="method-heading">
|
453
|
+
<span class="method-name">delete_containers</span><span
|
454
|
+
class="method-args">()</span>
|
455
|
+
<span class="method-click-advice">click to toggle source</span>
|
456
|
+
</div>
|
457
|
+
|
458
|
+
|
459
|
+
<div class="method-description">
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
<div class="method-source-code" id="delete_containers-source">
|
466
|
+
<pre>
|
467
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 105</span>
|
468
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete_containers</span>
|
469
|
+
<span class="ruby-identifier">containers_json</span> = <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">to_json</span>
|
470
|
+
<span class="ruby-identifier">containers</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">containers_json</span>)
|
471
|
+
|
472
|
+
<span class="ruby-identifier">container_names</span> = []
|
473
|
+
<span class="ruby-identifier">containers</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
474
|
+
<span class="ruby-identifier">container_names</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">containers</span>[<span class="ruby-identifier">i</span>][<span class="ruby-string">'key'</span>]
|
475
|
+
<span class="ruby-keyword">end</span>
|
476
|
+
<span class="ruby-identifier">start_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span>
|
477
|
+
<span class="ruby-identifier">container_names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">container</span><span class="ruby-operator">|</span>
|
478
|
+
<span class="ruby-identifier">delete_files</span>(<span class="ruby-identifier">container</span>)
|
479
|
+
<span class="ruby-identifier">delete_container</span>(<span class="ruby-identifier">container</span>)
|
480
|
+
<span class="ruby-identifier">end_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_f</span>
|
481
|
+
<span class="ruby-ivar">@time_elapsed</span> = <span class="ruby-identifier">end_time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">start_time</span>
|
482
|
+
<span class="ruby-keyword">end</span>
|
483
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
484
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Time elapsed to delete #{containers.length} containers: #{@time_elapsed} seconds"</span>.<span class="ruby-identifier">bright</span>
|
485
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
486
|
+
<span class="ruby-keyword">end</span></pre>
|
487
|
+
</div><!-- delete_containers-source -->
|
488
|
+
|
489
|
+
</div>
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
</div><!-- delete_containers-method -->
|
495
|
+
|
496
|
+
|
497
|
+
<div id="delete_objects-method" class="method-detail ">
|
498
|
+
<a name="method-i-delete_objects"></a>
|
499
|
+
|
500
|
+
|
501
|
+
<div class="method-heading">
|
502
|
+
<span class="method-name">delete_objects</span><span
|
503
|
+
class="method-args">(container)</span>
|
504
|
+
<span class="method-click-advice">click to toggle source</span>
|
505
|
+
</div>
|
506
|
+
|
507
|
+
|
508
|
+
<div class="method-description">
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
<div class="method-source-code" id="delete_objects-source">
|
515
|
+
<pre>
|
516
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 151</span>
|
517
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete_objects</span>(<span class="ruby-identifier">container</span>)
|
518
|
+
|
519
|
+
<span class="ruby-identifier">directory</span> = <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">container</span>)
|
520
|
+
<span class="ruby-identifier">files</span> = <span class="ruby-identifier">directory</span>.<span class="ruby-identifier">files</span>
|
521
|
+
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
522
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">destroy</span>
|
523
|
+
<span class="ruby-keyword">end</span>
|
524
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">''</span>
|
525
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"*Deleting all files in container #{container}"</span>.<span class="ruby-identifier">bright</span>
|
526
|
+
<span class="ruby-keyword">end</span></pre>
|
527
|
+
</div><!-- delete_objects-source -->
|
528
|
+
|
529
|
+
</div>
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
</div><!-- delete_objects-method -->
|
535
|
+
|
536
|
+
|
537
|
+
<div id="generate_json_output-method" class="method-detail ">
|
538
|
+
<a name="method-i-generate_json_output"></a>
|
539
|
+
|
540
|
+
|
541
|
+
<div class="method-heading">
|
542
|
+
<span class="method-name">generate_json_output</span><span
|
543
|
+
class="method-args">()</span>
|
544
|
+
<span class="method-click-advice">click to toggle source</span>
|
545
|
+
</div>
|
546
|
+
|
547
|
+
|
548
|
+
<div class="method-description">
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
<div class="method-source-code" id="generate_json_output-source">
|
555
|
+
<pre>
|
556
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 162</span>
|
557
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate_json_output</span>
|
558
|
+
<span class="ruby-identifier">container_json_path</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">home</span> <span class="ruby-operator">+</span> <span class="ruby-string">"/.swift-manager/shell/container.json"</span>
|
559
|
+
<span class="ruby-identifier">files_json_path</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">home</span> <span class="ruby-operator">+</span> <span class="ruby-string">"/.swift-manager/shell/files.json"</span>
|
560
|
+
|
561
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">container_json_path</span>, <span class="ruby-string">"w"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
562
|
+
<span class="ruby-identifier">f</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">to_json</span>
|
563
|
+
<span class="ruby-keyword">end</span>
|
564
|
+
<span class="ruby-keyword">end</span></pre>
|
565
|
+
</div><!-- generate_json_output-source -->
|
566
|
+
|
567
|
+
</div>
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
</div><!-- generate_json_output-method -->
|
573
|
+
|
574
|
+
|
575
|
+
<div id="list_containers-method" class="method-detail ">
|
576
|
+
<a name="method-i-list_containers"></a>
|
577
|
+
|
578
|
+
|
579
|
+
<div class="method-heading">
|
580
|
+
<span class="method-name">list_containers</span><span
|
581
|
+
class="method-args">()</span>
|
582
|
+
<span class="method-click-advice">click to toggle source</span>
|
583
|
+
</div>
|
584
|
+
|
585
|
+
|
586
|
+
<div class="method-description">
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
<div class="method-source-code" id="list_containers-source">
|
593
|
+
<pre>
|
594
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 67</span>
|
595
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">list_containers</span>
|
596
|
+
<span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">table</span>
|
597
|
+
<span class="ruby-keyword">end</span></pre>
|
598
|
+
</div><!-- list_containers-source -->
|
599
|
+
|
600
|
+
</div>
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
</div><!-- list_containers-method -->
|
606
|
+
|
607
|
+
|
608
|
+
<div id="list_objects-method" class="method-detail ">
|
609
|
+
<a name="method-i-list_objects"></a>
|
610
|
+
|
611
|
+
|
612
|
+
<div class="method-heading">
|
613
|
+
<span class="method-name">list_objects</span><span
|
614
|
+
class="method-args">(container_name)</span>
|
615
|
+
<span class="method-click-advice">click to toggle source</span>
|
616
|
+
</div>
|
617
|
+
|
618
|
+
|
619
|
+
<div class="method-description">
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
<div class="method-source-code" id="list_objects-source">
|
626
|
+
<pre>
|
627
|
+
<span class="ruby-comment"># File lib/swift_client.rb, line 147</span>
|
628
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">list_objects</span>(<span class="ruby-identifier">container_name</span>)
|
629
|
+
<span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">container_name</span>).<span class="ruby-identifier">files</span>.<span class="ruby-identifier">table</span>([<span class="ruby-value">:key</span>, <span class="ruby-value">:last_modified</span>, <span class="ruby-value">:content_length</span>])
|
630
|
+
<span class="ruby-keyword">end</span></pre>
|
631
|
+
</div><!-- list_objects-source -->
|
632
|
+
|
633
|
+
</div>
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
</div><!-- list_objects-method -->
|
639
|
+
|
640
|
+
|
641
|
+
</div><!-- public-instance-method-details -->
|
642
|
+
|
643
|
+
</div><!-- 5Buntitled-5D -->
|
644
|
+
|
645
|
+
|
646
|
+
</div><!-- documentation -->
|
647
|
+
|
648
|
+
<div id="validator-badges">
|
649
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
650
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
651
|
+
Rdoc Generator</a> 2</small>.</p>
|
652
|
+
</div>
|
653
|
+
|
654
|
+
</body>
|
655
|
+
</html>
|
656
|
+
|