Example #1
0
def sources_generation():
    config_yaml = ServiceUtils.get_step_config(request.form,
                                               'sources_generation.yaml',
                                               _params_to_yaml)

    execution_id = ConfigUtils.generate_id('src-gen-')
    config_yaml['execution_id'] = execution_id
    step = SourcesGenerationHost(config_yaml)
    ServiceUtils.run_host_step(step)

    return redirect("/sources-generation/%s" % execution_id)
def java_sources_staging():
    step_props = JavaSourcesStagingHost.host_step_properties(
        ConfigUtils.generate_id('java-src-stage-'))

    config_yaml = ServiceUtils.get_step_config(request.form,
                                               'java_sources_staging.yaml',
                                               _params_to_yaml)
    artifacts_zip_path = step_props.temp_subpath(ConfigUtils.artifact_name())
    config_yaml['generator_artifacts']['sources_zip'] = artifacts_zip_path
    execution_id = step_props.execution_id()
    config_yaml['staging']['git_branch'] = execution_id
    config_yaml['execution_id'] = execution_id

    ServiceUtils.run_host_step(JavaSourcesStagingHost(config_yaml))

    step = JavaSourcesStagingHost(config_yaml)
    step.pre_execute()
    request.files['generator_artifacts_sources_zip'].save(artifacts_zip_path)
    ServiceUtils.run_host_step(step)

    return redirect("/java-sources-staging/%s" % step_props.execution_id())
            self,
            JavaSourcesStagingHost.host_step_properties(
                config['execution_id']), config)

    def execute(self):
        self._stage_sources_in_guest()
        return self._host.execution_id()

    def _stage_sources_in_guest(self):
        host_art_path = self._config['generator_artifacts']['sources_zip']
        art_name = host_art_path[host_art_path.rfind('/') + 1:]
        guest_art_path = self._guest.guest_root_subpath(art_name)

        guest_config = copy.deepcopy(self._config)
        guest_config['generator_artifacts']['sources_zip'] = guest_art_path

        self.run_guest_script(guest_config,
                              [[host_art_path, guest_art_path, 'ro']])

    @staticmethod
    def host_step_properties(execution_id):
        return HostStepProperties(__file__, execution_id)


if __name__ == '__main__':
    execution_config = ConfigUtils.read_config(
        execution_id=ConfigUtils.generate_id('java-src-stage-'))
    step = JavaSourcesStagingHost(execution_config)
    step.pre_execute()
    step.execute()
        guest_config = copy.deepcopy(self._config)
        mounts = self._local_repo_mounts()
        extra_mounts = []
        for repo_name, repo_mounts in mounts.items():
            if repo_mounts:
                guest_config[repo_name]['git_repo'] = repo_mounts[1]
                extra_mounts.append(repo_mounts)

        self.run_guest_script(guest_config, extra_mounts)

    def _local_repo_mounts(self):
        config = self._config
        mounts = {
            'artman': self.local_repo_mount(config['artman']),
            'toolkit': self.local_repo_mount(config['toolkit']),
            'googleapis': self.local_repo_mount(config['googleapis'])
        }
        return mounts

    @staticmethod
    def host_step_properties(execution_id):
        return HostStepProperties(__file__, execution_id)


if __name__ == '__main__':
    execution_config = ConfigUtils.read_config(
        execution_id=ConfigUtils.generate_id('src-gen'))
    step = SourcesGenerationHost(execution_config)
    step.pre_execute()
    step.execute()