当前位置: 首页>>代码示例>>Python>>正文


Python Instance.delete方法代码示例

本文整理汇总了Python中core.models.Instance.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Instance.delete方法的具体用法?Python Instance.delete怎么用?Python Instance.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.models.Instance的用法示例。


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

示例1: manage_container

# 需要导入模块: from core.models import Instance [as 别名]
# 或者: from core.models.Instance import delete [as 别名]
    def manage_container(self):
        from core.models import Instance, Flavor

        if self.deleted:
            return

        if (self.instance is not None) and (self.instance.image != self.image):
            self.instance.delete()
            self.instance = None

        if self.instance is None:
            if not self.provider_service.slices.count():
                raise XOSConfigurationError("The VCPE service has no slices")

            flavors = Flavor.objects.filter(name="m1.small")
            if not flavors:
                raise XOSConfigurationError("No m1.small flavor")

            node =self.pick_node()
            instance = Instance(slice = self.provider_service.slices.all()[0],
                            node = node,
                            image = self.image,
                            creator = self.creator,
                            deployment = node.site_deployment.deployment,
                            flavor = flavors[0])
            instance.save()

            try:
                self.instance = instance
                super(TenantWithContainer, self).save()
            except:
                instance.delete()
                raise
开发者ID:Shelphy,项目名称:xos,代码行数:35,代码来源:service.py

示例2: manage_container

# 需要导入模块: from core.models import Instance [as 别名]
# 或者: from core.models.Instance import delete [as 别名]
    def manage_container(self):
        from core.models import Instance, Flavor

        if self.deleted:
            return

        if (self.instance is not None) and (self.instance.image != self.image):
            self.instance.delete()
            self.instance = None

        if self.instance is None:
            if not self.provider_service.slices.count():
                raise XOSConfigurationError("The service has no slices")

            new_instance_created = False
            instance = None
            if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
                # Find if any existing instances can be used for this tenant
                slices = self.provider_service.slices.all()
                instance = self.pick_least_loaded_instance_in_slice(slices)

            if not instance:
                slice = self.provider_service.slices.all()[0]
                flavors = Flavor.objects.filter(name=slice.default_flavor) #MCORD

                flavor = slice.default_flavor
                if not flavor:
                    flavors = Flavor.objects.filter(name="m1.small")
                    if not flavors:
                        raise XOSConfigurationError("No m1.small flavor")
                    flavor = flavors[0]
#                default_flavor = slice.default_flavor #MCORD


                if slice.default_isolation == "container_vm":
                    (node, parent) = ContainerVmScheduler(slice).pick()
                else:
                    (node, parent) = LeastLoadedNodeScheduler(slice).pick()

                instance = Instance(slice=slice,
                                    node=node,
                                    image=self.image,
                                    creator=self.creator,
                                    deployment=node.site_deployment.deployment,
                                    flavor=flavor,
                                    isolation=slice.default_isolation,
                                    parent=parent)
                self.save_instance(instance)
                new_instance_created = True

            try:
                self.instance = instance
                super(TenantWithContainer, self).save()
            except:
                if new_instance_created:
                    instance.delete()
                raise
开发者ID:xmaruto,项目名称:mcord,代码行数:59,代码来源:service.py


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