forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_image_id.py
More file actions
32 lines (24 loc) · 975 Bytes
/
Copy pathupdate_image_id.py
File metadata and controls
32 lines (24 loc) · 975 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
import json
import argparse
def main(image_id, confile):
print("Extracting instance conf file")
with open(confile, 'r') as conf_file:
conf = json.load(conf_file)
print("Getting new image ID")
with open(image_id, 'r') as image_id_file:
image_id_lines = image_id_file.readlines()
image_id_lines = [line.strip('\n') for line in image_id_lines]
print(image_id_lines)
id = image_id_lines[0]
id = id.split()[0]
conf['ImageId'] = id
print("Setting new image ID")
with open(confile, 'w') as conf_file:
data = json.dumps(conf)
conf_file.write(data)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Utility for updating image id')
parser.add_argument('-i', '--image', help='The image_id', required=True)
parser.add_argument('-c', '--conf', help='The conf file', required=True)
options = parser.parse_args()
main(options.image, options.conf)