1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2010 OpenStack LLC.
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
20
from cinder import exception as exc
22
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
26
def stub_volume(id, **kwargs):
29
'user_id': 'fakeuser',
30
'project_id': 'fakeproject',
33
'availability_zone': 'fakeaz',
34
'instance_uuid': 'fakeuuid',
36
'status': 'fakestatus',
37
'attach_status': 'attached',
40
'display_name': 'displayname',
41
'display_description': 'displaydesc',
42
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
45
'volume_type_id': '3e196c20-3c06-11e2-81c1-0800200c9a66',
46
'volume_metadata': [],
47
'volume_type': {'name': 'vol_type_name'}}
53
def stub_volume_create(self, context, size, name, description, snapshot,
55
vol = stub_volume('1')
57
vol['display_name'] = name
58
vol['display_description'] = description
59
vol['source_volid'] = None
61
vol['snapshot_id'] = snapshot['id']
62
except (KeyError, TypeError):
63
vol['snapshot_id'] = None
64
vol['availability_zone'] = param.get('availability_zone', 'fakeaz')
68
def stub_volume_create_from_image(self, context, size, name, description,
69
snapshot, volume_type, metadata,
71
vol = stub_volume('1')
72
vol['status'] = 'creating'
74
vol['display_name'] = name
75
vol['display_description'] = description
76
vol['availability_zone'] = 'cinder'
80
def stub_volume_update(self, context, *args, **param):
84
def stub_volume_delete(self, context, *args, **param):
88
def stub_volume_get(self, context, volume_id):
89
return stub_volume(volume_id)
92
def stub_volume_get_notfound(self, context, volume_id):
96
def stub_volume_get_all(context, search_opts=None):
97
return [stub_volume(100, project_id='fake'),
98
stub_volume(101, project_id='superfake'),
99
stub_volume(102, project_id='superduperfake')]
102
def stub_volume_get_all_by_project(self, context, search_opts=None):
103
return [stub_volume_get(self, context, '1')]
106
def stub_snapshot(id, **kwargs):
107
snapshot = {'id': id,
109
'status': 'available',
112
'display_name': 'Default name',
113
'display_description': 'Default description',
114
'project_id': 'fake'}
116
snapshot.update(kwargs)
120
def stub_snapshot_get_all(self):
121
return [stub_snapshot(100, project_id='fake'),
122
stub_snapshot(101, project_id='superfake'),
123
stub_snapshot(102, project_id='superduperfake')]
126
def stub_snapshot_get_all_by_project(self, context):
127
return [stub_snapshot(1)]
130
def stub_snapshot_update(self, context, *args, **param):