예제 #1
0
    def copy_dockerfile(self, soln_stk, container_cfg):
        """
        Copies the appropriate Dockerfile (preconfigured Docker) that match the
        given solution stack to given destination. For example, with the given
        solution stack:

        64bit Debian jessie v1.2.0 running GlassFish 4.1 Java 8 (Preconfigured - Docker)

        copy Dockerfile with name

        glassfish-runtime-4.1-jdk8

        to destination_dockerfile.

        :param destination_dockerfile: str: destination Dockerfile location
        :param soln_stk: SolutionStack: solution stack
        :param container_cfg: dict: container_config.json
        :return: None
        """

        assert (containerops.is_preconfigured(soln_stk, container_cfg))

        dfile_path = containerops._get_runtime_dockerfile_path(
            soln_stk, container_cfg)
        shutil.copyfile(dfile_path, self.pathconfig.new_dockerfile_path())
예제 #2
0
def make_container(envvars_str=None,
                   host_port=None,
                   allow_insecure_ssl=False,
                   pathconfig=PathConfig):
    """
    Factory function for making a container or multicontainer.
    :param envvars_str: str: key=val str of environment variables
    :param host_port: str: optional host port mapped to container port
    :param allow_insecure_ssl: bool: allow insecure connection to docker registry
    :param pathconfig: PathConfig: Holds path/existence info
    :return Container/MultiContainer
    """

    soln_stk = _determine_platform()
    container_cfg = containerops.get_configuration()
    opt_env = EnvvarCollector.from_str(envvars_str)

    if containerops.is_multi(soln_stk, container_cfg):
        return MultiContainer(
            fs_handler=make_multicontainer_fs_handler(pathconfig),
            opt_env=opt_env,
            allow_insecure_ssl=allow_insecure_ssl,
            soln_stk=soln_stk)

    elif containerops.is_generic(soln_stk, container_cfg):
        return GenericContainer(
            fs_handler=make_container_fs_handler(pathconfig),
            soln_stk=soln_stk,
            container_cfg=container_cfg,
            opt_env=opt_env,
            host_port=host_port)

    elif containerops.is_preconfigured(soln_stk, container_cfg):
        return PreconfiguredContainer(
            fs_handler=make_container_fs_handler(pathconfig),
            soln_stk=soln_stk,
            container_cfg=container_cfg,
            opt_env=opt_env,
            host_port=host_port)

    else:
        raise NotSupportedError(strings['local.unsupported'])
 def test_is_preconfigured(self):
     self.assertTrue(cops.is_preconfigured(PRECONFIG_SOLN_STK, self.config))
     self.assertFalse(cops.is_preconfigured(GENERIC_SOLN_STK, self.config))
     self.assertFalse(
         cops.is_preconfigured(NON_DOCKER_SOLN_STK, self.config))