1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Resource class and its manager for volume snapshots on Block Storage V2 API
18 """
19
20 from yakumo import base
21 from yakumo.constant import UNDEF
22 from yakumo import mapper
23
24
25 ATTRIBUTE_MAPPING = [
26 ('id', 'id', mapper.Noop),
27 ('name', 'name', mapper.Noop),
28 ('description', 'description', mapper.Noop),
29 ('size', 'size', mapper.Noop),
30 ('status', 'status', mapper.Noop),
31 ('force', 'force', mapper.Noop),
32 ('source', 'volume_id', mapper.Resource('cinder.volume')),
33 ('progress', 'os-extended-snapshot-attributes:progress', mapper.Noop),
34 ('project', 'os-extended-snapshot-attributes:project_id',
35 mapper.Resource('project')),
36 ('metadata', 'metadata', mapper.Noop),
37 ('created_at', 'created_at', mapper.DateTime),
38 ('updated_at', 'updated_at', mapper.DateTime),
39 ]
40
41
43 """resource class for volume snapshots on Block Storage V2 API"""
44
45 _stable_state = ['available', 'error', 'error_deleting']
46
56
68
81
82
84 """manager class for volume snapshots on Block Storage V2 API"""
85
86 resource_class = Resource
87 service_type = 'volume'
88 _attr_mapping = ATTRIBUTE_MAPPING
89 _json_resource_key = 'snapshot'
90 _json_resources_key = 'snapshots'
91 _hidden_methods = ["update"]
92 _url_resource_list_path = '/snapshots/detail'
93 _url_resource_path = '/snapshots'
94
97 """
98 Create a snapshot of a volume
99
100 @keyword name: Snapshot name
101 @type name: str
102 @keyword description: Description
103 @type description: str
104 @keyword metadata: Metadata
105 @type metadata: dict
106 @keyword source: Source volume
107 @type source: yakumo.cinder.v2.volume.Resource
108 @return: Created volume object
109 @rtype: yakumo.cinder.v2.snapshot.Resource
110 """
111 return super(Manager, self).create(name=name,
112 description=description,
113 metadata=metadata,
114 source=source,
115 force=force)
116