forked from whole-tale/deploy-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdestroy_instances.py
More file actions
executable file
·33 lines (28 loc) · 925 Bytes
/
Copy pathdestroy_instances.py
File metadata and controls
executable file
·33 lines (28 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import json
import requests
import time
import os
import sys
from requests.auth import HTTPBasicAuth
from subprocess import check_output
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
api_url = 'https://girder.local.wholetale.org/api/v1'
try:
r = requests.get(api_url + '/user/authentication', auth=HTTPBasicAuth('admin', 'arglebargle123'))
except:
print('Girder is no longer running')
exit()
r.raise_for_status()
headers['Girder-Token'] = r.json()['authToken']['token']
print('Deleting all running instances')
r = requests.get(api_url + '/instance', headers=headers,
params={'limit': 0})
r.raise_for_status()
for instance in r.json():
requests.delete(api_url + '/instance/' + instance['_id'], headers=headers)
cmd = "docker service ls --filter=name=tmp -q | xargs -r docker service rm"
print(check_output(cmd, shell=True))