Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cli/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Diagnostics extends BaseCLIHandler {
group: [constants.CMD_STRACE_UPDATE]
},
{
name: 'microservice-id', alias: 'i', type: String, description: 'Microservice ID',
name: 'microservice-uuid', alias: 'i', type: String, description: 'Microservice UUID',
group: [constants.CMD_STRACE_UPDATE, constants.CMD_STRACE_INFO, constants.CMD_STRACE_FTP_POST,
constants.CMD_IMAGE_SNAPSHOT_CREATE, constants.CMD_IMAGE_SNAPSHOT_GET]
},
Expand Down Expand Up @@ -128,38 +128,38 @@ const _executeCase = async function (diagnosticCommand, commandName, f, isUserRe
const _changeMicroserviceStraceState = async function (obj) {
logger.info(JSON.stringify(obj));

const enable = AppHelper.validateBooleanCliOptions(obj.enable, obj.disable);
await DiagnosticService.changeMicroserviceStraceState(obj.microserviceId, {enable: enable}, {}, true);
const msg = enable ? 'Microservice strace has been enabled' : 'Microservice strace has been disabled';
const isEnable = AppHelper.validateBooleanCliOptions(obj.enable, obj.disable);
await DiagnosticService.changeMicroserviceStraceState(obj.microserviceUuid, {enable: isEnable}, {}, true);
const msg = isEnable ? 'Microservice strace has been enabled' : 'Microservice strace has been disabled';
logger.info(msg);
};

const _getMicroserviceStraceData = async function (obj) {
logger.info(JSON.stringify(obj));

const result = await DiagnosticService.getMicroserviceStraceData(obj.microserviceId, {format: obj.format}, {}, true);
const result = await DiagnosticService.getMicroserviceStraceData(obj.microserviceUuid, {format: obj.format}, {}, true);
logger.info(JSON.stringify(result, null, 2));
logger.info('Microservice strace data has been retrieved successfully.');
};

const _postMicroserviceStraceDataToFtp = async function (obj) {
logger.info(JSON.stringify(obj));

await DiagnosticService.postMicroserviceStraceDatatoFtp(obj.microserviceId, obj, {}, true);
await DiagnosticService.postMicroserviceStraceDatatoFtp(obj.microserviceUuid, obj, {}, true);
logger.info('Strace data has been posted to ftp successfully.');
};

const _postMicroserviceImageSnapshotCreate = async function (obj) {
logger.info(JSON.stringify(obj));

await DiagnosticService.postMicroserviceImageSnapshotCreate(obj.microserviceId, {}, true);
await DiagnosticService.postMicroserviceImageSnapshotCreate(obj.microserviceUuid, {}, true);
logger.info('Microservice image snapshot has been created successfully.');
};

const _getMicroserviceImageSnapshot = async function (obj) {
logger.info(JSON.stringify(obj));

const filePath = await DiagnosticService.getMicroserviceImageSnapshot(obj.microserviceId, {}, true);
const filePath = await DiagnosticService.getMicroserviceImageSnapshot(obj.microserviceUuid, {}, true);
logger.info('Microservice images path = ' + filePath);
};

Expand Down
24 changes: 11 additions & 13 deletions src/controllers/diagnostic-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,36 @@ const AuthDecorator = require('./../decorators/authorization-decorator');

const changeMicroserviceStraceStateEndPoint = async function (req, user) {
logger.info("Parameters: " + JSON.stringify(req.body));
logger.info("Microservice id: " + req.params.id);
return await DiagnosticService.changeMicroserviceStraceState(req.params.id, req.body, user, false);
logger.info("Microservice UUID: " + req.params.uuid);
return await DiagnosticService.changeMicroserviceStraceState(req.params.uuid, req.body, user, false);
};

const getMicroserviceStraceDataEndPoint = async function (req, user) {
logger.info("Parameters:" + JSON.stringify(req.query));
logger.info("Microservice id: " + req.params.id);
return await DiagnosticService.getMicroserviceStraceData(req.params.id, req.query, user, false);
logger.info("Microservice UUID: " + req.params.uuid);
return await DiagnosticService.getMicroserviceStraceData(req.params.uuid, req.query, user, false);
};

const postMicroserviceStraceDataToFtpEndPoint = async function (req, user) {
logger.info("Parameters:" + JSON.stringify(req.body));
logger.info("Microservice id: " + req.params.id);
return await DiagnosticService.postMicroserviceStraceDatatoFtp(req.params.id, req.body, user, false);
logger.info("Microservice UUID: " + req.params.uuid);
return await DiagnosticService.postMicroserviceStraceDatatoFtp(req.params.uuid, req.body, user, false);
};

const createMicroserviceImageSnapshotEndPoint = async function (req, user) {
logger.info("Parameters:" + JSON.stringify(req.body));
logger.info("Microservice id: " + req.params.id);
return await DiagnosticService.postMicroserviceImageSnapshotCreate(req.params.id, user, false);
logger.info("Microservice UUID: " + req.params.uuid);
return await DiagnosticService.postMicroserviceImageSnapshotCreate(req.params.uuid, user, false);
};

const getMicroserviceImageSnapshotEndPoint = async function (req, user) {
logger.info("Parameters:" + JSON.stringify(req.body));
logger.info("Microservice id: " + req.params.id);
return await DiagnosticService.getMicroserviceImageSnapshot(req.params.id, user, false);
logger.info("Microservice UUID: " + req.params.uuid);
return await DiagnosticService.getMicroserviceImageSnapshot(req.params.uuid, user, false);
};

module.exports = {
changeMicroserviceStraceStateEndPoint: AuthDecorator.checkAuthToken(changeMicroserviceStraceStateEndPoint),
getMicroserviceStraceDataEndPoint: AuthDecorator.checkAuthToken(getMicroserviceStraceDataEndPoint),
postMicroserviceStraceDataToFtpEndPoint: AuthDecorator.checkAuthToken(postMicroserviceStraceDataToFtpEndPoint),
createMicroserviceImageSnapshotEndPoint: AuthDecorator.checkAuthToken(createMicroserviceImageSnapshotEndPoint),
getMicroserviceImageSnapshotEndPoint: AuthDecorator.checkAuthToken(getMicroserviceImageSnapshotEndPoint),
getMicroserviceImageSnapshotEndPoint: AuthDecorator.checkAuthToken(getMicroserviceImageSnapshotEndPoint)
};
28 changes: 14 additions & 14 deletions src/controllers/flow-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@ const logger = require('../logger');
const AuthDecorator = require('./../decorators/authorization-decorator');
const FlowService = require('../services/flow-service');

const _createFlowEndPoint = async function (req, user) {
const createFlowEndPoint = async function (req, user) {
const flow = req.body;

logger.info("Parameters:" + JSON.stringify(flow));

return await FlowService.createFlow(flow, user, false)
};

const _getFlowsByUserEndPoint = async function (req, user) {
const getFlowsByUserEndPoint = async function (req, user) {
return await FlowService.getUserFlows(user, false)
};

const _getFlowEndPoint = async function (req, user) {
const getFlowEndPoint = async function (req, user) {
const flowId = req.params.id;

logger.info("Flow id:" + JSON.stringify(flowId))
logger.info("Flow id:" + JSON.stringify(flowId));

return await FlowService.getFlowWithTransaction(flowId, user, false)
};

const _updateFlowEndPoint = async function (req, user) {
const updateFlowEndPoint = async function (req, user) {
const flow = req.body;
const flowId = req.params.id;

logger.info("Parameters:" + JSON.stringify(flow))
logger.info("Flow id:" + JSON.stringify(flowId))
logger.info("Parameters:" + JSON.stringify(flow));
logger.info("Flow id:" + JSON.stringify(flowId));

return await FlowService.updateFlow(flow, flowId, user, false)
};

const _deleteFlowEndPoint = async function (req, user) {
const deleteFlowEndPoint = async function (req, user) {
const flowId = req.params.id;

logger.info("Flow id:" + JSON.stringify(flowId))
logger.info("Flow id:" + JSON.stringify(flowId));

return await FlowService.deleteFlow(flowId, user, false)
};

module.exports = {
createFlowEndPoint: AuthDecorator.checkAuthToken(_createFlowEndPoint),
getFlowsByUserEndPoint: AuthDecorator.checkAuthToken(_getFlowsByUserEndPoint),
getFlowEndPoint: AuthDecorator.checkAuthToken(_getFlowEndPoint),
updateFlowEndPoint: AuthDecorator.checkAuthToken(_updateFlowEndPoint),
deleteFlowEndPoint: AuthDecorator.checkAuthToken(_deleteFlowEndPoint)
createFlowEndPoint: AuthDecorator.checkAuthToken(createFlowEndPoint),
getFlowsByUserEndPoint: AuthDecorator.checkAuthToken(getFlowsByUserEndPoint),
getFlowEndPoint: AuthDecorator.checkAuthToken(getFlowEndPoint),
updateFlowEndPoint: AuthDecorator.checkAuthToken(updateFlowEndPoint),
deleteFlowEndPoint: AuthDecorator.checkAuthToken(deleteFlowEndPoint)
};
11 changes: 5 additions & 6 deletions src/routes/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ const constants = require('../helpers/constants');
const DiagnosticController = require('../controllers/diagnostic-controller');
const ResponseDecorator = require('../decorators/response-decorator');
const Errors = require('../helpers/errors');
const ErrorMessages = require('../helpers/error-messages');
const fs = require('fs');

module.exports = [
{
method: 'post',
path: '/api/v3/microservices/:id/image-snapshot',
path: '/api/v3/microservices/:uuid/image-snapshot',
middleware: async (req, res) => {

const successCode = constants.HTTP_CODE_CREATED;
Expand Down Expand Up @@ -49,7 +48,7 @@ module.exports = [
},
{
method: 'get',
path: '/api/v3/microservices/:id/image-snapshot',
path: '/api/v3/microservices/:uuid/image-snapshot',
middleware: async (req, res) => {
const successCode = constants.HTTP_CODE_SUCCESS;
const errorCodes = [
Expand Down Expand Up @@ -85,7 +84,7 @@ module.exports = [
},
{
method: 'patch',
path: '/api/v3/microservices/:id/strace',
path: '/api/v3/microservices/:uuid/strace',
middleware: async (req, res) => {

const successCode = constants.HTTP_CODE_NO_CONTENT;
Expand Down Expand Up @@ -118,7 +117,7 @@ module.exports = [
},
{
method: 'get',
path: '/api/v3/microservices/:id/strace',
path: '/api/v3/microservices/:uuid/strace',
middleware: async (req, res) => {

const successCode = constants.HTTP_CODE_SUCCESS;
Expand Down Expand Up @@ -147,7 +146,7 @@ module.exports = [
},
{
method: 'put',
path: '/api/v3/microservices/:id/strace',
path: '/api/v3/microservices/:uuid/strace',
middleware: async (req, res) => {
const successCode = constants.HTTP_CODE_NO_CONTENT;
const errorCodes = [
Expand Down
Loading