本文整理汇总了Python中vnc_kubernetes_config.VncKubernetesConfig.cluster_project_name方法的典型用法代码示例。如果您正苦于以下问题:Python VncKubernetesConfig.cluster_project_name方法的具体用法?Python VncKubernetesConfig.cluster_project_name怎么用?Python VncKubernetesConfig.cluster_project_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnc_kubernetes_config.VncKubernetesConfig
的用法示例。
在下文中一共展示了VncKubernetesConfig.cluster_project_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_annotations
# 需要导入模块: from vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from vnc_kubernetes_config.VncKubernetesConfig import cluster_project_name [as 别名]
def _get_annotations(cls, vnc_caller, namespace, name, k8s_type,
**custom_ann_kwargs):
"""Get all annotations.
Annotations are aggregated from multiple sources like infra info,
input params and custom annotations. This method is meant to be an
aggregator of all possible annotations.
"""
# Get annotations declared on the caller.
annotations = dict(vnc_caller.get_annotations())
# Update annotations with infra specific annotations.
infra_anns = cls.get_infra_annotations()
infra_anns['project'] = vnc_kube_config.cluster_project_name(namespace)
annotations.update(infra_anns)
# Update annotations based on explicity input params.
input_anns = {}
input_anns['namespace'] = namespace
input_anns['name'] = name
if k8s_type:
input_anns['kind'] = k8s_type
annotations.update(input_anns)
# Append other custom annotations.
annotations.update(custom_ann_kwargs)
return annotations
示例2: vnc_namespace_delete
# 需要导入模块: from vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from vnc_kubernetes_config.VncKubernetesConfig import cluster_project_name [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
default_sg_fq_name = proj_fq_name[:]
sg = "-".join([vnc_kube_config.cluster_name(), name, 'default'])
default_sg_fq_name.append(sg)
ns_sg_fq_name = proj_fq_name[:]
ns_sg = "-".join([vnc_kube_config.cluster_name(), name, 'sg'])
ns_sg_fq_name.append(ns_sg)
sg_list = [default_sg_fq_name, ns_sg_fq_name]
try:
# If the namespace is isolated, delete its virtual network.
if self._is_namespace_isolated(name) == True:
vn_name = self._get_namespace_vn_name(name)
self._delete_isolated_ns_virtual_network(name, vn_name=vn_name,
proj_fq_name=proj_fq_name)
# delete default-sg and ns-sg security groups
security_groups = project.get_security_groups()
for sg_uuid in security_groups:
sg = SecurityGroupKM.get(sg_uuid)
if sg and sg.fq_name in sg_list[:]:
self._vnc_lib.security_group_delete(id=sg_uuid)
sg_list.remove(sg.fq_name)
if not len(sg_list):
break
# delete the label cache
if project:
self._clear_namespace_label_cache(namespace_id, project)
# delete the namespace
self._delete_namespace(name)
# If namespace=project, delete the project
if vnc_kube_config.cluster_project_name(name) == name:
self._vnc_lib.project_delete(fq_name=proj_fq_name)
except Exception as e:
pass