Пример #1
0
 def _check_existing(self, config, options):
     """Make sure that there isn't a stage with this name already.
     If there is, panic.
     """
     try:
         log.debug("checking for existing stage ...")
         StageConfig.make(options.name)
     except EnvironmentError:
         pass
     else:
         sys.exit("there seem to be a stage with that name already")
Пример #2
0
 def _check_existing(self, config, options):
     """Make sure that there isn't a stage with this name already.
     If there is, panic.
     """
     try:
         log.debug("checking for existing stage ...")
         StageConfig.make(options.name)
     except EnvironmentError:
         pass
     else:
         sys.exit("there seem to be a stage with that name already")
Пример #3
0
    def handle(self, config, options):
        self._check_existing(config, options)
        stage_config = StageConfig.create(options.name)
        self._check_credentials(stage_config, options)
        self._build_config(stage_config, options)

        # step 1. create resources
        conn = connect(
            stage_config.get('aws_region'),
            aws_access_key_id=stage_config.get('aws_access_key_id'),
            aws_secret_access_key=stage_config.get('aws_secret_access_key'))
        stage = AmazonWebServicesStage.create(conn, stage_config,
                                              options.name)

        # step 2. configure resources
        configure = Configure(
            stage_config.get('aws_ssh_username'),
            stage_config.get('aws_ssh_key_file'))
        self._configure(stage, configure)
        self._bootstrap(stage, configure)

        # step 3. update stage config
        stage_config.set('service_registry', [
                'http://{0}:3222'.format(hostname)
                for (hostname, roles) in stage.iter_roles()
                if 'service-registry' in roles])
        if options.repository:
            stage_config.set('repository', options.repository)

        # stage 4. profit.
        stage_config.write()
Пример #4
0
    def handle(self, config, options):
        self._check_existing(config, options)
        stage_config = StageConfig.create(options.name)
        self._check_credentials(stage_config, options)
        self._build_config(stage_config, options)

        # step 1. create resources
        conn = connect(
            stage_config.get('aws_region'),
            aws_access_key_id=stage_config.get('aws_access_key_id'),
            aws_secret_access_key=stage_config.get('aws_secret_access_key'))
        stage = AmazonWebServicesStage.create(conn, stage_config, options.name)

        # step 2. configure resources
        configure = Configure(stage_config.get('aws_ssh_username'),
                              stage_config.get('aws_ssh_key_file'))
        self._configure(stage, configure)
        self._bootstrap(stage, configure)

        # step 3. update stage config
        stage_config.set('service_registry', [
            'http://{0}:3222'.format(hostname)
            for (hostname, roles) in stage.iter_roles()
            if 'service-registry' in roles
        ])
        if options.repository:
            stage_config.set('repository', options.repository)

        # stage 4. profit.
        stage_config.write()
Пример #5
0
def main():
    """Main entry point for the command-line tool."""
    parser = argparse.ArgumentParser(
        prog='gilliam-aws',
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('--verbose', action='store_true')
    parser.add_argument('-D', '--debug', action='store_true')
    parser.add_argument('-s', '--stage',
                        metavar='STAGE', dest='stage')
    parser.add_argument('-q', '--quiet', dest='quiet',
                        action='store_true', default=False)
    cmds = dict(_init_commands(parser))

    options = parser.parse_args()
    logging.basicConfig(
        stream=sys.stdout,
        level=(logging.DEBUG if options.debug else
               logging.INFO if options.verbose else
               logging.WARNING),
        format=_DEBUG_FORMAT if options.debug else _NORMAL_FORMAT)

    project_dir = util.find_rootdir()

    form_config = (
        FormationConfig.make(project_dir) if project_dir else
        None)
    options.stage = (
        options.stage if options.stage else
        form_config.stage if form_config else
        None)


    try:
        stage_config = (
            StageConfig.make(options.stage) if options.stage else
            None)
    except EnvironmentError as err:
        sys.exit("%s: %s: cannot read stage config: %s" % (
                options.cmd, options.stage, err))

    config = Config(project_dir, stage_config, options.stage)
                         
    cmd = cmds[options.cmd]
    cmd.handle(config, options)
Пример #6
0
def main():
    """Main entry point for the command-line tool."""
    parser = argparse.ArgumentParser(
        prog='gilliam-aws',
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('--verbose', action='store_true')
    parser.add_argument('-D', '--debug', action='store_true')
    parser.add_argument('-s', '--stage', metavar='STAGE', dest='stage')
    parser.add_argument('-q',
                        '--quiet',
                        dest='quiet',
                        action='store_true',
                        default=False)
    cmds = dict(_init_commands(parser))

    options = parser.parse_args()
    logging.basicConfig(
        stream=sys.stdout,
        level=(logging.DEBUG if options.debug else
               logging.INFO if options.verbose else logging.WARNING),
        format=_DEBUG_FORMAT if options.debug else _NORMAL_FORMAT)

    project_dir = util.find_rootdir()

    form_config = (FormationConfig.make(project_dir) if project_dir else None)
    options.stage = (options.stage if options.stage else
                     form_config.stage if form_config else None)

    try:
        stage_config = (StageConfig.make(options.stage)
                        if options.stage else None)
    except EnvironmentError as err:
        sys.exit("%s: %s: cannot read stage config: %s" %
                 (options.cmd, options.stage, err))

    config = Config(project_dir, stage_config, options.stage)

    cmd = cmds[options.cmd]
    cmd.handle(config, options)