index.js 4.85 KB
#!/usr/bin/env node
var colors = require('colors');
var url = require("openurl");
var TASKS = [
	{name:"srv",summary:"lista dei server divisi per ambiente",state:"ok".green},
	{name:"git",summary:"operazioni legate a git",state:"void".red},
	{name:"arch",summary:"creazione archetipi",state:"void".red},
	{name:"lr",summary:"tools per sviluppo liferay",state:"void".red},
	{name:"osb",summary:"tools per sviluppo OSB",state:"void".red},
	{name:"jb",summary:"tools per sviluppo JBUS",state:"void".red},
	{name:"tst",summary:"tools di test",state:"void".red},
	{name:"mnt",summary:"tools di monitoraggio",state:"void".red}
	];

var tool={
	task:function(TASKS){
		if(TASKS==null) return;
		for (var i = 0; i < TASKS.length; i++) {
		    var task = TASKS[i];
		    if (task.summary) {
		      var name = '   ' + task.name + '  ';
		      var dots = '';
		      while ((name + dots).length < 20) {
		        dots += '.';
		      }
		      process.stderr.write(name.green.bold + dots.grey + '  ' + task.summary.bold + (task.state?'('+task.state+')':'')+'\n');
		    }
		  }
	},
	logo:function(){
		console.log("  ____   ____ ___  _____ __  ______");
		console.log(" /    \\_/ __ \\\\  \\/  /  |  \\/  ___/");
		console.log("|   |  \\  ___/ >    <|  |  /\___ \\ "); 
		console.log("|___|  /\\___  >__/\\_ \\____//____  >");
		console.log("     \\/     \\/      \\/          \\/ ");
		console.log("version: 0.1".red);
		console.log("=========================================".green);
		console.log("");
	}

}
       
var option = process.argv[2];
if(option==null){
	tool.logo();
	tool.task(TASKS);
}

var server={sviluppo:[	
	{name:"jsbus",summary:"lxjrv720",url:"http://lxjra701.gbm.lan:7001/console",usr:"nmol",psw:"Weblogic1"},
	{name:"osbfe",summary:"lxosb701",url:"http://lxosb701.gbm.lan:7002/sbconsole",usr:"nxs01",psw:"Ntrfgb47"},	
	{name:"nac",summary:"nac",url:"http://www-svil.bmednet.it/lr/",usr:"1813",psw:"Mediolanum<giorno>"},		

	{name:"qush",summary:"qush ssh",url:"http://lxpsh701.gbm.lan",usr:"oracle",psw:"oracle"},
	{name:"qushtom",summary:"ambiente tomcat di push",url:"http://lxpsh701.gbm.lan:8001/manager/html",usr:"admin",psw:"admin"},

	{name:"rdv",summary:"liferay rete di vendita",url:"http://www-svil.bmednet.it",usr:"1813",psw:"Mediolanum<giorno>"},
	{name:"lrrdv",summary:"liferay rete di vendita",url:"http://lxlfp720.gbm.lan:7001/lr",usr:"test",psw:"Mediolanum1"},
	{name:"mom",summary:"liferay rete di vendita",url:"http://svil.portaleoperativo.mediolanume.it",usr:"test",psw:"Lrmom101"},
	{name:"lrmom",summary:"liferay mom",url:"http://lxlfp720.gbm.lan:7001/lr",usr:"test",psw:"Mediolanum1"},
	{name:"nmol",summary:"lnmol",url:"http://www-svil.bmedonline.it",usr:"6674065",psw:"12345"},
	{name:"lrnmol",summary:"liferay mom",url:"http://lxlfp701.gbm.lan:7001/lr",usr:"test",psw:"liferay1"}

		
],
prd:[
	{name:"qush1",summary:"qush 1 ssh",url:"http://lxpsh001.gbm.lan",usr:"oracle",psw:"oracle"},
	{name:"qush2",summary:"qush 2 ssh",url:"http://lxpsh002.gbm.lan",usr:"oracle",psw:"oracle"}
],
test:[
	{name:"splnmol",summary:"splunk nmol",url:"http://splunksearch.gbm.lan/",usr:"nmol_test",psw:"test_nmol"},
	{name:"splnac",summary:"splunk nac",url:"http://splunksearch.gbm.lan/",usr:"nac_test",psw:"test_nac"},

	{name:"qush1",summary:"qush 1 ssh",url:"http://lxpsh801.gbm.lan",usr:"oracle",psw:"oracle"},
	{name:"qush2",summary:"qush 2 ssh",url:"http://lxpsh802.gbm.lan",usr:"oracle",psw:"oracle"}
],
otr:[
	{name:"nxsgit",summary:"git di nexus",url:"https://git.nexusat.it",usr:"massimiliano.regis",psw:"Nexus2015!"},
	{name:"distinte",summary:"distinte",url:"http://arch.gbm.lan:8080/distinta",usr:"massimiliano.regis",psw:"Bmed2017"},	
	{name:"jira",summary:"lxjrv720",url:"http://lxjrv720.gbm.lan:7001/console"},	
	{name:"redmine",summary:"redmine",url:"redmine.gbm.lan:8080"},	
	{name:"jenkins",summary:"lxosb701",url:"http://lxosb701.gbm.lan:7001/sbconsole"},
	{name:"QC",summary:"lxjrv720",url:"http://lxjrv720.gbm.lan:7001/console"},
	{name:"pip",summary:"lxjrv720",url:"http://lxjrv720.gbm.lan:7001/console"}	
]
};

//nexus srv svl osb 
if(option=='srv'){
	var env = process.argv[3];
	var name = process.argv[4];
	
	if(env!=null && name!=null){
		console.log("finding server "+name.red+" on "+env.red);
		var srv;
		if(env==="svl") srv = server.sviluppo;
		if(env==="gen") srv = server.otr;

		for(i in srv)
			if(srv[i].name===name){
				console.log(srv[i].usr.red+"/"+srv[i].psw.red);
				url.open(srv[i].url);
			}
		
	}
	if(name==null){
		tool.logo();
		console.log("\n--------------------"+"GENERALE".red+"(gen)----------------------------");
		tool.task(server.otr);
		console.log("\n--------------------"+"SVILUPPO".red+"(svl)------------------------");
		tool.task(server.sviluppo);
		console.log("\n--------------------"+"TEST".red+"(tst)----------------------------");
		tool.task(server.test);
		console.log("\n--------------------"+"PRODUZIONE".red+"(prd)----------------------------");
		tool.task(server.prd);
	}
}