Beispiel #1
0
    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)
        ns = NamespaceKM.locate(ns_name, 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)
        ns = NamespaceKM.locate(ns_name, ns_object)

        self.enqueue_event(ns_add_event)
        self.wait_for_all_tasks_done()

        return ns.uuid
Beispiel #3
0
    def test_add_namespace(self):
        ns_uuid = self._create_and_add_namespace(self.ns_name, {}, None)

        # Check for project
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", self.cluster_project])
        self.assertIsNotNone(proj)
        self.assertEquals(self.cluster_project, proj.name)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
    def test_add_namespace(self):
        ns_uuid = self._create_and_add_namespace(self.ns_name, {}, None)

        # Check for project
        proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                   self.cluster_project])
        self.assertIsNotNone(proj)
        self.assertEquals(self.cluster_project, proj.name)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
    def test_add_namespace(self):
        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
            None, locate=True)
        # Check for project
        proj_name = kube_config.VncKubernetesConfig.cluster_project_name(
                                                    self.cluster_project)
        proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                   proj_name])
        self.assertIsNotNone(proj)
        self.assertEquals(proj_name, proj.name)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
Beispiel #6
0
    def test_add_namespace(self):
        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
                                                 None,
                                                 locate=True)
        # Check for project
        proj_name = kube_config.VncKubernetesConfig.cluster_project_name(
            self.cluster_project)
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", proj_name])
        self.assertIsNotNone(proj)
        self.assertEquals(proj_name, proj.name)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
Beispiel #7
0
    def test_add_namespace_with_isolation_annotation(self):
        ns_annotations = {'opencontrail.org/isolation': "true"}

        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
                                                 ns_annotations, True)

        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", self.cluster_project])
        self.assertIsNotNone(proj)
        self.assertEquals(self.cluster_project, proj.name)

        fqname = ['default-domain', self.cluster_project, self.ns_name + '-vn']
        vn = self._vnc_lib.virtual_network_read(fq_name=fqname)
        self.assertIsNotNone(vn)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
    def test_add_namespace_with_isolation_annotation(self):
        ns_annotations = {'opencontrail.org/isolation': "true"}

        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
                                                 ns_annotations, True)

        proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                   self.cluster_project])
        self.assertIsNotNone(proj)
        self.assertEquals(self.cluster_project, proj.name)

        fqname = ['default-domain', self.cluster_project, self.ns_name+'-vn']
        vn = self._vnc_lib.virtual_network_read(fq_name=fqname)
        self.assertIsNotNone(vn)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
Beispiel #9
0
    def test_add_namespace_scaling(self):
        scale = 100
        ns_uuids = []

        for i in xrange(scale):
            ns_uuid = self._create_and_add_namespace(self.ns_name + str(i), {},
                                                     None, locate=True)
            proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                       self.cluster_project])
            self.assertIsNotNone(proj)
            self.assertEquals(self.cluster_project, proj.name)

            ns_uuids.append(ns_uuid)

        for i, ns_uuid in enumerate(ns_uuids):
            ns = NamespaceKM.find_by_name_or_uuid(ns_uuid)
            if ns:
                NamespaceKM.delete(ns_uuid)
                NamespaceKM.delete(ns.name)
    def test_add_namespace_with_isolation_annotation(self):
        ns_annotations = {'opencontrail.org/isolation': "true"}

        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
                                                 ns_annotations, locate=True)
        proj_name = kube_config.VncKubernetesConfig.cluster_project_name(
                                                    self.cluster_project)
        proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                   proj_name])
        self.assertIsNotNone(proj)
        self.assertEquals(proj_name, proj.name)

        fqname = ['default-domain', proj_name, \
            self.cluster_name() + '-' + self.ns_name + '-pod-network']
        vn = self._vnc_lib.virtual_network_read(fq_name=fqname)
        self.assertIsNotNone(vn)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)
    def test_add_namespace_scaling(self):
        scale = 100
        ns_uuids = []

        for i in xrange(scale):
            ns_uuid = self._create_and_add_namespace(self.ns_name + str(i), {},
                                                     None)
            proj = self._vnc_lib.project_read(fq_name=["default-domain",
                                                       self.cluster_project])
            self.assertIsNotNone(proj)
            self.assertEquals(self.cluster_project, proj.name)

            ns_uuids.append(ns_uuid)

        for i, ns_uuid in enumerate(ns_uuids):
            ns = NamespaceKM.find_by_name_or_uuid(ns_uuid)
            if ns:
                NamespaceKM.delete(ns_uuid)
                NamespaceKM.delete(ns.name)
Beispiel #12
0
    def test_add_namespace_with_isolation_annotation(self):
        ns_annotations = {'opencontrail.org/isolation': "true"}

        ns_uuid = self._create_and_add_namespace(self.ns_name, {},
                                                 ns_annotations,
                                                 locate=True)
        proj_name = kube_config.VncKubernetesConfig.cluster_project_name(
            self.cluster_project)
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", proj_name])
        self.assertIsNotNone(proj)
        self.assertEquals(proj_name, proj.name)

        fqname = ['default-domain', proj_name, \
            self.cluster_name() + '-' + self.ns_name + '-pod-network']
        vn = self._vnc_lib.virtual_network_read(fq_name=fqname)
        self.assertIsNotNone(vn)

        NamespaceKM.delete(ns_uuid)
        NamespaceKM.delete(self.ns_name)