-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathott.py
executable file
·56 lines (42 loc) · 1.79 KB
/
ott.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
#!/usr/bin/env python3
import json
import logging
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(threadName)s %(levelname)7s %(module)s:%(funcName)s -> %(message)s',
level=logging.INFO)
# should this be here or elsewhere? TBD
from pkg_resources import packaging
import oci
if packaging.version.parse(oci.__version__) < packaging.version.parse("2.123.0"):
logging.fatal("Please update your version of the Python oci package")
import sys
sys.exit(-1)
logging.info("Parsing command line and configuring...")
from ott.config import config
cfg = config()
logging.debug("Configured")
logging.debug("Preparing for search")
from ott.search import search
srch = search(cfg)
# at this point we have the search results
results = srch.find_resource(cfg._search_string)
if not results:
logging.error("No results returned from search.")
else:
for region in results:
logging.info("Region {}".format(region))
from ott.tagger import tagger
t = tagger(cfg)
for item in results[region]:
# I feel like this should be in tagger. But am not convinced
logging.debug("Item info:")
logging.debug(" ID: {}".format(item.identifier))
logging.debug(" Compartment: {}".format(item.compartment_id))
logging.debug(" Type: {}".format(item.resource_type))
# check out my tricky trick...
item.region = region
t.queueUpdate( item, cfg._change )
if cfg._dryRun:
logging.info("Dry run. Changes not being made")
else:
t.executeUpdate(cfg._change,cfg._wait)