Exemplo n.º 1
0
class CommandHandler(object):
    """Dispatch the commandline instructions to the right component."""

    def __init__(self, options):
        self.options = options
        self.config = Configurator(options)

    def run(self):
        """Execute the specified command parameterized by CLI options"""
        getattr(self, 'run_' + self.options.command)()

    def interrupt(self):
        """Perform clean up operations on user interuptions (if any)"""
        handler = getattr(self, 'interrupt_' + self.options.command, None)
        if handler is not None:
            return handler()

    def run_init(self):
        self.config.init_cluster(self.options.name)

    def run_select(self):
        self.config.set_default_cluster(self.options.name)

    def run_start(self):
        provisioner = Provisioner(self.config)
        provisioner.start(self.options.profile,
                          n_nodes=self.options.n_nodes,
                          name_prefix=self.options.name_prefix)
Exemplo n.º 2
0
 def __init__(self, options):
     self.options = options
     self.config = Configurator(options)