Beispiel #1
0
 def _get_running_instance(self, obj=True):
     instance_ref = test_utils.get_test_instance(obj=obj)
     network_info = test_utils.get_test_network_info()
     network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
         '1.1.1.1'
     image_info = test_utils.get_test_image_info(None, instance_ref)
     self.connection.spawn(self.ctxt, instance_ref, image_info,
                           [], 'herp', network_info=network_info)
     return instance_ref, network_info
Beispiel #2
0
 def test_get_vif_info(self, mock_get_network_ref):
     network_info = utils.get_test_network_info()
     vif_info = vif.get_vif_info('fake_session', 'fake_cluster',
                                 'is_neutron', 'fake_model', network_info)
     expected = [{'iface_id': 'vif-xxx-yyy-zzz',
                  'mac_address': 'fake',
                  'network_name': 'fake',
                  'network_ref': 'fake_ref',
                  'vif_model': 'fake_model'}]
     self.assertEqual(expected, vif_info)
Beispiel #3
0
 def test_get_vif_info(self, mock_get_network_ref):
     network_info = utils.get_test_network_info()
     vif_info = vif.get_vif_info('fake_session', 'fake_cluster',
                                 'is_neutron', 'fake_model', network_info)
     expected = [{
         'iface_id': 'vif-xxx-yyy-zzz',
         'mac_address': 'fake',
         'network_name': 'fake',
         'network_ref': 'fake_ref',
         'vif_model': 'fake_model'
     }]
     self.assertEqual(expected, vif_info)
Beispiel #4
0
 def test_unfilter_instance(self):
     instance_ref = test_utils.get_test_instance()
     network_info = test_utils.get_test_network_info()
     self.connection.unfilter_instance(instance_ref, network_info)
Beispiel #5
0
 def test_ensure_filtering_for_instance(self):
     instance = test_utils.get_test_instance(obj=True)
     network_info = test_utils.get_test_network_info()
     self.connection.ensure_filtering_rules_for_instance(instance,
                                                         network_info)
Beispiel #6
0
 def test_destroy_instance_nonexistent(self):
     fake_instance = test_utils.get_test_instance(obj=True)
     network_info = test_utils.get_test_network_info()
     self.connection.destroy(self.ctxt, fake_instance, network_info)
Beispiel #7
0
    def setUp(self, mock_register):
        super(ConfigDriveTestCase, self).setUp()
        vm_util.vm_refs_cache_reset()
        self.context = context.RequestContext('fake', 'fake', is_admin=False)
        cluster_name = 'test_cluster'
        self.flags(cluster_name=[cluster_name],
                   host_ip='test_url',
                   host_username='******',
                   host_password='******',
                   use_linked_clone=False, group='vmware')
        self.flags(vnc_enabled=False)
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        patron.tests.unit.image.fake.stub_out_image_service(self.stubs)
        self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
        self.network_info = utils.get_test_network_info()
        self.node_name = '%s(%s)' % (self.conn.dict_mors.keys()[0],
                                     cluster_name)
        image_ref = patron.tests.unit.image.fake.get_valid_image_id()
        instance_values = {
            'vm_state': 'building',
            'project_id': 'fake',
            'user_id': 'fake',
            'name': '1',
            'kernel_id': '1',
            'ramdisk_id': '1',
            'mac_addresses': [{'address': 'de:ad:be:ef:be:ef'}],
            'memory_mb': 8192,
            'flavor': 'm1.large',
            'instance_type_id': 0,
            'vcpus': 4,
            'root_gb': 80,
            'image_ref': image_ref,
            'host': 'fake_host',
            'task_state': 'scheduling',
            'reservation_id': 'r-3t8muvr0',
            'id': 1,
            'uuid': 'fake-uuid',
            'node': self.node_name,
            'metadata': [],
            'expected_attrs': ['system_metadata'],
        }
        self.test_instance = fake_instance.fake_instance_obj(self.context,
                                                             **instance_values)
        self.test_instance.flavor = objects.Flavor(extra_specs={})

        (image_service, image_id) = glance.get_remote_image_service(context,
                                    image_ref)
        metadata = image_service.show(context, image_id)
        self.image = {
            'id': image_ref,
            'disk_format': 'vmdk',
            'size': int(metadata['size']),
        }

        class FakeInstanceMetadata(object):
            def __init__(self, instance, content=None, extra_md=None):
                pass

            def metadata_for_config_drive(self):
                return []

        self.useFixture(fixtures.MonkeyPatch(
                'patron.api.metadata.base.InstanceMetadata',
                FakeInstanceMetadata))

        def fake_make_drive(_self, _path):
            pass
        # We can't actually make a config drive v2 because ensure_tree has
        # been faked out
        self.stubs.Set(patron.virt.configdrive.ConfigDriveBuilder,
                       'make_drive', fake_make_drive)

        def fake_upload_iso_to_datastore(iso_path, instance, **kwargs):
            pass
        self.stubs.Set(images,
                       'upload_iso_to_datastore',
                       fake_upload_iso_to_datastore)