Exemple #1
0
    def _live_migration_dest_check(self, context, instance_ref, dest):
        """Live migration check routine (for destination host).

        :param context: security context
        :param instance_ref: nova.db.sqlalchemy.models.Instance object
        :param dest: destination host
        """

        # Checking dest exists and compute node.
        dservice_refs = db.service_get_all_compute_by_host(context, dest)
        dservice_ref = dservice_refs[0]

        # Checking dest host is alive.
        if not utils.service_is_up(dservice_ref):
            raise exception.ComputeServiceUnavailable(host=dest)

        # Checking whether The host where instance is running
        # and dest is not same.
        src = instance_ref['host']
        if dest == src:
            raise exception.UnableToMigrateToSelf(
                    instance_id=instance_ref['uuid'], host=dest)

        # Check memory requirements
        self._assert_compute_node_has_enough_memory(context,
                                                   instance_ref, dest)
Exemple #2
0
    def _live_migration_dest_check(self, context, instance_ref, dest,
                                   block_migration, disk_over_commit):
        """Live migration check routine (for destination host).

        :param context: security context
        :param instance_ref: nova.db.sqlalchemy.models.Instance object
        :param dest: destination host
        :param block_migration: if true, block_migration.
        :param disk_over_commit: if True, consider real(not virtual)
                                 disk size.
        """

        # Checking dest exists and compute node.
        dservice_refs = db.service_get_all_compute_by_host(context, dest)
        dservice_ref = dservice_refs[0]

        # Checking dest host is alive.
        if not utils.service_is_up(dservice_ref):
            raise exception.ComputeServiceUnavailable(host=dest)

        # Checking whether The host where instance is running
        # and dest is not same.
        src = instance_ref['host']
        if dest == src:
            raise exception.UnableToMigrateToSelf(
                    instance_id=instance_ref['uuid'], host=dest)

        # Checking dst host still has enough capacities.
        self.assert_compute_node_has_enough_resources(context,
                                                      instance_ref,
                                                      dest,
                                                      block_migration,
                                                      disk_over_commit)
Exemple #3
0
    def _live_migration_dest_check(self, context, instance_ref, dest,
                                   block_migration):
        """Live migration check routine (for destination host).

        :param context: security context
        :param instance_ref: nova.db.sqlalchemy.models.Instance object
        :param dest: destination host

        """

        # Checking dest exists and compute node.
        dservice_refs = db.service_get_all_compute_by_host(context, dest)
        dservice_ref = dservice_refs[0]

        # Checking dest host is alive.
        if not self.service_is_up(dservice_ref):
            raise exception.ComputeServiceUnavailable(host=dest)

        # Checking whether The host where instance is running
        # and dest is not same.
        src = instance_ref['host']
        if dest == src:
            instance_id = ec2utils.id_to_ec2_id(instance_ref['id'])
            raise exception.UnableToMigrateToSelf(instance_id=instance_id,
                                                  host=dest)

        # Checking dst host still has enough capacities.
        self.assert_compute_node_has_enough_resources(context, instance_ref,
                                                      dest, block_migration)
    def test_migrate_live_unable_to_migrate_to_self(self):
        ctxt = context.get_admin_context()
        ctxt.user_id = 'fake'
        ctxt.project_id = 'fake'
        ctxt.is_admin = True
        app = fakes.wsgi_app(fake_auth_context=ctxt, init_only=('servers', ))
        req = webob.Request.blank('/v2/fake/servers/%s/action' % self.UUID)
        req.method = 'POST'
        req.body = jsonutils.dumps({
            'os-migrateLive': {
                'host': 'hostname',
                'block_migration': False,
                'disk_over_commit': False,
            }
        })
        req.content_type = 'application/json'

        def fake_update(inst, context, instance, task_state,
                        expected_task_state):
            return None

        def fake_migrate_server(self, context, instance, scheduler_hint, live,
                                rebuild, flavor, block_migration,
                                disk_over_commit):
            raise exception.UnableToMigrateToSelf(self.UUID, host='host')

        self.stubs.Set(compute_api.API, 'update', fake_update)
        self.stubs.Set(conductor_api.ComputeTaskAPI, 'migrate_server',
                       fake_migrate_server)

        res = req.get_response(app)
        self.assertEqual(res.status_int, 400)
        self.assertIn(
            unicode(exception.UnableToMigrateToSelf(self.UUID, host='host')),
            res.body)
 def _check_destination_is_not_source(self):
     #if self.destination == self.source:
     if CONF.allow_migrate_to_same_host:
        LOG.info("_check_destination_is_not_source_1:::::::::::")
        LOG.info(CONF.allow_migrate_to_same_host)  
     elif self.destination == self.source:
         raise exception.UnableToMigrateToSelf(
                 instance_id=self.instance.uuid, host=self.destination)
