~citrix-openstack/nova/xenapi

« back to all changes in this revision

Viewing changes to nova/tests/test_xenapi.py

  • Committer: Salvatore Orlando
  • Date: 2011-02-28 16:12:06 UTC
  • mfrom: (408.9.326 nova)
  • Revision ID: salvatore.orlando@eu.citrix.com-20110228161206-eo8z2knv7bpck1da
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from nova.virt.xenapi import fake as xenapi_fake
33
33
from nova.virt.xenapi import volume_utils
34
34
from nova.virt.xenapi.vmops import SimpleDH
 
35
from nova.virt.xenapi.vmops import VMOps
35
36
from nova.tests.db import fakes as db_fakes
36
37
from nova.tests.xenapi import stubs
37
38
from nova.tests.glance import stubs as glance_stubs
141
142
        self.stubs.UnsetAll()
142
143
 
143
144
 
 
145
def reset_network(*args):
 
146
    pass
 
147
 
 
148
 
144
149
class XenAPIVMTestCase(test.TestCase):
145
150
    """
146
151
    Unit tests for VM operations
162
167
        stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
163
168
        stubs.stubout_get_this_vm_uuid(self.stubs)
164
169
        stubs.stubout_stream_disk(self.stubs)
 
170
        stubs.stubout_is_vdi_pv(self.stubs)
 
171
        self.stubs.Set(VMOps, 'reset_network', reset_network)
165
172
        glance_stubs.stubout_glance_client(self.stubs,
166
173
                                           glance_stubs.FakeGlance)
167
174
        self.conn = xenapi_conn.get_connection(False)
243
250
        # Check that the VM is running according to XenAPI.
244
251
        self.assertEquals(vm['power_state'], 'Running')
245
252
 
246
 
    def _test_spawn(self, image_id, kernel_id, ramdisk_id):
 
253
    def _test_spawn(self, image_id, kernel_id, ramdisk_id,
 
254
                    instance_type="m1.large"):
247
255
        stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
248
256
        values = {'name': 1,
249
257
                  'id': 1,
252
260
                  'image_id': image_id,
253
261
                  'kernel_id': kernel_id,
254
262
                  'ramdisk_id': ramdisk_id,
255
 
                  'instance_type': 'm1.large',
 
263
                  'instance_type': instance_type,
256
264
                  'mac_address': 'aa:bb:cc:dd:ee:ff',
257
265
                  }
258
266
        conn = xenapi_conn.get_connection(False)
260
268
        conn.spawn(instance)
261
269
        self.check_vm_record(conn)
262
270
 
 
271
    def test_spawn_not_enough_memory(self):
 
272
        FLAGS.xenapi_image_service = 'glance'
 
273
        self.assertRaises(Exception,
 
274
                          self._test_spawn,
 
275
                          1, 2, 3, "m1.xlarge")
 
276
 
263
277
    def test_spawn_raw_objectstore(self):
264
278
        FLAGS.xenapi_image_service = 'objectstore'
265
279
        self._test_spawn(1, None, None)