//
// 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.name = "IT Service Management Suite (DEVELOPMENT)";
dev.color = "rgb(255, 0, 0)";
dev.admins = ["ww26ekt6-admin","allen.doering","db692ss2326-admin","ekt6mp576-admin","bm364al28-admin","gilbertml34-admin","drm43hp269-admin","james.woodford", "kp385"michael.hale","df336-admin"];
dev.SMTPUseractors = "servicenow-dev@yale.edu"[];
dev.POP3UserSMTPUser = "servicenow-dev@yale.edu";
dev.SMTPActivePOP3User = true"servicenow-dev@yale.edu";
dev.SMTPActive = 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.name = "IT Service Management Suite (TEST)";
tst.color = "rgb(255, 165, 0)";
tst.admins = ["ww26"ekt6-admin","ss2326-admin","allen.doering","james.woodford","michael.hale","hp269-admin","db692ml34-admin","ha239al28-admin","ekt6df336-admin"];
tst.SMTPUseractors = "servicenow-tst@yale.edu"["mp576-actor","rico-actor"];
tst.POP3UserSMTPUser = "servicenow-tst@yale.edu";
tst.SMTPActivePOP3User = "servicenow-tst@yale.edu";
tst.SMTPActive = true;
tst.testRcpt = "its50test@gmail.com";
tst.dataSources["IST-User"] = "jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/ist2,cn=oracleContext,dc=world";
tst.dataSources["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.name = "IT Service Management Suite (TRAINING)";
trn.color = "rgb(0, 127, 0)";
trn.admins = ["ww26kb32-admin","db692ekt6-admin","kb32dmo6-admin","ekt6mk2-admin","dmo6ss2326-admin","mk2df336-admin"];
trn.SMTPUseractors = "servicenow-trn@yale.edu"["ml34-actor","al28-actor","mp576-actor","rico-actor"];
trn.POP3UserSMTPUser = "servicenow-trn@yale.edu";
trn.SMTPActivePOP3User = false; trn.testRcpt = "servicenow-trn@yale.edu";
trn.SMTPActive = 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 = "pre";
pre.name = "IT Service Management Suite (PRE-PRODUCTION)";
pre.color = "rgb(15, 77, 146)";
pre.admins = ["ww26hp269-admin","db692-admins_metricus","ha239-adminmichael.hale","s_mirror42,ss2326-admin","s_metricusdf336-admin"];
pre.SMTPUseractors = ["servicenow-pre@yale.edu";
pre.POP3Userml34-actor","al28-actor","mp576-actor","rico-actor"];
pre.SMTPUser = "servicenow-pre@yale.edu";
pre.POP3User = "servicenow-pre@yale.edu";
pre.SMTPActive = true;
pre.testRcpt = "its50test@gmail.com";
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/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 = "yale";
prd.shortName = "prd";
prd.name = "IT Service Management Suite";
prd.color = "rgb(15, 77, 146)";
prd.admins = ["ww26ekt6-admin","ss2326-admin","db692df336-admin"];
prd.SMTPUseractors = "servicenow@yale.edu"[];
prd.POP3UserSMTPUser = "servicenow@yale.edu";
prd.SMTPActivePOP3User = true"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;
defaultConfig(tst);
break;
case trn.longName:
defaultConfig(trn);
break;
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);
enableActorUsers(specific.actors);
setPOP3Properties(specific.POP3User,
common.POP3Server,
common.POP3Secure);
setSMTPProperties(specific.SMTPUser ,
common.SMTPServer ,
common.SMTPPort ,
common.SMTPTLS ,
common.SMTPAuth ,
specific.SMTPActive,
specific.testRcpt ,
"https://" + specific.longName + ".service-now.com/nav_to.do");
setCloningProperties(specific.longName);
setSomeCatalogActive ( specific.shortName );
setOrgTestValues (
specific.shortName );
gs.print("Applied Instance-Specific Configurations");
} // end defaultConfig()
function setCloningProperties(instance) {
//
// typically for non-prod instances, allow instance to be a clone targer
gs.setProperty("glide.db.clone.allow_clone_target","true");
} // end setCloningProperties()
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, overrideURL) {
//
// 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);
gs.setProperty("glide.email.override.url",overrideURL);
//
} // 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 setEnvironmentMarkersenableActorUsers(color,nameactors) {
// set the base color
gs.setProperty("css.base.color",color);
// set header name
gs.setProperty("glide.product.description",name);
//
} // end setEnvironmentMarkers()
//
// for each user matching user_name in actors, remove lockout and activate user
for (var i = 0; i < actors.length; i++) {
var gr = new GlideRecord("sys_user");
gr.addQuery("user_name","=",actors[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()
function setSomeCatalogActive ( shortName ){
if ( shortName == 'trn' ||
shortName == 'pre' ) {
// dce9f6109df47c0094adfdb88ae63850 is Phones and Cable TV
// 477f1d98a1bbc5c094ad46651315d89e is Pagers
// 67af5d98a1bbc5c094ad46651315d822 is Telephone Services
// d12fd958a1bbc5c094ad46651315d842 is Mobile Devices
// d4e9f6109df47c0094adfdb88ae63856 is Wifi and Networks; now defaulting to active.
// set categories active
var gr1 = new GlideRecord('sc_category');
var gr1OR = gr1.addQuery('sys_id','dce9f6109df47c0094adfdb88ae63850');
gr1OR.addOrCondition('sys_id','477f1d98a1bbc5c094ad46651315d89e');
gr1OR.addOrCondition('sys_id','67af5d98a1bbc5c094ad46651315d822');
gr1OR.addOrCondition('sys_id','d12fd958a1bbc5c094ad46651315d842');
gr1OR.addOrCondition('sys_id','d4e9f6109df47c0094adfdb88ae63856');
gr1.query();
while ( gr1.next() ) {
// gs.print('in loop, gr1.sys_id: ' + gr1.sys_id);
gr1.active = 'true';
gr1.update();
}
// ethernet add is 986e0ccc8795410094ad56926d434d0d
var gr2 = new GlideRecord('sc_cat_item');
gr2.addQuery('sys_id','986e0ccc8795410094ad56926d434d0d');
gr2.query();
while ( gr2.next() ) {
// gs.print('in loop, gr2.sys_id: ' + gr2.sys_id);
gr2.active = 'true';
gr2.update();
}
}
}
function setOrgTestValues ( shortName ){
if ( shortName == 'tst' ||
shortName == 'pre' ) {
// In PRE-PROD and TEST, maybe in TRAINING,
// we need to turn off the loader for ORG data,
// then over ride the data in select ORGS with certain
// cases to then walk through our large set of test cases.
// DWH - Organization -> 2f32f71ea1fa858094ad46651315d80d
var gr1 = new GlideRecord('scheduled_import_set');
gr1.addQuery('sys_id','2f32f71ea1fa858094ad46651315d80d');
gr1.query();
if ( gr1.next() ) {
//gs.print('the value of the import was: ' + gr1.active);
gr1.active = 'false';
gr1.update();
//gs.print('the value of the import is now: ' + gr1.active);
}
// force values on ORGs
// Nancy Scanlon -> 09bea76ad8d46c007ac0638b5167dcc6
// Julie Grant -> df3c00b201d0ac0094adf4b82250a6d5
// Holly Piscatelli -> fc6850360194ac0094adf4b82250a689
// Jack Beecher -> c72a84be0190ac0094adf4b82250a6b4
// Sue Castaldi -> a656147e0154ac0094adf4b82250a63c
// Jim Slattery -> 446a14fa0194ac0094adf4b82250a648
// Rose Rita Riccitelli -> 23bee3e6d8d46c007ac0638b5167dc59
// 000803
var org1 = new GlideRecord('u_cmn_organization');
org1.addQuery('u_id','000803');
org1.query();
if ( org1.next() ) {
//gs.print('ORG is: ' + org1.u_id);
//gs.print('Ops: ' + org1.u_opsmgr);
//gs.print('Lead: ' + org1.u_head);
//gs.print('BOLT: ' + org1.u_bolt_member);
org1.u_opsmgr = '09bea76ad8d46c007ac0638b5167dcc6';
org1.u_head = 'fc6850360194ac0094adf4b82250a689';
org1.u_bolt_member = 'df3c00b201d0ac0094adf4b82250a6d5';
org1.update();
}
// 883001
var org2 = new GlideRecord('u_cmn_organization');
org2.addQuery('u_id','883001');
org2.query();
if ( org2.next() ) {
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
org2.u_opsmgr = '';
org2.u_head = 'a656147e0154ac0094adf4b82250a63c';
org2.u_bolt_member = 'c72a84be0190ac0094adf4b82250a6b4';
org2.update();
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
}
// 869001
var org1 = new GlideRecord('u_cmn_organization');
org1.addQuery('u_id','869001');
org1.query();
if ( org1.next() ) {
//gs.print('ORG is: ' + org1.u_id);
//gs.print('Ops: ' + org1.u_opsmgr);
//gs.print('Lead: ' + org1.u_head);
//gs.print('BOLT: ' + org1.u_bolt_member);
org1.u_opsmgr = '23bee3e6d8d46c007ac0638b5167dc59';
org1.u_head = '';
org1.u_bolt_member = '446a14fa0194ac0094adf4b82250a648';
org1.update();
}
// 016601
var org2 = new GlideRecord('u_cmn_organization');
org2.addQuery('u_id','016601');
org2.query();
if ( org2.next() ) {
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
org2.u_opsmgr = '';
org2.u_head = '';
org2.u_bolt_member = 'df3c00b201d0ac0094adf4b82250a6d5';
org2.update();
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
}
// 017901
var org1 = new GlideRecord('u_cmn_organization');
org1.addQuery('u_id','017901');
org1.query();
if ( org1.next() ) {
//gs.print('ORG is: ' + org1.u_id);
//gs.print('Ops: ' + org1.u_opsmgr);
//gs.print('Lead: ' + org1.u_head);
//gs.print('BOLT: ' + org1.u_bolt_member);
org1.u_opsmgr = '09bea76ad8d46c007ac0638b5167dcc6';
org1.u_head = 'fc6850360194ac0094adf4b82250a689';
org1.u_bolt_member = '';
org1.update();
}
// 018501
var org2 = new GlideRecord('u_cmn_organization');
org2.addQuery('u_id','018501');
org2.query();
if ( org2.next() ) {
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
org2.u_opsmgr = '';
org2.u_head = 'fc6850360194ac0094adf4b82250a689';
org2.u_bolt_member = '';
org2.update();
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
}
// 019501
var org1 = new GlideRecord('u_cmn_organization');
org1.addQuery('u_id','019501');
org1.query();
if ( org1.next() ) {
//gs.print('ORG is: ' + org1.u_id);
//gs.print('Ops: ' + org1.u_opsmgr);
//gs.print('Lead: ' + org1.u_head);
//gs.print('BOLT: ' + org1.u_bolt_member);
org1.u_opsmgr = '09bea76ad8d46c007ac0638b5167dcc6';
org1.u_head = '';
org1.u_bolt_member = '';
org1.update();
}
// 015701
var org2 = new GlideRecord('u_cmn_organization');
org2.addQuery('u_id','015701');
org2.query();
if ( org2.next() ) {
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
org2.u_opsmgr = '';
org2.u_head = '';
org2.u_bolt_member = '';
org2.update();
//gs.print('ORG is: ' + org2.u_id);
//gs.print('Ops: ' + org2.u_opsmgr);
//gs.print('Lead: ' + org2.u_head);
//gs.print('BOLT: ' + org2.u_bolt_member);
}
}
} |