コード例 #1
0
def deploy_openstack_code(image, component, env_dict=None):
    tag = config.get('image-tag')
    docker_utils.pull(image, tag)

    # remove previous attempt
    docker_utils.remove_container_by_image(image)

    path = get_component_sys_paths(component)
    files = PLUGIN_FILES[component]
    name = docker_utils.create(image, tag)
    try:
        for item in files:
            dst = item.format(python_path=path)
            try:
                src = files[item]
                if isinstance(src, tuple):
                    src = src[0]
                tmp_folder = os.path.join('/tmp', str(uuid.uuid4()))
                # docker copies content of src folder if dst folder is not present
                # and directory itself if dst is present
                # therefore we copy content from container into tmp and then content of tmp into dst
                docker_utils.cp(name, src, tmp_folder)
                copy_tree(tmp_folder, dst)
                shutil.rmtree(tmp_folder, ignore_errors=True)
            except Exception:
                if not isinstance(files[item], tuple):
                    raise
                for folder in files[item][1]:
                    try:
                        docker_utils.cp(name, folder, dst)
                    except Exception:
                        pass
    finally:
        docker_utils.remove_container_by_image(image)

    try:
        version = docker_utils.get_contrail_version(image, tag)
        application_version_set(version)
    except CalledProcessError as e:
        log("Couldn't detect installed application version: " + str(e))
コード例 #2
0
def deploy_ccd_code(image, tag):
    docker_utils.remove_container_by_image(image)

    name = docker_utils.create(image, tag)
    try:
        src = '/' + image
        tmp_folder = os.path.join('/tmp', str(uuid.uuid4()))
        docker_utils.cp(name, src, tmp_folder)
        try:
            os.mkdir(tmp_folder + '/docker')
            os.mkdir('/etc/ansible')
        except Exception:
            pass

        docker_utils.cp(name, '/bin/deploy_contrail_command',
                        tmp_folder + '/docker/')
        docker_utils.cp(name, '/etc/ansible/ansible.cfg', '/etc/ansible/')

        dst = '/' + image
        copy_tree(tmp_folder, dst)

        shutil.rmtree(tmp_folder, ignore_errors=True)
    finally:
        docker_utils.remove_container_by_image(image)