Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 83 Next »

Scripted Steps

This is now a scheduled job. Move this into VCS when you get a chance (smile)

//
// 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                        = ["db692-admin","ekt6-admin","allen.doering","ss2326-admin","mp576-admin","al28-admin","ml34-admin","hp269-admin","james.woodford","michael.hale","df336-admin"];
dev.actors                        = [];
dev.SMTPUser                      = "servicenow-dev@yale.edu";
dev.POP3User                      = "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                        = ["db692-admin","ekt6-admin","ss2326-admin","allen.doering","james.woodford","michael.hale","hp269-admin","ml34-admin","al28-admin","df336-admin"];
tst.actors                        = ["mp576-actor","rico-actor"];
tst.SMTPUser                      = "servicenow-tst@yale.edu";
tst.POP3User                      = "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                        = ["db692-admin","kb32-admin","ekt6-admin","dmo6-admin","mk2-admin","ss2326-admin","df336-admin"];
trn.actors                        = ["ml34-actor","al28-actor","mp576-actor","rico-actor"];
trn.SMTPUser                      = "servicenow-trn@yale.edu";
trn.POP3User                      = "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                        = ["db692-admin","hp269-admin","s_mirror42,","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                        = ["db692-admin","ekt6-admin","ss2326-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 
  • No labels