blob: 436db8f2cd6f9c90b60a46f6788139d3d5d63d9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
Python API v2
=============
To create a client::
from keystoneclient.auth.identity import v2 as identity
from keystoneclient import session
from glanceclient import Client
auth = identity.Password(auth_url=AUTH_URL,
username=USERNAME,
password=PASSWORD,
tenant_name=PROJECT_ID)
sess = session.Session(auth=auth)
token = auth.get_token(sess)
glance = Client('2', endpoint=OS_IMAGE_ENDPOINT, token=token)
Create
------
Create a new image::
image = glance.images.create(name="myNewImage")
glance.images.upload(image.id, open('/tmp/myimage.iso', 'rb'))
Show
----
Describe a specific image::
glance.images.get(image.id)
Update
------
Update a specific image::
# update with a list of image attribute names and their new values
glance.images.update(image.id, name="myNewImageName")
Custom Properties
-----------------
Set a custom property on an image::
# set an arbitrary property on an image
glance.images.update(image.id, my_custom_property='value')
Remove a custom property from an image::
# remove the custom property 'my_custom_property'
glance.images.update(image.id, remove_props=['my_custom_property'])
Delete
------
Delete specified image(s)::
glance.images.delete(image.id)
List
----
List images you can access::
for image in glance.images.list():
print image
Download
--------
Download a specific image::
d = glance.images.data(image.id)
Share an Image
--------------
Share a specific image with a tenant::
glance.image_members.create(image_id, member_id)
Remove a Share
--------------
Remove a shared image from a tenant::
glance.image_members.delete(image_id, member_id)
List Sharings
-------------
Describe sharing permissions by image or tenant::
glance.image_members.list(image_id)
|