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
93 changes: 93 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,34 @@ paths:
description: Not Authorized
"500":
description: Internal Server Error
/agent/config/gps:
patch:
tags:
- Agent
summary: Updates an ioFog node GPS configuration
operationId: updateIOFogNodeGps
security:
- authToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/IOFogNodeGpsRequest"
required: true
responses:
"204":
description: Success
headers:
X-Timestamp:
description: FogController server timestamp
schema:
type: number
"400":
description: Bad Request
"401":
description: Not Authorized
"500":
description: Internal Server Error
/agent/config/changes:
get:
tags:
Expand Down Expand Up @@ -2609,6 +2637,64 @@ paths:
description: Not Found
"500":
description: Internal Server Error
"/microservices/{uuid}/start":
patch:
tags:
- Microservices
summary: Starts a microservice
operationId: startMicroservice
parameters:
- in: path
name: uuid
description: Microservice Uuid
required: true
schema:
type: string
security:
- authToken: []
responses:
"204":
description: Success
headers:
X-Timestamp:
description: FogController server timestamp
schema:
type: number
"401":
description: Not Authorized
"404":
description: Not Found
"500":
description: Internal Server Error
"/microservices/{uuid}/stop":
patch:
tags:
- Microservices
summary: Stops a microservice
operationId: stopMicroservice
parameters:
- in: path
name: uuid
description: Microservice Uuid
required: true
schema:
type: string
security:
- authToken: []
responses:
"204":
description: Success
headers:
X-Timestamp:
description: FogController server timestamp
schema:
type: number
"401":
description: Not Authorized
"404":
description: Not Found
"500":
description: Internal Server Error
"/microservices/{uuid}/exec":
post:
tags:
Expand Down Expand Up @@ -5786,6 +5872,13 @@ components:
type: number
dockerPruningFrequency:
type: number
IOFogNodeGpsRequest:
type: object
properties:
latitude:
type: number
longitude:
type: number
AgentStatus:
type: object
properties:
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datasance/iofogcontroller",
"version": "3.5.5",
"version": "3.5.6",
"description": "ioFog Controller project for Datasance PoT @ datasance.com \\nCopyright (c) 2023 Datasance Teknoloji A.S.",
"main": "./src/main.js",
"author": "Emirhan Durmus",
Expand Down Expand Up @@ -55,7 +55,7 @@
"iofog-controller": "src/main.js"
},
"dependencies": {
"@datasance/ecn-viewer": "1.2.0",
"@datasance/ecn-viewer": "1.2.1",
"@kubernetes/client-node": "^0.22.3",
"@msgpack/msgpack": "^3.1.2",
"@opentelemetry/api": "^1.9.0",
Expand Down
7 changes: 7 additions & 0 deletions src/controllers/agent-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const updateAgentConfigEndPoint = async function (req, fog) {
return AgentService.updateAgentConfig(updateData, fog)
}

const updateAgentGpsEndPoint = async function (req, fog) {
const updateData = req.body

return AgentService.updateAgentGpsEndPoint(updateData, fog)
}

const getAgentConfigChangesEndPoint = async function (req, fog) {
return AgentService.getAgentConfigChanges(fog)
}
Expand Down Expand Up @@ -123,6 +129,7 @@ module.exports = {
agentDeprovisionEndPoint: AuthDecorator.checkFogToken(agentDeprovisionEndPoint),
getAgentConfigEndPoint: AuthDecorator.checkFogToken(getAgentConfigEndPoint),
updateAgentConfigEndPoint: AuthDecorator.checkFogToken(updateAgentConfigEndPoint),
updateAgentGpsEndPoint: AuthDecorator.checkFogToken(updateAgentGpsEndPoint),
getAgentConfigChangesEndPoint: AuthDecorator.checkFogToken(getAgentConfigChangesEndPoint),
updateAgentStatusEndPoint: AuthDecorator.checkFogToken(updateAgentStatusEndPoint),
getAgentMicroservicesEndPoint: AuthDecorator.checkFogToken(getAgentMicroservicesEndPoint),
Expand Down
14 changes: 13 additions & 1 deletion src/controllers/microservices-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ const deleteSystemMicroserviceExecEndPoint = async function (req) {
return MicroservicesService.deleteSystemExecEndPoint(uuid, false)
}

const startMicroserviceEndPoint = async function (req) {
const uuid = req.params.uuid
return MicroservicesService.startMicroserviceEndPoint(uuid, false)
}

const stopMicroserviceEndPoint = async function (req) {
const uuid = req.params.uuid
return MicroservicesService.stopMicroserviceEndPoint(uuid, false)
}

module.exports = {
createMicroserviceOnFogEndPoint: (createMicroserviceOnFogEndPoint),
getMicroserviceEndPoint: (getMicroserviceEndPoint),
Expand Down Expand Up @@ -278,5 +288,7 @@ module.exports = {
createMicroserviceExecEndPoint: (createMicroserviceExecEndPoint),
deleteMicroserviceExecEndPoint: (deleteMicroserviceExecEndPoint),
createSystemMicroserviceExecEndPoint: (createSystemMicroserviceExecEndPoint),
deleteSystemMicroserviceExecEndPoint: (deleteSystemMicroserviceExecEndPoint)
deleteSystemMicroserviceExecEndPoint: (deleteSystemMicroserviceExecEndPoint),
startMicroserviceEndPoint: (startMicroserviceEndPoint),
stopMicroserviceEndPoint: (stopMicroserviceEndPoint)
}
11 changes: 10 additions & 1 deletion src/data/managers/microservice-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Application = models.Application
const Routing = models.Routing
const Registry = models.Registry
const MicroserviceStatus = models.MicroserviceStatus
const MicroserviceExecStatus = models.MicroserviceExecStatus
const MicroserviceHealthCheck = models.MicroserviceHealthCheck
const Op = require('sequelize').Op

Expand Down Expand Up @@ -272,7 +273,10 @@ class MicroserviceManager extends BaseManager {
[Op.or]:
[
{
'$application.is_activated$': true
[Op.and]: [
{ '$application.is_activated$': true },
{ isActivated: true }
]
},
{
'$catalogItem.category$': { [Op.eq]: 'SYSTEM' },
Expand Down Expand Up @@ -418,6 +422,11 @@ class MicroserviceManager extends BaseManager {
model: MicroserviceStatus,
as: 'microserviceStatus',
required: false
},
{
model: MicroserviceExecStatus,
as: 'microserviceExecStatus',
required: false
}
],
where: where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,4 +810,6 @@ CREATE INDEX idx_microservice_health_check_microservice_uuid ON MicroserviceHeal

ALTER TABLE MicroserviceStatuses ADD COLUMN health_status TEXT;

ALTER TABLE Microservices ADD COLUMN is_activated BOOLEAN DEFAULT true;

COMMIT;
Original file line number Diff line number Diff line change
Expand Up @@ -808,4 +808,6 @@ CREATE TABLE IF NOT EXISTS "MicroserviceHealthChecks" (

CREATE INDEX idx_microservice_health_check_microservice_uuid ON "MicroserviceHealthChecks" (microservice_uuid);

ALTER TABLE "MicroserviceStatuses" ADD COLUMN health_status TEXT;
ALTER TABLE "MicroserviceStatuses" ADD COLUMN health_status TEXT;

ALTER TABLE "Microservices" ADD COLUMN is_activated BOOLEAN DEFAULT true;
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,6 @@ CREATE TABLE IF NOT EXISTS MicroserviceHealthChecks (

CREATE INDEX idx_microservice_health_check_microservice_uuid ON MicroserviceHealthChecks (microservice_uuid);

ALTER TABLE MicroserviceStatuses ADD COLUMN health_status TEXT;
ALTER TABLE MicroserviceStatuses ADD COLUMN health_status TEXT;

ALTER TABLE Microservices ADD COLUMN is_activated BOOLEAN DEFAULT true;
5 changes: 5 additions & 0 deletions src/data/models/microservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
field: 'delete_with_cleanup',
defaultValue: false
},
isActivated: {
type: DataTypes.BOOLEAN,
field: 'is_activated',
defaultValue: true
}
}, {
tableName: 'Microservices',
Expand Down
12 changes: 6 additions & 6 deletions src/data/providers/database-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class DatabaseProvider {

// SQLite migration
async runMigrationSQLite (dbName) {
const migrationSqlPath = path.resolve(__dirname, '../migrations/sqlite/db_migration_sqlite_v1.0.3.sql')
const migrationVersion = '1.0.3'
const migrationSqlPath = path.resolve(__dirname, '../migrations/sqlite/db_migration_sqlite_v1.0.4.sql')
const migrationVersion = '1.0.4'

if (!fs.existsSync(migrationSqlPath)) {
logger.error(`Migration file not found: ${migrationSqlPath}`)
Expand Down Expand Up @@ -324,8 +324,8 @@ class DatabaseProvider {

// MySQL migration
async runMigrationMySQL (db) {
const migrationSqlPath = path.resolve(__dirname, '../migrations/mysql/db_migration_mysql_v1.0.3.sql')
const migrationVersion = '1.0.3'
const migrationSqlPath = path.resolve(__dirname, '../migrations/mysql/db_migration_mysql_v1.0.4.sql')
const migrationVersion = '1.0.4'

if (!fs.existsSync(migrationSqlPath)) {
logger.error(`Migration file not found: ${migrationSqlPath}`)
Expand Down Expand Up @@ -385,8 +385,8 @@ class DatabaseProvider {

// PostgreSQL migration
async runMigrationPostgres (db) {
const migrationSqlPath = path.resolve(__dirname, '../migrations/postgres/db_migration_pg_v1.0.3.sql')
const migrationVersion = '1.0.3'
const migrationSqlPath = path.resolve(__dirname, '../migrations/postgres/db_migration_pg_v1.0.4.sql')
const migrationVersion = '1.0.4'

if (!fs.existsSync(migrationSqlPath)) {
logger.error(`Migration file not found: ${migrationSqlPath}`)
Expand Down
1 change: 1 addition & 0 deletions src/helpers/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = {
'List of invalid microservices:\n',
INVALID_MICROSERVICE_CONFIG: 'Can\'t create network microservice without appropriate configuration.',
INVALID_MICROSERVICE_USER: 'Invalid microservice user or UUID',
APPLICATION_NOT_ACTIVATED: 'Application {} is not activated',
ROUTE_NOT_FOUND: 'Route not found',
IMAGE_SNAPSHOT_WITHOUT_FOG: 'Can not run image snapshot for microservice without ioFog.',
IMAGE_SNAPSHOT_NOT_AVAILABLE: 'Image snapshot is not available for this microservice.',
Expand Down
Loading
Loading