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


Python VncKubernetesConfig.get_project_name_for_namespace方法代码示例

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


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

示例1: vnc_namespace_delete

# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import get_project_name_for_namespace [as 别名]
    def vnc_namespace_delete(self, namespace_id, name):
        proj_fq_name = vnc_kube_config.cluster_project_fq_name(name)
        project_uuid = ProjectKM.get_fq_name_to_uuid(proj_fq_name)
        if not project_uuid:
            self._logger.error("Unable to locate project for k8s namespace "
                               "[%s]" % (name))
            return

        project = ProjectKM.get(project_uuid)
        if not project:
            self._logger.error("Unable to locate project for k8s namespace "
                               "[%s]" % (name))
            return

        try:
            # If the namespace is isolated, delete its virtual network.
            if self._is_namespace_isolated(name):
                self._delete_policy(name, proj_fq_name)
                vn_name = self._get_namespace_pod_vn_name(name)
                self._delete_isolated_ns_virtual_network(
                    name, vn_name=vn_name, proj_fq_name=proj_fq_name)
                # Clear pod network info from namespace entry.
                self._set_namespace_pod_virtual_network(name, None)
                vn_name = self._get_namespace_service_vn_name(name)
                self._delete_isolated_ns_virtual_network(
                    name, vn_name=vn_name, proj_fq_name=proj_fq_name)
                # Clear service network info from namespace entry.
                self._set_namespace_service_virtual_network(name, None)

            # delete security groups
            security_groups = project.get_security_groups()
            for sg_uuid in security_groups:
                sg = SecurityGroupKM.get(sg_uuid)
                if not sg:
                    continue
                sg_name = vnc_kube_config.get_default_sg_name(name)
                if sg.name != sg_name:
                    continue
                for vmi_id in list(sg.virtual_machine_interfaces):
                    try:
                        self._vnc_lib.ref_update('virtual-machine-interface', vmi_id,
                            'security-group', sg.uuid, None, 'DELETE')
                    except NoIdError:
                        pass
                self._vnc_lib.security_group_delete(id=sg_uuid)

            # delete the label cache
            if project:
                self._clear_namespace_label_cache(namespace_id, project)
            # delete the namespace
            self._delete_namespace(name)

            # If project was created for this namesspace, delete the project.
            if vnc_kube_config.get_project_name_for_namespace(name) ==\
               project.name:
                self._vnc_lib.project_delete(fq_name=proj_fq_name)

        except:
            # Raise it up to be logged.
            raise
开发者ID:Juniper,项目名称:contrail-controller,代码行数:62,代码来源:vnc_namespace.py


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