Table of Contents |
---|
Scripted Steps
Info |
---|
Copy & paste into Background Scripts in each instance. |
Code Block |
This is now a scheduled job in System Definition > Scheduled Jobs. Move this into VCS when you get a chance |
In github now https://git.yale.edu/df336/ServiceNow
Code Block |
---|
// // bw - 20120416 - adapted from http://wiki.service-now.com/index.php?title=Post-Cloning_Checklist // // canonicalkeep instance names... change if any instancepseudo-globals in object namespace to avoid name changescollisions var devcommon = "yaledevelopment"{}; var dev tst = "yaletest"{}; var trntst = "yaletraining"{}; var trn pre = "yalepreproduction"{}; var prdpre = "yale"; // //get this instance's name var thisInstance = gs.getProperty("instance_name")= {}; var prd = {}; // // alluse non-prodto ishash brokendatasource outnames in+ case the need arises to break formation // with the defaultConfig(). switch (thisInstance) { case prd: // 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: var thisShortName = "dev"; var thisIST = "ist3";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 var thisDWH = "dwh7yaledevelopment"; dev.shortName var thisAdmins = ["ww26-admin","ekt6-admin","bm364-admin","gilbert-admin","drm43-admin"]; defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins); break; case tst:dev"; dev.name var thisShortName = "tst";IT Service Management Suite (DEVELOPMENT)"; dev.color var thisIST = "ist2"; = "rgb(255, 0, 0)"; dev.admins var thisDWH = "dwh4"; var thisAdmins = ["ww26"ekt6-admin","allen.doering","ss2326-admin","vb248mp576-admin"]; defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins); break; case trn:,"al28-admin","ml34-admin","hp269-admin","james.woodford","michael.hale","df336-admin"]; dev.actors var thisShortName = "trn";[]; dev.SMTPUser var thisIST = "ist1servicenow-dev@yale.edu"; dev.POP3User var thisDWH = "dwh1servicenow-dev@yale.edu"; dev.SMTPActive var thisAdmins = ["ww26-admin","mo4-admin","kb32-admin"]; defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins); break; case pre: true; dev.testRcpt var thisShortName = "predh4234@gmail.com"; dev.dataSources["IST-User"] var thisIST = "ist1"; var thisDWH = "dwh1"; var thisAdmins = ["ww26-admin"]; defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins); break; default: gs.print("**** I don't understand what this instance is for: " + thisInstance); } // // default way to configure a non-prod instance function defaultConfig(instance, shortName, IST, DWH) { //set the base color (did we decide yet??) // gs.setProperty("css.base.color","mediumseagreen"); //set header name (did we decide yet??) // gs.setProperty("glide.product.description","DEV Instance");= "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 setSAMLProperties(instance); = "IT Service Management Suite setSMTPProperties(shortNameTEST)"; tst.color setPOP3Properties(shortName); = "rgb(255, 165, //0)"; tst.admins // align instance-specific data sources setDataSourceURL("IST-User","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + IST + ",cn=oracleContext,dc=world");= ["ekt6-admin","ss2326-admin","allen.doering","james.woodford","michael.hale","hp269-admin","ml34-admin","al28-admin","df336-admin"]; tst.actors = setDataSourceURL(["DW mp576- Manageractor","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + DWH + ",cn=oracleContext,dc=world");rico-actor"]; tst.SMTPUser = setDataSourceURL("DWH-DIVDEPTORG","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + DWH + ",cn=oracleContext,dc=world");servicenow-tst@yale.edu"; tst.POP3User // let the admin know we're all done gs.print("Applied Instance-Specific Configurations"); = "servicenow-tst@yale.edu"; tst.SMTPActive } // end defaultConfig() function setSAMLProperties(instance) { = // true; tst.testRcpt // set SAML properties so SSO logins are redirected to the right instance gs.setProperty("glide.authenticate.sso.saml2.issuer","https://" + instance + ".service-now.com");= "its50test@gmail.com"; tst.dataSources["IST-User"] = gs.setProperty("glide.authenticate.sso.saml2.service_url","https://" + instance + ".service-now.com/navpage.do"); } // end setSAMLProperties() function setSMTPProperties(shortName) {"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 // = // set SMTP properties for a given instance... assume password the same across instances."yaletraining"; trn.shortName gs.setProperty("glide.email.user","servicenow-" + shortName + "@yale.edu");= "trn"; trn.name gs.setProperty("glide.email.server","smtp.gmail.com"); gs.setProperty("glide.smtp.port",587); = "IT Service Management Suite gs.setProperty(TRAINING)"glide.smtp.tls",true);; trn.color gs.setProperty("glide.smtp.auth",true); = gs.setProperty("glide.smtp.active",true); // for now, maybe we'll only do this for test later on"rgb(0, 127, 0)"; trn.admins gs.setProperty("glide.email.test.user","its50test@mailman.yale.edu"); // } // end setSMTPProperties() function setPOP3Properties(shortName) {= ["kb32-admin","ekt6-admin","dmo6-admin","mk2-admin","ss2326-admin","df336-admin"]; trn.actors // // set POP3 properties for a given instance... assume password the same across instances.= ["ml34-actor","al28-actor","mp576-actor","rico-actor"]; trn.SMTPUser = gs.setProperty("glide.pop3.server","pop.gmail.com");"servicenow-trn@yale.edu"; trn.POP3User gs.setProperty("glide.pop3.secure",true); gs.setProperty("glide.pop3.user","servicenow-" + shortName += "@yaleservicenow-trn@yale.edu"); trn.SMTPActive // } // end setPOP3Properties() function setDataSourceURL(name, url) { = // false; trn.testRcpt // align data source(s) with this name to specified url var gr = new GlideRecord("sys_data_source"); "its50test@mailman.yale.edu"; trn.dataSources["IST-User"] gr.addQuery("name","=",name); gr.query(); while(gr.next()) { gr.connection_url = url; gr.update();= "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 } // } // end setDataSourceURL() |
Manual Steps
...
= "pre";
pre.name = "IT Service Management Suite (PRE-PRODUCTION)";
pre.color = "rgb(15, 77, 146)";
pre.admins = ["hp269-admin","s_metricus","michael.hale","ss2326-admin","df336-admin"];
pre.actors = ["ml34-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 = ["ekt6-admin","ss2326-admin","df336-admin"];
prd.actors = [];
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);
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 enableActorUsers(actors) {
//
// 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);
}
}
} |
Manual Steps
- add MID server accounts, re-register MID servers (to script) (all accounts on prod, persist through clone)
- delete non-relevant (i.e. production) MID servers (to script) (all MIDs & MID service accounts on prod, persist through clone by design)
- ensure SMTP & POP passwords are correct (these should survive a clone anyway) (these are set to be the same, so this is now an assumption of the script)
- reset any user passwords for *-admin accounts (on demand... this encourages semi-regular password resets, and silent death of unused admin accounts).
- any data sources using MID must be pointed to active/instance-specific MID server (this can be scripted, just not done yet)
- During the interval where START Replacement catalog items must be hidden in PROD, we want to show them in TRAIN and PREPROD; even with the post-clone, you need to manually add the category Phones and Cable TV
- Enable mail sending to DEV / TEST account
https://wiki.servicenow.com/index.php?title=Post-Cloning_Checklist#ServiceNow_Mail_Servers