• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.add_instance_fault_from_exc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.compute.utils.add_instance_fault_from_exc函数的典型用法代码示例。如果您正苦于以下问题:Python add_instance_fault_from_exc函数的具体用法?Python add_instance_fault_from_exc怎么用?Python add_instance_fault_from_exc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_instance_fault_from_exc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: handle_schedule_error

def handle_schedule_error(context, ex, instance_uuid, request_spec):
    """On run_instance failure, update instance state and
    send notifications.
    """

    if not isinstance(ex, exception.NoValidHost):
        LOG.exception(_("Exception during scheduler.run_instance"))
    state = vm_states.ERROR.upper()
    LOG.warning(_("Setting instance to %s state."), state, instance_uuid=instance_uuid)

    (old_ref, new_ref) = db.instance_update_and_get_original(
        context, instance_uuid, {"vm_state": vm_states.ERROR, "task_state": None}
    )
    notifications.send_update(context, old_ref, new_ref, service="scheduler")
    compute_utils.add_instance_fault_from_exc(context, conductor_api.LocalAPI(), new_ref, ex, sys.exc_info())

    properties = request_spec.get("instance_properties", {})
    payload = dict(
        request_spec=request_spec,
        instance_properties=properties,
        instance_id=instance_uuid,
        state=vm_states.ERROR,
        method="run_instance",
        reason=ex,
    )

    notifier.get_notifier("scheduler").error(context, "scheduler.run_instance", payload)
开发者ID:osrg,项目名称:nova,代码行数:27,代码来源:driver.py


示例2: set_vm_state_and_notify

def set_vm_state_and_notify(context, service, method, updates, ex, request_spec, db):
    """changes VM state and notifies."""
    LOG.warning(_("Failed to %(service)s_%(method)s: %(ex)s"), {"service": service, "method": method, "ex": ex})

    vm_state = updates["vm_state"]
    properties = request_spec.get("instance_properties", {})
    # NOTE(vish): We shouldn't get here unless we have a catastrophic
    #             failure, so just set all instances to error. if uuid
    #             is not set, instance_uuids will be set to [None], this
    #             is solely to preserve existing behavior and can
    #             be removed along with the 'if instance_uuid:' if we can
    #             verify that uuid is always set.
    uuids = [properties.get("uuid")]
    notifier = rpc.get_notifier(service)
    for instance_uuid in request_spec.get("instance_uuids") or uuids:
        if instance_uuid:
            state = vm_state.upper()
            LOG.warning(_("Setting instance to %s state."), state, instance_uuid=instance_uuid)

            # update instance state and notify on the transition
            (old_ref, new_ref) = db.instance_update_and_get_original(context, instance_uuid, updates)
            notifications.send_update(context, old_ref, new_ref, service=service)
            compute_utils.add_instance_fault_from_exc(context, new_ref, ex, sys.exc_info())

        payload = dict(
            request_spec=request_spec,
            instance_properties=properties,
            instance_id=instance_uuid,
            state=vm_state,
            method=method,
            reason=ex,
        )

        event_type = "%s.%s" % (service, method)
        notifier.error(context, event_type, payload)
开发者ID:kelsieflynn,项目名称:nova,代码行数:35,代码来源:utils.py


示例3: set_vm_state_and_notify

def set_vm_state_and_notify(context, instance_uuid, service, method, updates,
                            ex, request_spec):
    """changes VM state and notifies."""
    LOG.warning(_LW("Failed to %(service)s_%(method)s: %(ex)s"),
                {'service': service, 'method': method, 'ex': ex})

    vm_state = updates['vm_state']
    properties = request_spec.get('instance_properties', {})
    # NOTE(vish): We shouldn't get here unless we have a catastrophic
    #             failure, so just set the instance to its internal state
    notifier = rpc.get_notifier(service)
    state = vm_state.upper()
    LOG.warning(_LW('Setting instance to %s state.'), state,
                instance_uuid=instance_uuid)

    instance = objects.Instance(context=context, uuid=instance_uuid,
                                **updates)
    instance.obj_reset_changes(['uuid'])
    instance.save()
    compute_utils.add_instance_fault_from_exc(context,
            instance, ex, sys.exc_info())

    payload = dict(request_spec=request_spec,
                    instance_properties=properties,
                    instance_id=instance_uuid,
                    state=vm_state,
                    method=method,
                    reason=ex)

    event_type = '%s.%s' % (service, method)
    notifier.error(context, event_type, payload)
