~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_bdm.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
"""
21
21
 
22
22
from nova.api.ec2 import cloud
 
23
from nova.api.ec2 import ec2utils
23
24
from nova import test
24
25
 
25
26
 
26
27
class BlockDeviceMappingEc2CloudTestCase(test.TestCase):
27
28
    """Test Case for Block Device Mapping"""
28
29
 
 
30
    def fake_ec2_vol_id_to_uuid(obj, ec2_id):
 
31
        if ec2_id == 'snap-12345678':
 
32
            return '00000000-1111-2222-3333-444444444444'
 
33
        elif ec2_id == 'snap-23456789':
 
34
            return '11111111-2222-3333-4444-555555555555'
 
35
        elif ec2_id == 'vol-87654321':
 
36
            return '22222222-3333-4444-5555-666666666666'
 
37
        elif ec2_id == 'vol-98765432':
 
38
            return '77777777-8888-9999-0000-aaaaaaaaaaaa'
 
39
        else:
 
40
            return 'OhNoooo'
 
41
 
29
42
    def _assertApply(self, action, bdm_list):
30
43
        for bdm, expected_result in bdm_list:
31
44
            self.assertDictMatch(action(bdm), expected_result)
32
45
 
33
46
    def test_parse_block_device_mapping(self):
 
47
        self.stubs.Set(ec2utils,
 
48
                'ec2_vol_id_to_uuid',
 
49
                self.fake_ec2_vol_id_to_uuid)
 
50
 
34
51
        bdm_list = [
35
52
            ({'device_name': '/dev/fake0',
36
53
              'ebs': {'snapshot_id': 'snap-12345678',
37
54
                      'volume_size': 1}},
38
55
            {'device_name': '/dev/fake0',
39
 
             'snapshot_id': 0x12345678,
 
56
             'snapshot_id': '00000000-1111-2222-3333-444444444444',
40
57
             'volume_size': 1,
41
58
             'delete_on_termination': True}),
42
59
 
44
61
              'ebs': {'snapshot_id': 'snap-23456789',
45
62
                      'delete_on_termination': False}},
46
63
             {'device_name': '/dev/fake1',
47
 
              'snapshot_id': 0x23456789,
 
64
              'snapshot_id': '11111111-2222-3333-4444-555555555555',
48
65
              'delete_on_termination': False}),
49
66
 
50
67
            ({'device_name': '/dev/fake2',
51
68
              'ebs': {'snapshot_id': 'vol-87654321',
52
69
                      'volume_size': 2}},
53
70
            {'device_name': '/dev/fake2',
54
 
             'volume_id': 0x87654321,
 
71
             'volume_id': '22222222-3333-4444-5555-666666666666',
55
72
             'volume_size': 2,
56
73
             'delete_on_termination': True}),
57
74
 
59
76
              'ebs': {'snapshot_id': 'vol-98765432',
60
77
                      'delete_on_termination': False}},
61
78
             {'device_name': '/dev/fake3',
62
 
              'volume_id': 0x98765432,
 
79
              'volume_id': '77777777-8888-9999-0000-aaaaaaaaaaaa',
63
80
              'delete_on_termination': False}),
64
81
 
65
82
            ({'device_name': '/dev/fake4',