From abe306bfebee85530502bcf7d1e5f7a2a82da4b2 Mon Sep 17 00:00:00 2001 From: Aarsh2001 Date: Wed, 4 Oct 2023 18:47:15 +0100 Subject: [PATCH] gcp auth --- .github/auth/vm_auth.py | 8 ++++---- .github/workflows/gcp-test.yaml | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/auth/vm_auth.py b/.github/auth/vm_auth.py index 05df3a0b..99153481 100644 --- a/.github/auth/vm_auth.py +++ b/.github/auth/vm_auth.py @@ -10,7 +10,7 @@ def authenticate_vm(path): credentials = Credentials.from_service_account_file(path) return discovery.build('compute', 'v1', credentials=credentials), credentials -def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'): +def start_runner(creds, key, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'): compute, credentials = authenticate_vm(creds) compute.instances().start(project=id, zone=zone, instance=instance).execute() # request = compute.instances().get(project=id, zone=zone, instance=instance) @@ -27,7 +27,7 @@ def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instanc ssh.connect( hostname=f'{instance}.{zone}.compute.internal', username=ssh_username, # Typically 'your-username' or 'gce-username' - key_filename= 'gcp_auth.pem', + pkey = paramiko.RSAKey(file_obj=key), ) @@ -43,9 +43,9 @@ def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instanc return output if __name__ == "__main__": - user = sys.argv[1] + key = sys.argv[1] # Start the instance - start_runner('gcp_auth.json', user) + start_runner('gcp_auth.json', key) diff --git a/.github/workflows/gcp-test.yaml b/.github/workflows/gcp-test.yaml index b3f27b0a..5902ecb2 100644 --- a/.github/workflows/gcp-test.yaml +++ b/.github/workflows/gcp-test.yaml @@ -28,8 +28,7 @@ jobs: run: | cd demos/.github/auth python3 db_auth.py ${{ secrets.DB_ENDPOINT }} ${{ secrets.DB_OBJ_ID }} - openssl pkcs8 -inform PEM -outform PEM -in gcp_auth.json -out gcp_auth.pem - python3 vm_auth.py ${{ secrets.SSH_USERNAME}} + python3 vm_auth.py ${{ secrets.SSH_KEY}} run-test: needs: activate-vm