开发者ID:375670450,项目名称:nova,代码行数:31,代码来源:utils.py


示例4: test_basic_schedule_run_instance_no_hosts

    def test_basic_schedule_run_instance_no_hosts(self):
        ctxt = context.RequestContext('fake', 'fake', False)
        ctxt_elevated = 'fake-context-elevated'
        fake_args = (1, 2, 3)
        uuid = 'fake-uuid1'
        instance_opts = {'fake_opt1': 'meow', 'launch_index': -1}
        request_spec = {'instance_uuids': [uuid],
                        'instance_properties': instance_opts}

        self.mox.StubOutWithMock(ctxt, 'elevated')
        self.mox.StubOutWithMock(self.driver, 'hosts_up')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        # instance 1
        ctxt.elevated().AndReturn(ctxt_elevated)
        self.driver.hosts_up(ctxt_elevated, 'compute').AndReturn([])
        old_ref, new_ref = db.instance_update_and_get_original(ctxt, uuid,
                {'vm_state': vm_states.ERROR,
                 'task_state': None}).AndReturn(({}, {}))
        compute_utils.add_instance_fault_from_exc(ctxt,
                new_ref, mox.IsA(exception.NoValidHost), mox.IgnoreArg())

        self.mox.ReplayAll()
        self.driver.schedule_run_instance(
                ctxt, request_spec, None, None, None, None, {})
开发者ID:beride,项目名称:nova,代码行数:26,代码来源:test_chance_scheduler.py


示例5: test_run_instance_non_admin

    def test_run_instance_non_admin(self):
        self.was_admin = False

        def fake_get(context, *args, **kwargs):
            # make sure this is called with admin context, even though
            # we're using user context below
            self.was_admin = context.is_admin
            return {}

        sched = fakes.FakeFilterScheduler()
        self.stubs.Set(sched.host_manager, "get_all_host_states", fake_get)

        fake_context = context.RequestContext("user", "project")

        uuid = "fake-uuid1"
        instance_properties = {"project_id": 1, "os_type": "Linux"}
        request_spec = {
            "instance_type": {"memory_mb": 1, "local_gb": 1},
            "instance_properties": instance_properties,
            "instance_uuids": [uuid],
        }
        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")
        old_ref, new_ref = db.instance_update_and_get_original(
            fake_context, uuid, {"vm_state": vm_states.ERROR, "task_state": None}
        ).AndReturn(({}, {}))
        compute_utils.add_instance_fault_from_exc(
            fake_context, mox.IsA(conductor_api.LocalAPI), new_ref, mox.IsA(exception.NoValidHost), mox.IgnoreArg()
        )
        self.mox.ReplayAll()
        sched.schedule_run_instance(fake_context, request_spec, None, None, None, None, {}, False)
        self.assertTrue(self.was_admin)
开发者ID:pacharya-pf9,项目名称:nova,代码行数:32,代码来源:test_filter_scheduler.py


示例6: test_run_instance_no_hosts

    def test_run_instance_no_hosts(self):
        def _fake_empty_call_zone_method(*args, **kwargs):
            return []

        sched = fakes.FakeFilterScheduler()

        uuid = "fake-uuid1"
        fake_context = context.RequestContext("user", "project")
        instance_properties = {"project_id": 1, "os_type": "Linux"}
        request_spec = {
            "instance_type": {"memory_mb": 1, "root_gb": 1, "ephemeral_gb": 0},
            "instance_properties": instance_properties,
            "instance_uuids": [uuid],
        }

        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")
        old_ref, new_ref = db.instance_update_and_get_original(
            fake_context, uuid, {"vm_state": vm_states.ERROR, "task_state": None}
        ).AndReturn(({}, {}))
        compute_utils.add_instance_fault_from_exc(
            fake_context, mox.IsA(conductor_api.LocalAPI), new_ref, mox.IsA(exception.NoValidHost), mox.IgnoreArg()
        )

        self.mox.StubOutWithMock(db, "compute_node_get_all")
        db.compute_node_get_all(mox.IgnoreArg()).AndReturn([])

        self.mox.ReplayAll()
        sched.schedule_run_instance(fake_context, request_spec, None, None, None, None, {}, False)
开发者ID:pacharya-pf9,项目名称:nova,代码行数:29,代码来源:test_filter_scheduler.py


示例7: handle_schedule_error

