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

« back to all changes in this revision

Viewing changes to nova/tests/image/fake.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:
20
20
 
21
21
import copy
22
22
import datetime
 
23
import uuid
23
24
 
24
25
from nova import exception
25
 
from nova import flags
26
26
import nova.image.glance
 
27
from nova.openstack.common import cfg
27
28
from nova.openstack.common import log as logging
28
 
from nova import utils
29
 
 
30
 
 
 
29
 
 
30
 
 
31
CONF = cfg.CONF
 
32
CONF.import_opt('null_kernel', 'nova.config')
31
33
LOG = logging.getLogger(__name__)
32
34
 
33
35
 
34
 
FLAGS = flags.FLAGS
35
 
 
36
 
 
37
36
class _FakeImageService(object):
38
37
    """Mock (fake) image service for unit testing."""
39
38
 
53
52
                 'is_public': False,
54
53
                 'container_format': 'raw',
55
54
                 'disk_format': 'raw',
56
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
57
 
                                'ramdisk_id': FLAGS.null_kernel,
 
55
                 'properties': {'kernel_id': CONF.null_kernel,
 
56
                                'ramdisk_id': CONF.null_kernel,
58
57
                                'architecture': 'x86_64'}}
59
58
 
60
59
        image2 = {'id': 'a2459075-d96c-40d5-893e-577ff92e721c',
67
66
                 'is_public': True,
68
67
                 'container_format': 'ami',
69
68
                 'disk_format': 'ami',
70
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
71
 
                                'ramdisk_id': FLAGS.null_kernel}}
 
69
                 'properties': {'kernel_id': CONF.null_kernel,
 
70
                                'ramdisk_id': CONF.null_kernel}}
72
71
 
73
72
        image3 = {'id': '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6',
74
73
                 'name': 'fakeimage123456',
80
79
                 'is_public': True,
81
80
                 'container_format': None,
82
81
                 'disk_format': None,
83
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
84
 
                                'ramdisk_id': FLAGS.null_kernel}}
 
82
                 'properties': {'kernel_id': CONF.null_kernel,
 
83
                                'ramdisk_id': CONF.null_kernel}}
85
84
 
86
85
        image4 = {'id': 'cedef40a-ed67-4d10-800e-17455edce175',
87
86
                 'name': 'fakeimage123456',
93
92
                 'is_public': True,
94
93
                 'container_format': 'ami',
95
94
                 'disk_format': 'ami',
96
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
97
 
                                'ramdisk_id': FLAGS.null_kernel}}
 
95
                 'properties': {'kernel_id': CONF.null_kernel,
 
96
                                'ramdisk_id': CONF.null_kernel}}
98
97
 
99
98
        image5 = {'id': 'c905cedb-7281-47e4-8a62-f26bc5fc4c77',
100
99
                 'name': 'fakeimage123456',
120
119
                 'is_public': False,
121
120
                 'container_format': 'ova',
122
121
                 'disk_format': 'vhd',
123
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
124
 
                                'ramdisk_id': FLAGS.null_kernel,
 
122
                 'properties': {'kernel_id': CONF.null_kernel,
 
123
                                'ramdisk_id': CONF.null_kernel,
125
124
                                'architecture': 'x86_64',
126
125
                                'auto_disk_config': 'False'}}
127
126
 
135
134
                 'is_public': False,
136
135
                 'container_format': 'ova',
137
136
                 'disk_format': 'vhd',
138
 
                 'properties': {'kernel_id': FLAGS.null_kernel,
139
 
                                'ramdisk_id': FLAGS.null_kernel,
 
137
                 'properties': {'kernel_id': CONF.null_kernel,
 
138
                                'ramdisk_id': CONF.null_kernel,
140
139
                                'architecture': 'x86_64',
141
140
                                'auto_disk_config': 'True'}}
142
141
 
178
177
        :raises: Duplicate if the image already exist.
179
178
 
180
179
        """
181
 
        image_id = str(metadata.get('id', utils.gen_uuid()))
 
180
        image_id = str(metadata.get('id', uuid.uuid4()))
182
181
        metadata['id'] = image_id
183
182
        if image_id in self.images:
184
183
            raise exception.Duplicate()