~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/api/ec2/test_cloud.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Soren Hansen
  • Date: 2012-09-07 17:49:53 UTC
  • mfrom: (1.1.61)
  • Revision ID: package-import@ubuntu.com-20120907174953-oapuvix1jxm830he
Tags: 2012.2~rc1~20120907.15996-0ubuntu1
[ Chuck Short ]
* New upstream release.
* debian/nova-common.postinst: Drop nova_sudoers permission changing
  since we do it in the debian/rules. (LP: #995285)

[ Soren Hansen ]
* Update debian/watch to account for symbolically named tarballs and
  use newer URL.
* Fix Launchpad URLs in debian/watch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
from nova.tests.image import fake
47
47
from nova import utils
48
48
from nova.virt import fake as fake_virt
 
49
from nova.volume import iscsi
49
50
 
50
51
 
51
52
LOG = logging.getLogger(__name__)
97
98
        vol_tmpdir = tempfile.mkdtemp()
98
99
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
99
100
                   volumes_dir=vol_tmpdir)
 
101
        self.stubs.Set(iscsi.TgtAdm, '_get_target', self.fake_get_target)
100
102
 
101
103
        def fake_show(meh, context, id):
102
104
            return {'id': id,
158
160
        super(CloudTestCase, self).tearDown()
159
161
        fake.FakeImageService_reset()
160
162
 
 
163
    def fake_get_target(obj, iqn):
 
164
        return 1
 
165
 
161
166
    def _stub_instance_get_with_fixed_ips(self, func_name):
162
167
        orig_func = getattr(self.cloud.compute_api, func_name)
163
168
 
1993
1998
        self.assertTrue(result)
1994
1999
 
1995
2000
    def _volume_create(self, volume_id=None):
 
2001
        location = '10.0.2.15:3260'
 
2002
        iqn = 'iqn.2010-10.org.openstack:%s' % volume_id
1996
2003
        kwargs = {'status': 'available',
1997
2004
                  'host': self.volume.host,
1998
2005
                  'size': 1,
 
2006
                  'provider_location': '1 %s,fake %s' % (location, iqn),
1999
2007
                  'attach_status': 'detached', }
2000
2008
        if volume_id:
2001
2009
            kwargs['id'] = volume_id
2090
2098
        kwargs = {'image_id': 'ami-1',
2091
2099
                  'instance_type': FLAGS.default_instance_type,
2092
2100
                  'max_count': 1,
2093
 
                  'block_device_mapping': [{'device_name': '/dev/vdb',
 
2101
                  'block_device_mapping': [{'device_name': '/dev/sdb',
2094
2102
                                            'volume_id': vol1['id'],
2095
2103
                                            'delete_on_termination': True}]}
2096
2104
        ec2_instance_id = self._run_instance(**kwargs)
2102
2110
        self.assertEqual(len(vols), 1)
2103
2111
        for vol in vols:
2104
2112
            self.assertEqual(vol['id'], vol1['id'])
2105
 
            self._assert_volume_attached(vol, instance_uuid, '/dev/vdb')
 
2113
            self._assert_volume_attached(vol, instance_uuid, '/dev/sdb')
2106
2114
 
2107
2115
        vol = db.volume_get(self.context, vol2['id'])
2108
2116
        self._assert_volume_detached(vol)
2113
2121
                                             volume_id=vol2['id'],
2114
2122
                                             device='/dev/vdc')
2115
2123
        vol = db.volume_get(self.context, vol2['id'])
2116
 
        self._assert_volume_attached(vol, instance_uuid, '/dev/vdc')
 
2124
        self._assert_volume_attached(vol, instance_uuid, '/dev/sdc')
2117
2125
 
2118
2126
        self.cloud.compute_api.detach_volume(self.context,
2119
2127
                                             volume_id=vol1['id'])
2124
2132
        self.assertTrue(result)
2125
2133
 
2126
2134
        vol = db.volume_get(self.context, vol2['id'])
2127
 
        self._assert_volume_attached(vol, instance_uuid, '/dev/vdc')
 
2135
        self._assert_volume_attached(vol, instance_uuid, '/dev/sdc')
2128
2136
 
2129
2137
        self.cloud.start_instances(self.context, [ec2_instance_id])
2130
2138
        vols = db.volume_get_all_by_instance_uuid(self.context, instance_uuid)
2131
2139
        self.assertEqual(len(vols), 1)
2132
2140
        for vol in vols:
2133
2141
            self.assertEqual(vol['id'], vol2['id'])
2134
 
            self._assert_volume_attached(vol, instance_uuid, '/dev/vdc')
 
2142
            self._assert_volume_attached(vol, instance_uuid, '/dev/sdc')
2135
2143
 
2136
2144
        vol = db.volume_get(self.context, vol1['id'])
2137
2145
        self._assert_volume_detached(vol)