Skip to content

Commit

Permalink
gcp auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarsh2001 committed Oct 4, 2023
1 parent 1d53183 commit b752f7d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/auth/vm_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def authenticate_vm(path):
credentials = Credentials.from_service_account_file(path)
return discovery.build('compute', 'v1', credentials=credentials)
def start_runner(creds, path, ssh_username, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'):
def start_runner(creds, path, ssh_username, passphrase, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'):
compute = authenticate_vm(creds)
request = compute.instances().start(project=id, zone=zone, instance=instance)
request.execute()
Expand All @@ -27,6 +27,7 @@ def start_runner(creds, path, ssh_username, id = "gpu-insatnce", zone='us-centra
external_ip,
username=ssh_username, # Typically 'your-username' or 'gce-username'
key_filename = path,
passphrase=passphrase,
)

# Execute the command on the instance
Expand All @@ -41,10 +42,10 @@ def start_runner(creds, path, ssh_username, id = "gpu-insatnce", zone='us-centra
return output

if __name__ == "__main__":
username = sys.argv[1]
username, passphrase = sys.argv[1], sys.argv[2]
# Start the instance
ssh_key_path = os.path.expanduser('~/.ssh/id_rsa')
start_runner('gcp_auth.json', ssh_key_path, str(username))
start_runner('gcp_auth.json', ssh_key_path, str(username), passphrase)



0 comments on commit b752f7d

Please sign in to comment.