Spaces:
Runtime error
Runtime error
elfsong
commited on
Commit
•
f6e5539
1
Parent(s):
ba264c6
Update
Browse files
app.py
CHANGED
@@ -15,14 +15,11 @@ def auth():
|
|
15 |
def get_status(credentials, instance_name):
|
16 |
status = False
|
17 |
client = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
18 |
-
|
19 |
-
|
20 |
-
print(result)
|
21 |
-
st.write(result)
|
22 |
-
for item in result['items']:
|
23 |
if item["name"] == instance_name:
|
24 |
try:
|
25 |
-
ip_address = item['networkInterfaces'][0]['
|
26 |
except Exception as e:
|
27 |
ip_address = None
|
28 |
status = True if item["status"] == "RUNNING" else False
|
|
|
15 |
def get_status(credentials, instance_name):
|
16 |
status = False
|
17 |
client = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
18 |
+
response = client.instances().list(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c').execute()
|
19 |
+
for item in response['items']:
|
|
|
|
|
|
|
20 |
if item["name"] == instance_name:
|
21 |
try:
|
22 |
+
ip_address = item['networkInterfaces'][0]['accessConfigs'][0]['natIP']
|
23 |
except Exception as e:
|
24 |
ip_address = None
|
25 |
status = True if item["status"] == "RUNNING" else False
|