Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
//
// bw - 20120416 - adapted from http://wiki.service-now.com/index.php?title=Post-Cloning_Checklist

//
// canonicalkeep instance names... change if any instance name changespseudo-globals in object namespace to avoid name collisions
var common = {};
var dev    = "yaledevelopment"{};
var tst    = "yaletest"{};
var trn    = "yaletraining"{};
var pre    = "yalepreproduction"{};
var prd    = "yale"{};

//
//get this instance's name
var thisInstance = gs.getProperty("instance_name");
 
//
// all non-prod is broken out 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: 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                    var thisShortName = "devyaledevelopment";
dev.shortName                var    thisIST = "ist3dev";
dev.admins                var thisDWH = "dwh7";                 var thisAdmins = ["ww26-admin","ekt6-admin","bm364-admin","gilbert-admin","drm43-admin"];
		defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins);
		break;
	case tst:dev.SMTPUser                     var thisShortName = "tstservicenow-dev@yale.edu";
dev.POP3User                 var thisIST = "ist2";   = "servicenow-dev@yale.edu";
dev.SMTPActive                  var thisDWH = "dwh4"true;
dev.testRcpt                 var    thisAdmins = ["ww26-admin","vb248-admin"];
		defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins);
		break;
	case trn:"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.admins                        = ["ww26-admin","vb248-admin"];
tst.SMTPUser                      = "servicenow-tst@yale.edu";
tst.POP3User                      = "servicenow-tst@yale.edu";
tst.SMTPActive                    = true;
tst.testRcpt                      = "its50test@mailman.yale.edu";
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.admins                        = ["ww26-admin","mo4-admin","kb32-admin"];
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.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/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.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  ,
                        var thisShortName = "trn";
common.SMTPServer  ,
               var thisIST = "ist1";        common.SMTPPort    ,
    var thisDWH = "dwh1";                 var thisAdmins = ["ww26-admin","mo4-admin","kb32-admin"];
		defaultConfig(thisInstance,thisShortName,thisIST,thisDWH,thisAdmins);
		break;
	case pre:common.SMTPTLS     ,
                          common.SMTPAuth  var thisShortName =,
"pre";                  var thisIST = "ist1";     specific.SMTPActive,
            var thisDWH = "dwh1";           specific.testRcpt);         var thisAdmins
=
["ww26-admin"]	gs.print("Applied Instance-Specific Configurations"); 
  
} // end defaultConfig()


function 		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");
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) {
        setSAMLProperties(instance);//
        setSMTPProperties(shortName);
        setPOP3Properties(shortName);

  // set SMTP properties for a given instance... assume password the same across instances.
     //   gs.setProperty("glide.email.user",user);
     // align instance-specific data sources gs.setProperty("glide.email.server",server);
         setDataSourceURL("IST-User","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + IST + ",cn=oracleContext,dc=world");   gs.setProperty("glide.smtp.port",port);
          setDataSourceURL("DW - Manager","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + DWH + ",cn=oracleContext,dc=world");   gs.setProperty("glide.smtp.tls",tls);
          setDataSourceURL("DWH-DIVDEPTORG","jdbc:oracle:thin:@ldap://oid.its.yale.edu:389/" + DWH + ",cn=oracleContext,dc=world");     

        // let the admin know we're all done
	gs.print("Applied Instance-Specific Configurations"); 
  
gs.setProperty("glide.smtp.auth",auth);
        gs.setProperty("glide.smtp.active",active);  // for now, maybe we'll only do this for test later on
        gs.setProperty("glide.email.test.user",testRcpt);
  //
} // end defaultConfigsetSMTPProperties()


function setSAMLProperties(instancesetPOP3Properties(user, server, secure) {
        //
        // set SAMLPOP3 properties sofor SSOa logins are redirected togiven instance... assume password the rightsame instanceacross   instances.
     gs.setProperty("glide.authenticate.sso.saml2.issuer","https://" + instance + gs.setProperty("glide.service-nowpop3.comserver",server);
        gs.setProperty("glide.authenticate.sso.saml2.service_url","https://" + instance + ".service-now.com/navpage.do"pop3.secure",true);
        gs.setProperty("glide.pop3.user",user);
  //
} // end setSAMLPropertiessetPOP3Properties()


function setSMTPPropertiessetDataSourceURLs(shortNamedataSources) {
        //
        // align data source(s) with this name to specified url
        for (var name in dataSources) //{
        // set SMTP properties forvar agr given instance... assume password the same across instances.= new GlideRecord("sys_data_source");
             gsgr.setPropertyaddQuery("glide.email.username","servicenow-" + shortName + "@yale.edu");=",name);
            gsgr.setProperty("glide.email.server","smtp.gmail.com"query(); 
       gs.setProperty("glide.smtp.port",587);     while(gr.next()) {
                gs.setProperty("glide.smtp.tls",true)gr.connection_url = dataSources[name];
        gs.setProperty("glide.smtp.auth",true);         gsgr.setProperty("glide.smtp.active",trueupdate();
 // for now, maybe we'll only do this for test later on}
        gs.setProperty("glide.email.test.user","its50test@mailman.yale.edu");}
  //
} // end setSMTPPropertiessetDataSourceURLs()


function setPOP3PropertiesenableAdminUsers(shortNameadmins) {
        // 
       // set POP3 properties for a given instance... assume password the same across instances.
        gs.setProperty("glide.pop3.server","pop.gmail.com"); // for each user matching user_name in admins, remove lockout and activate user
        for (var i = 0; i < admins.length; i++) {
            var gr  gs.setProperty("glide.pop3.secure",true= new GlideRecord("sys_user");
        gs.setProperty    gr.addQuery("glide.pop3.user_name","servicenow-" + shortName + "@yale.edu");
  //
} // end setPOP3Properties()


function setDataSourceURL(name, url=",admins[i]);
            gr.query(); 
            while(gr.next()) {
        //        gr.active // align data source(s) with this name to specified url= true;
               var gr.locked_out = new GlideRecord("sys_data_source")false;
        gr.addQuery("name","=",name);
        gr.queryupdate();
         while(gr.next()) {     }
       gr.connection_url = url;
 }
}


function setEnvironmentMarkers(color,name) {
	// set the base color 
gr	gs.update(setProperty("css.base.color",color);
 
	// set header name 
 }	gs.setProperty("glide.product.description",name);
   //
} // end setDataSourceURLsetEnvironmentMarkers()


Manual Steps

  • add MID server accounts, re-register MID servers (to script)
  • delete non-relevant (i.e. production) MID servers (to script)
  • ensure SMTP & POP passwords are correct (these should survive a clone anyway)
  • reset any user passwords for *-admin accounts (on demand... this encourages semi-regular password resets).