mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 13:15:14 +09:00
* fix ONE_LOCATION for VMRC * eslint alias for VS Signed-off-by: Jorge Lobo <jlobo@opennebula.io>
This commit is contained in:
1 parent
6c634228c3
commit
7c5b72836f
7 files changed
+68
-29
No files matched your search
@@ -19,5 +19,16 @@
|
||||
}
|
||||
],
|
||||
"default-case": 0
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"alias": {
|
||||
"map": [
|
||||
["client", "./src/client"],
|
||||
["server", "./src/server"]
|
||||
],
|
||||
"extensions": [".js"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ LIMIT_TOKEN:
|
||||
# VMRC
|
||||
VMRC:
|
||||
TARGET: 'http://opennebula.io'
|
||||
TOKENS_PATH: '/var/lib/one/sunstone_vnc_tokens/vmrc'
|
||||
|
||||
# Guacamole: use it if you have the Guacd in other server or port
|
||||
# GUACD:
|
||||
|
||||
@@ -27,9 +27,11 @@
|
||||
"devDependencies": {
|
||||
"cypress": "^5.3.0",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-import-resolver-webpack": "^0.13.0",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"eslint-plugin-cypress": "^2.11.2",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-react": "^7.21.2",
|
||||
"fireedge-genpotfile": "^1.0.0",
|
||||
"fireedge-pojson": "^1.0.2",
|
||||
|
||||
@@ -15,13 +15,13 @@ import {
|
||||
} from 'fs-extra';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import { defaultTypeLog, defaultPort } from './utils/constants/defaults';
|
||||
import {
|
||||
defaultConfigLogPath,
|
||||
defaultConfigLogFile,
|
||||
defaultTypeLog,
|
||||
defaultPort
|
||||
} from './utils/constants/defaults';
|
||||
import { validateServerIsSecure, getCert, getKey } from './utils/server';
|
||||
validateServerIsSecure,
|
||||
getCert,
|
||||
getKey,
|
||||
genPathResources
|
||||
} from './utils/server';
|
||||
import {
|
||||
entrypoint404,
|
||||
entrypointApi,
|
||||
@@ -32,6 +32,9 @@ import { vmrcUpgrade } from './routes/websockets/vmrc';
|
||||
import { guacamole } from './routes/websockets/guacamole';
|
||||
import { messageTerminal, getConfig } from './utils';
|
||||
|
||||
// set paths
|
||||
genPathResources();
|
||||
|
||||
// destructure imports
|
||||
const unsecureServer = http.createServer;
|
||||
const secureServer = https.createServer;
|
||||
@@ -71,19 +74,20 @@ if (env.NODE_ENV === 'development') {
|
||||
frontPath = '../client';
|
||||
}
|
||||
let log = morgan('dev');
|
||||
if (userLog === defaultTypeLog) {
|
||||
let logPath = `${defaultConfigLogPath}`;
|
||||
if (env && env.ONE_LOCATION) {
|
||||
logPath = env.ONE_LOCATION + logPath;
|
||||
}
|
||||
if (userLog === defaultTypeLog && global && global.FIREEDGE_LOG) {
|
||||
try {
|
||||
accessSync(logPath, constants.W_OK);
|
||||
const logStream = createWriteStream(logPath + defaultConfigLogFile, {
|
||||
accessSync(global.FIREEDGE_LOG, constants.W_OK);
|
||||
const logStream = createWriteStream(global.FIREEDGE_LOG, {
|
||||
flags: 'a'
|
||||
});
|
||||
log = morgan('combined', { stream: logStream });
|
||||
} catch (err) {
|
||||
console.error('no access!');
|
||||
const config = {
|
||||
color: 'red',
|
||||
message: 'Error: %s',
|
||||
type: err.message || ''
|
||||
};
|
||||
messageTerminal(config);
|
||||
}
|
||||
}
|
||||
app.use(helmet.hidePoweredBy());
|
||||
|
||||
@@ -16,22 +16,24 @@ const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
const { readFileSync } = require('fs-extra');
|
||||
const { getConfig } = require('server/utils/yml');
|
||||
const { messageTerminal } = require('server/utils/general');
|
||||
const { genPathResources } = require('server/utils/server');
|
||||
const { endpointVmrc } = require('server/utils/constants/defaults');
|
||||
|
||||
genPathResources();
|
||||
|
||||
const appConfig = getConfig();
|
||||
const vmrcData = appConfig.VMRC || {};
|
||||
|
||||
const endpoint = '/vmrc';
|
||||
const url = vmrcData.TARGET || '';
|
||||
const config = {
|
||||
color: 'red'
|
||||
};
|
||||
const vmrcProxy = createProxyMiddleware(endpoint, {
|
||||
const vmrcProxy = createProxyMiddleware(endpointVmrc, {
|
||||
target: url,
|
||||
changeOrigin: false,
|
||||
ws: true,
|
||||
secure: /^(https):\/\/[^ "]+$/.test(url),
|
||||
logLevel: 'debug',
|
||||
pathRewrite: path => path.replace(endpoint, '/ticket'),
|
||||
pathRewrite: path => path.replace(endpointVmrc, '/ticket'),
|
||||
onError: err => {
|
||||
config.type = err.message;
|
||||
config.message = 'Error connection : %s';
|
||||
@@ -43,7 +45,7 @@ const vmrcProxy = createProxyMiddleware(endpoint, {
|
||||
const ticket = req.url.split('/')[2] || '';
|
||||
try {
|
||||
const esxi = readFileSync(
|
||||
`${vmrcData.TOKENS_PATH || ''}/${ticket}`
|
||||
`${global.VMRC_TOKENS || ''}/${ticket}`
|
||||
).toString();
|
||||
return esxi;
|
||||
} catch (error) {
|
||||
@@ -55,11 +57,6 @@ const vmrcProxy = createProxyMiddleware(endpoint, {
|
||||
}
|
||||
});
|
||||
|
||||
const vmrc = appServer => {
|
||||
if (appServer) {
|
||||
appServer(endpoint, vmrcProxy);
|
||||
}
|
||||
};
|
||||
const vmrcUpgrade = appServer => {
|
||||
if (
|
||||
appServer &&
|
||||
@@ -73,7 +70,5 @@ const vmrcUpgrade = appServer => {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
endpoint,
|
||||
vmrc,
|
||||
vmrcUpgrade
|
||||
};
|
||||
@@ -45,9 +45,13 @@ const defaults = {
|
||||
defaultTypeLog: 'prod',
|
||||
defaultWebpackMode: 'development',
|
||||
defaultWebpackDevTool: 'inline-source-map',
|
||||
defaultConfigLogPath: '/var/log/one/',
|
||||
defaultConfigLogFile: 'fireedge.log',
|
||||
defaultLogPath: '/var/log/one',
|
||||
defaultVarPath: '/var/lib/one',
|
||||
defaultEtcPath: '/etc/one',
|
||||
defaultLogFilename: 'fireedge.log',
|
||||
defaultVmrcTokens: '/var/lib/one/sunstone_vnc_tokens/vmrc',
|
||||
defaultBaseURL: '',
|
||||
endpointVmrc: '/vmrc',
|
||||
defaultNamespace: 'one.',
|
||||
defaultMessageInvalidZone: 'Invalid Zone',
|
||||
default2FAIssuer: 'fireedge-UI',
|
||||
|
||||
@@ -12,9 +12,16 @@
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
const { env } = require('process');
|
||||
const { Map } = require('immutable');
|
||||
const { existsSync } = require('fs-extra');
|
||||
|
||||
const { internalServerError } = require('./constants/http-codes');
|
||||
const {
|
||||
defaultLogFilename,
|
||||
defaultLogPath,
|
||||
defaultVmrcTokens
|
||||
} = require('./constants/defaults');
|
||||
|
||||
let cert = '';
|
||||
let key = '';
|
||||
@@ -43,6 +50,23 @@ const httpResponse = (response, data, message) => {
|
||||
return rtn;
|
||||
};
|
||||
|
||||
const genPathResources = () => {
|
||||
const ONE_LOCATION = env && env.ONE_LOCATION;
|
||||
const LOG_LOCATION = !ONE_LOCATION ? defaultLogPath : `${ONE_LOCATION}/var`;
|
||||
const VMRC_LOCATION = !ONE_LOCATION
|
||||
? defaultVmrcTokens
|
||||
: `${ONE_LOCATION}/${defaultVmrcTokens}`;
|
||||
|
||||
if (global) {
|
||||
if (!global.VMRC_TOKENS) {
|
||||
global.VMRC_TOKENS = `${VMRC_LOCATION}/`;
|
||||
}
|
||||
if (!global.FIREEDGE_LOG) {
|
||||
global.FIREEDGE_LOG = `${LOG_LOCATION}/${defaultLogFilename}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
httpResponse,
|
||||
validateServerIsSecure,
|
||||
|
||||
Reference in new issue
Block a user