def handle_schedule_error(context, ex, instance_uuid, request_spec):
    if not isinstance(ex, exception.NoValidHost):
        LOG.exception(_("Exception during scheduler.run_instance"))
    compute_utils.add_instance_fault_from_exc(context,
            instance_uuid, ex, sys.exc_info())
    state = vm_states.ERROR.upper()
    LOG.warning(_('Setting instance to %(state)s state.'),
                locals(), instance_uuid=instance_uuid)

    # update instance state and notify on the transition
    (old_ref, new_ref) = db.instance_update_and_get_original(context,
            instance_uuid, {'vm_state': vm_states.ERROR,
                            'task_state': None})
    notifications.send_update(context, old_ref, new_ref,
            service="scheduler")

    properties = request_spec.get('instance_properties', {})
    payload = dict(request_spec=request_spec,
                   instance_properties=properties,
                   instance_id=instance_uuid,
                   state=vm_states.ERROR,
                   method='run_instance',
                   reason=ex)

    notifier.notify(context, notifier.publisher_id("scheduler"),
                    'scheduler.run_instance', notifier.ERROR, payload)
开发者ID:dscannell,项目名称:nova,代码行数:26,代码来源:driver.py


示例8: test_live_migration_set_vmstate_error

    def test_live_migration_set_vmstate_error(self):
        inst = {"uuid": "fake-instance-id", "vm_state": vm_states.ACTIVE}

        dest = "fake_host"
        block_migration = False
        disk_over_commit = False

        self._mox_schedule_method_helper("schedule_live_migration")
        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")

        self.manager.driver.schedule_live_migration(
            self.context, inst, dest, block_migration, disk_over_commit
        ).AndRaise(ValueError)
        db.instance_update_and_get_original(self.context, inst["uuid"], {"vm_state": vm_states.ERROR}).AndReturn(
            (inst, inst)
        )
        compute_utils.add_instance_fault_from_exc(
            self.context, mox.IsA(conductor_api.LocalAPI), inst, mox.IsA(ValueError), mox.IgnoreArg()
        )

        self.mox.ReplayAll()
        self.stub_out_client_exceptions()
        self.assertRaises(
            ValueError, self.manager.live_migration, self.context, inst, dest, block_migration, disk_over_commit
        )
开发者ID:jjo,项目名称:openstack-nova,代码行数:26,代码来源:test_scheduler.py


示例9: test_live_migration_compute_service_notavailable

    def test_live_migration_compute_service_notavailable(self):
        inst = {"uuid": "fake-instance-id",
                "vm_state": vm_states.ACTIVE,
                "task_state": task_states.MIGRATING, }

        dest = 'fake_host'
        block_migration = False
        disk_over_commit = False

        self._mox_schedule_method_helper('schedule_live_migration')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        self.manager.driver.schedule_live_migration(self.context,
                    inst, dest, block_migration, disk_over_commit).AndRaise(
                    exception.ComputeServiceUnavailable(host="src"))
        db.instance_update_and_get_original(self.context, inst["uuid"],
                                {"vm_state": inst['vm_state'],
                                 "task_state": None,
                                 "expected_task_state": task_states.MIGRATING,
                                }).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(self.context,
                                mox.IsA(conductor_api.LocalAPI), inst,
                                mox.IsA(exception.ComputeServiceUnavailable),
                                mox.IgnoreArg())

        self.mox.ReplayAll()
        self.stub_out_client_exceptions()
        self.assertRaises(exception.ComputeServiceUnavailable,
                          self.manager.live_migration,
                          self.context, inst, dest, block_migration,
                          disk_over_commit)
开发者ID:achbarou,项目名称:nova,代码行数:32,代码来源:test_scheduler.py


