Skip to content

Commit

Permalink
F #2312: Fireedge VMRC proxy (#225)
Browse files Browse the repository at this point in the history
* add vmrc proxy
* fix zeromq and vmrc
* organizate code websockets
* catch error vmrc

Signed-off-by: Jorge Lobo <[email protected]>
  • Loading branch information
jloboescalona2 authored and rsmontero committed Sep 24, 2020
1 parent 8fa45a8 commit e40b953
Show file tree
Hide file tree
Showing 19 changed files with 529 additions and 385 deletions.
7 changes: 6 additions & 1 deletion src/fireedge/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ TOKEN_SECRET: secret_token
# JWT life time (days)
LIMIT_TOKEN:
MIN: 14
MAX: 30
MAX: 30

# VMRC
VMRC:
TARGET: 'http://opennebula.io'
TOKENS_PATH: '/var/lib/one/sunstone_vnc_tokens/vmrc'
30 changes: 0 additions & 30 deletions src/fireedge/genPotFile.js

This file was deleted.

16 changes: 7 additions & 9 deletions src/fireedge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"start": "node dist/index",
"cypress:open": "cypress open",
"cypress:run": "cypress run --headless --browser chrome --spec \"cypress/integration/**/*.spec.js\"",
"genPot": "node genPotFile.js",
"pot": "node potfile.js",
"po2json": "node po2json.js",
"copy_static_assets": "node copyStaticAssets.js"
},
"keywords": [
Expand Down Expand Up @@ -41,11 +42,11 @@
"concurrently": "^5.2.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"fireedge-genpotfile": "^1.0.0",
"fs-extra": "^9.0.1",
"fuse.js": "^6.4.1",
"helmet": "^3.23.3",
"http": "0.0.1-security",
"http-proxy-middleware": "^1.0.5",
"immutable": "^4.0.0-rc.12",
"intersection-observer": "^0.11.0",
"jsonschema": "^1.2.6",
Expand Down Expand Up @@ -101,20 +102,17 @@
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-cypress": "^2.11.1",
"file-loader": "^6.0.0",
"fireedge-genpotfile": "^1.0.0",
"fireedge-pojson": "^1.0.1",
"jloboescalona-eslint-config": "^1.1.0",
"node-sass": "^4.12.0",
"nodemon": "^1.18.10",
"once": "^1.4.0",
"path": "^0.12.7",
"react-addons-test-utils": "^15.6.2",
"readdirp": "^3.4.0",
"split": "^1.0.1",
"stream-combiner": "^0.2.2",
"style-loader": "^1.0.0",
"through2": "^4.0.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.7",
"webpack-livereload-plugin": "^2.3.0",
"webpack-node-externals": "^1.7.2",
"xgettext-regex": "^0.3.0"
"webpack-node-externals": "^1.7.2"
}
}
22 changes: 22 additions & 0 deletions src/fireedge/po2json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

const { createReadStream, generateFile } = require('fireedge-pojson');

const testFolder = './src/public/assets/languages';

createReadStream(testFolder, { exportPath: testFolder });

generateFile();
45 changes: 45 additions & 0 deletions src/fireedge/potfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */

const { createReadStream, generateFile } = require('fireedge-genpotfile');
const constants = require('./src/utils/constants');
const clientConstants = require('./src/public/constants');

const testFolder = './src/public';
const exportFile = './src/public/assets/languages/messages.pot';
const definitions = { ...constants, ...clientConstants };

// function Tr()
const optsFunc = {
regex: /Tr(\("|\('|\()[a-zA-Z0-9_ ]*("\)|'\)|\))/g,
removeStart: /Tr(\()/g,
removeEnd: /(\))/g,
regexTextCaptureIndex: 0,
definitions
};

// React component <Translate word="word"/>
const optsComponent = {
regex: /<Translate word=('|"|{|{'|{")[a-zA-Z0-9_ ]*('|"|}|'}|"}) \/>/g,
removeStart: /<Translate word=('|"|{|{'|{")/g,
removeEnd: /('|"|}|'}|"}) \/>/g,
regexTextCaptureIndex: 0,
definitions
};

createReadStream(testFolder, optsFunc);
createReadStream(testFolder, optsComponent);

generateFile(exportFile);
15 changes: 8 additions & 7 deletions src/fireedge/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const helmet = require('helmet');
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const socketIO = require('socket.io');
const cors = require('cors');
const {
accessSync,
Expand All @@ -33,21 +32,24 @@ const bodyParser = require('body-parser');
const {
defaultConfigLogPath,
defaultConfigLogFile,
defaultTypeLog
defaultTypeLog,
defaultPort
} = require('./utils/constants/defaults');
const { validateServerIsSecure, getCert, getKey } = require('./utils/server');
const {
entrypoint404,
entrypointApi,
entrypointApp
} = require('./routes/entrypoints');
const { messageTerminal, addWsServer, getConfig } = require('./utils');
const { oneHooks } = require('./routes/websockets/zeromq');
const { vmrcUpgrade } = require('./routes/websockets/vmrc');
const { messageTerminal, getConfig } = require('./utils');

const app = express();

// settings
const appConfig = getConfig();
const port = appConfig.PORT || 3000;
const port = appConfig.PORT || defaultPort;
const userLog = appConfig.LOG || 'dev';

let log = morgan('dev');
Expand Down Expand Up @@ -102,9 +104,7 @@ const appServer = validateServerIsSecure()
)
: unsecureServer(app);

// connect to websocket
const io = socketIO.listen(appServer);
addWsServer(io);
oneHooks(appServer);

appServer.listen(port, () => {
const config = {
Expand All @@ -114,3 +114,4 @@ appServer.listen(port, () => {
};
messageTerminal(config);
});
vmrcUpgrade(appServer);
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@

import React, { useState, useEffect } from 'react';
import io from 'socket.io-client';
import { findStorageData } from '../../../utils';
import { findStorageData } from 'client/utils';
import constants from 'client/constants';
import { defaultPort } from 'server/utils/constants/defaults';

const { jwtName } = constants;

const ENDPOINT = 'http://127.0.0.1:3000';
const ENDPOINT = `http://127.0.0.1:${defaultPort}`;

function Webconsole() {
const Webconsole = () => {
const [response, setResponse] = useState({});

useEffect(() => {
const socket = io(ENDPOINT, {
path: '/zeromq',
query: {
token: findStorageData(jwtName)
}
Expand All @@ -37,6 +39,5 @@ function Webconsole() {
}, []);
console.log('-->', response);
return <p />;
}

};
export default Webconsole;
58 changes: 0 additions & 58 deletions src/fireedge/src/public/containers/Websocket/WSConsole.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/fireedge/src/public/router/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Login from 'client/containers/Login';
import Dashboard from 'client/containers/Dashboard';
import Settings from 'client/containers/Settings';
import TestApi from 'client/containers/TestApi';
import Webconsole from 'client/containers/Webconsole';
import {
ApplicationCreate,
ApplicationDeploy,
Expand Down Expand Up @@ -74,6 +75,14 @@ const ENDPOINTS = [
icon: BallotIcon,
component: TestApi
},
{
label: 'Webconsole',
path: '/webconsole',
authenticated: true,
devMode: true,
icon: BallotIcon,
component: Webconsole
},
{
label: 'Create Application',
path: PATH.APPLICATION.CREATE,
Expand Down
Loading

0 comments on commit e40b953

Please sign in to comment.