Exemple #1
0
    def get_cluster_template(self,
                             template_name,
                             tag_name=None,
                             ec2_conn=None):
        """
        Returns Cluster instance configured with the settings in the
        config file.

        template_name is the name of a cluster section defined in the config

        tag_name if not specified will be set to template_name
        """
        try:
            kwargs = {}
            tag_name = tag_name or template_name
            kwargs.update(dict(cluster_tag=tag_name))
            kwargs.update(self.clusters[template_name])
            plugs = kwargs.get('plugins')
            kwargs['plugins'] = deathrow._load_plugins(plugs,
                                                       debug=DEBUG_CONFIG)
            if not ec2_conn:
                ec2_conn = self.get_easy_ec2()

            clust = Cluster(ec2_conn, **kwargs)
            return clust
        except KeyError:
            raise exception.ClusterTemplateDoesNotExist(template_name)
Exemple #2
0
    def test_get_free_node_nums(self):
        res = Cluster.get_free_ids_among_nodes(0, [])
        assert res == []

        node001 = FooNode("node001", "1.2.3.4")
        res = Cluster.get_free_ids_among_nodes(1, [node001])
        assert res == [2]

        res = Cluster.get_free_ids_among_nodes(3, [node001])
        assert res == [2, 3, 4]

        node003 = FooNode("node003", "1.2.3.4")
        node005 = FooNode("node005", "1.2.3.4")
        node006 = FooNode("node006", "1.2.3.4")
        node106 = FooNode("node106", "1.2.3.4")
        res = Cluster.get_free_ids_among_nodes(5, [node001, node003, node005, node006, node106])
        assert res == [2, 4, 7, 8, 9]
    def test_get_free_node_nums(self):
        res = Cluster.get_free_ids_among_nodes(0, [])
        assert res == []

        node001 = FooNode("node001", "1.2.3.4")
        res = Cluster.get_free_ids_among_nodes(1, [node001])
        assert res == [2]

        res = Cluster.get_free_ids_among_nodes(3, [node001])
        assert res == [2, 3, 4]

        node003 = FooNode("node003", "1.2.3.4")
        node005 = FooNode("node005", "1.2.3.4")
        node006 = FooNode("node006", "1.2.3.4")
        node106 = FooNode("node106", "1.2.3.4")
        res = Cluster.get_free_ids_among_nodes(
            5, [node001, node003, node005, node006, node106])
        assert res == [2, 4, 7, 8, 9]
 def __test_cases_from_cluster(self, cases, test):
     """
     Tests all cases by manually loading a cluster template using the
     Cluster class. All settings for a case are passed in as constructor
     keywords.  Avoids the config module by using the Cluster object
     directly to create a test case.
     """
     failed = []
     for case in cases:
         cluster = Cluster(**case)
         try:
             getattr(cluster, test)()
         except exception.ClusterValidationError:
             continue
         else:
             failed.append(case)
     return failed
Exemple #5
0
    def get_cluster_template(self, template_name, tag_name=None,
                             ec2_conn=None):
        """
        Returns Cluster instance configured with the settings in the
        config file.

        template_name is the name of a cluster section defined in the config

        tag_name, if specified, will be passed to Cluster instance
        as cluster_tag
        """
        try:
            kwargs = {}
            if tag_name:
                kwargs.update(dict(cluster_tag=tag_name))
            kwargs.update(self.clusters[template_name])
            if not ec2_conn:
                ec2_conn = self.get_easy_ec2()
            clust = Cluster(ec2_conn, **kwargs)
            return clust
        except KeyError:
            raise exception.ClusterTemplateDoesNotExist(template_name)
Exemple #6
0
    def get_cluster_template(self,
                             template_name,
                             tag_name=None,
                             ec2_conn=None,
                             load_plugins=True):
        """
        Returns Cluster instance configured with the settings in the
        config file.

        template_name is the name of a cluster section defined in the config

        tag_name if not specified will be set to template_name
        """
        try:
            kwargs = {}
            tag_name = tag_name or template_name
            kwargs.update(dict(cluster_tag=tag_name))
            kwargs.update(self.clusters[template_name])
            plugs = kwargs.get('plugins')
            plugins_order = []
            for p in plugs:
                plugins_order.append(p["setup_class"].split(".")[-1])
            kwargs['plugins_order'] = plugins_order
            if load_plugins:
                kwargs['plugins'] = deathrow._load_plugins(plugs,
                                                           debug=DEBUG_CONFIG)
            else:
                kwargs['plugins'] = []

            if not ec2_conn:
                ec2_conn = self.get_easy_ec2()

            del kwargs['__name__']
            del kwargs['extends']
            clust = Cluster(ec2_conn, **kwargs)
            return clust
        except KeyError:
            raise exception.ClusterTemplateDoesNotExist(template_name)