# HG changeset patch # User enis # Date 1752527526 0 # Node ID 7852c0efafd77c1e9c14d7a0c80750502a72c491 planemo upload for repository https://github.com/afgane/gcp_batch_netcat diff -r 000000000000 -r 7852c0efafd7 Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Dockerfile Mon Jul 14 21:12:06 2025 +0000 @@ -0,0 +1,8 @@ +FROM google/cloud-sdk:latest + +RUN apt-get update && apt-get install -y python3 netcat-openbsd + +COPY gcp_batch_netcat.py /usr/bin/ +COPY gcp_batch_netcat.xml /usr/bin/ + +ENTRYPOINT ["python3", "/usr/bin/gcp_batch_netcat.py"] diff -r 000000000000 -r 7852c0efafd7 gcp_batch_netcat.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcp_batch_netcat.py Mon Jul 14 21:12:06 2025 +0000 @@ -0,0 +1,63 @@ + +import json +import subprocess +import argparse +import uuid + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--nfs_address', required=True) + parser.add_argument('--output', required=True) + parser.add_argument('--project', required=True) + parser.add_argument('--region', required=True) + parser.add_argument('--port', default='2049') + args = parser.parse_args() + + job_name = f'netcat-job-{uuid.uuid4()}' + + job_spec = { + "taskGroups": [ + { + "taskSpec": { + "runnables": [ + { + "script": { + "text": f"nc -z -v {args.nfs_address} {args.port}" + } + } + ] + }, + "taskCount": 1, + "parallelism": 1 + } + ], + "logsPolicy": { + "destination": "CLOUD_LOGGING" + } + } + + job_spec_file = 'job.json' + with open(job_spec_file, 'w') as f: + json.dump(job_spec, f) + + command = [ + 'gcloud', 'batch', 'jobs', 'submit', job_name, + '--location', args.region, + '--project', args.project, + '--config', job_spec_file, + '--format=text' + ] + + try: + result = subprocess.run(command, capture_output=True, text=True, check=True) + with open(args.output, 'w') as f: + f.write("Job output:\n") + f.write(result.stdout) + f.write(result.stderr) + except subprocess.CalledProcessError as e: + with open(args.output, 'w') as f: + f.write("Error submitting job:\n") + f.write(e.stderr) + +if __name__ == '__main__': + main() diff -r 000000000000 -r 7852c0efafd7 gcp_batch_netcat.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcp_batch_netcat.xml Mon Jul 14 21:12:06 2025 +0000 @@ -0,0 +1,26 @@ + + Submit a job to GCP Batch and connect to an NFS server. + + google-cloud-sdk + netcat + afgane/gcp-batch-netcat:0.1.0 + + + + + + + + + + + + + + diff -r 000000000000 -r 7852c0efafd7 test-data/gcp_batch_netcat_out.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/gcp_batch_netcat_out.txt Mon Jul 14 21:12:06 2025 +0000 @@ -0,0 +1,1 @@ +Job submitted successfully.