-
Notifications
You must be signed in to change notification settings - Fork 5
/
ociextirpate.py
executable file
·59 lines (41 loc) · 1.65 KB
/
ociextirpate.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import io
import importlib
import logging
__requires__ = 'oci==2.78.0'
def extirpate():
logging.basicConfig(format='%(asctime)s %(threadName)s %(levelname)7s %(module)s:%(funcName)s -> %(message)s')
logging.getLogger().setLevel(logging.INFO)
logging.info("Starting up")
logging.info("Configuring...")
from ociextirpater.config import config
cfg = config()
logging.info("Configured")
# at this point we should have a signer and some other stuff in the cfg object
clients = cfg.categories_to_delete
logging.info("{} clients".format( len(clients)))
for client in clients:
logging.debug( "Importing {}".format(client))
my_module = importlib.import_module("ociextirpater.ociclients.%s" % client)
logging.debug( "Module name: {}".format( my_module.__name__ ))
logging.debug( "Getting {}".format( client ) )
cls = getattr( importlib.import_module("ociextirpater.ociclients.%s" % client), client )
logging.debug( "Name for {} is {}".format( client, cls.service_name ) )
logging.debug( "Instantiating" )
o = cls( cfg )
logging.debug("Instantiated OK")
# executor.submit(o.findAndDeleteAllInCompartment)
try:
o.findAndDeleteAllInCompartment()
except Exception as e:
logging.error("Exception caught")
logging.debug(e)
def handler(ctx, data: io.BytesIO = None):
extirpate()
from fdk import response
return response.Response(
ctx, response_data='Finished extirpating',
headers={"Content-Type": "text/plain"}
)
if __name__ == '__main__':
extirpate()