Odyssey
ody_migr_config.py
1 #!/usr/bin/env python
2 """Common config file shared accross all the modules."""
3 
4 
5 import os
6 
7 # GENERAL VARIABLES
8 
9 # common log formatter
10 LOG_FORMATTER = ('%(asctime)s %(name)-4s %(process)-6s '
11  '%(levelname)-6s %(message)s')
12 
13 # log file name structure
14 LOG_FILE_NAME = "/home/{}/logs/ody_migr_{}_{}.log"
15 
16 # server url based on DEVMODE and REQUIRE_ENCRYPTION env variables
17 http_protocol = "https" if os.getenv("REQUIRE_ENCRYPTION") == "1" else "http"
18 
19 if os.getenv("DEVMODE") == "1":
20  server_host = "localhost:8000"
21 else:
22  # this line should obtain appropriate domain url if DEVMODE=0
23  server_host = os.getenv("TICKET_DOMAIN", "localhost:8000")
24  # if TICKET_DOMAIN is still "", then somehow DEVMODE is set to "0"
25  # (eg. from inside web-shell during debugging), then we set the server host
26  # to be localhost:8000
27  if server_host.strip() == "":
28  # we should not
29  server_host = "localhost:8000"
30 
31 # System variables re-defined from app/web/monitor/library/cu_top.i
32 # Need to match values from cu_top.i script
33 SYS_TYPE_BATCH = 1
34 SYS_TYPE_LIVE = 2
35 SYS_TYPE_WEBONLY = 16
36 SYS_TYPE_CLOSED = 64
37 
38 SERVER_URL = "{}://{}".format(http_protocol, server_host)
39 
40 # root directory of the migration related scripts
41 SCRIPT_ROOT = "/project/app/tools/bin" if os.getenv(
42  "DEVMODE") == "1" else "/opt/odyssey/tools/bin"
43 
44 
45 # keyword for secret key env variable
46 ENV_MIGR_SECRET_KEY = "ODY_MIGR_SECRET_KEY"
47 
48 # REQUIRED FOR TESTING
49 TEST_USERNAME = ""
50 TEST_PASSWORD = ""
51 TESTING_SERVER = "www4"
52 
53 # lists of supported CUs (argparse) -- only associated with `www4` and used
54 # for development testing purpose
55 # Even if we add other invalid CU's here for migration from www4 during
56 # development, Samuel's code re-validates existence of the CU in www4 and
57 # the migration will not proceed
58 SUPPORTED_DEV_CU = ["SCRUBCU", "CRUISECU"]
59 
60 # supported end servers (argparse)
61 # "www" is used only with DATA_OPT_GETCULIST option
62 SERVER_CHOICES = ["www4", "www3", "www5", "www6"]
63 
64 # all action keywords
65 ACTION_OPT_CLEAN = "clean"
66 ACTION_OPT_MIGRATE = "migrate"
67 ACTION_OPT_SUMMARY = "summary"
68 
69 # action choices (argparse)
70 ACTION_CHOICES = [ACTION_OPT_CLEAN, ACTION_OPT_MIGRATE, ACTION_OPT_SUMMARY]
71 
72 # all data category keywords
73 DATA_OPT_SETTINGS = "settings"
74 DATA_OPT_MEMBERS = "members"
75 DATA_OPT_MEMDATA = "memdata"
76 DATA_OPT_SWITCH_ACCT_MEMBERS = "switchaccountmembers"
77 DATA_OPT_SWITCH_ACCOUNTS = "switchaccounts"
78 DATA_OPT_MEMHIST = "memhist"
79 DATA_OPT_CREATE_HIST = "createhistoryfile"
80 DATA_OPT_GET_HIST = "gethistoryfile"
81 DATA_OPT_ADMIN = "admin"
82 DATA_OPT_LOANAPP = "loanapp"
83 DATA_OPT_GETCULIST = "getculist" # get a list of CU's from www for validation
84 DATA_OPT_CLEANUP = "cleanup" # memhist cleanup after the migration is complete
85 
86 # wait for this many SECONDS after requesting for createhistoryfile and
87 # before requesting for gethistoryfile
88 HIST_CREATE_WAIT_TIME = 10
89 # number of members to import at a time for memdata
90 MEMBERS_PAGE_SIZE = 50
91 SWITCH_ACC_BATCH_SIZE = 400
92 
93 # data categories for testing MAMMOTH endpoint
94 DATA_CHOICES_FOR_TEST = [
95  DATA_OPT_SETTINGS,
96  DATA_OPT_MEMBERS,
97  DATA_OPT_MEMDATA,
98  DATA_OPT_CREATE_HIST,
99  DATA_OPT_GET_HIST,
100  DATA_OPT_ADMIN
101 ]
102 
103 # list of CU's that you may want to use for testing
104 # do not use SOCU in the list - one test case will fail if included
105 SUPPORTED_CU_TEST = ["SCRUBCU", "CRUISECU"]
106 
107 # data category choices (argparse)
108 DATA_CHOICES = [
109  DATA_OPT_SETTINGS,
110  DATA_OPT_MEMDATA,
111  DATA_OPT_SWITCH_ACCOUNTS,
112  DATA_OPT_MEMHIST,
113  DATA_OPT_ADMIN,
114  DATA_OPT_LOANAPP
115 
116 ]
117 
118 # dictionary of pre-genererated expected authentication
119 # pass-phrases based on the chosen hashing algorithm (SHA1)
120 # generated based on CU, action (settings, members, etc) and secret key
121 EXPECTED_HASH_DICT = {
122  DATA_OPT_SETTINGS: {
123  "SCRUBCU": "0fd5f28efe6f1c8858ab251738eda5555a38bd9e",
124  "CRUISECU": "ae74dc467ffacdaaafaa1a457d73704df8e6dbb2",
125  },
126  "members": {
127  "SCRUBCU": "64ee2be7ed12c75fbe03f761685dad4386cfff97",
128  "CRUISECU": "e603fbfca999c4b02bc831bd5ab49037b788736e",
129  },
130  DATA_OPT_MEMDATA: {
131  "SCRUBCU": "72a82e4b1b29eb2e1ab9b7eed2094bcd9d4bc520",
132  "CRUISECU": "63067f1c4f8d8c7abec7df6a3cad1ee920ef6630",
133  },
134  DATA_OPT_CREATE_HIST: {
135  "SCRUBCU": "f0e7befce9d7cd29b05a85787438a8a553aca290",
136  "CRUISECU": "12a7944ca58b49bd3af001145d4b6877326eceb9",
137  },
138  DATA_OPT_GET_HIST: {
139  "SCRUBCU": "c2d6f276212bfcfc7c68fe080806648d2bbd3910",
140  "CRUISECU": "af5eb1dd2862f9433d8d85dd21e45aee09b2043f",
141  # to test history file does not exist as SOCU is not listed in
142  # SUPPORTED_CU_TEST
143  "SOCU": "d38f8bb69acaef2fe1c5a1055fe0abab723f313c"
144  },
145  DATA_OPT_ADMIN: {
146  "SCRUBCU": "39ca9d4bc5a81fbf4dd1bf64b56c3f0e5b71d323",
147  "CRUISECU": "666b7bcb47937454acf4eaebf537ae4eb26cebf6",
148  }
149 }
150 
151 # key parameter to `memdata` in HTTP GET parameter
152 KEY_MEMBERS = "members"
153 # Default error string in the MAMMOTH response
154 DEFAULT_ERROR_STR = ''
155 # Keys in the response dictionary from MAMMOTH
156 RESPONSE_KEYS = ["data", "action", "error"]
157 RESPONSE_HIST_KEYS = ["file", "action", "error"]
158 # Keys in the response dictionary for different
159 # data category type received from MAMMOTH
160 EXPECTED_DATA_KEYS = {
161  DATA_OPT_SETTINGS: [
162  "cuadmin",
163  "custom-content",
164  "menu",
165  "branding"
166  ],
167  DATA_OPT_MEMBERS: [
168  "count",
169  "list"
170  ],
171  DATA_OPT_MEMDATA: {
172  "cuusers",
173  "cuquestselect",
174  "accountbalance",
175  "loanbalance",
176  "holds",
177  "cualertbal",
178  "cualertcheck",
179  "cualertloan",
180  "cualerttrans",
181  "cuadmeco",
182  "culogtrack",
183  "userlogins",
184  "cusurveysays",
185  "curepeattx",
186  "cucmsresponse",
187  "cuauditusers",
188  "cuovermicr"
189  },
190  DATA_OPT_CREATE_HIST: [],
191  DATA_OPT_GET_HIST: [],
192  DATA_OPT_ADMIN: [
193  'cualertmsgs',
194  'cusurveydetail',
195  'cusurveymaster',
196  'extkey',
197  'cuadmnotify',
198  'cutrusteddetail',
199  'adminusers',
200  'cusurveyintro',
201  'cucontact',
202  'cuhavetrans',
203  'cusurveyquest',
204  'cualtroute'
205  ]
206 }
207 
208 # All database SQL operation keywords
209 CREATE = "create"
210 INSERT = "insert_all"
211 INSERT_ONE = "insert_one"
212 SELECT_RETURN = "select_and_return"
213 SELECT = "select_and_print"
214 SELECT_COUNT = "select_count"
215 DELETE = "delete"
216 TABLE_EXISTS = "table_exists"
217 SUMMARY = "tables_summary"
218 
219 # MENU CONFIG
220 
221 # default entry for menu item platform for cu_featuremenu table
222 DEF_MENU_ITEM_PLATFORM = ["D", "M", "A"]
223 # code to indicate menu feature that has no mapping
224 FEATURE_NOT_FOUND = "CD_NT_FND"
225 # expected empty feature code
226 EXPECTED_EMPTY_FEATURE_CODE = ""
227 
228 # hrefs that do not have feature code
229 NO_FEATURE_CODE_HREF = [
230  "hcuLogout",
231  "hcuContactUs"
232 ]
233 
234 # hcuConnect mode=`XXX` that do not map to menu link
235 NO_MENU_LINK_MODE = [
236  "DREAMPOINTS",
237  "HcuDMI",
238  "DMI",
239  "PSCU_ACCPT",
240  "PSCU_INFO",
241  "FICS",
242  "FIS_EZCARD",
243  "HcuEZCARD",
244  "GOTOMYCARD",
245  "FISERV_CPS"
246 ]
247 
248 # Menu feature code mapping dictionaries
249 # Note: comments are left as they are intentionally
250 # as these mappings were the result of continuous
251 # discussions and this might help with any surprise
252 # cases in future when dealing with data from other CUs
253 HCUCONNECT_MODE_CODE_MAP = {
254  # "DREAMPOINTS": "", # no menu link
255  # "HcuDMI": "", # no menu link
256  # "DMI": "", # no menu link
257  "ENSENTA_BRDC": "RDC",
258  "CHKFREE": "BILLPAY",
259  "PAYVERIS": "BILLPAY",
260  "IPAY_V3": "BILLPAY",
261  "PSCUPAY_SSO": "BILLPAY",
262  # "PSCU_ACCPT": "", # no menu link
263  # "PSCU_INFO": "", # no menu link
264  "MemberPay": "BILLPAY",
265  # "FICS": "", # no menu link
266  # "FIS_EZCARD": "", # no menu link
267  # "HcuEZCARD": "", # no menu link
268  # "GOTOMYCARD": "", # no menu link
269  "LASERTEC_ES": "ESTMT",
270  "IDS_ES": "ESTMT",
271  "LASERPRINT_ES": "ESTMT",
272  "MWI_LOANPAY": "BILLPAY",
273  "Bit": "ESTMT",
274  "CERTEGY": "BILLPAY",
275  "LKCS": "ESTMT",
276  "MVANTE": "BILLPAY",
277  "MidIPAY": "BILLPAY", # no implementation
278  "IPAY": "BILLPAY",
279  "MDesk": "PFM",
280  "MDesk3": "PFM",
281  "VSOFT": "RDC",
282  "Digital": "ESTMT",
283  "BDI": "ESTMT",
284  "DELUXE_OP": "BASIC", # implies hcuOrderChecks
285  "ThinkDigital": "ESTMT",
286  "hcuLoanApp": "ONLINEAPP",
287  # "FISERV_CPS": "", # never implemented
288  "MeridianLink": "ONLINEAPP",
289  "WebShare": "ESTMT"
290 }
291 
292 FEATURE_CODE_HREF_MAP = {
293  "hcuAccounts": "BASIC",
294  "hcuTxtBanking": "SMS",
295  "hcuTransfer": "TRN",
296  "hcuAlerts": "ALERT",
297  # seen in www4 (doesn't have equivalent .prg file in Odyssey)
298  "hcuEalerts": "ALERT",
299  "hcuMobilePay": "MBILLPAY",
300  "hcuStatement": "ESTMT",
301  # seen in www4 (doesn't have equivalent .prg file in Odyssey)
302  "hcuStatements": "ESTMT",
303  "hcuSecureMail": "SECUREMSG",
304  "hcuDownload": "TRNDOWN",
305  "hcuTransferSchedule": "TRNSCHED",
306  "hcuArchiveCheck": "BASIC",
307  "hcuForms": "BASIC",
308  "hcuProfileAlias": "BASIC",
309  "hcuProfileEmail": "BASIC",
310  "hcuProfilePwd": "BASIC",
311  "hcuProfileSecurity": "BASIC",
312  "hcuProfileDesc": "BASIC",
313  "hcuOrderChecks": "BASIC", # hcuConnect + mode=DELUXE_OP
314  "hcuDisclosures": "BASIC",
315  "hcuHistory": "BASIC"
316 }
317 
318 # fa-icon mapping for S and H type menus - does not relate to D type menus
319 # Maps from menu_item["display"]["en_US"] to fa-icon name
320 FA_ICON_MAP = {
321  "Sign Out": "power-off",
322  "Logout": "power-off",
323  "Transfers": "exchange",
324  "Transfer": "exchange",
325  "Account": "bank",
326  "Accounts": "bank",
327  "Commercial": "sitemap",
328  "Communications": "sliders",
329  "Disclosures": "file-text-o",
330  "Profile": "cogs",
331  "Pay Bills": "money",
332  "PayBills": "money",
333  "Mobile PayBills": "money",
334  "Mobile Pay": "money",
335  "Mobile Deposit": "anchor"
336 }
337 
338 # BRANDING CONFIG
339 
340 # main <cu> specific brand.<cu>.css file path (needs to append cu code)
341 BRANDING_TARGET_FILE = ("/home/{}/public_html/bankingIncludes/production"
342  "/css/brand.{}.css")
343 
344 # .brand.<cu>.css backup file path (needs to append cu code)
345 BRANDING_BCK_FILE = os.path.join(
346  os.path.dirname(BRANDING_TARGET_FILE), ".brand.{}.css")
347 
348 # recently imported mammoth version of brand.css file (needs to append cu code)
349 BRANDING_MMTH_FILE = os.path.join(
350  os.path.dirname(BRANDING_TARGET_FILE), "brand.css")
351 
352 # ODY brand.css template file path
353 BRANDING_TMPL_FILE = ("/home/homecu/public_html/bankingIncludes"
354  "/css/brand.css")
355 
356 BRANDING_DEFAULTS = {
357  "fontFamily":
358  "Helvetica, \"Helvetica Neue\", Arial, sans-serif",
359  "headerBackground": "#24417A",
360  "headerForeground": "#FFFFFF",
361  "headerBorder": "#2A2D33",
362  "footerBackground": "#E7E8EA",
363  "footerForeground": "#777777",
364  "menuGroupBackground": "#1B8DD6",
365  "menuGroupBackgroundLighter": "#2198E3",
366  "menuGroupForeground": "#FFFFFF",
367  "menuForeground": "#337AB7",
368  "menuForegroundHover": "#23527C",
369  "menuBackgroundHover": "#EEEEEE",
370  "menuBackground": "#F8F8F8",
371  "slideinBackground": "#808080",
372  "slideinForeground": "#FFFFFF",
373  "contentBackground": "#FFFFFF",
374  "contentForeground": "#333333",
375  "logoHeightDesktop": "75px",
376  "logoHeightMobile": "35px",
377  "logoBackground": "transparent",
378  "contentBorderWidth": "0px",
379  "contentBorderStyle": "solid",
380  "contentBorderColor": "#000000",
381  "navBadgeColor": "#777777",
382  "navIconColor": "#9D9D9D",
383  "navIconColorHover": "#FFFFFF",
384  "navBackground": "transparent",
385  "navForeground": "#FFFFFF",
386  "navActiveBorder": "#FF0000",
387  "bannerBackground": "#161620",
388  "bannerHeight": "60px"
389 }
390 
391 # memberdata cu_scheduledtxn interval mapping
392 SCHEDULE_INTERVAL_MAPPING = {
393  "OneTime": "OneTime",
394  "EveryWeek": "Weekly",
395  "Every2Weeks": "BiWeekly",
396  "Every2Months": "Every2Months",
397  "SemiMonthly": "FifteenthLast",
398  "OnceMonthly": "Monthly",
399  "Every3Months": "Quarterly",
400  "Every6Months": "SemiAnnually",
401  "Annually": "Annually"
402 }
403 
404 # cuadminprogs mapping from Mammoth to Odyssey to be used in cuadminallow
405 # and cuadminexclude
406 CUADMINPROGS_PERMISSIONS_MAPPING = {
407  "LockedRpt": "lockedRpt",
408  "cu_notify": "notificationEmails",
409  "Index": "secureForms",
410  "ContMaint": "contMaint",
411  "SetupMail": "setupMail",
412  "SendMail": "sendMail",
413  "cu_reports": "cuReports",
414  "EmailSearch": "emailSearch",
415  "SurveyMntc": "surveyMntc",
416  "AdmECO": "secureMessages",
417  "AddChange": "userSupport"
418 }
419 
420 # Member account rights
421 MEMBER_ACC_RIGHTS = ["ACCESS", "ES", "RDC", "BP"]
422 
423 # Default member account rights options
424 DEF_MEMACCT_RIGHTS_OPTIONS = ["D", "A"]
425 
426 # Referred from cu_flagconst.i -> 'CU2_SPEC18' variable
427 # Special handling for loan type 18 Credit Cards
428 CU2_SPEC18 = 4
429 
430 # User id cross reference csv file
431 USERID_CROSS_REF_CSV_FILE = "/home/{}/tmp/ody_migr_user_id_cross_reference.csv"
432 
433 # File to record a list of orphaned users identified during migration
434 MAMMOTH_ORPHANED_MEMLIST_CSV_FILE =\
435  "/home/{}/tmp/ody_migr_mammoth_orphaned_members.csv"
436 
437 # File to record a list of members who never logged in in Mammoth
438 MAMMOTH_NEVER_LOGGEDIN_MEMLIST_CSV_FILE =\
439  "/home/{}/tmp/ody_migr_mammoth_never_loggedin_members.csv"
440 
441 # File to store mammoth to odyssey cusurvemaster.surveyid mappings
442 ADMIN_CUSURVEY_ID_MAP_CSV_FILE =\
443  "/home/{}/tmp/ody_migr_admin_cusurveyid_map.csv"
444 
445 # LOANAPP related csv files
446 # File to store mapping to mammoth lnappschemamaster.loanid
447 # to odyssey lnappschemamaster.loanid
448 LOANAPP_SCHEMAMASTER_LOANID_MAP_CSV_FILE =\
449  "/home/{}/tmp/ody_migr_loanapp_loanid_map.csv"
450 
451 # File to store mapping to mammoth lnappuser.userid
452 # to odyssey lnappuser.userid
453 LOANAPP_USER_USERID_MAP_CSV_FILE =\
454  "/home/{}/tmp/ody_migr_loanapp_userid_map.csv"
455 
456 # File to log curepeattx outliers during member data migration
457 SCHEDULED_TRANSFER_OUTLIERS_CSV_FILE =\
458  "/home/{}/tmp/ody_migr_curepeattx_outliers.csv"
459 
460 # downloaded copy of member history files
461 MEMHIST_DOWNLOADED_FILE = "/home/{}/tmp/memhist"
462 MEMHIST_ACCOUNT_HISTORY_FILENAME = "memhist_accounthistory"
463 MEMHIST_LOAN_HISTORY_FILENAME = "memhist_loanhistory"
464 
465 KEY_CU_PREFIXED_TBLS = "cu_prefixed"
466 KEY_COMMON_TBLS = "common"
467 
468 # tables that are REQUIRED to exist before running any migration operation
469 ODY_MUST_EXIST_TABLES = {
470  DATA_OPT_SETTINGS: {
471  KEY_CU_PREFIXED_TBLS: [],
472  KEY_COMMON_TBLS: ["cuadmin", "cucmsfrags",
473  "cu_featuremenu", "lnappconfig"]
474  },
475  DATA_OPT_SWITCH_ACCOUNTS: {
476  KEY_CU_PREFIXED_TBLS: [
477  "{}memberacctrights",
478  "{}useraccounts"
479  ],
480  KEY_COMMON_TBLS: []
481  },
482  DATA_OPT_MEMDATA: {
483  KEY_CU_PREFIXED_TBLS: [
484  "{}user",
485  "{}group",
486  "{}usercontact",
487  "{}memberacct",
488  "{}memberacctrights",
489  "{}accountbalance",
490  "{}loanbalance",
491  "{}useraccounts",
492  "{}holds",
493  "{}audituser",
494  "{}crossaccounts",
495  "{}transdtl",
496  "{}transhdr"
497  ],
498  KEY_COMMON_TBLS: [
499  "cu_profile",
500  "cusurveysays",
501  "curepeattx",
502  "cucmsresponse",
503  "cu_alerts",
504  "culogtrack",
505  "cuadmeco",
506  "cu_scheduledtxn",
507  "cuovermicr"
508  ]
509  },
510  DATA_OPT_MEMHIST: {
511  KEY_CU_PREFIXED_TBLS: ["{}accounthistory", "{}loanhistory"],
512  KEY_COMMON_TBLS: []
513  },
514  DATA_OPT_ADMIN: {
515  KEY_CU_PREFIXED_TBLS: ["{}extkey"],
516  KEY_COMMON_TBLS: [
517  "cuauditadmin",
518  "cuadminallow",
519  "cuadminexclude",
520  "cucontact",
521  "cuadminusers",
522  "cusurveyquest",
523  "cusurveydetail",
524  "cusurveymaster",
525  "cualertmsgs",
526  "cuadmnotify",
527  "cusurveyintro",
528  "cuhavetrans",
529  "cutrusteddetail",
530  "cualtroute"
531  ]
532  },
533  DATA_OPT_LOANAPP: {
534  KEY_CU_PREFIXED_TBLS: [],
535  KEY_COMMON_TBLS: [
536  "lnappschemamaster",
537  "lnappschemadetail",
538  "lnappuser",
539  "lnappuser_questselect",
540  "lnappuserresponse"
541  ]
542  }
543 }
544 
545 # Used for drop down lists in admin. auditaction => auditfulldesc
546 AUDITUSER_DESCMAP = {
547  "ADD": "Add New Account",
548  "DEL_A": "Delete Account",
549  "DEL_H": "Delete History",
550  "RESET": "Forgot Password",
551  "UPD_F": "Update Account"
552 }