Exemplo n.º 1
0
 def start(self):
     if major_version(self.image_version) == 1:
         pass
     else:
         log = logging.getLogger(__name__)
         log.info(
             headline(
                 'Starting logging feature based on elasticsearch and kibana'
             ))
         log.info(
             'conductr-kibana bundle is packaged as a Docker image. Checking Docker requirements..'
         )
         docker.validate_docker_vm(docker.vm_type())
         log.info('Docker is installed and configured correctly.')
         elasticsearch = select_bintray_uri('conductr-elasticsearch',
                                            self.version_args)
         log.info('Deploying bundle %s..' % elasticsearch['bundle'])
         elasticsearch_load_command = ['load', elasticsearch['bundle'], '--disable-instructions'] + \
             parse_offline_mode_arg(self.offline_mode)
         conduct_main.run(elasticsearch_load_command,
                          configure_logging=False)
         conduct_main.run(
             ['run', elasticsearch['name'], '--disable-instructions'],
             configure_logging=False)
         kibana = select_bintray_uri('conductr-kibana', self.version_args)
         log.info('Deploying bundle %s..' % kibana['bundle'])
         kibana_load_command = ['load', kibana['bundle'], '--disable-instructions'] + \
             parse_offline_mode_arg(self.offline_mode)
         conduct_main.run(kibana_load_command, configure_logging=False)
         conduct_main.run([
             'run', kibana['name'], '--disable-instructions',
             '--wait-timeout', '600'
         ],
                          configure_logging=False)
Exemplo n.º 2
0
def run(args):
    """`sandbox run` command"""
    is_conductr_v1 = major_version(args.image_version) == 1
    features = sandbox_features.collect_features(args.features,
                                                 args.image_version,
                                                 args.offline_mode)
    sandbox = sandbox_run_docker if is_conductr_v1 else sandbox_run_jvm

    run_result = sandbox.run(args, features)

    is_started, wait_timeout = wait_for_start(args, run_result)
    if is_started:
        if not is_conductr_v1:
            feature_ports = []
            for feature in features:
                feature_ports.extend(feature.ports)

            proxy_ports = sorted(args.ports + feature_ports)
            sandbox_proxy.start_proxy(proxy_bind_addr=run_result.core_addrs[0],
                                      proxy_ports=proxy_ports)

        for feature in features:
            feature.start()

    sandbox.log_run_attempt(args, run_result, is_started, wait_timeout)

    return True
Exemplo n.º 3
0
 def conductr_args(self):
     if major_version(self.image_version) == 1:
         return []
     else:
         return [
             '-Dcontrail.syslog.server.port=9200',
             '-Dcontrail.syslog.server.elasticsearch.enabled=on'
         ]
Exemplo n.º 4
0
 def start(self):
     if major_version(self.image_version) == 1:
         pass
     else:
         log = logging.getLogger(__name__)
         log.info(headline('Starting visualization feature'))
         visualizer = select_bintray_uri('visualizer', self.version_args)
         log.info('Deploying bundle %s..' % visualizer['bundle'])
         conduct_main.run(['load', visualizer['bundle'], '--disable-instructions'], configure_logging=False)
         conduct_main.run(['run', visualizer['name'], '--disable-instructions'], configure_logging=False)
Exemplo n.º 5
0
 def start(self):
     if major_version(self.image_version) == 1:
         pass
     else:
         log = logging.getLogger(__name__)
         log.info(headline('Starting logging feature based on eslite'))
         eslite = select_bintray_uri('eslite', self.version_args)
         log.info('Deploying bundle %s..' % eslite['bundle'])
         conduct_main.run(['load', eslite['bundle'], '--disable-instructions'], configure_logging=False)
         conduct_main.run(['run', eslite['name'], '--disable-instructions'], configure_logging=False)
Exemplo n.º 6
0
def run(args):
    """`sandbox run` command"""

    pull_image(args)
    features = collect_features(args.features, args.image_version)
    container_names = scale_cluster(args, features)
    is_started, wait_timeout = wait_for_start(args)
    if is_started:
        if major_version(args.image_version) != 1:
            start_proxy(args.nr_of_containers)
        for feature in features:
            feature.start()
    print_result(container_names, is_started, args.no_wait, wait_timeout, args.image_version)
Exemplo n.º 7
0
 def start(self):
     if major_version(self.image_version) == 1:
         pass
     else:
         log = logging.getLogger(__name__)
         log.info(headline('Starting logging feature based on eslite'))
         eslite = select_bintray_uri('eslite', self.version_args)
         log.info('Deploying bundle %s..' % eslite['bundle'])
         load_command = ['load', eslite['bundle'], '--disable-instructions'] + \
             parse_offline_mode_arg(self.offline_mode)
         conduct_main.run(load_command, configure_logging=False)
         conduct_main.run(['run', eslite['name'], '--disable-instructions'],
                          configure_logging=False)
