def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError) as ex: log.error("Listing nodes from cluster %s: %s\n" % (cluster_name, ex)) return from elasticluster.gc3pie_config import create_gc3pie_config_snippet if self.params.append: path = os.path.expanduser(self.params.append) try: fd = open(path, 'a') fd.write(create_gc3pie_config_snippet(cluster)) fd.close() except IOError as ex: log.error("Unable to write configuration to file %s: %s", path, ex) else: print(create_gc3pie_config_snippet(cluster))
def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError) as ex: log.error("Listing nodes from cluster %s: %s\n" % (cluster_name, ex)) return from elasticluster.gc3pie_config import create_gc3pie_config_snippet if self.params.append: path = os.path.expanduser(self.params.append) try: fd = open(path, 'a') fd.write(create_gc3pie_config_snippet(cluster)) fd.close() except IOError as ex: log.error("Unable to write configuration to file %s: %s", path, ex) else: print(create_gc3pie_config_snippet(cluster))
def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ log.warning("Command `elasticluster gc3pie-config` is DEPRECATED" " and will be removed in release 1.4 of ElastiCluster") creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError) as ex: log.error("Listing nodes from cluster %s: %s", cluster_name, ex) return from elasticluster.gc3pie_config import create_gc3pie_config_snippet if self.params.append: path = os.path.expanduser(self.params.append) try: fd = open(path, 'a') fd.write(create_gc3pie_config_snippet(cluster)) fd.close() except IOError as ex: log.error("Unable to write configuration to file %s: %s", path, ex) else: print(create_gc3pie_config_snippet(cluster))
def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ log.warning( "Command `elasticluster gc3pie-config` is DEPRECATED" " and will be removed in release 1.4 of ElastiCluster") creator = make_creator(self.params.config, storage_path=self.params.storage) cluster_name = self.params.cluster try: cluster = creator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError) as ex: log.error("Listing nodes from cluster %s: %s", cluster_name, ex) return from elasticluster.gc3pie_config import create_gc3pie_config_snippet if self.params.append: path = os.path.expanduser(self.params.append) try: fd = open(path, 'a') fd.write(create_gc3pie_config_snippet(cluster)) fd.close() except IOError as ex: log.error("Unable to write configuration to file %s: %s", path, ex) else: print(create_gc3pie_config_snippet(cluster))
class GC3PieConfig(AbstractCommand): """ Print a GC3Pie configuration snippet for a specific cluster """ def setup(self, subparsers): parser = subparsers.add_parser( "gc3pie-config", help="Print a GC3Pie configuration snippet.", description=self.__doc__) parser.set_defaults(func=self) parser.add_argument('cluster', help='name of the cluster') parser.add_argument('-v', '--verbose', action='count', default=0, help="Increase verbosity.") parser.add_argument('-a', '--append', metavar='FILE', help='append configuration to file FILE') def execute(self): """ Load the cluster and build a GC3Pie configuration snippet. """ configurator = Configurator.fromConfig( self.params.config, storage_path=self.params.storage, include_config_dirs=True) cluster_name = self.params.cluster try: cluster = configurator.load_cluster(cluster_name) except (ClusterNotFound, ConfigurationError), ex: log.error("Listing nodes from cluster %s: %s\n" % (cluster_name, ex)) return from elasticluster.gc3pie_config import create_gc3pie_config_snippet if self.params.append: path = os.path.expanduser(self.params.append) try: fd = open(path, 'a') fd.write(create_gc3pie_config_snippet(cluster)) fd.close() except IOError as ex: log.error("Unable to write configuration to file %s: %s", path, ex) else: print(create_gc3pie_config_snippet(cluster))