Exemple #6
0
    def _live_migration_dest_check(self,
                                   context,
                                   instance_ref,
                                   dest,
                                   ignore_hosts=None):
        """Live migration check routine (for destination host).

        :param context: security context
        :param instance_ref: nova.db.sqlalchemy.models.Instance object
        :param dest: destination host
        :param ignore_hosts: hosts that should be avoided as dest host
        """

        # If dest is not specified, have scheduler pick one.
        if dest is None:
            instance_type = flavors.extract_instance_type(instance_ref)
            if not instance_ref['image_ref']:
                image = None
            else:
                image = self.image_service.show(context,
                                                instance_ref['image_ref'])
            request_spec = {
                'instance_properties': instance_ref,
                'instance_type': instance_type,
                'instance_uuids': [instance_ref['uuid']],
                'image': image
            }
            filter_properties = {'ignore_hosts': ignore_hosts}
            return self.select_hosts(context, request_spec,
                                     filter_properties)[0]

        # Checking whether The host where instance is running
        # and dest is not same.
        src = instance_ref['host']
        if dest == src:
            raise exception.UnableToMigrateToSelf(
                instance_id=instance_ref['uuid'], host=dest)

        # Checking dest exists and compute node.
        try:
            dservice_ref = db.service_get_by_compute_host(context, dest)
        except exception.NotFound:
            raise exception.ComputeServiceUnavailable(host=dest)

        # Checking dest host is alive.
        if not self.servicegroup_api.service_is_up(dservice_ref):
            raise exception.ComputeServiceUnavailable(host=dest)

        # Check memory requirements
        self._assert_compute_node_has_enough_memory(context, instance_ref,
                                                    dest)

        return dest
Exemple #7
0
 def _check_destination_is_not_source(self):
     if self.destination == self.source:
         raise exception.UnableToMigrateToSelf(
                 instance_id=self.instance.uuid, host=self.destination)
Exemple #8
0
 def test_migrate_live_unable_to_migrate_to_self(self):
     uuid = uuidutils.generate_uuid()
     self._test_migrate_live_failed_with_exception(
             exception.UnableToMigrateToSelf(instance_id=uuid,
                                             host='host'),
                                             uuid=uuid)
Exemple #9
0
 def fake_migrate_server(self, context, instance,
         scheduler_hint, live, rebuild, flavor,
         block_migration, disk_over_commit):
     raise exception.UnableToMigrateToSelf(self.UUID, host='host')
Exemple #10
0
 def test_migrate_live_unable_to_migrate_to_self(self):
     self._test_migrate_live_failed_with_exception(
         exception.UnableToMigrateToSelf(instance_id=self.UUID,
                                         host='host'))
Exemple #11
0
 def fake_scheduler_api_live_migration(context, dest,
                                 block_migration=False,
                                 disk_over_commit=False, instance=None,
                                 instance_id=None, topic=None):
     raise exception.UnableToMigrateToSelf(self.UUID, host='host')