Exemplo n.º 8
0
 def start(self):
     if major_version(self.image_version) == 1:
         pass
     else:
         log = logging.getLogger(__name__)
         log.info(headline('Starting logging feature based on elasticsearch and kibana'))
         elasticsearch = select_bintray_uri('conductr-elasticsearch', self.version_args)
         log.info('Deploying bundle %s..' % elasticsearch['bundle'])
         conduct_main.run(['load', elasticsearch['bundle'], '--disable-instructions'], configure_logging=False)
         conduct_main.run(['run', elasticsearch['name'], '--disable-instructions'], configure_logging=False)
         kibana = select_bintray_uri('conductr-kibana', self.version_args)
         log.info('Deploying bundle %s..' % kibana['bundle'])
         conduct_main.run(['load', kibana['bundle'], '--disable-instructions'], configure_logging=False)
         conduct_main.run(['run', kibana['name'], '--disable-instructions'], configure_logging=False)
Exemplo n.º 9
0
 def start(self):
     log = logging.getLogger(__name__)
     log.info(headline('Starting monitoring feature'))
     bundle_repo = 'lightbend/commercial-monitoring/' if self.version_args and self.version_args[0] == 'snapshot' \
         else ''
     bundle_name = 'cinnamon-grafana' if major_version(
         self.image_version) == 1 else 'cinnamon-grafana-docker'
     grafana = select_bintray_uri(bundle_name, self.version_args,
                                  bundle_repo)
     log.info('Deploying bundle %s..' % grafana['bundle'])
     load_command = ['load', grafana['bundle'], '--disable-instructions'] + \
         parse_offline_mode_arg(self.offline_mode)
     conduct_main.run(load_command, configure_logging=False)
     conduct_main.run([
         'run', grafana['name'], '--disable-instructions', '--wait-timeout',
         '600'
     ],
                      configure_logging=False)
Exemplo n.º 10
0
def print_result(container_names, is_started, no_wait, wait_timeout, image_version):
    if not no_wait:
        log = logging.getLogger(__name__)
        if is_started:
            log.info(headline('Summary'))
            log.info('ConductR has been started')
            plural_string = 's' if len(container_names) > 1 else ''
            log.info('Check resource consumption of Docker container{} that run the ConductR node{} with:'
                     .format(plural_string, plural_string))
            log.info('  docker stats {}'.format(' '.join(container_names)))
            log.info('Check current bundle status with:')
            log.info('  conduct info')
            if major_version(image_version) != 1:
                log.info('Bundle status:')
                conduct_main.run(['info'], configure_logging=False)
        else:
            log.info(headline('Summary'))
            log.error('ConductR has not been started within {} seconds.'.format(wait_timeout))
            log.error('Set the env CONDUCTR_SANDBOX_WAIT_RETRY_INTERVAL to increase the wait timeout.')
Exemplo n.º 11
0
def run():
    # Parse arguments
    parser = build_parser()
    argcomplete.autocomplete(parser)
    args = parser.parse_args()

    # Print help or execute subparser function
    if not vars(args).get('func'):
        parser.print_help()
    # Validate image_version
    elif vars(args).get('func').__name__ == 'run' and not args.image_version:
        parser.exit('The version of ConductR need to be set.\n'
                    'Please visit https://www.lightbend.com/product/conductr/developer '
                    'to obtain the current version information.')
    # Call sandbox function
    elif vars(args).get('func').__name__ == 'version':
        logging_setup.configure_logging(args)
        args.func(args)
    else:
        logging_setup.configure_logging(args)
        # Check that all feature arguments are valid
        if vars(args).get('func').__name__ == 'run':
            if args.features and args.no_wait:
                parser.exit('Option --no-wait is not allowed when starting ConductR with option --feature')
            invalid_features = [f for f, *a in args.features if f not in feature_names]
            if invalid_features:
                parser.exit('Invalid features: %s (choose from %s)' %
                            (', '.join("'%s'" % f for f in invalid_features),
                             ', '.join("'%s'" % f for f in feature_names)))
        # Docker VM validation
        args.vm_type = docker.vm_type()
        if vars(args).get('func').__name__ == 'run' and major_version(args.image_version) == 1:
            docker.validate_docker_vm(args.vm_type)

        result = args.func(args)
        if not result:
            exit(1)
Exemplo n.º 12
0
 def conductr_roles(self):
     if major_version(self.image_version) == 1:
         return []
     else:
         return ['elasticsearch', 'kibana']
Exemplo n.º 13
0
 def conductr_args(self):
     if major_version(self.image_version) == 1:
         return []
     else:
         return ['-Dcontrail.syslog.server.port=9200', '-Dcontrail.syslog.server.elasticsearch.enabled=on']
Exemplo n.º 14
0
 def conductr_feature_envs(self):
     if major_version(self.image_version) == 1:
         return [self.name]
     else:
         return []
Exemplo n.º 15
0
 def conductr_feature_envs(self):
     if major_version(self.image_version) == 1:
         return [self.name]
     else:
         return []
Exemplo n.º 16
0
 def conductr_roles(self):
     if major_version(self.image_version) == 1:
         return []
     else:
         return ['elasticsearch']