Пример #1
0
    def test_vm_type_docker_machine(self):
        with_docker_machine_mock = MagicMock(return_value="result")
        with patch("conductr_cli.host.with_docker_machine", with_docker_machine_mock):
            result = host.resolve_ip_by_vm_type(DockerVmType.DOCKER_MACHINE)
            self.assertEqual(result, "result")

        with_docker_machine_mock.assert_called_with()
Пример #2
0
    def test_vm_type_none(self):
        with_docker_machine_mock = MagicMock(return_value="result")
        with patch("conductr_cli.host.with_docker_machine", with_docker_machine_mock):
            result = host.resolve_ip_by_vm_type(DockerVmType.NONE)
            self.assertEqual(result, "127.0.0.1")

        with_docker_machine_mock.assert_not_called()
Пример #3
0
def start_nodes(args, features):
    container_names = []
    log = logging.getLogger(__name__)
    log.info(headline('Starting ConductR'))
    ports = collect_ports(args, features)
    conductr_args = flatten([feature.conductr_args() for feature in features])
    conductr_features = flatten([feature.conductr_feature_envs() for feature in features])
    feature_conductr_roles = flatten([feature.conductr_roles() for feature in features])
    for i in range(args.nr_of_containers):
        container_name = '{prefix}{nr}'.format(prefix=CONDUCTR_NAME_PREFIX, nr=i)
        container_names.append(container_name)
        # Display the ports on the command line. Only if the user specifies a certain feature, then
        # the corresponding port will be displayed when running 'sandbox run' or 'sandbox debug'
        if ports:
            host_ip = host.resolve_ip_by_vm_type(args.vm_type)
            ports_desc = ' exposing ' + ', '.join(['{}:{}'.format(host_ip, map_port(i, port))
                                                   for port in sorted(ports)])
        else:
            ports_desc = ''
        log.info('Starting container {container}{port_desc}..'.format(container=container_name,
                                                                      port_desc=ports_desc))
        cond0_ip = inspect_cond0_ip() if i > 0 else None
        conductr_container_roles = resolve_conductr_roles_by_container(args.conductr_roles, feature_conductr_roles, i)
        run_conductr_cmd(
            i,
            args.nr_of_containers,
            container_name,
            cond0_ip,
            args.envs,
            '{image}:{version}'.format(image=args.image, version=args.image_version),
            args.log_level,
            ports,
            args.bundle_http_port,
            conductr_features,
            conductr_container_roles,
            conductr_args
        )
    return container_names
Пример #4
0
 def __init__(self, vm_type):
     self.ip = host.resolve_ip_by_vm_type(vm_type)