本文整理汇总了Python中kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig.cluster_name方法的典型用法代码示例。如果您正苦于以下问题:Python VncKubernetesConfig.cluster_name方法的具体用法?Python VncKubernetesConfig.cluster_name怎么用?Python VncKubernetesConfig.cluster_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig
的用法示例。
在下文中一共展示了VncKubernetesConfig.cluster_name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _associate_security_groups
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _associate_security_groups(vmi_obj, proj_obj, ns):
sg_name = "-".join([vnc_kube_config.cluster_name(), ns, 'default'])
sg_obj = SecurityGroup(sg_name, proj_obj)
vmi_obj.add_security_group(sg_obj)
ns_sg_name = "-".join([vnc_kube_config.cluster_name(), ns, 'sg'])
sg_obj = SecurityGroup(ns_sg_name, proj_obj)
vmi_obj.add_security_group(sg_obj)
return
示例2: vnc_namespace_delete
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_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):
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:
pass
示例3: _delete_policy
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _delete_policy(self, ns_name, proj_fq_name):
policy_name = "-".join([vnc_kube_config.cluster_name(), ns_name, 'pod-service-np'])
policy_fq_name = proj_fq_name[:]
policy_fq_name.append(policy_name)
try:
self._vnc_lib.network_policy_delete(fq_name=policy_fq_name)
except NoIdError:
pass
示例4: _sync_pod_vm
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _sync_pod_vm(self):
vm_uuid_set = set(VirtualMachineKM.keys())
pod_uuid_set = set(PodKM.keys())
deleted_pod_set = vm_uuid_set - pod_uuid_set
for pod_uuid in deleted_pod_set:
vm = VirtualMachineKM.get(pod_uuid)
if not vm or\
vm.owner != 'k8s' or\
vm.cluster != vnc_kube_config.cluster_name():
continue
self._create_pod_event('delete', pod_uuid, vm)
for uuid in pod_uuid_set:
vm = VirtualMachineKM.get(uuid)
if not vm or\
vm.owner != 'k8s' or\
vm.cluster != vnc_kube_config.cluster_name():
continue
if not vm.virtual_router and vm.pod_node and vm.node_ip:
self._link_vm_to_node(vm, vm.pod_node, vm.node_ip)
return
示例5: _create_attach_policy
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _create_attach_policy(self, ns_name, proj_obj,
ip_fabric_vn_obj, pod_vn_obj, service_vn_obj):
if not self._cluster_service_policy:
cluster_service_np_fq_name = \
vnc_kube_config.cluster_default_service_network_policy_fq_name()
try:
cluster_service_policy = self._vnc_lib. \
network_policy_read(fq_name=cluster_service_np_fq_name)
except NoIdError:
return
self._cluster_service_policy = cluster_service_policy
if not self._ip_fabric_policy:
cluster_ip_fabric_np_fq_name = \
vnc_kube_config.cluster_ip_fabric_policy_fq_name()
try:
cluster_ip_fabric_policy = self._vnc_lib. \
network_policy_read(fq_name=cluster_ip_fabric_np_fq_name)
except NoIdError:
return
self._ip_fabric_policy = cluster_ip_fabric_policy
self._nested_underlay_policy = None
if DBBaseKM.is_nested() and not self._nested_underlay_policy:
try:
name = vnc_kube_config.cluster_nested_underlay_policy_fq_name()
self._nested_underlay_policy = \
self._vnc_lib.network_policy_read(fq_name=name)
except NoIdError:
return
policy_name = "-".join([vnc_kube_config.cluster_name(), ns_name, 'pod-service-np'])
#policy_name = '%s-default' %ns_name
ns_default_policy = self._create_vn_vn_policy(policy_name, proj_obj,
pod_vn_obj, service_vn_obj)
self._attach_policy(pod_vn_obj, ns_default_policy,
self._ip_fabric_policy, self._cluster_service_policy,
self._nested_underlay_policy)
self._attach_policy(service_vn_obj, ns_default_policy,
self._ip_fabric_policy, self._nested_underlay_policy)
示例6: _get_namespace_service_vn_name
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _get_namespace_service_vn_name(self, ns_name):
return vnc_kube_config.cluster_name() + \
'-' + ns_name + "-service-network"
示例7: _get_namespace_pod_vn_name
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _get_namespace_pod_vn_name(self, ns_name):
return vnc_kube_config.cluster_name() + \
'-' + ns_name + "-pod-network"
示例8: _get_namespace_firewall_egress_rule_name
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _get_namespace_firewall_egress_rule_name(self, ns_name):
return "-".join([vnc_kube_config.cluster_name(),
self._k8s_event_type, ns_name, "egress"])
示例9: _get_network_pod_ipam_name
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _get_network_pod_ipam_name(self, nw_name):
return vnc_kube_config.cluster_name() + \
'-' + nw_name + '-pod-ipam'
示例10: _update_security_groups
# 需要导入模块: from kube_manager.vnc.vnc_kubernetes_config import VncKubernetesConfig [as 别名]
# 或者: from kube_manager.vnc.vnc_kubernetes_config.VncKubernetesConfig import cluster_name [as 别名]
def _update_security_groups(self, ns_name, proj_obj, network_policy):
def _get_rule(ingress, sg, prefix, ethertype):
sgr_uuid = str(uuid.uuid4())
if sg:
addr = AddressType(
security_group=proj_obj.get_fq_name_str() + ':' + sg)
elif prefix:
addr = AddressType(subnet=SubnetType(prefix, 0))
local_addr = AddressType(security_group='local')
if ingress:
src_addr = addr
dst_addr = local_addr
else:
src_addr = local_addr
dst_addr = addr
rule = PolicyRuleType(rule_uuid=sgr_uuid, direction='>',
protocol='any',
src_addresses=[src_addr],
src_ports=[PortType(0, 65535)],
dst_addresses=[dst_addr],
dst_ports=[PortType(0, 65535)],
ethertype=ethertype)
return rule
sg_dict = {}
# create default security group
sg_name = "-".join([vnc_kube_config.cluster_name(), ns_name, 'default'])
DEFAULT_SECGROUP_DESCRIPTION = "Default security group"
id_perms = IdPermsType(enable=True,
description=DEFAULT_SECGROUP_DESCRIPTION)
rules = []
ingress = True
egress = True
if network_policy and 'ingress' in network_policy:
ingress_policy = network_policy['ingress']
if ingress_policy and 'isolation' in ingress_policy:
isolation = ingress_policy['isolation']
if isolation == 'DefaultDeny':
ingress = False
if ingress:
if self._is_service_isolated(ns_name):
rules.append(_get_rule(True, sg_name, None, 'IPv4'))
rules.append(_get_rule(True, sg_name, None, 'IPv6'))
else:
rules.append(_get_rule(True, None, '0.0.0.0', 'IPv4'))
rules.append(_get_rule(True, None, '::', 'IPv6'))
if egress:
rules.append(_get_rule(False, None, '0.0.0.0', 'IPv4'))
rules.append(_get_rule(False, None, '::', 'IPv6'))
sg_rules = PolicyEntriesType(rules)
sg_obj = SecurityGroup(name=sg_name, parent_obj=proj_obj,
id_perms=id_perms,
security_group_entries=sg_rules)
SecurityGroupKM.add_annotations(self, sg_obj, namespace=ns_name,
name=sg_obj.name,
k8s_type=self._k8s_event_type)
try:
self._vnc_lib.security_group_create(sg_obj)
self._vnc_lib.chown(sg_obj.get_uuid(), proj_obj.get_uuid())
except RefsExistError:
self._vnc_lib.security_group_update(sg_obj)
sg_obj = self._vnc_lib.security_group_read(sg_obj.fq_name)
sg_uuid = sg_obj.get_uuid()
SecurityGroupKM.locate(sg_uuid)
sg_dict[sg_name] = sg_uuid
# create namespace security group
ns_sg_name = "-".join([vnc_kube_config.cluster_name(), ns_name, 'sg'])
NAMESPACE_SECGROUP_DESCRIPTION = "Namespace security group"
id_perms = IdPermsType(enable=True,
description=NAMESPACE_SECGROUP_DESCRIPTION)
sg_obj = SecurityGroup(name=ns_sg_name, parent_obj=proj_obj,
id_perms=id_perms,
security_group_entries=None)
SecurityGroupKM.add_annotations(self, sg_obj, namespace=ns_name,
name=sg_obj.name,
k8s_type=self._k8s_event_type)
try:
self._vnc_lib.security_group_create(sg_obj)
self._vnc_lib.chown(sg_obj.get_uuid(), proj_obj.get_uuid())
except RefsExistError:
pass
sg_obj = self._vnc_lib.security_group_read(sg_obj.fq_name)
sg_uuid = sg_obj.get_uuid()
SecurityGroupKM.locate(sg_uuid)
sg_dict[ns_sg_name] = sg_uuid
return sg_dict