Debian Codegraph @

doc/source/reference/apiv2.rst

raw
1 Python API v2
2 =============
3
4 These Identity Service credentials can be used to authenticate::
5
6 * auth_url: Identity Service endpoint for authorization
7 * username: name of user
8 * password: user's password
9 * project_{name|id}: name or ID of project
10
11 Also the following parameters are required when using the Identity API v3::
12
13 * user_domain_{name|id}: name or ID of a domain the user belongs to
14 * project_domain_{name|id}: name or ID for a domain the project belongs to
15
16 To create a client::
17
18 from keystoneauth1 import loading
19 from keystoneauth1 import session
20 from glanceclient import Client
21
22 loader = loading.get_plugin_loader('password')
23 auth = loader.load_from_options(
24 auth_url=AUTH_URL,
25 username=USERNAME,
26 password=PASSWORD,
27 project_id=PROJECT_ID)
28 session = session.Session(auth=auth)
29
30 glance = Client('2', session=session)
31
32
33 Create
34 ------
35 Create a new image::
36
37 image = glance.images.create(name="myNewImage")
38 glance.images.upload(image.id, open('/tmp/myimage.iso', 'rb'))
39
40 Show
41 ----
42 Describe a specific image::
43
44 glance.images.get(image.id)
45
46 Update
47 ------
48 Update a specific image::
49
50 # update with a list of image attribute names and their new values
51 glance.images.update(image.id, name="myNewImageName")
52
53 Custom Properties
54 -----------------
55 Set a custom property on an image::
56
57 # set an arbitrary property on an image
58 glance.images.update(image.id, my_custom_property='value')
59
60 Remove a custom property from an image::
61
62 # remove the custom property 'my_custom_property'
63 glance.images.update(image.id, remove_props=['my_custom_property'])
64
65 Delete
66 ------
67 Delete specified image(s)::
68
69 glance.images.delete(image.id)
70
71 List
72 ----
73 List images you can access::
74
75 for image in glance.images.list():
76 print image
77
78 Download
79 --------
80 Download a specific image::
81
82 d = glance.images.data(image.id)
83
84 Share an Image
85 --------------
86 Share a specific image with a tenant::
87
88 glance.image_members.create(image_id, member_id)
89
90 Remove a Share
91 --------------
92 Remove a shared image from a tenant::
93
94 glance.image_members.delete(image_id, member_id)
95
96 List Sharings
97 -------------
98 Describe sharing permissions by image or tenant::
99
100 glance.image_members.list(image_id)
101