Initial commit for OpenECOMP SDN-C OA&M

Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680
Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com>

Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
diff --git a/admportal/server/router/routes/root.js b/admportal/server/router/routes/root.js
new file mode 100644
index 0000000..f586892
--- /dev/null
+++ b/admportal/server/router/routes/root.js
@@ -0,0 +1,111 @@
+var express = require('express');
+var router = express.Router();
+var csp = require('./csp.js');
+var dbRoutes = require('./dbRoutes.js');
+var sla = require('./sla');
+var os = require('os');
+var async = require('async');
+var Odl = require('./Odl');
+var properties = require(process.env.SDNC_CONFIG_DIR + '/admportal.json');
+
+
+
+router.use('/healthcheck', function(req,res){
+	res.render('pages/healthcheck');
+});
+router.get('/test', function(req,res){
+
+//console.log('port='+ req.socket.localPort);
+//console.log('port='+ req.protocol);
+
+	// pass host, username and password to ODL
+	var username = properties.odlUser;
+	var password = properties.odlPasswd;
+	var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
+
+	// target host for ODL request
+	var host = properties.odlHost;
+	var header = {'Host': host, 'Authorization': auth, 'Content-Type': 'application/yang.data+json'};
+	var c_header = {'Host': properties.odlConexusHost, 'Authorization': auth, 'Content-Type': 'application/yang.data+json'};
+
+// path = '/restconf/config/SLI-API:healthcheck',
+	var _options = {
+		method			  : 'POST',
+        host              : host,
+        headers           : header,
+        port              : '8443',
+		path			  : '/restconf/operations/SLI-API:healthcheck',
+        rejectUnauthorized: false,
+        strictSSL         : false
+	};
+	var c_options = {
+		method			  : 'POST',
+        host              : properties.odlConexusHost,
+        headers           : c_header,
+        port              : '8543',
+		path			  : '/restconf/operations/SLI-API:healthcheck',
+        rejectUnauthorized: false,
+        strictSSL         : false
+	};
+
+
+    var tasks = [];
+    //tasks.push( function(callback) { dbRoutes.testdb(req,res,callback); } );
+
+	tasks.push ( createFunctionObj(_options) );
+
+	tasks.push ( createFunctionObj(c_options) );
+
+    async.series(tasks, function(err,result){
+    	if(err) {
+			res.status(400).send(err);
+			return;
+    	}
+		res.status(200).send(result);
+		return;
+	});
+});
+
+function createFunctionObj( loptions ) {
+	return function(callback) { Odl.Healthcheck(loptions,callback); };
+}
+
+router.get('/mytree', function(req,res) {
+	res.render('pages/tree');
+});
+router.get('/setuplogin', function(req,res) {
+	res.render('pages/setuplogin');
+});
+router.post('/formSetupLogin', dbRoutes.checkDB, function(req,res) {
+	dbRoutes.saveSetupLogin(req,res);
+});
+router.post('/formSignUp', dbRoutes.checkDB, function(req,res) {
+	dbRoutes.saveUser(req,res);
+});
+router.post('/formlogin', csp.login, dbRoutes.checkDB, function(req,res) {
+});
+router.get('/login', function(req,res) {
+	res.render('pages/login');
+	// handle get
+});
+router.get('/signup', function(req,res) {
+	res.render('pages/signup');
+	// handle get
+});
+router.get('/info', function(req,res) {
+	// handle get
+	res.send("login info");
+});
+router.get('/logout', csp.logout, function(req,res) {
+    // handle get
+});
+router.get('/csplogout', function(req,res) {
+    // handle get
+	res.render("pages/csplogout", {result:{code:'success', msg:'You have been successfylly logged out.'},header:process.env.MAIN_MENU});
+});
+router.get('/getuser', function(req,res) {
+    // handle get
+    res.render("pages/home");
+});
+
+module.exports = router;