Merge lp:~jaypipes/glance/docs into lp:~hudson-openstack/glance/trunk
- docs
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Jay Pipes | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 29 | ||||||||
Proposed branch: | lp:~jaypipes/glance/docs | ||||||||
Merge into: | lp:~hudson-openstack/glance/trunk | ||||||||
Diff against target: |
1797 lines (+1131/-555) 12 files modified
doc/Makefile (+97/-0) doc/source/_static/jquery.tweet.js (+154/-0) doc/source/_static/tweaks.css (+65/-0) doc/source/_theme/layout.html (+86/-0) doc/source/_theme/theme.conf (+5/-0) doc/source/client.rst (+231/-0) doc/source/community.rst (+83/-0) doc/source/conf.py (+10/-6) doc/source/glanceapi.rst (+294/-0) doc/source/identifiers.rst (+27/-0) doc/source/index.rst (+57/-549) doc/source/registries.rst (+22/-0) |
||||||||
To merge this branch: | bzr merge lp:~jaypipes/glance/docs | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Anne Gentle (community) | Approve | ||
Rick Harris (community) | Approve | ||
Jesse Andrews (community) | Approve | ||
Review via email: mp+44496@code.launchpad.net |
Commit message
Description of the change
documentation cleanup and matching to other OpenStack projects. Glance is no longer the red-headed documentation stepchild in OpenStack...
Anne Gentle (annegentle) wrote : | # |
Just a couple of comments, other than "I love it!" Nicely done.
I'd remove "glance.
Couple of nitpicks - ensure it's means "it is" and use periods at the end of bulleted list items.
If you want the CSS to match, you could use the Swift site as an example where the tweaks.css adds in OpenStack colors. Swift doesn't have the @OpenStack Twitter feed on the front page, Nova does. Feel free to copy the site you like best.
Should we track Glance.
Jay Pipes (jaypipes) wrote : | # |
Hi Anne, thanks for the review!
> Just a couple of comments, other than "I love it!" Nicely done.
>
> I'd remove "glance.
> vmstore.
> clickable url that takes them to the doc site which is potentially confusion
> for the examples you're using.
Done. s/glance.
> Couple of nitpicks - ensure it's means "it is" and use periods at the end of
> bulleted list items.
Done.
> If you want the CSS to match, you could use the Swift site as an example where
> the tweaks.css adds in OpenStack colors. Swift doesn't have the @OpenStack
> Twitter feed on the front page, Nova does. Feel free to copy the site you like
> best.
Done. Added both :)
> Should we track Glance.
> give the code to you if you want, or I can embed it after this gets merged.
Please feel free to do what you think is best here and to do that in a separate merge.
Thanks!
jay
Rick Harris (rconradharris) wrote : | # |
Looks great! :)
- 28. By Rick Harris
-
Converts timestamp attributes to datetime objects before persisting.
Refactors image_update and image_create to use the same basic code.
Anne Gentle (annegentle) wrote : | # |
Thanks for all the fixes. Coolio.
The Module Index link is broken, as you know. There's a similar (though maybe not related) bug on the nova.openstack.org site, https:/
Preview Diff
1 | === added file 'doc/Makefile' |
2 | --- doc/Makefile 1970-01-01 00:00:00 +0000 |
3 | +++ doc/Makefile 2010-12-23 17:34:13 +0000 |
4 | @@ -0,0 +1,97 @@ |
5 | +# Makefile for Sphinx documentation |
6 | +# |
7 | + |
8 | +# You can set these variables from the command line. |
9 | +SPHINXOPTS = |
10 | +SPHINXBUILD = sphinx-build |
11 | +SPHINXSOURCE = source |
12 | +PAPER = |
13 | +BUILDDIR = build |
14 | + |
15 | +# Internal variables. |
16 | +PAPEROPT_a4 = -D latex_paper_size=a4 |
17 | +PAPEROPT_letter = -D latex_paper_size=letter |
18 | +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SPHINXSOURCE) |
19 | + |
20 | +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest |
21 | + |
22 | +.DEFAULT_GOAL = html |
23 | + |
24 | +help: |
25 | + @echo "Please use \`make <target>' where <target> is one of" |
26 | + @echo " html to make standalone HTML files" |
27 | + @echo " dirhtml to make HTML files named index.html in directories" |
28 | + @echo " pickle to make pickle files" |
29 | + @echo " json to make JSON files" |
30 | + @echo " htmlhelp to make HTML files and a HTML help project" |
31 | + @echo " qthelp to make HTML files and a qthelp project" |
32 | + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" |
33 | + @echo " changes to make an overview of all changed/added/deprecated items" |
34 | + @echo " linkcheck to check all external links for integrity" |
35 | + @echo " doctest to run all doctests embedded in the documentation (if enabled)" |
36 | + |
37 | +clean: |
38 | + -rm -rf $(BUILDDIR)/* |
39 | + -rm -rf nova.sqlite |
40 | + if [ -f .autogenerated ] ; then \ |
41 | + cat .autogenerated | xargs rm ; \ |
42 | + rm .autogenerated ; \ |
43 | + fi |
44 | + |
45 | +html: |
46 | + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html |
47 | + @echo |
48 | + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." |
49 | + |
50 | +dirhtml: |
51 | + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml |
52 | + @echo |
53 | + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." |
54 | + |
55 | +pickle: |
56 | + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle |
57 | + @echo |
58 | + @echo "Build finished; now you can process the pickle files." |
59 | + |
60 | +json: |
61 | + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json |
62 | + @echo |
63 | + @echo "Build finished; now you can process the JSON files." |
64 | + |
65 | +htmlhelp: |
66 | + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp |
67 | + @echo |
68 | + @echo "Build finished; now you can run HTML Help Workshop with the" \ |
69 | + ".hhp project file in $(BUILDDIR)/htmlhelp." |
70 | + |
71 | +qthelp: |
72 | + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp |
73 | + @echo |
74 | + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ |
75 | + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" |
76 | + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/nova.qhcp" |
77 | + @echo "To view the help file:" |
78 | + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/nova.qhc" |
79 | + |
80 | +latex: |
81 | + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex |
82 | + @echo |
83 | + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." |
84 | + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ |
85 | + "run these through (pdf)latex." |
86 | + |
87 | +changes: |
88 | + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes |
89 | + @echo |
90 | + @echo "The overview file is in $(BUILDDIR)/changes." |
91 | + |
92 | +linkcheck: |
93 | + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck |
94 | + @echo |
95 | + @echo "Link check complete; look for any errors in the above output " \ |
96 | + "or in $(BUILDDIR)/linkcheck/output.txt." |
97 | + |
98 | +doctest: |
99 | + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest |
100 | + @echo "Testing of doctests in the sources finished, look at the " \ |
101 | + "results in $(BUILDDIR)/doctest/output.txt." |
102 | |
103 | === added file 'doc/source/_static/jquery.tweet.js' |
104 | --- doc/source/_static/jquery.tweet.js 1970-01-01 00:00:00 +0000 |
105 | +++ doc/source/_static/jquery.tweet.js 2010-12-23 17:34:13 +0000 |
106 | @@ -0,0 +1,154 @@ |
107 | +(function($) { |
108 | + |
109 | + $.fn.tweet = function(o){ |
110 | + var s = { |
111 | + username: ["seaofclouds"], // [string] required, unless you want to display our tweets. :) it can be an array, just do ["username1","username2","etc"] |
112 | + list: null, //[string] optional name of list belonging to username |
113 | + avatar_size: null, // [integer] height and width of avatar if displayed (48px max) |
114 | + count: 3, // [integer] how many tweets to display? |
115 | + intro_text: null, // [string] do you want text BEFORE your your tweets? |
116 | + outro_text: null, // [string] do you want text AFTER your tweets? |
117 | + join_text: null, // [string] optional text in between date and tweet, try setting to "auto" |
118 | + auto_join_text_default: "i said,", // [string] auto text for non verb: "i said" bullocks |
119 | + auto_join_text_ed: "i", // [string] auto text for past tense: "i" surfed |
120 | + auto_join_text_ing: "i am", // [string] auto tense for present tense: "i was" surfing |
121 | + auto_join_text_reply: "i replied to", // [string] auto tense for replies: "i replied to" @someone "with" |
122 | + auto_join_text_url: "i was looking at", // [string] auto tense for urls: "i was looking at" http:... |
123 | + loading_text: null, // [string] optional loading text, displayed while tweets load |
124 | + query: null // [string] optional search query |
125 | + }; |
126 | + |
127 | + if(o) $.extend(s, o); |
128 | + |
129 | + $.fn.extend({ |
130 | + linkUrl: function() { |
131 | + var returning = []; |
132 | + var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; |
133 | + this.each(function() { |
134 | + returning.push(this.replace(regexp,"<a href=\"$1\">$1</a>")); |
135 | + }); |
136 | + return $(returning); |
137 | + }, |
138 | + linkUser: function() { |
139 | + var returning = []; |
140 | + var regexp = /[\@]+([A-Za-z0-9-_]+)/gi; |
141 | + this.each(function() { |
142 | + returning.push(this.replace(regexp,"<a href=\"http://twitter.com/$1\">@$1</a>")); |
143 | + }); |
144 | + return $(returning); |
145 | + }, |
146 | + linkHash: function() { |
147 | + var returning = []; |
148 | + var regexp = / [\#]+([A-Za-z0-9-_]+)/gi; |
149 | + this.each(function() { |
150 | + returning.push(this.replace(regexp, ' <a href="http://search.twitter.com/search?q=&tag=$1&lang=all&from='+s.username.join("%2BOR%2B")+'">#$1</a>')); |
151 | + }); |
152 | + return $(returning); |
153 | + }, |
154 | + capAwesome: function() { |
155 | + var returning = []; |
156 | + this.each(function() { |
157 | + returning.push(this.replace(/\b(awesome)\b/gi, '<span class="awesome">$1</span>')); |
158 | + }); |
159 | + return $(returning); |
160 | + }, |
161 | + capEpic: function() { |
162 | + var returning = []; |
163 | + this.each(function() { |
164 | + returning.push(this.replace(/\b(epic)\b/gi, '<span class="epic">$1</span>')); |
165 | + }); |
166 | + return $(returning); |
167 | + }, |
168 | + makeHeart: function() { |
169 | + var returning = []; |
170 | + this.each(function() { |
171 | + returning.push(this.replace(/(<)+[3]/gi, "<tt class='heart'>♥</tt>")); |
172 | + }); |
173 | + return $(returning); |
174 | + } |
175 | + }); |
176 | + |
177 | + function relative_time(time_value) { |
178 | + var parsed_date = Date.parse(time_value); |
179 | + var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); |
180 | + var delta = parseInt((relative_to.getTime() - parsed_date) / 1000); |
181 | + var pluralize = function (singular, n) { |
182 | + return '' + n + ' ' + singular + (n == 1 ? '' : 's'); |
183 | + }; |
184 | + if(delta < 60) { |
185 | + return 'less than a minute ago'; |
186 | + } else if(delta < (45*60)) { |
187 | + return 'about ' + pluralize("minute", parseInt(delta / 60)) + ' ago'; |
188 | + } else if(delta < (24*60*60)) { |
189 | + return 'about ' + pluralize("hour", parseInt(delta / 3600)) + ' ago'; |
190 | + } else { |
191 | + return 'about ' + pluralize("day", parseInt(delta / 86400)) + ' ago'; |
192 | + } |
193 | + } |
194 | + |
195 | + function build_url() { |
196 | + var proto = ('https:' == document.location.protocol ? 'https:' : 'http:'); |
197 | + if (s.list) { |
198 | + return proto+"//api.twitter.com/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?per_page="+s.count+"&callback=?"; |
199 | + } else if (s.query == null && s.username.length == 1) { |
200 | + return proto+'//twitter.com/status/user_timeline/'+s.username[0]+'.json?count='+s.count+'&callback=?'; |
201 | + } else { |
202 | + var query = (s.query || 'from:'+s.username.join('%20OR%20from:')); |
203 | + return proto+'//search.twitter.com/search.json?&q='+query+'&rpp='+s.count+'&callback=?'; |
204 | + } |
205 | + } |
206 | + |
207 | + return this.each(function(){ |
208 | + var list = $('<ul class="tweet_list">').appendTo(this); |
209 | + var intro = '<p class="tweet_intro">'+s.intro_text+'</p>'; |
210 | + var outro = '<p class="tweet_outro">'+s.outro_text+'</p>'; |
211 | + var loading = $('<p class="loading">'+s.loading_text+'</p>'); |
212 | + |
213 | + if(typeof(s.username) == "string"){ |
214 | + s.username = [s.username]; |
215 | + } |
216 | + |
217 | + if (s.loading_text) $(this).append(loading); |
218 | + $.getJSON(build_url(), function(data){ |
219 | + if (s.loading_text) loading.remove(); |
220 | + if (s.intro_text) list.before(intro); |
221 | + $.each((data.results || data), function(i,item){ |
222 | + // auto join text based on verb tense and content |
223 | + if (s.join_text == "auto") { |
224 | + if (item.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) { |
225 | + var join_text = s.auto_join_text_reply; |
226 | + } else if (item.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)) { |
227 | + var join_text = s.auto_join_text_url; |
228 | + } else if (item.text.match(/^((\w+ed)|just) .*/im)) { |
229 | + var join_text = s.auto_join_text_ed; |
230 | + } else if (item.text.match(/^(\w*ing) .*/i)) { |
231 | + var join_text = s.auto_join_text_ing; |
232 | + } else { |
233 | + var join_text = s.auto_join_text_default; |
234 | + } |
235 | + } else { |
236 | + var join_text = s.join_text; |
237 | + }; |
238 | + |
239 | + var from_user = item.from_user || item.user.screen_name; |
240 | + var profile_image_url = item.profile_image_url || item.user.profile_image_url; |
241 | + var join_template = '<span class="tweet_join"> '+join_text+' </span>'; |
242 | + var join = ((s.join_text) ? join_template : ' '); |
243 | + var avatar_template = '<a class="tweet_avatar" href="http://twitter.com/'+from_user+'"><img src="'+profile_image_url+'" height="'+s.avatar_size+'" width="'+s.avatar_size+'" alt="'+from_user+'\'s avatar" title="'+from_user+'\'s avatar" border="0"/></a>'; |
244 | + var avatar = (s.avatar_size ? avatar_template : ''); |
245 | + var date = '<a href="http://twitter.com/'+from_user+'/statuses/'+item.id+'" title="view tweet on twitter">'+relative_time(item.created_at)+'</a>'; |
246 | + var text = '<span class="tweet_text">' +$([item.text]).linkUrl().linkUser().linkHash().makeHeart().capAwesome().capEpic()[0]+ '</span>'; |
247 | + |
248 | + // until we create a template option, arrange the items below to alter a tweet's display. |
249 | + list.append('<li>' + avatar + date + join + text + '</li>'); |
250 | + |
251 | + list.children('li:first').addClass('tweet_first'); |
252 | + list.children('li:odd').addClass('tweet_even'); |
253 | + list.children('li:even').addClass('tweet_odd'); |
254 | + }); |
255 | + if (s.outro_text) list.after(outro); |
256 | + }); |
257 | + |
258 | + }); |
259 | + }; |
260 | +})(jQuery); |
261 | \ No newline at end of file |
262 | |
263 | === added file 'doc/source/_static/tweaks.css' |
264 | --- doc/source/_static/tweaks.css 1970-01-01 00:00:00 +0000 |
265 | +++ doc/source/_static/tweaks.css 2010-12-23 17:34:13 +0000 |
266 | @@ -0,0 +1,65 @@ |
267 | +ul.todo_list { |
268 | + list-style-type: none; |
269 | + margin: 0; |
270 | + padding: 0; |
271 | +} |
272 | + |
273 | +ul.todo_list li { |
274 | + display: block; |
275 | + margin: 0; |
276 | + padding: 7px 0; |
277 | + border-top: 1px solid #eee; |
278 | +} |
279 | + |
280 | +ul.todo_list li p { |
281 | + display: inline; |
282 | +} |
283 | + |
284 | +ul.todo_list li p.link { |
285 | + font-weight: bold; |
286 | +} |
287 | + |
288 | +ul.todo_list li p.details { |
289 | + font-style: italic; |
290 | +} |
291 | + |
292 | +ul.todo_list li { |
293 | +} |
294 | + |
295 | +div.admonition { |
296 | + border: 1px solid #8F1000; |
297 | +} |
298 | + |
299 | +div.admonition p.admonition-title { |
300 | + background-color: #8F1000; |
301 | + border-bottom: 1px solid #8E8E8E; |
302 | +} |
303 | + |
304 | +a { |
305 | + color: #CF2F19; |
306 | +} |
307 | + |
308 | +div.related ul li a { |
309 | + color: #CF2F19; |
310 | +} |
311 | + |
312 | +div.sphinxsidebar h4 { |
313 | + background-color:#8E8E8E; |
314 | + border:1px solid #255E6E; |
315 | + color:white; |
316 | + font-size:1em; |
317 | + margin:1em 0 0.5em; |
318 | + padding:0.1em 0 0.1em 0.5em; |
319 | +} |
320 | + |
321 | +em { |
322 | + font-style: normal; |
323 | +} |
324 | + |
325 | +table.docutils { |
326 | + font-size: 11px; |
327 | +} |
328 | + |
329 | +a tt { |
330 | + color:#CF2F19; |
331 | +} |
332 | \ No newline at end of file |
333 | |
334 | === added directory 'doc/source/_templates' |
335 | === added file 'doc/source/_templates/.placeholder' |
336 | === added directory 'doc/source/_theme' |
337 | === added file 'doc/source/_theme/layout.html' |
338 | --- doc/source/_theme/layout.html 1970-01-01 00:00:00 +0000 |
339 | +++ doc/source/_theme/layout.html 2010-12-23 17:34:13 +0000 |
340 | @@ -0,0 +1,86 @@ |
341 | +{% extends "sphinxdoc/layout.html" %} |
342 | +{% set css_files = css_files + ['_static/tweaks.css'] %} |
343 | +{% set script_files = script_files + ['_static/jquery.tweet.js'] %} |
344 | +{% block extrahead %} |
345 | + <script type='text/javascript'> |
346 | + $(document).ready(function(){ |
347 | + $("#twitter_feed").tweet({ |
348 | + username: "openstack", |
349 | + query: "from:openstack", |
350 | + avatar_size: 32, |
351 | + count: 10, |
352 | + loading_text: "loading tweets..." |
353 | + }); |
354 | + }); |
355 | + </script> |
356 | +{% endblock %} |
357 | + |
358 | +{%- macro sidebar() %} |
359 | + {%- if not embedded %}{% if not theme_nosidebar|tobool %} |
360 | + <div class="sphinxsidebar"> |
361 | + <div class="sphinxsidebarwrapper"> |
362 | + {%- block sidebarlogo %} |
363 | + {%- if logo %} |
364 | + <p class="logo"><a href="{{ pathto(master_doc) }}"> |
365 | + <img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/> |
366 | + </a></p> |
367 | + {%- endif %} |
368 | + {%- endblock %} |
369 | + {%- block sidebartoc %} |
370 | + {%- if display_toc %} |
371 | + <h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3> |
372 | + {{ toc }} |
373 | + {%- endif %} |
374 | + {%- endblock %} |
375 | + {%- block sidebarrel %} |
376 | + {%- if prev %} |
377 | + <h4>{{ _('Previous topic') }}</h4> |
378 | + <p class="topless"><a href="{{ prev.link|e }}" |
379 | + title="{{ _('previous chapter') }}">{{ prev.title }}</a></p> |
380 | + {%- endif %} |
381 | + {%- if next %} |
382 | + <h4>{{ _('Next topic') }}</h4> |
383 | + <p class="topless"><a href="{{ next.link|e }}" |
384 | + title="{{ _('next chapter') }}">{{ next.title }}</a></p> |
385 | + {%- endif %} |
386 | + {%- endblock %} |
387 | + {%- block sidebarsourcelink %} |
388 | + {%- if show_source and has_source and sourcename %} |
389 | + <h3>{{ _('This Page') }}</h3> |
390 | + <ul class="this-page-menu"> |
391 | + <li><a href="{{ pathto('_sources/' + sourcename, true)|e }}" |
392 | + rel="nofollow">{{ _('Show Source') }}</a></li> |
393 | + </ul> |
394 | + {%- endif %} |
395 | + {%- endblock %} |
396 | + {%- if customsidebar %} |
397 | + {% include customsidebar %} |
398 | + {%- endif %} |
399 | + {%- block sidebarsearch %} |
400 | + {%- if pagename != "search" %} |
401 | + <div id="searchbox" style="display: none"> |
402 | + <h3>{{ _('Quick search') }}</h3> |
403 | + <form class="search" action="{{ pathto('search') }}" method="get"> |
404 | + <input type="text" name="q" size="18" /> |
405 | + <input type="submit" value="{{ _('Go') }}" /> |
406 | + <input type="hidden" name="check_keywords" value="yes" /> |
407 | + <input type="hidden" name="area" value="default" /> |
408 | + </form> |
409 | + <p class="searchtip" style="font-size: 90%"> |
410 | + {{ _('Enter search terms or a module, class or function name.') }} |
411 | + </p> |
412 | + </div> |
413 | + <script type="text/javascript">$('#searchbox').show(0);</script> |
414 | + {%- endif %} |
415 | + |
416 | + {%- if pagename == "index" %} |
417 | + <h3>{{ _('Twitter Feed') }}</h3> |
418 | + <div id="twitter_feed" class='twitter_feed'></div> |
419 | + {%- endif %} |
420 | + |
421 | + |
422 | + {%- endblock %} |
423 | + </div> |
424 | + </div> |
425 | + {%- endif %}{% endif %} |
426 | +{%- endmacro %} |
427 | |
428 | === added file 'doc/source/_theme/theme.conf' |
429 | --- doc/source/_theme/theme.conf 1970-01-01 00:00:00 +0000 |
430 | +++ doc/source/_theme/theme.conf 2010-12-23 17:34:13 +0000 |
431 | @@ -0,0 +1,5 @@ |
432 | +[theme] |
433 | +inherit = sphinxdoc |
434 | +stylesheet = sphinxdoc.css |
435 | +pygments_style = friendly |
436 | + |
437 | |
438 | === added file 'doc/source/client.rst' |
439 | --- doc/source/client.rst 1970-01-01 00:00:00 +0000 |
440 | +++ doc/source/client.rst 2010-12-23 17:34:13 +0000 |
441 | @@ -0,0 +1,231 @@ |
442 | +.. |
443 | + Copyright 2010 OpenStack, LLC |
444 | + All Rights Reserved. |
445 | + |
446 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
447 | + not use this file except in compliance with the License. You may obtain |
448 | + a copy of the License at |
449 | + |
450 | + http://www.apache.org/licenses/LICENSE-2.0 |
451 | + |
452 | + Unless required by applicable law or agreed to in writing, software |
453 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
454 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
455 | + License for the specific language governing permissions and limitations |
456 | + under the License. |
457 | + |
458 | +Using Glance Programmatically with Glance's Client |
459 | +================================================== |
460 | + |
461 | +While it is perfectly acceptable to issue HTTP requests directly to Glance |
462 | +via its RESTful API, sometimes it is better to be able to access and modify |
463 | +image resources via a client class that removes some of the complexity and |
464 | +tedium of dealing with raw HTTP requests. |
465 | + |
466 | +Glance includes a client class for just this purpose. You can retrieve |
467 | +metadata about an image, change metadata about an image, remove images, and |
468 | +of course retrieve an image itself via this client class. |
469 | + |
470 | +Below are some examples of using Glance's Client class. We assume that |
471 | +there is a Glance server running at the address `glance.example.com` |
472 | +on port `9292`. |
473 | + |
474 | +Requesting a List of Public VM Images |
475 | +------------------------------------- |
476 | + |
477 | +We want to see a list of available virtual machine images that the Glance |
478 | +server knows about. |
479 | + |
480 | +Using Glance's Client, we can do this using the following code:: |
481 | + |
482 | + from glance import client |
483 | + |
484 | + c = client.Client("glance.example.com", 9292) |
485 | + |
486 | + print c.get_images() |
487 | + |
488 | + |
489 | +Requesting Detailed Metadata on Public VM Images |
490 | +------------------------------------------------ |
491 | + |
492 | +We want to see more detailed information on available virtual machine images |
493 | +that the Glance server knows about. |
494 | + |
495 | +Using Glance's Client, we can do this using the following code:: |
496 | + |
497 | + from glance import client |
498 | + |
499 | + c = client.Client("glance.example.com", 9292) |
500 | + |
501 | + print c.get_images_detailed() |
502 | + |
503 | + |
504 | +Requesting Detailed Metadata on a Specific Image |
505 | +------------------------------------------------ |
506 | + |
507 | +We want to see detailed information for a specific virtual machine image |
508 | +that the Glance server knows about. |
509 | + |
510 | +We have queried the Glance server for a list of public images and the |
511 | +data returned includes the `uri` field for each available image. This |
512 | +`uri` field value contains the exact location needed to get the metadata |
513 | +for a specific image. |
514 | + |
515 | +Continuing the example from above, in order to get metadata about the |
516 | +first public image returned, we can use the following code:: |
517 | + |
518 | + from glance import client |
519 | + |
520 | + c = client.Client("glance.example.com", 9292) |
521 | + |
522 | + print c.get_image_meta("http://glance.example.com/images/1") |
523 | + |
524 | + |
525 | +Retrieving a Virtual Machine Image |
526 | +---------------------------------- |
527 | + |
528 | +We want to retrieve that actual raw data for a specific virtual machine image |
529 | +that the Glance server knows about. |
530 | + |
531 | +We have queried the Glance server for a list of public images and the |
532 | +data returned includes the `uri` field for each available image. This |
533 | +`uri` field value contains the exact location needed to get the metadata |
534 | +for a specific image. |
535 | + |
536 | +Continuing the example from above, in order to get both the metadata about the |
537 | +first public image returned and its image data, we can use the following code:: |
538 | + |
539 | + from glance import client |
540 | + |
541 | + c = client.Client("glance.example.com", 9292) |
542 | + |
543 | + meta, image_file = c.get_image("http://glance.example.com/images/1") |
544 | + |
545 | + print meta |
546 | + |
547 | + f = open('some_local_file', 'wb') |
548 | + for chunk in image_file: |
549 | + f.write(chunk) |
550 | + f.close() |
551 | + |
552 | +Note that the return from Client.get_image() is a tuple of (`metadata`, `file`) |
553 | +where `metadata` is a mapping of metadata about the image and `file` is a |
554 | +generator that yields chunks of image data. |
555 | + |
556 | +Adding a New Virtual Machine Image |
557 | +---------------------------------- |
558 | + |
559 | +We have created a new virtual machine image in some way (created a |
560 | +"golden image" or snapshotted/backed up an existing image) and we |
561 | +wish to do two things: |
562 | + |
563 | + * Store the disk image data in Glance |
564 | + * Store metadata about this image in Glance |
565 | + |
566 | +We can do the above two activities in a single call to the Glance client. |
567 | +Assuming, like in the examples above, that a Glance API server is running |
568 | +at `glance.example.com`, we issue a call to `glance.client.Client.add_image`. |
569 | + |
570 | +The method signature is as follows:: |
571 | + |
572 | + glance.client.Client.add_image(image_meta, image_data=None) |
573 | + |
574 | +The `image_meta` argument is a mapping containing various image metadata. The |
575 | +`image_data` argument is the disk image data. |
576 | + |
577 | +The list of metadata that `image_meta` can contain are listed below. |
578 | + |
579 | + * `name` |
580 | + |
581 | + This key/value is required. Its value should be the name of the image. |
582 | + |
583 | + Note that the name of an image *is not unique to a Glance node*. It |
584 | + would be an unrealistic expectation of users to know all the unique |
585 | + names of all other user's images. |
586 | + |
587 | + * `id` |
588 | + |
589 | + This key/value is optional. |
590 | + |
591 | + When present, Glance will use the supplied identifier for the image. |
592 | + If the identifier already exists in that Glance node, then a |
593 | + `glance.common.exception.Duplicate` will be raised. |
594 | + |
595 | + When this key/value is *not* present, Glance will generate an identifier |
596 | + for the image and return this identifier in the response (see below) |
597 | + |
598 | + * `store` |
599 | + |
600 | + This key/value is optional. Valid values are one of `file` or `swift` |
601 | + |
602 | + When present, Glance will attempt to store the disk image data in the |
603 | + backing store indicated by the value. If the Glance node does not support |
604 | + the backing store, Glance will raise a `glance.common.exception.BadRequest` |
605 | + |
606 | + When not present, Glance will store the disk image data in the backing |
607 | + store that is marked default. See the configuration option `default_store` |
608 | + for more information. |
609 | + |
610 | + * `type` |
611 | + |
612 | + This key/values is required. Valid values are one of `kernel`, `machine`, |
613 | + `raw`, or `ramdisk`. |
614 | + |
615 | + * `size` |
616 | + |
617 | + This key/value is optional. |
618 | + |
619 | + When present, Glance assumes that the expected size of the request body |
620 | + will be the value. If the length in bytes of the request body *does not |
621 | + match* the value, Glance will raise a `glance.common.exception.BadRequest` |
622 | + |
623 | + When not present, Glance will calculate the image's size based on the size |
624 | + of the request body. |
625 | + |
626 | + * `is_public` |
627 | + |
628 | + This key/value is optional. |
629 | + |
630 | + When present, Glance converts the value to a boolean value, so "on, 1, true" |
631 | + are all true values. When true, the image is marked as a public image, |
632 | + meaning that any user may view its metadata and may read the disk image from |
633 | + Glance. |
634 | + |
635 | + When not present, the image is assumed to be *not public* and specific to |
636 | + a user. |
637 | + |
638 | + * `properties` |
639 | + |
640 | + This key/value is optional. |
641 | + |
642 | + When present, the value is assumed to be a mapping of free-form key/value |
643 | + attributes to store with the image. |
644 | + |
645 | + For example, if the following is the value of the `properties` key in the |
646 | + `image_meta` argument:: |
647 | + |
648 | + {'distro': 'Ubuntu 10.10'} |
649 | + |
650 | + Then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the |
651 | + image in Glance. |
652 | + |
653 | + There is no limit on the number of free-form key/value attributes that can |
654 | + be attached to the image with `properties`. However, keep in mind that there |
655 | + is a 8K limit on the size of all HTTP headers sent in a request and this |
656 | + number will effectively limit the number of image properties. |
657 | + |
658 | +As a complete example, the following code would add a new machine image to |
659 | +Glance:: |
660 | + |
661 | + from glance.client import Client |
662 | + |
663 | + c = Client("glance.example.com", 9292) |
664 | + |
665 | + meta = {'name': 'Ubuntu 10.10 5G', |
666 | + 'type': 'machine', |
667 | + 'is_public': True, |
668 | + 'properties': {'distro': 'Ubuntu 10.10'}} |
669 | + |
670 | + new_meta = c.add_image(meta, open('/path/to/image.tar.gz')) |
671 | + |
672 | + print 'Stored image. Got identifier: %s' % new_meta['id'] |
673 | |
674 | === added file 'doc/source/community.rst' |
675 | --- doc/source/community.rst 1970-01-01 00:00:00 +0000 |
676 | +++ doc/source/community.rst 2010-12-23 17:34:13 +0000 |
677 | @@ -0,0 +1,83 @@ |
678 | +.. |
679 | + Copyright 2010 OpenStack, LLC |
680 | + All Rights Reserved. |
681 | + |
682 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
683 | + not use this file except in compliance with the License. You may obtain |
684 | + a copy of the License at |
685 | + |
686 | + http://www.apache.org/licenses/LICENSE-2.0 |
687 | + |
688 | + Unless required by applicable law or agreed to in writing, software |
689 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
690 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
691 | + License for the specific language governing permissions and limitations |
692 | + under the License. |
693 | + |
694 | +Getting Involved |
695 | +================ |
696 | + |
697 | +The Glance community is a very friendly group and there are places online to join in with the |
698 | +community. Feel free to ask questions. This document points you to some of the places where you can |
699 | +communicate with people. |
700 | + |
701 | +How to Join the OpenStack Community |
702 | +----------------------------------- |
703 | + |
704 | +Our community welcomes all people interested in open source cloud computing, and there are no formal |
705 | +membership requirements. The best way to join the community is to talk with others online or at a meetup |
706 | +and offer contributions through Launchpad, the wiki, or blogs. We welcome all types of contributions, |
707 | +from blueprint designs to documentation to testing to deployment scripts. |
708 | + |
709 | +Contributing Code |
710 | +----------------- |
711 | + |
712 | +To contribute code, sign up for a Launchpad account and sign a contributor license agreement, |
713 | +available on the `<http://wiki.openstack.org/CLA>`_. Once the CLA is signed you |
714 | +can contribute code through the Bazaar version control system which is related to your Launchpad account. |
715 | + |
716 | +#openstack on Freenode IRC Network |
717 | +---------------------------------- |
718 | + |
719 | +There is a very active chat channel at `<irc://freenode.net/#openstack>`_. This |
720 | +is usually the best place to ask questions and find your way around. IRC stands for Internet Relay |
721 | +Chat and it is a way to chat online in real time. You can also ask a question and come back to the |
722 | +log files to read the answer later. Logs for the #openstack IRC channel are stored at |
723 | +`<http://eavesdrop.openstack.org/irclogs/>`_. |
724 | + |
725 | +OpenStack Wiki |
726 | +-------------- |
727 | + |
728 | +The wiki is a living source of knowledge. It is edited by the community, and |
729 | +has collections of links and other sources of information. Typically the pages are a good place |
730 | +to write drafts for specs or documentation, describe a blueprint, or collaborate with others. |
731 | + |
732 | +`OpenStack Wiki <http://wiki.openstack.org/>`_ |
733 | + |
734 | +Glance on Launchpad |
735 | +------------------- |
736 | + |
737 | +Launchpad is a code hosting service that hosts the Glance source code. From |
738 | +Launchpad you can report bugs, ask questions, and register blueprints (feature requests). |
739 | + |
740 | +* `Learn about how to use bzr with launchpad <http://wiki.openstack.org/LifeWithBzrAndLaunchpad>`_ |
741 | +* `Launchpad Glance Page <http://launchpad.net/glance>`_ |
742 | + |
743 | +OpenStack Blog |
744 | +-------------- |
745 | + |
746 | +The OpenStack blog includes a weekly newsletter that aggregates OpenStack news |
747 | +from around the internet, as well as providing inside information on upcoming |
748 | +events and posts from OpenStack contributors. |
749 | + |
750 | +`OpenStack Blog <http://openstack.org/blog>`_ |
751 | + |
752 | +See also: `Planet OpenStack <http://planet.openstack.org/>`_, aggregating blogs |
753 | +about OpenStack from around the internet into a single feed. If you'd like to contribute to this blog |
754 | +aggregation with your blog posts, there are instructions for `adding your blog <http://wiki.openstack.org/AddingYourBlog>`_. |
755 | + |
756 | |
757 | +------- |
758 | + |
759 | +Because all the cool kids do it: `@openstack <http://twitter.com/openstack>`_. Also follow the |
760 | +`#openstack <http://search.twitter.com/search?q=%23openstack>`_ tag for relevant tweets. |
761 | |
762 | === modified file 'doc/source/conf.py' |
763 | --- doc/source/conf.py 2010-09-26 07:25:34 +0000 |
764 | +++ doc/source/conf.py 2010-12-23 17:34:13 +0000 |
765 | @@ -31,8 +31,7 @@ |
766 | # If extensions (or modules to document with autodoc) are in another directory, |
767 | # add these directories to sys.path here. If the directory is relative to the |
768 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
769 | -sys.path.append([os.path.abspath('../teller'), |
770 | - os.path.abspath('../parallax'), |
771 | +sys.path.append([os.path.abspath('../glance'), |
772 | os.path.abspath('..'), |
773 | os.path.abspath('../bin') |
774 | ]) |
775 | @@ -45,7 +44,11 @@ |
776 | todo_include_todos = True |
777 | |
778 | # Add any paths that contain templates here, relative to this directory. |
779 | -templates_path = ['_templates'] |
780 | +templates_path = [] |
781 | +if os.getenv('HUDSON_PUBLISH_DOCS'): |
782 | + templates_path = ['_ga', '_templates'] |
783 | +else: |
784 | + templates_path = ['_templates'] |
785 | |
786 | # The suffix of source filenames. |
787 | source_suffix = '.rst' |
788 | @@ -104,14 +107,15 @@ |
789 | pygments_style = 'sphinx' |
790 | |
791 | # A list of ignored prefixes for module index sorting. |
792 | -modindex_common_prefix = ['parallax.','teller.'] |
793 | +modindex_common_prefix = ['glance.'] |
794 | |
795 | |
796 | # -- Options for HTML output --------------------------------------------------- |
797 | |
798 | # The theme to use for HTML and HTML Help pages. Major themes that come with |
799 | # Sphinx are currently 'default' and 'sphinxdoc'. |
800 | -html_theme = 'default' |
801 | +html_theme_path = ["."] |
802 | +html_theme = '_theme' |
803 | |
804 | # Theme options are theme-specific and customize the look and feel of a theme |
805 | # further. For a list of options available for each theme, see the |
806 | @@ -119,7 +123,7 @@ |
807 | #html_theme_options = {} |
808 | |
809 | # Add any paths that contain custom themes here, relative to this directory. |
810 | -#html_theme_path = [] |
811 | +#html_theme_path = ['_theme'] |
812 | |
813 | # The name for this set of Sphinx documents. If None, it defaults to |
814 | # "<project> v<release> documentation". |
815 | |
816 | === added file 'doc/source/glanceapi.rst' |
817 | --- doc/source/glanceapi.rst 1970-01-01 00:00:00 +0000 |
818 | +++ doc/source/glanceapi.rst 2010-12-23 17:34:13 +0000 |
819 | @@ -0,0 +1,294 @@ |
820 | +.. |
821 | + Copyright 2010 OpenStack, LLC |
822 | + All Rights Reserved. |
823 | + |
824 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
825 | + not use this file except in compliance with the License. You may obtain |
826 | + a copy of the License at |
827 | + |
828 | + http://www.apache.org/licenses/LICENSE-2.0 |
829 | + |
830 | + Unless required by applicable law or agreed to in writing, software |
831 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
832 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
833 | + License for the specific language governing permissions and limitations |
834 | + under the License. |
835 | + |
836 | +The Glance REST API |
837 | +=================== |
838 | + |
839 | +Glance has a RESTful API that exposes both metadata about registered virtual |
840 | +machine images and the image data itself. |
841 | + |
842 | +A host that runs the `bin/glance-api` service is said to be a *Glance API |
843 | +Server*. |
844 | + |
845 | +Assume there is a Glance API server running at the URL |
846 | +http://glance.example.com. |
847 | + |
848 | +Let's walk through how a user might request information from this server. |
849 | + |
850 | +Requesting a List of Public VM Images |
851 | +------------------------------------- |
852 | + |
853 | +We want to see a list of available virtual machine images that the Glance |
854 | +server knows about. |
855 | + |
856 | +We issue a `GET` request to http://glance.example.com/images/ to retrieve |
857 | +this list of available *public* images. The data is returned as a JSON-encoded |
858 | +mapping in the following format:: |
859 | + |
860 | + {'images': [ |
861 | + {'uri': 'http://glance.example.com/images/1', |
862 | + 'name': 'Ubuntu 10.04 Plain', |
863 | + 'type': 'kernel', |
864 | + 'size': '5368709120'} |
865 | + ...]} |
866 | + |
867 | +Notes: |
868 | + |
869 | + * All images returned from the above `GET` request are *public* images |
870 | + |
871 | + |
872 | +Requesting Detailed Metadata on Public VM Images |
873 | +------------------------------------------------ |
874 | + |
875 | +We want to see more detailed information on available virtual machine images |
876 | +that the Glance server knows about. |
877 | + |
878 | +We issue a `GET` request to http://glance.example.com/images/detail to |
879 | +retrieve this list of available *public* images. The data is returned as a |
880 | +JSON-encoded mapping in the following format:: |
881 | + |
882 | + {'images': [ |
883 | + {'uri': 'http://glance.example.com/images/1', |
884 | + 'name': 'Ubuntu 10.04 Plain 5GB', |
885 | + 'type': 'kernel', |
886 | + 'size': '5368709120', |
887 | + 'store': 'swift', |
888 | + 'created_at': '2010-02-03 09:34:01', |
889 | + 'updated_at': '2010-02-03 09:34:01', |
890 | + 'deleted_at': '', |
891 | + 'status': 'available', |
892 | + 'is_public': True, |
893 | + 'properties': {'distro': 'Ubuntu 10.04 LTS'}}, |
894 | + ...]} |
895 | + |
896 | +Notes: |
897 | + |
898 | + * All images returned from the above `GET` request are *public* images |
899 | + * All timestamps returned are in UTC |
900 | + * The `updated_at` timestamp is the timestamp when an image's metadata |
901 | + was last updated, not its image data, as all image data is immutable |
902 | + once stored in Glance |
903 | + * The `properties` field is a mapping of free-form key/value pairs that |
904 | + have been saved with the image metadata |
905 | + |
906 | + |
907 | +Requesting Detailed Metadata on a Specific Image |
908 | +------------------------------------------------ |
909 | + |
910 | +We want to see detailed information for a specific virtual machine image |
911 | +that the Glance server knows about. |
912 | + |
913 | +We have queried the Glance server for a list of public images and the |
914 | +data returned includes the `uri` field for each available image. This |
915 | +`uri` field value contains the exact location needed to get the metadata |
916 | +for a specific image. |
917 | + |
918 | +Continuing the example from above, in order to get metadata about the |
919 | +first public image returned, we can issue a `HEAD` request to the Glance |
920 | +server for the image's URI. |
921 | + |
922 | +We issue a `HEAD` request to http://glance.example.com/images/1 to |
923 | +retrieve complete metadata for that image. The metadata is returned as a |
924 | +set of HTTP headers that begin with the prefix `x-image-meta-`. The |
925 | +following shows an example of the HTTP headers returned from the above |
926 | +`HEAD` request:: |
927 | + |
928 | + x-image-meta-uri http://glance.example.com/images/1 |
929 | + x-image-meta-name Ubuntu 10.04 Plain 5GB |
930 | + x-image-meta-type kernel |
931 | + x-image-meta-size 5368709120 |
932 | + x-image-meta-store swift |
933 | + x-image-meta-created_at 2010-02-03 09:34:01 |
934 | + x-image-meta-updated_at 2010-02-03 09:34:01 |
935 | + x-image-meta-deleted_at |
936 | + x-image-meta-status available |
937 | + x-image-meta-is_public True |
938 | + x-image-meta-property-distro Ubuntu 10.04 LTS |
939 | + |
940 | +Notes: |
941 | + |
942 | + * All timestamps returned are in UTC |
943 | + * The `x-image-meta-updated_at` timestamp is the timestamp when an |
944 | + image's metadata was last updated, not its image data, as all |
945 | + image data is immutable once stored in Glance |
946 | + * There may be multiple headers that begin with the prefix |
947 | + `x-image-meta-property-`. These headers are free-form key/value pairs |
948 | + that have been saved with the image metadata. The key is the string |
949 | + after `x-image-meta-property-` and the value is the value of the header |
950 | + |
951 | + |
952 | +Retrieving a Virtual Machine Image |
953 | +---------------------------------- |
954 | + |
955 | +We want to retrieve that actual raw data for a specific virtual machine image |
956 | +that the Glance server knows about. |
957 | + |
958 | +We have queried the Glance server for a list of public images and the |
959 | +data returned includes the `uri` field for each available image. This |
960 | +`uri` field value contains the exact location needed to get the metadata |
961 | +for a specific image. |
962 | + |
963 | +Continuing the example from above, in order to get metadata about the |
964 | +first public image returned, we can issue a `HEAD` request to the Glance |
965 | +server for the image's URI. |
966 | + |
967 | +We issue a `GET` request to http://glance.example.com/images/1 to |
968 | +retrieve metadata for that image as well as the image itself encoded |
969 | +into the response body. |
970 | + |
971 | +The metadata is returned as a set of HTTP headers that begin with the |
972 | +prefix `x-image-meta-`. The following shows an example of the HTTP headers |
973 | +returned from the above `GET` request:: |
974 | + |
975 | + x-image-meta-uri http://glance.example.com/images/1 |
976 | + x-image-meta-name Ubuntu 10.04 Plain 5GB |
977 | + x-image-meta-type kernel |
978 | + x-image-meta-size 5368709120 |
979 | + x-image-meta-store swift |
980 | + x-image-meta-created_at 2010-02-03 09:34:01 |
981 | + x-image-meta-updated_at 2010-02-03 09:34:01 |
982 | + x-image-meta-deleted_at |
983 | + x-image-meta-status available |
984 | + x-image-meta-is_public True |
985 | + x-image-meta-property-distro Ubuntu 10.04 LTS |
986 | + |
987 | +Notes: |
988 | + |
989 | + * All timestamps returned are in UTC |
990 | + * The `x-image-meta-updated_at` timestamp is the timestamp when an |
991 | + image's metadata was last updated, not its image data, as all |
992 | + image data is immutable once stored in Glance |
993 | + * There may be multiple headers that begin with the prefix |
994 | + `x-image-meta-property-`. These headers are free-form key/value pairs |
995 | + that have been saved with the image metadata. The key is the string |
996 | + after `x-image-meta-property-` and the value is the value of the header |
997 | + * The response's `Content-Length` header shall be equal to the value of |
998 | + the `x-image-meta-size` header |
999 | + * The image data itself will be the body of the HTTP response returned |
1000 | + from the request, which will have content-type of |
1001 | + `application/octet-stream`. |
1002 | + |
1003 | + |
1004 | +Adding a New Virtual Machine Image |
1005 | +---------------------------------- |
1006 | + |
1007 | +We have created a new virtual machine image in some way (created a |
1008 | +"golden image" or snapshotted/backed up an existing image) and we |
1009 | +wish to do two things: |
1010 | + |
1011 | + * Store the disk image data in Glance |
1012 | + * Store metadata about this image in Glance |
1013 | + |
1014 | +We can do the above two activities in a single call to the Glance API. |
1015 | +Assuming, like in the examples above, that a Glance API server is running |
1016 | +at `glance.example.com`, we issue a `POST` request to add an image to |
1017 | +Glance:: |
1018 | + |
1019 | + POST http://glance.example.com/images/ |
1020 | + |
1021 | +The metadata about the image is sent to Glance in HTTP headers. The body |
1022 | +of the HTTP request to the Glance API will be the MIME-encoded disk |
1023 | +image data. |
1024 | + |
1025 | + |
1026 | +Adding Image Metadata in HTTP Headers |
1027 | +************************************* |
1028 | + |
1029 | +Glance will view as image metadata any HTTP header that it receives in a |
1030 | +`POST` request where the header key is prefixed with the strings |
1031 | +`x-image-meta-` and `x-image-meta-property-`. |
1032 | + |
1033 | +The list of metadata headers that Glance accepts are listed below. |
1034 | + |
1035 | + * `x-image-meta-name` |
1036 | + |
1037 | + This header is required. Its value should be the name of the image. |
1038 | + |
1039 | + Note that the name of an image *is not unique to a Glance node*. It |
1040 | + would be an unrealistic expectation of users to know all the unique |
1041 | + names of all other user's images. |
1042 | + |
1043 | + * `x-image-meta-id` |
1044 | + |
1045 | + This header is optional. |
1046 | + |
1047 | + When present, Glance will use the supplied identifier for the image. |
1048 | + If the identifier already exists in that Glance node, then a |
1049 | + `409 Conflict` will be returned by Glance. |
1050 | + |
1051 | + When this header is *not* present, Glance will generate an identifier |
1052 | + for the image and return this identifier in the response (see below) |
1053 | + |
1054 | + * `x-image-meta-store` |
1055 | + |
1056 | + This header is optional. Valid values are one of `file` or `swift` |
1057 | + |
1058 | + When present, Glance will attempt to store the disk image data in the |
1059 | + backing store indicated by the value of the header. If the Glance node |
1060 | + does not support the backing store, Glance will return a `400 Bad Request`. |
1061 | + |
1062 | + When not present, Glance will store the disk image data in the backing |
1063 | + store that is marked default. See the configuration option `default_store` |
1064 | + for more information. |
1065 | + |
1066 | + * `x-image-meta-type` |
1067 | + |
1068 | + This header is required. Valid values are one of `kernel`, `machine`, `raw`, |
1069 | + or `ramdisk`. |
1070 | + |
1071 | + * `x-image-meta-size` |
1072 | + |
1073 | + This header is optional. |
1074 | + |
1075 | + When present, Glance assumes that the expected size of the request body |
1076 | + will be the value of this header. If the length in bytes of the request |
1077 | + body *does not match* the value of this header, Glance will return a |
1078 | + `400 Bad Request`. |
1079 | + |
1080 | + When not present, Glance will calculate the image's size based on the size |
1081 | + of the request body. |
1082 | + |
1083 | + * `x-image-meta-is_public` |
1084 | + |
1085 | + This header is optional. |
1086 | + |
1087 | + When present, Glance converts the value of the header to a boolean value, |
1088 | + so "on, 1, true" are all true values. When true, the image is marked as |
1089 | + a public image, meaning that any user may view its metadata and may read |
1090 | + the disk image from Glance. |
1091 | + |
1092 | + When not present, the image is assumed to be *not public* and specific to |
1093 | + a user. |
1094 | + |
1095 | + * `x-image-meta-property-*` |
1096 | + |
1097 | + When Glance receives any HTTP header whose key begins with the string prefix |
1098 | + `x-image-meta-property-`, Glance adds the key and value to a set of custom, |
1099 | + free-form image properties stored with the image. The key is the |
1100 | + lower-cased string following the prefix `x-image-meta-property-` with dashes |
1101 | + and punctuation replaced with underscores. |
1102 | + |
1103 | + For example, if the following HTTP header were sent:: |
1104 | + |
1105 | + x-image-meta-property-distro Ubuntu 10.10 |
1106 | + |
1107 | + Then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the |
1108 | + image in Glance. |
1109 | + |
1110 | + There is no limit on the number of free-form key/value attributes that can |
1111 | + be attached to the image. However, keep in mind that the 8K limit on the |
1112 | + size of all HTTP headers sent in a request will effectively limit the number |
1113 | + of image properties. |
1114 | |
1115 | === added file 'doc/source/identifiers.rst' |
1116 | --- doc/source/identifiers.rst 1970-01-01 00:00:00 +0000 |
1117 | +++ doc/source/identifiers.rst 2010-12-23 17:34:13 +0000 |
1118 | @@ -0,0 +1,27 @@ |
1119 | +.. |
1120 | + Copyright 2010 OpenStack, LLC |
1121 | + All Rights Reserved. |
1122 | + |
1123 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
1124 | + not use this file except in compliance with the License. You may obtain |
1125 | + a copy of the License at |
1126 | + |
1127 | + http://www.apache.org/licenses/LICENSE-2.0 |
1128 | + |
1129 | + Unless required by applicable law or agreed to in writing, software |
1130 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
1131 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
1132 | + License for the specific language governing permissions and limitations |
1133 | + under the License. |
1134 | + |
1135 | +Image Identifiers |
1136 | +================= |
1137 | + |
1138 | +Images are uniquely identified by way of a URI that |
1139 | +matches the following signature:: |
1140 | + |
1141 | + <Glance Server Location>/images/<ID> |
1142 | + |
1143 | +where `<Glance Server Location>` is the resource location of the Glance service |
1144 | +that knows about an image, and `<ID>` is the image's identifier that is |
1145 | +*unique to that Glance server*. |
1146 | |
1147 | === modified file 'doc/source/index.rst' |
1148 | --- doc/source/index.rst 2010-12-20 17:12:46 +0000 |
1149 | +++ doc/source/index.rst 2010-12-23 17:34:13 +0000 |
1150 | @@ -1,7 +1,18 @@ |
1151 | -.. Glance documentation master file, created by |
1152 | - sphinx-quickstart on Tue May 18 13:50:15 2010. |
1153 | - You can adapt this file completely to your liking, but it should at least |
1154 | - contain the root `toctree` directive. |
1155 | +.. |
1156 | + Copyright 2010 OpenStack, LLC |
1157 | + All Rights Reserved. |
1158 | + |
1159 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
1160 | + not use this file except in compliance with the License. You may obtain |
1161 | + a copy of the License at |
1162 | + |
1163 | + http://www.apache.org/licenses/LICENSE-2.0 |
1164 | + |
1165 | + Unless required by applicable law or agreed to in writing, software |
1166 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
1167 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
1168 | + License for the specific language governing permissions and limitations |
1169 | + under the License. |
1170 | |
1171 | Welcome to Glance's documentation! |
1172 | ================================== |
1173 | @@ -14,555 +25,52 @@ |
1174 | locations from simple filesystems to object-storage systems like the |
1175 | OpenStack Swift project. |
1176 | |
1177 | -.. toctree:: |
1178 | - :maxdepth: 1 |
1179 | - |
1180 | -Overview |
1181 | +Glance, as with all OpenStack projects, is written with the following design |
1182 | +guidelines in mind: |
1183 | + |
1184 | +* **Component based architecture**: Quickly add new behaviors |
1185 | +* **Highly available**: Scale to very serious workloads |
1186 | +* **Fault tolerant**: Isolated processes avoid cascading failures |
1187 | +* **Recoverable**: Failures should be easy to diagnose, debug, and rectify |
1188 | +* **Open standards**: Be a reference implementation for a community-driven api |
1189 | + |
1190 | +This documentation is generated by the Sphinx toolkit and lives in the source |
1191 | +tree. Additional documentation on Glance and other components of OpenStack can |
1192 | +be found on the `OpenStack wiki`_. Also see the :doc:`community` page for |
1193 | +other ways to interact with the community. |
1194 | + |
1195 | +.. _`OpenStack wiki`: http://wiki.openstack.org |
1196 | + |
1197 | +Concepts |
1198 | ======== |
1199 | |
1200 | -The Glance project provides services for discovering, registering, and |
1201 | -retrieving virtual machine images. Glance has a RESTful API that allows |
1202 | -querying of VM image metadata as well as retrieval of the actual image. |
1203 | - |
1204 | -.. toctree:: |
1205 | - :maxdepth: 1 |
1206 | - |
1207 | -The Glance API |
1208 | +.. toctree:: |
1209 | + :maxdepth: 1 |
1210 | + |
1211 | + identifiers |
1212 | + registries |
1213 | + |
1214 | +Using Glance |
1215 | +============ |
1216 | + |
1217 | +.. toctree:: |
1218 | + :maxdepth: 1 |
1219 | + |
1220 | + glanceapi |
1221 | + client |
1222 | + |
1223 | +Developer Docs |
1224 | ============== |
1225 | |
1226 | -Glance has a RESTful API that exposes both metadata about registered virtual |
1227 | -machine images and the image data itself. |
1228 | - |
1229 | -A host that runs the `bin/glance-api` service is said to be a *Glance API |
1230 | -Server*. |
1231 | - |
1232 | -Assume there is a Glance API server running at the URL |
1233 | -http://glance.openstack.org. |
1234 | - |
1235 | -Let's walk through how a user might request information from this server. |
1236 | - |
1237 | -Requesting a List of Public VM Images |
1238 | -------------------------------------- |
1239 | - |
1240 | -We want to see a list of available virtual machine images that the Glance |
1241 | -server knows about. |
1242 | - |
1243 | -We issue a `GET` request to http://glance.openstack.org/images/ to retrieve |
1244 | -this list of available *public* images. The data is returned as a JSON-encoded |
1245 | -mapping in the following format:: |
1246 | - |
1247 | - {'images': [ |
1248 | - {'uri': 'http://glance.openstack.org/images/1', |
1249 | - 'name': 'Ubuntu 10.04 Plain', |
1250 | - 'type': 'kernel', |
1251 | - 'size': '5368709120'} |
1252 | - ...]} |
1253 | - |
1254 | -Notes: |
1255 | - |
1256 | - * All images returned from the above `GET` request are *public* images |
1257 | - |
1258 | - |
1259 | -Requesting Detailed Metadata on Public VM Images |
1260 | ------------------------------------------------- |
1261 | - |
1262 | -We want to see more detailed information on available virtual machine images |
1263 | -that the Glance server knows about. |
1264 | - |
1265 | -We issue a `GET` request to http://glance.openstack.org/images/detail to |
1266 | -retrieve this list of available *public* images. The data is returned as a |
1267 | -JSON-encoded mapping in the following format:: |
1268 | - |
1269 | - {'images': [ |
1270 | - {'uri': 'http://glance.openstack.org/images/1', |
1271 | - 'name': 'Ubuntu 10.04 Plain 5GB', |
1272 | - 'type': 'kernel', |
1273 | - 'size': '5368709120', |
1274 | - 'store': 'swift', |
1275 | - 'created_at': '2010-02-03 09:34:01', |
1276 | - 'updated_at': '2010-02-03 09:34:01', |
1277 | - 'deleted_at': '', |
1278 | - 'status': 'available', |
1279 | - 'is_public': True, |
1280 | - 'properties': {'distro': 'Ubuntu 10.04 LTS'}}, |
1281 | - ...]} |
1282 | - |
1283 | -Notes: |
1284 | - |
1285 | - * All images returned from the above `GET` request are *public* images |
1286 | - * All timestamps returned are in UTC |
1287 | - * The `updated_at` timestamp is the timestamp when an image's metadata |
1288 | - was last updated, not it's image data, as all image data is immutable |
1289 | - once stored in Glance |
1290 | - * The `properties` field is a mapping of free-form key/value pairs that |
1291 | - have been saved with the image metadata |
1292 | - |
1293 | - |
1294 | -Requesting Detailed Metadata on a Specific Image |
1295 | ------------------------------------------------- |
1296 | - |
1297 | -We want to see detailed information for a specific virtual machine image |
1298 | -that the Glance server knows about. |
1299 | - |
1300 | -We have queried the Glance server for a list of public images and the |
1301 | -data returned includes the `uri` field for each available image. This |
1302 | -`uri` field value contains the exact location needed to get the metadata |
1303 | -for a specific image. |
1304 | - |
1305 | -Continuing the example from above, in order to get metadata about the |
1306 | -first public image returned, we can issue a `HEAD` request to the Glance |
1307 | -server for the image's URI. |
1308 | - |
1309 | -We issue a `HEAD` request to http://glance.openstack.org/images/1 to |
1310 | -retrieve complete metadata for that image. The metadata is returned as a |
1311 | -set of HTTP headers that begin with the prefix `x-image-meta-`. The |
1312 | -following shows an example of the HTTP headers returned from the above |
1313 | -`HEAD` request:: |
1314 | - |
1315 | - x-image-meta-uri http://glance.openstack.org/images/1 |
1316 | - x-image-meta-name Ubuntu 10.04 Plain 5GB |
1317 | - x-image-meta-type kernel |
1318 | - x-image-meta-size 5368709120 |
1319 | - x-image-meta-store swift |
1320 | - x-image-meta-created_at 2010-02-03 09:34:01 |
1321 | - x-image-meta-updated_at 2010-02-03 09:34:01 |
1322 | - x-image-meta-deleted_at |
1323 | - x-image-meta-status available |
1324 | - x-image-meta-is_public True |
1325 | - x-image-meta-property-distro Ubuntu 10.04 LTS |
1326 | - |
1327 | -Notes: |
1328 | - |
1329 | - * All timestamps returned are in UTC |
1330 | - * The `x-image-meta-updated_at` timestamp is the timestamp when an |
1331 | - image's metadata was last updated, not it's image data, as all |
1332 | - image data is immutable once stored in Glance |
1333 | - * There may be multiple headers that begin with the prefix |
1334 | - `x-image-meta-property-`. These headers are free-form key/value pairs |
1335 | - that have been saved with the image metadata. The key is the string |
1336 | - after `x-image-meta-property-` and the value is the value of the header |
1337 | - |
1338 | - |
1339 | -Retrieving a Virtual Machine Image |
1340 | ----------------------------------- |
1341 | - |
1342 | -We want to retrieve that actual raw data for a specific virtual machine image |
1343 | -that the Glance server knows about. |
1344 | - |
1345 | -We have queried the Glance server for a list of public images and the |
1346 | -data returned includes the `uri` field for each available image. This |
1347 | -`uri` field value contains the exact location needed to get the metadata |
1348 | -for a specific image. |
1349 | - |
1350 | -Continuing the example from above, in order to get metadata about the |
1351 | -first public image returned, we can issue a `HEAD` request to the Glance |
1352 | -server for the image's URI. |
1353 | - |
1354 | -We issue a `GET` request to http://glance.openstack.org/images/1 to |
1355 | -retrieve metadata for that image as well as the image itself encoded |
1356 | -into the response body. |
1357 | - |
1358 | -The metadata is returned as a set of HTTP headers that begin with the |
1359 | -prefix `x-image-meta-`. The following shows an example of the HTTP headers |
1360 | -returned from the above `GET` request:: |
1361 | - |
1362 | - x-image-meta-uri http://glance.openstack.org/images/1 |
1363 | - x-image-meta-name Ubuntu 10.04 Plain 5GB |
1364 | - x-image-meta-type kernel |
1365 | - x-image-meta-size 5368709120 |
1366 | - x-image-meta-store swift |
1367 | - x-image-meta-created_at 2010-02-03 09:34:01 |
1368 | - x-image-meta-updated_at 2010-02-03 09:34:01 |
1369 | - x-image-meta-deleted_at |
1370 | - x-image-meta-status available |
1371 | - x-image-meta-is_public True |
1372 | - x-image-meta-property-distro Ubuntu 10.04 LTS |
1373 | - |
1374 | -Notes: |
1375 | - |
1376 | - * All timestamps returned are in UTC |
1377 | - * The `x-image-meta-updated_at` timestamp is the timestamp when an |
1378 | - image's metadata was last updated, not it's image data, as all |
1379 | - image data is immutable once stored in Glance |
1380 | - * There may be multiple headers that begin with the prefix |
1381 | - `x-image-meta-property-`. These headers are free-form key/value pairs |
1382 | - that have been saved with the image metadata. The key is the string |
1383 | - after `x-image-meta-property-` and the value is the value of the header |
1384 | - * The response's `Content-Length` header shall be equal to the value of |
1385 | - the `x-image-meta-size` header |
1386 | - * The image data itself will be the body of the HTTP response returned |
1387 | - from the request, which will have content-type of |
1388 | - `application/octet-stream`. |
1389 | - |
1390 | - |
1391 | -.. toctree:: |
1392 | - :maxdepth: 1 |
1393 | - |
1394 | - |
1395 | -Adding a New Virtual Machine Image |
1396 | ----------------------------------- |
1397 | - |
1398 | -We have created a new virtual machine image in some way (created a |
1399 | -"golden image" or snapshotted/backed up an existing image) and we |
1400 | -wish to do two things: |
1401 | - |
1402 | - * Store the disk image data in Glance |
1403 | - * Store metadata about this image in Glance |
1404 | - |
1405 | -We can do the above two activities in a single call to the Glance API. |
1406 | -Assuming, like in the examples above, that a Glance API server is running |
1407 | -at `glance.openstack.org`, we issue a `POST` request to add an image to |
1408 | -Glance:: |
1409 | - |
1410 | - POST http://glance.openstack.org/images/ |
1411 | - |
1412 | -The metadata about the image is sent to Glance in HTTP headers. The body |
1413 | -of the HTTP request to the Glance API will be the MIME-encoded disk |
1414 | -image data. |
1415 | - |
1416 | - |
1417 | -Adding Image Metadata in HTTP Headers |
1418 | -************************************* |
1419 | - |
1420 | -Glance will view as image metadata any HTTP header that it receives in a |
1421 | -`POST` request where the header key is prefixed with the strings |
1422 | -`x-image-meta-` and `x-image-meta-property-`. |
1423 | - |
1424 | -The list of metadata headers that Glance accepts are listed below. |
1425 | - |
1426 | - * `x-image-meta-name` |
1427 | - |
1428 | - This header is required. Its value should be the name of the image. |
1429 | - |
1430 | - Note that the name of an image *is not unique to a Glance node*. It |
1431 | - would be an unrealistic expectation of users to know all the unique |
1432 | - names of all other user's images. |
1433 | - |
1434 | - * `x-image-meta-id` |
1435 | - |
1436 | - This header is optional. |
1437 | - |
1438 | - When present, Glance will use the supplied identifier for the image. |
1439 | - If the identifier already exists in that Glance node, then a |
1440 | - `409 Conflict` will be returned by Glance. |
1441 | - |
1442 | - When this header is *not* present, Glance will generate an identifier |
1443 | - for the image and return this identifier in the response (see below) |
1444 | - |
1445 | - * `x-image-meta-store` |
1446 | - |
1447 | - This header is optional. Valid values are one of `file` or `swift` |
1448 | - |
1449 | - When present, Glance will attempt to store the disk image data in the |
1450 | - backing store indicated by the value of the header. If the Glance node |
1451 | - does not support the backing store, Glance will return a `400 Bad Request`. |
1452 | - |
1453 | - When not present, Glance will store the disk image data in the backing |
1454 | - store that is marked default. See the configuration option `default_store` |
1455 | - for more information. |
1456 | - |
1457 | - * `x-image-meta-type` |
1458 | - |
1459 | - This header is required. Valid values are one of `kernel`, `machine`, `raw`, |
1460 | - or `ramdisk`. |
1461 | - |
1462 | - * `x-image-meta-size` |
1463 | - |
1464 | - This header is optional. |
1465 | - |
1466 | - When present, Glance assumes that the expected size of the request body |
1467 | - will be the value of this header. If the length in bytes of the request |
1468 | - body *does not match* the value of this header, Glance will return a |
1469 | - `400 Bad Request`. |
1470 | - |
1471 | - When not present, Glance will calculate the image's size based on the size |
1472 | - of the request body. |
1473 | - |
1474 | - * `x-image-meta-is_public` |
1475 | - |
1476 | - This header is optional. |
1477 | - |
1478 | - When present, Glance converts the value of the header to a boolean value, |
1479 | - so "on, 1, true" are all true values. When true, the image is marked as |
1480 | - a public image, meaning that any user may view its metadata and may read |
1481 | - the disk image from Glance. |
1482 | - |
1483 | - When not present, the image is assumed to be *not public* and specific to |
1484 | - a user. |
1485 | - |
1486 | - * `x-image-meta-property-*` |
1487 | - |
1488 | - When Glance receives any HTTP header whose key begins with the string prefix |
1489 | - `x-image-meta-property-`, Glance adds the key and value to a set of custom, |
1490 | - free-form image properties stored with the image. The key is the |
1491 | - lower-cased string following the prefix `x-image-meta-property-` with dashes |
1492 | - and punctuation replaced with underscores. |
1493 | - |
1494 | - For example, if the following HTTP header were sent:: |
1495 | - |
1496 | - x-image-meta-property-distro Ubuntu 10.10 |
1497 | - |
1498 | - Then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the |
1499 | - image in Glance. |
1500 | - |
1501 | - There is no limit on the number of free-form key/value attributes that can |
1502 | - be attached to the image. However, keep in mind that the 8K limit on the |
1503 | - size of all HTTP headers sent in a request will effectively limit the number |
1504 | - of image properties. |
1505 | - |
1506 | - |
1507 | -.. toctree:: |
1508 | - :maxdepth: 1 |
1509 | - |
1510 | -Image Identifiers |
1511 | -================= |
1512 | - |
1513 | -Images are uniquely identified by way of a URI that |
1514 | -matches the following signature:: |
1515 | - |
1516 | - <Glance Server Location>/images/<ID> |
1517 | - |
1518 | -where `<Glance Server Location>` is the resource location of the Glance service |
1519 | -that knows about an image, and `<ID>` is the image's identifier that is |
1520 | -*unique to that Glance server*. |
1521 | - |
1522 | -.. toctree:: |
1523 | - :maxdepth: 1 |
1524 | - |
1525 | -Image Registration |
1526 | -================== |
1527 | - |
1528 | -Image metadata made available through Glance can be stored in image |
1529 | -*registries*. Image registries are any web service that adheres to the |
1530 | -Glance RESTful API for image metadata. |
1531 | - |
1532 | -.. toctree:: |
1533 | - :maxdepth: 1 |
1534 | - |
1535 | -Using Glance Programmatically with Glance's Client |
1536 | -================================================== |
1537 | - |
1538 | -While it is perfectly acceptable to issue HTTP requests directly to Glance |
1539 | -via its RESTful API, sometimes it is better to be able to access and modify |
1540 | -image resources via a client class that removes some of the complexity and |
1541 | -tedium of dealing with raw HTTP requests. |
1542 | - |
1543 | -Glance includes a client class for just this purpose. You can retrieve |
1544 | -metadata about an image, change metadata about an image, remove images, and |
1545 | -of course retrieve an image itself via this client class. |
1546 | - |
1547 | -Below are some examples of using Glance's Client class. We assume that |
1548 | -there is a Glance server running at the address `glance.openstack.org` |
1549 | -on port `9292`. |
1550 | - |
1551 | -Requesting a List of Public VM Images |
1552 | -------------------------------------- |
1553 | - |
1554 | -We want to see a list of available virtual machine images that the Glance |
1555 | -server knows about. |
1556 | - |
1557 | -Using Glance's Client, we can do this using the following code:: |
1558 | - |
1559 | - from glance import client |
1560 | - |
1561 | - c = client.Client("glance.openstack.org", 9292) |
1562 | - |
1563 | - print c.get_images() |
1564 | - |
1565 | - |
1566 | -Requesting Detailed Metadata on Public VM Images |
1567 | ------------------------------------------------- |
1568 | - |
1569 | -We want to see more detailed information on available virtual machine images |
1570 | -that the Glance server knows about. |
1571 | - |
1572 | -Using Glance's Client, we can do this using the following code:: |
1573 | - |
1574 | - from glance import client |
1575 | - |
1576 | - c = client.Client("glance.openstack.org", 9292) |
1577 | - |
1578 | - print c.get_images_detailed() |
1579 | - |
1580 | - |
1581 | -Requesting Detailed Metadata on a Specific Image |
1582 | ------------------------------------------------- |
1583 | - |
1584 | -We want to see detailed information for a specific virtual machine image |
1585 | -that the Glance server knows about. |
1586 | - |
1587 | -We have queried the Glance server for a list of public images and the |
1588 | -data returned includes the `uri` field for each available image. This |
1589 | -`uri` field value contains the exact location needed to get the metadata |
1590 | -for a specific image. |
1591 | - |
1592 | -Continuing the example from above, in order to get metadata about the |
1593 | -first public image returned, we can use the following code:: |
1594 | - |
1595 | - from glance import client |
1596 | - |
1597 | - c = client.Client("glance.openstack.org", 9292) |
1598 | - |
1599 | - print c.get_image_meta("http://glance.openstack.org/images/1") |
1600 | - |
1601 | - |
1602 | -Retrieving a Virtual Machine Image |
1603 | ----------------------------------- |
1604 | - |
1605 | -We want to retrieve that actual raw data for a specific virtual machine image |
1606 | -that the Glance server knows about. |
1607 | - |
1608 | -We have queried the Glance server for a list of public images and the |
1609 | -data returned includes the `uri` field for each available image. This |
1610 | -`uri` field value contains the exact location needed to get the metadata |
1611 | -for a specific image. |
1612 | - |
1613 | -Continuing the example from above, in order to get both the metadata about the |
1614 | -first public image returned and its image data, we can use the following code:: |
1615 | - |
1616 | - from glance import client |
1617 | - |
1618 | - c = client.Client("glance.openstack.org", 9292) |
1619 | - |
1620 | - meta, image_file = c.get_image("http://glance.openstack.org/images/1") |
1621 | - |
1622 | - print meta |
1623 | - |
1624 | - f = open('some_local_file', 'wb') |
1625 | - for chunk in image_file: |
1626 | - f.write(chunk) |
1627 | - f.close() |
1628 | - |
1629 | -Note that the return from Client.get_image() is a tuple of (`metadata`, `file`) |
1630 | -where `metadata` is a mapping of metadata about the image and `file` is a |
1631 | -generator that yields chunks of image data. |
1632 | - |
1633 | - |
1634 | -.. toctree:: |
1635 | - :maxdepth: 1 |
1636 | - |
1637 | - |
1638 | -Adding a New Virtual Machine Image |
1639 | ----------------------------------- |
1640 | - |
1641 | -We have created a new virtual machine image in some way (created a |
1642 | -"golden image" or snapshotted/backed up an existing image) and we |
1643 | -wish to do two things: |
1644 | - |
1645 | - * Store the disk image data in Glance |
1646 | - * Store metadata about this image in Glance |
1647 | - |
1648 | -We can do the above two activities in a single call to the Glance client. |
1649 | -Assuming, like in the examples above, that a Glance API server is running |
1650 | -at `glance.openstack.org`, we issue a call to `glance.client.Client.add_image`. |
1651 | - |
1652 | -The method signature is as follows:: |
1653 | - |
1654 | - glance.client.Client.add_image(image_meta, image_data=None) |
1655 | - |
1656 | -The `image_meta` argument is a mapping containing various image metadata. The |
1657 | -`image_data` argument is the disk image data. |
1658 | - |
1659 | -The list of metadata that `image_meta` can contain are listed below. |
1660 | - |
1661 | - * `name` |
1662 | - |
1663 | - This key/value is required. Its value should be the name of the image. |
1664 | - |
1665 | - Note that the name of an image *is not unique to a Glance node*. It |
1666 | - would be an unrealistic expectation of users to know all the unique |
1667 | - names of all other user's images. |
1668 | - |
1669 | - * `id` |
1670 | - |
1671 | - This key/value is optional. |
1672 | - |
1673 | - When present, Glance will use the supplied identifier for the image. |
1674 | - If the identifier already exists in that Glance node, then a |
1675 | - `glance.common.exception.Duplicate` will be raised. |
1676 | - |
1677 | - When this key/value is *not* present, Glance will generate an identifier |
1678 | - for the image and return this identifier in the response (see below) |
1679 | - |
1680 | - * `store` |
1681 | - |
1682 | - This key/value is optional. Valid values are one of `file` or `swift` |
1683 | - |
1684 | - When present, Glance will attempt to store the disk image data in the |
1685 | - backing store indicated by the value. If the Glance node does not support |
1686 | - the backing store, Glance will raise a `glance.common.exception.BadRequest` |
1687 | - |
1688 | - When not present, Glance will store the disk image data in the backing |
1689 | - store that is marked default. See the configuration option `default_store` |
1690 | - for more information. |
1691 | - |
1692 | - * `type` |
1693 | - |
1694 | - This key/values is required. Valid values are one of `kernel`, `machine`, |
1695 | - `raw`, or `ramdisk`. |
1696 | - |
1697 | - * `size` |
1698 | - |
1699 | - This key/value is optional. |
1700 | - |
1701 | - When present, Glance assumes that the expected size of the request body |
1702 | - will be the value. If the length in bytes of the request body *does not |
1703 | - match* the value, Glance will raise a `glance.common.exception.BadRequest` |
1704 | - |
1705 | - When not present, Glance will calculate the image's size based on the size |
1706 | - of the request body. |
1707 | - |
1708 | - * `is_public` |
1709 | - |
1710 | - This key/value is optional. |
1711 | - |
1712 | - When present, Glance converts the value to a boolean value, so "on, 1, true" |
1713 | - are all true values. When true, the image is marked as a public image, |
1714 | - meaning that any user may view its metadata and may read the disk image from |
1715 | - Glance. |
1716 | - |
1717 | - When not present, the image is assumed to be *not public* and specific to |
1718 | - a user. |
1719 | - |
1720 | - * `properties` |
1721 | - |
1722 | - This key/value is optional. |
1723 | - |
1724 | - When present, the value is assumed to be a mapping of free-form key/value |
1725 | - attributes to store with the image. |
1726 | - |
1727 | - For example, if the following is the value of the `properties` key in the |
1728 | - `image_meta` argument:: |
1729 | - |
1730 | - {'distro': 'Ubuntu 10.10'} |
1731 | - |
1732 | - Then a key/value pair of "distro"/"Ubuntu 10.10" will be stored with the |
1733 | - image in Glance. |
1734 | - |
1735 | - There is no limit on the number of free-form key/value attributes that can |
1736 | - be attached to the image with `properties`. However, keep in mind that there |
1737 | - is a 8K limit on the size of all HTTP headers sent in a request and this |
1738 | - number will effectively limit the number of image properties. |
1739 | - |
1740 | -As a complete example, the following code would add a new machine image to |
1741 | -Glance:: |
1742 | - |
1743 | - from glance.client import Client |
1744 | - |
1745 | - c = Client("glance.openstack.org", 9292) |
1746 | - |
1747 | - meta = {'name': 'Ubuntu 10.10 5G', |
1748 | - 'type': 'machine', |
1749 | - 'is_public': True, |
1750 | - 'properties': {'distro': 'Ubuntu 10.10'}} |
1751 | - |
1752 | - new_meta = c.add_image(meta, open('/path/to/image.tar.gz')) |
1753 | - |
1754 | - print 'Stored image. Got identifier: %s' % new_meta['id'] |
1755 | - |
1756 | - |
1757 | -.. toctree:: |
1758 | - :maxdepth: 1 |
1759 | +.. toctree:: |
1760 | + :maxdepth: 1 |
1761 | + |
1762 | + community |
1763 | + |
1764 | +Outstanding Documentation Tasks |
1765 | +=============================== |
1766 | + |
1767 | +.. todolist:: |
1768 | |
1769 | Indices and tables |
1770 | ================== |
1771 | |
1772 | === added file 'doc/source/registries.rst' |
1773 | --- doc/source/registries.rst 1970-01-01 00:00:00 +0000 |
1774 | +++ doc/source/registries.rst 2010-12-23 17:34:13 +0000 |
1775 | @@ -0,0 +1,22 @@ |
1776 | +.. |
1777 | + Copyright 2010 OpenStack, LLC |
1778 | + All Rights Reserved. |
1779 | + |
1780 | + Licensed under the Apache License, Version 2.0 (the "License"); you may |
1781 | + not use this file except in compliance with the License. You may obtain |
1782 | + a copy of the License at |
1783 | + |
1784 | + http://www.apache.org/licenses/LICENSE-2.0 |
1785 | + |
1786 | + Unless required by applicable law or agreed to in writing, software |
1787 | + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
1788 | + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
1789 | + License for the specific language governing permissions and limitations |
1790 | + under the License. |
1791 | + |
1792 | +Image Registries |
1793 | +================ |
1794 | + |
1795 | +Image metadata made available through Glance can be stored in image |
1796 | +*registries*. Image registries are any web service that adheres to the |
1797 | +Glance RESTful API for image metadata. |
LGTM - merge reviews of docs are a great time to catch up on state of glance ;)