示例10: test_prep_resize_no_valid_host_back_in_active_state

    def test_prep_resize_no_valid_host_back_in_active_state(self):
        fake_instance_uuid = 'fake-instance-id'
        fake_instance = {'uuid': fake_instance_uuid}
        inst = {"vm_state": "", "task_state": ""}

        self._mox_schedule_method_helper('schedule_prep_resize')

        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        request_spec = {'instance_type': 'fake_type',
                        'instance_uuids': [fake_instance_uuid],
                        'instance_properties': {'uuid': fake_instance_uuid}}
        kwargs = {
                'context': self.context,
                'image': 'fake_image',
                'request_spec': request_spec,
                'filter_properties': 'fake_props',
                'instance': fake_instance,
                'instance_type': 'fake_type',
                'reservations': list('fake_res'),
        }
        self.manager.driver.schedule_prep_resize(**kwargs).AndRaise(
                exception.NoValidHost(reason=""))
        old_ref, new_ref = db.instance_update_and_get_original(self.context,
                fake_instance_uuid,
                {"vm_state": vm_states.ACTIVE, "task_state": None}).AndReturn(
                        (inst, inst))
        compute_utils.add_instance_fault_from_exc(self.context,
                mox.IsA(conductor_api.LocalAPI), new_ref,
                mox.IsA(exception.NoValidHost), mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager.prep_resize(**kwargs)
开发者ID:achbarou,项目名称:nova,代码行数:34,代码来源:test_scheduler.py


示例11: test_prep_resize_exception_host_in_error_state_and_raise

    def test_prep_resize_exception_host_in_error_state_and_raise(self):
        fake_instance_uuid = "fake-instance-id"
        fake_instance = {"uuid": fake_instance_uuid}

        self._mox_schedule_method_helper("schedule_prep_resize")

        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")

        request_spec = {"instance_properties": {"uuid": fake_instance_uuid}}
        kwargs = {
            "context": self.context,
            "image": "fake_image",
            "request_spec": request_spec,
            "filter_properties": "fake_props",
            "instance": fake_instance,
            "instance_type": "fake_type",
            "reservations": list("fake_res"),
        }

        self.manager.driver.schedule_prep_resize(**kwargs).AndRaise(test.TestingException("something happened"))

        inst = {"vm_state": "", "task_state": ""}
        old_ref, new_ref = db.instance_update_and_get_original(
            self.context, fake_instance_uuid, {"vm_state": vm_states.ERROR, "task_state": None}
        ).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(
            self.context, mox.IsA(conductor_api.LocalAPI), new_ref, mox.IsA(test.TestingException), mox.IgnoreArg()
        )

        self.mox.ReplayAll()

        self.assertRaises(test.TestingException, self.manager.prep_resize, **kwargs)
开发者ID:jjo,项目名称:openstack-nova,代码行数:33,代码来源:test_scheduler.py


示例12: test_run_instance_exception_puts_instance_in_error_state

    def test_run_instance_exception_puts_instance_in_error_state(self):
        fake_instance_uuid = 'fake-instance-id'
        inst = {"vm_state": "", "task_state": ""}

        self._mox_schedule_method_helper('schedule_run_instance')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        request_spec = {'instance_properties': inst,
                        'instance_uuids': [fake_instance_uuid]}

        self.manager.driver.schedule_run_instance(self.context,
                request_spec, None, None, None, None, {}).AndRaise(
                        exception.NoValidHost(reason=""))
        old, new_ref = db.instance_update_and_get_original(self.context,
                fake_instance_uuid,
                {"vm_state": vm_states.ERROR,
                 "task_state": None}).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(self.context,
                mox.IsA(conductor_api.LocalAPI), new_ref,
                mox.IsA(exception.NoValidHost), mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager.run_instance(self.context, request_spec,
                None, None, None, None, {})
开发者ID:achbarou,项目名称:nova,代码行数:25,代码来源:test_scheduler.py


示例13: test_live_migration_schedule_novalidhost

    def test_live_migration_schedule_novalidhost(self):
        inst = {"uuid": "fake-instance-id",
                "vm_state": vm_states.ACTIVE,
                "task_state": task_states.MIGRATING, }

        dest = None
        block_migration = False
        disk_over_commit = False
        pclm = "pclm"

        self.mox.StubOutWithMock(self.manager, '_schedule_live_migration')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        self.manager._schedule_live_migration(self.context,
                    inst, dest, block_migration, disk_over_commit, pclm).AndRaise(
                    exception.NoValidHost(reason=""))
        db.instance_update_and_get_original(self.context, inst["uuid"],
                                {"vm_state": inst['vm_state'],
                                 "task_state": None,
                                 "expected_task_state": task_states.MIGRATING,
                                }).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(self.context,
                                mox.IsA(conductor_api.LocalAPI), inst,
                                mox.IsA(exception.NoValidHost),
                                mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager = utils.ExceptionHelper(self.manager)
        self.assertRaises(exception.NoValidHost,
                          self.manager.live_migration,
                          self.context, inst, dest, block_migration,
                          disk_over_commit, pclm)
开发者ID:guykr-stratoscale,项目名称:nova,代码行数:33,代码来源:test_scheduler.py


示例14: test_prep_resize_no_valid_host_back_in_active_state

    def test_prep_resize_no_valid_host_back_in_active_state(self):
        fake_instance_uuid = "fake-instance-id"
        fake_instance = {"uuid": fake_instance_uuid}
        inst = {"vm_state": "", "task_state": ""}

        self._mox_schedule_method_helper("schedule_prep_resize")

        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")

        request_spec = {
            "instance_type": "fake_type",
            "instance_uuids": [fake_instance_uuid],
            "instance_properties": {"uuid": fake_instance_uuid},
        }
        kwargs = {
            "context": self.context,
            "image": "fake_image",
            "request_spec": request_spec,
            "filter_properties": "fake_props",
            "instance": fake_instance,
            "instance_type": "fake_type",
            "reservations": list("fake_res"),
        }
        self.manager.driver.schedule_prep_resize(**kwargs).AndRaise(exception.NoValidHost(reason=""))
        old_ref, new_ref = db.instance_update_and_get_original(
            self.context, fake_instance_uuid, {"vm_state": vm_states.ACTIVE, "task_state": None}
        ).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(
            self.context, mox.IsA(conductor_api.LocalAPI), new_ref, mox.IsA(exception.NoValidHost), mox.IgnoreArg()
        )

        self.mox.ReplayAll()
        self.manager.prep_resize(**kwargs)
开发者ID:jjo,项目名称:openstack-nova,代码行数:34,代码来源:test_scheduler.py


示例15: test_live_migration_schedule_novalidhost

    def test_live_migration_schedule_novalidhost(self):
        inst = {"uuid": "fake-instance-id", "vm_state": vm_states.ACTIVE, "task_state": task_states.MIGRATING}

        dest = None
        block_migration = False
        disk_over_commit = False

        self._mox_schedule_method_helper("schedule_live_migration")
        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")

        self.manager.driver.schedule_live_migration(
            self.context, inst, dest, block_migration, disk_over_commit
        ).AndRaise(exception.NoValidHost(reason=""))
        db.instance_update_and_get_original(
            self.context,
            inst["uuid"],
            {"vm_state": inst["vm_state"], "task_state": None, "expected_task_state": task_states.MIGRATING},
        ).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(
            self.context, mox.IsA(conductor_api.LocalAPI), inst, mox.IsA(exception.NoValidHost), mox.IgnoreArg()
        )

        self.mox.ReplayAll()
        self.stub_out_client_exceptions()
        self.assertRaises(
            exception.NoValidHost,
            self.manager.live_migration,
            self.context,
            inst,
            dest,
            block_migration,
            disk_over_commit,
        )
开发者ID:jjo,项目名称:openstack-nova,代码行数:34,代码来源:test_scheduler.py


示例16: test_live_migration_compute_service_notavailable

    def test_live_migration_compute_service_notavailable(self):
        inst = {"uuid": "fake-instance-id", "vm_state": vm_states.ACTIVE, "task_state": task_states.MIGRATING}

        dest = "fake_host"
        block_migration = False
        disk_over_commit = False

        self.mox.StubOutWithMock(self.manager, "_schedule_live_migration")
        self.mox.StubOutWithMock(compute_utils, "add_instance_fault_from_exc")
        self.mox.StubOutWithMock(db, "instance_update_and_get_original")

        self.manager._schedule_live_migration(self.context, inst, dest, block_migration, disk_over_commit).AndRaise(
            exception.ComputeServiceUnavailable(host="src")
        )
        db.instance_update_and_get_original(
            self.context,
            inst["uuid"],
            {"vm_state": inst["vm_state"], "task_state": None, "expected_task_state": task_states.MIGRATING},
        ).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(
            self.context, inst, mox.IsA(exception.ComputeServiceUnavailable), mox.IgnoreArg()
        )

        self.mox.ReplayAll()
        self.manager = utils.ExceptionHelper(self.manager)
        self.assertRaises(
            exception.ComputeServiceUnavailable,
            self.manager.live_migration,
            self.context,
            inst,
            dest,
            block_migration,
            disk_over_commit,
        )
开发者ID:B-Rich,项目名称:nova-1,代码行数:34,代码来源:test_scheduler.py


示例17: test_upload_image_retries_on_signal_exception

    def test_upload_image_retries_on_signal_exception(self):
        self.flags(num_retries=2, group='glance')
        params = self._get_upload_params()

        self.mox.StubOutWithMock(self.session, 'call_plugin_serialized')
        self.mox.StubOutWithMock(time, 'sleep')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        error_details = ["", "task signaled", "", ""]
        error = self.session.XenAPI.Failure(details=error_details)
        self.session.call_plugin_serialized('glance', 'upload_vhd2',
                                            **params).AndRaise(error)
        compute_utils.add_instance_fault_from_exc(self.context, self.instance,
                                                  error, (fake.Failure,
                                                          error,
                                                          mox.IgnoreArg()))
        time.sleep(0.5)
        # Note(johngarbutt) XenServer 6.1 and later has this error
        error_details = ["", "signal: SIGTERM", "", ""]
        error = self.session.XenAPI.Failure(details=error_details)
        self.session.call_plugin_serialized('glance', 'upload_vhd2',
                                            **params).AndRaise(error)
        compute_utils.add_instance_fault_from_exc(self.context, self.instance,
                                                  error, (fake.Failure,
                                                          error,
                                                          mox.IgnoreArg()))
        time.sleep(1)
        self.session.call_plugin_serialized('glance', 'upload_vhd2',
                                            **params)
        self.mox.ReplayAll()

        self.store.upload_image(self.context, self.session, self.instance,
                                'fake_image_uuid', ['fake_vdi_uuid'])
        self.mox.VerifyAll()
开发者ID:BU-NU-CLOUD-SP16,项目名称:Trusted-Platform-Module-nova,代码行数:33,代码来源:test_glance.py


示例18: test_live_migration_set_vmstate_error

    def test_live_migration_set_vmstate_error(self):
        inst = {"uuid": "fake-instance-id",
                "vm_state": vm_states.ACTIVE, }

        dest = 'fake_host'
        block_migration = False
        disk_over_commit = False
        pclm = "pclm"

        self.mox.StubOutWithMock(self.manager, '_schedule_live_migration')
        self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
        self.mox.StubOutWithMock(db, 'instance_update_and_get_original')

        self.manager._schedule_live_migration(self.context,
                    inst, dest, block_migration, disk_over_commit, pclm).AndRaise(
                    ValueError)
        db.instance_update_and_get_original(self.context, inst["uuid"],
                                {"vm_state": vm_states.ERROR,
                                }).AndReturn((inst, inst))
        compute_utils.add_instance_fault_from_exc(self.context,
                                mox.IsA(conductor_api.LocalAPI), inst,
                                mox.IsA(ValueError),
                                mox.IgnoreArg())

        self.mox.ReplayAll()
        self.manager = utils.ExceptionHelper(self.manager)
        self.assertRaises(ValueError,
                          self.manager.live_migration,
                          self.context, inst, dest, block_migration,
                          disk_over_commit, pclm)
开发者ID:guykr-stratoscale,项目名称:nova,代码行数:30,代码来源:test_scheduler.py


示例19: handle_schedule_error

def handle_schedule_error(context, ex, instance_uuid, request_spec):
    """On run_instance failure, update instance state and
    send notifications.
    """

    if isinstance(ex, exception.NoValidHost):
        LOG.warning(_LW("NoValidHost exception with message: \'%s\'"),
                    ex.format_message().strip(),
                    instance_uuid=instance_uuid)
    else:
        LOG.exception(_LE("Exception during scheduler.run_instance"))
    state = vm_states.ERROR.upper()
    LOG.warning(_LW('Setting instance to %s state.'), state,
                instance_uuid=instance_uuid)

    (old_ref, new_ref) = db.instance_update_and_get_original(context,
            instance_uuid, {'vm_state': vm_states.ERROR,
                            'task_state': None})
    notifications.send_update(context, old_ref, new_ref,
            service="scheduler")
    compute_utils.add_instance_fault_from_exc(context,
            new_ref, ex, sys.exc_info())

    properties = request_spec.get('instance_properties', {})
    payload = dict(request_spec=request_spec,
                   instance_properties=properties,
                   instance_id=instance_uuid,
                   state=vm_states.ERROR,
                   method='run_instance',
                   reason=ex)

    rpc.get_notifier('scheduler').error(context,
                                        'scheduler.run_instance', payload)
开发者ID:NxtCloud,项目名称:nova,代码行数:33,代码来源:driver.py


示例20: _add_instance_fault

 def _add_instance_fault(self, error, exc_info):
     LOG.warning("Ignoring error while configuring instance with agent: %s",
                 error, instance=self.instance, exc_info=True)
     try:
         ctxt = context.get_admin_context()
         compute_utils.add_instance_fault_from_exc(
                 ctxt, self.instance, error, exc_info=exc_info)
     except Exception:
         LOG.debug("Error setting instance fault.", exc_info=True)
开发者ID:arbrandes,项目名称:nova,代码行数:9,代码来源:agent.py



注:本文中的nova.compute.utils.add_instance_fault_from_exc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap