~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/fake_volume.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
"""Implementation of a fake volume API"""
16
16
 
 
17
import uuid
 
18
 
17
19
from nova import exception
18
20
from nova.openstack.common import log as logging
19
21
from nova.openstack.common import timeutils
20
 
from nova import utils
 
22
 
21
23
 
22
24
LOG = logging.getLogger(__name__)
23
25
 
27
29
    instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66'
28
30
 
29
31
    def __init__(self, size, name,
30
 
                 description, id, snapshot,
 
32
                 description, volume_id, snapshot,
31
33
                 volume_type, metadata,
32
34
                 availability_zone):
33
35
        snapshot_id = None
34
36
        if snapshot is not None:
35
37
            snapshot_id = snapshot['id']
36
 
        if id is None:
37
 
            id = str(utils.gen_uuid())
 
38
        if volume_id is None:
 
39
            volume_id = str(uuid.uuid4())
38
40
        self.vol = {
39
41
            'created_at': timeutils.utcnow(),
40
42
            'deleted_at': None,
41
43
            'updated_at': timeutils.utcnow(),
42
44
            'uuid': 'WTF',
43
45
            'deleted': False,
44
 
            'id': id,
 
46
            'id': volume_id,
45
47
            'user_id': self.user_uuid,
46
48
            'project_id': 'fake-project-id',
47
49
            'snapshot_id': snapshot_id,
79
81
 
80
82
    def __init__(self, volume_id, size, name, desc, id=None):
81
83
        if id is None:
82
 
            id = str(utils.gen_uuid())
 
84
            id = str(uuid.uuid4())
83
85
        self.snap = {
84
86
            'created_at': timeutils.utcnow(),
85
87
            'deleted_at': None,
133
135
        return v.vol
134
136
 
135
137
    def create_with_kwargs(self, context, **kwargs):
 
138
        volume_id = kwargs.get('volume_id', None)
 
139
        print volume_id
136
140
        v = fake_volume(kwargs['size'],
137
141
                        kwargs['name'],
138
142
                        kwargs['description'],
139
 
                        str(kwargs.get('volume_id', None)),
 
143
                        str(volume_id),
140
144
                        None,
141
145
                        None,
142
146
                        None,
143
147
                        None)
 
148
        print v.vol['id']
144
149
        if kwargs.get('status', None) is not None:
145
150
            v.vol['status'] = kwargs['status']
146
151
        if kwargs['host'] is not None:
163
168
            if v['id'] == str(volume_id):
164
169
                return v
165
170
 
 
171
        raise exception.VolumeNotFound(volume_id=volume_id)
 
172
 
166
173
    def get_all(self, context):
167
174
        return self.volume_list
168
175
 
173
180
    def check_attach(self, context, volume):
174
181
        if volume['status'] != 'available':
175
182
            msg = _("status must be available")
 
183
            msg = "%s" % volume
176
184
            raise exception.InvalidVolume(reason=msg)
177
185
        if volume['attach_status'] == 'attached':
178
186
            msg = _("already attached")