def _enqueue_add_custom_isolated_namespace(self, project, network): custom_network_config = { 'virtual_network': network, 'domain': 'default-domain', 'project': project, 'name': network } kube_config.VncKubernetesConfig.args().cluster_service_network = str( custom_network_config) ns_uuid = str(uuid.uuid4()) namespace_name = 'custom_isolated_namespace' ns_add_event = self.create_add_namespace_event(namespace_name, ns_uuid) annotations = { 'opencontrail.org/network': str({ 'domain': 'default-domain', 'project': project, 'name': network }) } ns_add_event['object']['metadata']['annotations'] = annotations NamespaceKM.locate(ns_uuid, ns_add_event['object']) self.enqueue_event(ns_add_event) self.wait_for_all_tasks_done() return namespace_name, ns_uuid
def _create_namespace(self, ns_name, ns_eval_vn_dict, is_isolated=False): ns_uuid = str(uuid.uuid4()) ns_add_event = self.create_add_namespace_event(ns_name, ns_uuid) ns_object = ns_add_event['object'] ns_object['spec'] = {} ns_meta = ns_object['metadata'] ns_meta['annotations'] = {} ns_meta['name'] = ns_name ns_meta['uid'] = ns_uuid ns_meta['namespace'] = ns_name ns_meta['labels'] = {} if ns_eval_vn_dict: ns_meta['annotations']['opencontrail.org/network'] = \ ns_eval_vn_dict if is_isolated: ns_meta['annotations']['opencontrail.org/isolation'] = 'true' NamespaceKM.delete(ns_name) NamespaceKM.delete(ns_uuid) NamespaceKM.locate(ns_name, ns_object) NamespaceKM.locate(ns_uuid, ns_object) self.enqueue_event(ns_add_event) self.wait_for_all_tasks_done() return ns_uuid
def _create_namespace(self, ns_name, ns_eval_vn_dict, is_isolated=False, labels={}): ns_uuid = str(uuid.uuid4()) ns_add_event = self.create_add_namespace_event(ns_name, ns_uuid) ns_object = ns_add_event['object'] ns_object['spec'] = {} ns_meta = ns_object['metadata'] ns_meta['annotations'] = {} ns_meta['name'] = ns_name ns_meta['uid'] = ns_uuid ns_meta['namespace'] = ns_name ns_meta['labels'] = labels if ns_eval_vn_dict: ns_meta['annotations']['opencontrail.org/network'] = \ ns_eval_vn_dict if is_isolated: ns_meta['annotations']['opencontrail.org/isolation'] = 'true' NamespaceKM.delete(ns_name) NamespaceKM.delete(ns_uuid) NamespaceKM.locate(ns_name, ns_object) NamespaceKM.locate(ns_uuid, ns_object) self.enqueue_event(ns_add_event) self.wait_for_all_tasks_done() return ns_uuid
def _add_namespace(self, namespace_name, isolated=False): ns_uid = str(uuid.uuid4()) ns_add_event = self.create_add_namespace_event(namespace_name, ns_uid) if isolated: ns_add_event['object']['metadata']['annotations'] = { 'opencontrail.org/isolation': 'true'} NamespaceKM.locate(ns_uid, ns_add_event['object']) self.enqueue_event(ns_add_event) return namespace_name, ns_uid
def _enqueue_add_namespace(self, isolated=False): ns_uuid = str(uuid.uuid4()) namespace_name = 'namespace_name' ns_add_event = self.create_add_namespace_event(namespace_name, ns_uuid) if isolated: annotations = {'opencontrail.org/isolation': 'true'} ns_add_event['object']['metadata']['annotations'] = annotations NamespaceKM.locate(ns_uuid, ns_add_event['object']) self.enqueue_event(ns_add_event) self.wait_for_all_tasks_done() return namespace_name, ns_uuid
def _enqueue_add_custom_isolated_namespace(self, project, network): custom_network_config = {'virtual_network': network, 'domain': 'default-domain', 'project': project, 'name': network} kube_config.VncKubernetesConfig.args().cluster_network = str( custom_network_config) ns_uuid = str(uuid.uuid4()) namespace_name = 'custom_isolated_namespace' ns_add_event = self.create_add_namespace_event(namespace_name, ns_uuid) annotations = {'opencontrail.org/network': str({'domain': 'default-domain', 'project': project, 'name': network})} ns_add_event['object']['metadata']['annotations'] = annotations NamespaceKM.locate(ns_uuid, ns_add_event['object']) self.enqueue_event(ns_add_event) return namespace_name, ns_uuid