-
Notifications
You must be signed in to change notification settings - Fork 6
/
sf_genrole
executable file
·49 lines (36 loc) · 1.39 KB
/
sf_genrole
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
#!/usr/bin/env python3
import argparse
import re
from sfconfig import SfConfig
from sfconn import SfConn
from sflogger import SfLogger
from sfprovisionconfig import SfProvisionConfig
from sfgenconfig import SfGenConfig
# Load configuration for provisioning
prov_cfg = SfProvisionConfig()
# Validate the configuration
try:
prov_cfg.validate_config()
except ValueError:
print("Configuration problem exiting")
exit(-1)
parser = argparse.ArgumentParser(description='Snowflake functional role configuration generator')
parser.add_argument('role', help='Names of functional roles to parse and build configuration for. ALL queries for roles ending in _FR', nargs='+')
parser.add_argument('--log_level', type=str, choices=['DEBUG','INFO','WARNING','ERROR','CRITICAL'], default='WARNING', help='Log Level to output')
args = parser.parse_args()
fr_role_list = args.role
if fr_role_list is None or type(fr_role_list) is not list:
parser.print_help()
print("Please specify roles to generate configuration from")
exit(-1)
# Connect to Snowflake with configuration from config.json
sf_cfg = SfConfig('config.json')
logger = SfLogger(args.log_level, __file__)
sf_conn = SfConn(sf_cfg.config, logger)
gen_cfg = SfGenConfig(prov_cfg, sf_conn, fr_role_list)
roles = gen_cfg.list_roles()
for fr_role in roles:
gen_cfg.gen_role_config(fr_role)
gen_cfg.print_config()
sf_conn.close_conn()
exit(0)