...
Code Block |
---|
// // bw - 20120416 - adapted from http://wiki.service-now.com/index.php?title=Post-Cloning_Checklist // // keep pseudo-globals in object namespace to avoid name collisions var common = {}; var dev = {}; var tst = {}; var trn = {}; var pre = {}; var prd = {}; // // use to hash datasource names + urls dev.dataSources = new Array(); tst.dataSources = new Array(); trn.dataSources = new Array(); pre.dataSources = new Array(); prd.dataSources = new Array(); // // other canon (common to all but desirable here anyway) common.SMTPServer = "smtp.gmail.com"; common.SMTPPort = 587; common.SMTPTLS = true; common.SMTPAuth = true; common.POP3Server = "pop.gmail.com"; common.POP3Secure = true; // // get this instance's name common.instance = gs.getProperty("instance_name"); // // here's where you should set all instance-specific values dev.longName = "yaledevelopment"; dev.shortName = "dev"; dev.adminsname = ["ww26-admin","ekt6-admin","bm364-admin","gilbert-admin","drm43-admin"]; dev.SMTPUser"IT Service Management Suite (DEVELOPMENT)" dev.color = "servicenow-dev@yale.edurgb(255, 0, 0)"; dev.POP3Useradmins = "servicenow-dev@yale.edu"["ww26-admin","ekt6-admin","bm364-admin","gilbert-admin","drm43-admin"]; dev.SMTPActiveSMTPUser = true"servicenow-dev@yale.edu"; dev.testRcptPOP3User = "dh4234@gmailservicenow-dev@yale.comedu"; dev.dataSources["IST-User"]SMTPActive = "jdbc: = true; dev.testRcpt = "dh4234@gmail.com"; dev.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist3,cn=oracleContext,dc=world"; dev.dataSources["DW - Manager"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh7,cn=oracleContext,dc=world"; dev.dataSources["DWH-DIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh7,cn=oracleContext,dc=world"; tst.longName = "yaletest"; tst.shortName = "tst"; tst.adminsname = ["ww26-admin","vb248-admin"]; tst.SMTPUser"IT Service Management Suite (TEST)" tst.color = "servicenow-tst@yale.edurgb(255, 165, 0)"; tst.POP3Useradmins = "servicenow-tst@yale.edu"["ww26-admin","vb248-admin"]; tst.SMTPActiveSMTPUser = true"servicenow-tst@yale.edu"; tst.testRcptPOP3User = "its50test@mailmanservicenow-tst@yale.yale.edu"; tst.dataSources["IST-User"]SMTPActive = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist2,cn=oracleContext,dc=world"; tst.dataSources["DW - Manager"] = " = true; tst.testRcpt = "its50test@mailman.yale.edu"; tst.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh4ist2,cn=oracleContext,dc=world"; tst.dataSources["DWH-DW - Manager"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh4,cn=oracleContext,dc=world"; tst.dataSources["DWH-DIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh4,cn=oracleContext,dc=world"; trn.longName = "yaletraining"; trn.shortName = "trn"; trn.adminsname = ["ww26-admin","mo4-admin","kb32-admin","ekt6-admin"]; trn.SMTPUser"IT Service Management Suite (TRAINING)" tst.color = "servicenow-trn@yale.edurgb(102, 153, 204)"; trn.POP3Useradmins = "servicenow-trn@yale.edu"; trn.SMTPActive ["ww26-admin","mo4-admin","kb32-admin","ekt6-admin"]; trn.SMTPUser = false"servicenow-trn@yale.edu"; trn.testRcptPOP3User = "its50test@mailmanservicenow-trn@yale.yale.edu"; trn.dataSources["IST-User"]SMTPActive = "jdbc:oracle:false; trn.testRcpt = "its50test@mailman.yale.edu"; trn.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist1,cn=oracleContext,dc=world"; trn.dataSources["DW - Manager"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; trn.dataSources["DWH-DIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; pre.longName = "yalepreproduction"; pre.shortName = "yalepreproduction"; pre.shortNamepre"; pre.name = "IT Service Management Suite (PRE-PRODUCTION)" pre.color = "prergb(102, 153, 204)"; pre.admins = ["ww26-admin"]; pre.SMTPUser = "servicenow-pre@yale.edu"; pre.POP3User = "servicenow-pre@yale.edu"; pre.SMTPActive = true; pre.testRcpt = "its50test@mailman.yale.edu"; pre.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist1,cn=oracleContext,dc=world"; pre.dataSources["DW - Manager"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist1dwh1,cn=oracleContext,dc=world"; pre.dataSources["DW DWH- ManagerDIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; pre.dataSources["DWH-DIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; prd.longName prd.longName = "yale"; prd.shortName = "prd"; pre.name = "yale";IT Service Management Suite" prd.shortNamecolor = "prdrgb(102, 153, 204)"; prd.admins = ["ww26-admin"]; prd.SMTPUser = "servicenow@yale.edu"; prd.POP3User = "servicenow@yale.edu"; prd.SMTPActive = true; prd.testRcpt = ""; prd.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist1,cn=oracleContext,dc=world"; prd.dataSources["DW - Manager"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; prd.dataSources["DWH-DIVDEPTORG"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/dwh1,cn=oracleContext,dc=world"; // // all non-prod is broken out in case the need arises to break formation // with the defaultConfig(). switch (common.instance) { case prd.longName: // shouldn't be cloning prod post-go-live! gs.print("**** You're running this script in production, are you asking for trouble?"); break; case dev.longName: defaultConfig(dev); break; case tst.longName: defaultConfig(tst); break; case trn.longName: defaultConfig(trn); break; case pre.longName: defaultConfig(pre); break; default: // bail if this is an unknown instance gs.print("**** I don't understand what this instance is for: " + common.instance); // } // end switch statement function defaultConfig(specific) { // // default way to configure a non-prod environment // setEnvironmentMarkers(specific.color,specific.name); setSAMLProperties(specific.longName); setDataSourceURLs(specific.dataSources); enableAdminUsers(specific.admins); setPOP3Properties(specific.POP3User, common.POP3Server, common.POP3Secure); setSMTPProperties(specific.SMTPUser , common.SMTPServer , common.SMTPPort , common.SMTPTLS , common.SMTPAuth , specific.SMTPActive, specific.testRcpt); gs.print("Applied Instance-Specific Configurations"); } // end defaultConfig() function setSAMLProperties(instance) { // // set SAML properties so SSO logins are redirected to the right instance gs.setProperty("glide.authenticate.sso.saml2.issuer","https://" + instance + ".service-now.com"); gs.setProperty("glide.authenticate.sso.saml2.service_url","https://" + instance + ".service-now.com/navpage.do"); } // end setSAMLProperties() function setSMTPProperties(user, server, port, tls, auth, active, testRcpt) { // // set SMTP properties for a given instance... assume password the same across instances. gs.setProperty("glide.email.user",user); gs.setProperty("glide.email.server",server); gs.setProperty("glide.smtp.port",port); gs.setProperty("glide.smtp.tls",tls); gs.setProperty("glide.smtp.auth",auth); gs.setProperty("glide.smtp.active",active); gs.setProperty("glide.email.test.user",testRcpt); // } // end setSMTPProperties() function setPOP3Properties(user, server, secure) { // // set POP3 properties for a given instance... assume password the same across instances. gs.setProperty("glide.pop3.server",server); gs.setProperty("glide.pop3.secure",true); gs.setProperty("glide.pop3.user",user); // } // end setPOP3Properties() function setDataSourceURLs(dataSources) { // // align data source(s) with this name to specified url for (var name in dataSources) { var gr = new GlideRecord("sys_data_source"); gr.addQuery("name","=",name); gr.query(); while(gr.next()) { gr.connection_url = dataSources[name]; gr.update(); } } // } // end setDataSourceURLs() function enableAdminUsers(admins) { // // for each user matching user_name in admins, remove lockout and activate user for (var i = 0; i < admins.length; i++) { var gr = new GlideRecord("sys_user"); gr.addQuery("user_name","=",admins[i]); gr.query(); while(gr.next()) { gr.active = true; gr.locked_out = false; gr.update(); } } } function setEnvironmentMarkers(color,name) { // set the base color gs.setProperty("css.base.color",color); // set header name gs.setProperty("glide.product.description",name); // } // end setEnvironmentMarkers() |
...