Example #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)
Example #2
0
 def get_default_cluster_template(self):
     """
     Returns the default_template specified in the [global] section
     of the config. Raises NoDefaultTemplateFound if no default cluster
     template has been specified in the config.
     """
     default = self.globals.get('default_template')
     if not default:
         raise exception.NoDefaultTemplateFound(
             options=self.clusters.keys())
     if default not in self.clusters:
         raise exception.ClusterTemplateDoesNotExist(default)
     return default
Example #3
0
 def get_default_cluster_template(self):
     """
     Returns the cluster template with "DEFAULT=True" in the config
     If more than one found, raises MultipleDefaultTemplates exception.
     If no cluster template has "DEFAULT=True", raises
     NoDefaultTemplateFound exception.
     """
     default = self.globals.get('default_template')
     if not default:
         raise exception.NoDefaultTemplateFound(
             options=self.clusters.keys())
     if not default in self.clusters:
         raise exception.ClusterTemplateDoesNotExist(default)
     return default
Example #4
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)
Example #5
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)