blob: b314d7dbe76c5ff9e3a74ca1c3fd7af6bd3e0464 [file] [log] [blame]
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05001var express = require('express');
2var router = express.Router();
3var csp = require('./csp.js');
4var dbRoutes = require('./dbRoutes.js');
5var sla = require('./sla');
6var os = require('os');
7var async = require('async');
Al Rotundo2f8e4d02017-03-24 13:54:52 +00008var OdlInterface = require('./OdlInterface');
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05009var properties = require(process.env.SDNC_CONFIG_DIR + '/admportal.json');
10
11
12
13router.use('/healthcheck', function(req,res){
14 res.render('pages/healthcheck');
15});
16router.get('/test', function(req,res){
17
18//console.log('port='+ req.socket.localPort);
19//console.log('port='+ req.protocol);
20
21 // pass host, username and password to ODL
22 var username = properties.odlUser;
23 var password = properties.odlPasswd;
24 var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
25
26 // target host for ODL request
27 var host = properties.odlHost;
28 var header = {'Host': host, 'Authorization': auth, 'Content-Type': 'application/yang.data+json'};
29 var c_header = {'Host': properties.odlConexusHost, 'Authorization': auth, 'Content-Type': 'application/yang.data+json'};
30
31// path = '/restconf/config/SLI-API:healthcheck',
32 var _options = {
33 method : 'POST',
34 host : host,
35 headers : header,
36 port : '8443',
37 path : '/restconf/operations/SLI-API:healthcheck',
38 rejectUnauthorized: false,
39 strictSSL : false
40 };
41 var c_options = {
42 method : 'POST',
43 host : properties.odlConexusHost,
44 headers : c_header,
45 port : '8543',
46 path : '/restconf/operations/SLI-API:healthcheck',
47 rejectUnauthorized: false,
48 strictSSL : false
49 };
50
51
52 var tasks = [];
53 //tasks.push( function(callback) { dbRoutes.testdb(req,res,callback); } );
54
55 tasks.push ( createFunctionObj(_options) );
56
57 tasks.push ( createFunctionObj(c_options) );
58
59 async.series(tasks, function(err,result){
60 if(err) {
61 res.status(400).send(err);
62 return;
63 }
64 res.status(200).send(result);
65 return;
66 });
67});
68
69function createFunctionObj( loptions ) {
Al Rotundo2f8e4d02017-03-24 13:54:52 +000070 return function(callback) { OdlInterface.Healthcheck(loptions,callback); };
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -050071}
72
73router.get('/mytree', function(req,res) {
74 res.render('pages/tree');
75});
76router.get('/setuplogin', function(req,res) {
77 res.render('pages/setuplogin');
78});
Al Rotundo2f8e4d02017-03-24 13:54:52 +000079router.post('/formSetupLogin', function(req,res) {
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -050080 dbRoutes.saveSetupLogin(req,res);
81});
Al Rotundo2f8e4d02017-03-24 13:54:52 +000082router.post('/formSignUp', function(req,res) {
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -050083 dbRoutes.saveUser(req,res);
84});
Al Rotundo2f8e4d02017-03-24 13:54:52 +000085router.post('/formlogin', csp.login, function(req,res) {
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -050086});
87router.get('/login', function(req,res) {
88 res.render('pages/login');
89 // handle get
90});
91router.get('/signup', function(req,res) {
92 res.render('pages/signup');
93 // handle get
94});
95router.get('/info', function(req,res) {
96 // handle get
97 res.send("login info");
98});
99router.get('/logout', csp.logout, function(req,res) {
100 // handle get
101});
102router.get('/csplogout', function(req,res) {
103 // handle get
104 res.render("pages/csplogout", {result:{code:'success', msg:'You have been successfylly logged out.'},header:process.env.MAIN_MENU});
105});
106router.get('/getuser', function(req,res) {
107 // handle get
108 res.render("pages/home");
109});
110
111module.exports = router;