-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathott.py
More file actions
executable file
·59 lines (41 loc) · 1.89 KB
/
ott.py
File metadata and controls
executable file
·59 lines (41 loc) · 1.89 KB
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 json
import logging
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(threadName)s %(levelname)7s %(module)s:%(funcName)s -> %(message)s',
level=logging.INFO)
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))
if hasattr( item, "display_name" ):
logging.debug(" Name: {}".format(item.display_name))
logging.debug(" Type: {}".format(item.resource_type))
if hasattr( item, "description" ):
logging.debug(" Description: {}".format(item.description))
if hasattr( item, "lifecycle_state" ):
logging.debug(" State: {}".format(item.lifecycle_state))
logging.debug(" Compartment: {}".format(item.compartment_id))
# 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)