Skip to content

Commit 4f7a4fc

Browse files
authored
release 1.0.27 version (#419)
* feat(core): add migration between versions (EWC-379) * feat(core): add cli help output (EWC-385) * fix(bug): fix cli `microservice port-mapping-remove` error message (EWC-395) * fix(bug): fix cli `diagnostics strace-update` parsing of boolean (EWC-389) * fix(bug): fix cli `diagnostics strace-...` validation error messages (EWC-390) * feat(core): add cli `diagnostics strace-info` microservice validation (EWC-392) * refactor(core): replace sequelize (deprecated)find -> findOne (EWC-394) * refactor(core): edit validation of flowId in delete flow service (EWC-388) * feat(core): add validation of microserviceUuid in image snapshot services (EWC-393) * fix(help): Fix rsa-key description in cli tunnel help need to update description for parameter -k, --rsa-key in help for tunnel from 'Tunnel RSA key' to 'Path to tunnel RSA key' Closes EWC-396 * fix(tunnel): if port range not provided in config use default values default range: 2000-10000 Closes EWC-397 * fix(tests): rename logLimit -> logSize (#416) create microservice request in Postman Collection diagnostics block Closes EWC-401 * feat(npm-scripts): allow to use only one image on catalog item creation (#415) Closes EWC-399 * fix(transactions): fix transaction validation if last method's arg is undefined (#414) Closes EWC-400 * feat(npm-scripts): init db automatically after installation (#413) Closes EWC-368 * fix(code): delete routes on microservice deletion Closes EWC-362
1 parent af2e78f commit 4f7a4fc

22 files changed

+129
-131
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ $ iofog-controller config <*options*>
100100
-a, --email-address string (Email address to send activations from) <br>
101101
-w, --email-password string (Email password to send activations from) <br>
102102
-s, --email-service string (Email service to send activations) <br>
103-
-d, --log-dir string (Log files directory) <br>
103+
-d, --log-dir string (Path to log files directory) <br>
104104
-z, --log-size number (Log files size (MB)) <br>
105105

106106
*list*<br>
@@ -135,7 +135,7 @@ $ iofog-controller connector <*command*> <*options*>
135135
-n, --name string (Connector name) <br>
136136
-d, --domain string (Connector domain name) <br>
137137
-i, --public-ip string (Connector public IP address) <br>
138-
-c, --cert string (Certificate) <br>
138+
-c, --cert string (Path to certificate file) <br>
139139
-S, --self-signed-on (Switch on self-signed enabled) <br>
140140
-s, --self-signed-off (Switch off self-signed disabled) <br>
141141
-H, --dev-mode-on (Switch on dev mode) <br>
@@ -173,7 +173,7 @@ $ iofog-controller tunnel <*command*> <*options*>
173173
-u, --username string (Tunnel username) <br>
174174
-p, --password string (Tunnel password) <br>
175175
-s, --host string (Tunnel host address) <br>
176-
-k, --rsa-key string (Tunnel RSA key) <br>
176+
-k, --rsa-key string (Path to tunnel RSA key) <br>
177177
-o, --port number (Tunnel port) <br>
178178
-f, --iofogUuid string (Fog UUID) <br>
179179

@@ -215,11 +215,11 @@ tunnel list
215215
-d, --description string (ioFog node description) <br>
216216
-D, --docker-url string (ioFog node docker url) <br>
217217
-M, --disk-limit number (ioFog node disk usage limit (MB)) <br>
218-
-T, --disk-directory string (ioFog node disk directory) <br>
218+
-T, --disk-directory string (Path to ioFog node disk directory) <br>
219219
-m, --memory-limit number (ioFog node memory usage limit (MB)) <br>
220220
-c, --cpu-limit number (ioFog node CPU usage limit (%)) <br>
221221
-G, --log-limit number (ioFog node log size limit (MB)) <br>
222-
-Y, --log-directory string (ioFog node log files directory) <br>
222+
-Y, --log-directory string (Path to ioFog node log files directory) <br>
223223
-C, --log-file-count number (ioFog node log files count) <br>
224224
-s, --status-frequency number (ioFog node status check frequency (seconds)) <br>
225225
-F, --change-frequency number (ioFog node configuration change check frequency (seconds)) <br>
@@ -702,7 +702,7 @@ $ iofog-controller catalog <*command*> <*options*> <br>
702702

703703
*strace-info -i* <*microservice-id*><br>
704704

705-
-f, --format string (Format of strace data to receive)<br>
705+
-f, --format string (Format of strace data to receive. Possible values: string, file)<br>
706706

707707
*strace-ftp-post -i* <*microservice-id*><br>
708708

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iofogcontroller",
3-
"version": "1.0.26",
3+
"version": "1.0.27",
44
"description": "ioFog Controller project for Eclipse IoFog @ iofog.org \\nCopyright (c) 2018 Edgeworx, Inc.",
55
"main": "./src/main.js",
66
"author": "Saeid Baghbidi",
@@ -79,7 +79,8 @@
7979
"xss-clean": "^0.1.1",
8080
"qs": "^6.5.2",
8181
"child_process": "^1.0.2",
82-
"os": "^0.1.1"
82+
"os": "^0.1.1",
83+
"semver": "^5.6.0"
8384
},
8485
"devDependencies": {
8586
"automatic-release": "^1.1.1",

scripts/postinstall.js

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
*
1212
*/
1313

14-
1514
const os = require('os');
1615
const execSync = require('child_process').execSync;
1716
const fs = require('fs');
17+
const semver = require('semver');
18+
const currentVersion = require('../package').version;
1819

1920
const rootDir = `${__dirname}/../`;
20-
let installation_variables_file_name = 'iofogcontroller_install_variables';
21-
let installation_variables_file;
21+
let installationVariablesFileName = 'iofogcontroller_install_variables';
22+
let installationVariablesFile;
2223
let tempDir;
2324

2425
if (os.type() === 'Linux') {
@@ -31,17 +32,56 @@ if (os.type() === 'Linux') {
3132
throw new Error("Unsupported OS found: " + os.type());
3233
}
3334

34-
installation_variables_file = tempDir + installation_variables_file_name;
35-
35+
installationVariablesFile = tempDir + installationVariablesFileName;
3636

3737
const devDbBackup = `${tempDir}dev_database.sqlite`;
38+
const devDb = `${rootDir}/src/sequelize/dev_database.sqlite`;
3839
if (fs.existsSync(devDbBackup)) {
39-
fs.renameSync(devDbBackup, `${rootDir}/src/sequelize/dev_database.sqlite`)
40+
fs.renameSync(devDbBackup, devDb);
4041
}
4142

4243
const prodDbBackup = `${tempDir}prod_database.sqlite`;
44+
const prodDb = `${rootDir}/src/sequelize/prod_database.sqlite`;
4345
if (fs.existsSync(prodDbBackup)) {
44-
fs.renameSync(prodDbBackup, `${rootDir}/src/sequelize/prod_database.sqlite`)
46+
fs.renameSync(prodDbBackup, prodDb);
4547
}
4648

47-
//TODO: add version migrations
49+
try {
50+
const instalationVarsStr = fs.readFileSync(installationVariablesFile);
51+
const instalationVars = JSON.parse(instalationVarsStr);
52+
const prevVersion = instalationVars.prevVer;
53+
54+
console.log(`previous version - ${prevVersion}`);
55+
console.log(`new version - ${currentVersion}`);
56+
57+
if (semver.satisfies(prevVersion, '<=1.0.0')) {
58+
console.log('upgrading from version <=1.0.0 :');
59+
console.log(' inserting seeds meta info in db');
60+
const options = {
61+
env: {
62+
"PATH": process.env.PATH
63+
},
64+
stdio: [process.stdin, process.stdout, process.stderr]
65+
};
66+
67+
execSync(`sqlite3 ${prodDb} "insert into SequelizeMeta (name) values ('20180928110125-insert-registry.js');"`, options);
68+
execSync(`sqlite3 ${prodDb} "insert into SequelizeMeta (name) values ('20180928111532-insert-catalog-item.js');"`, options);
69+
execSync(`sqlite3 ${prodDb} "insert into SequelizeMeta (name) values ('20180928112152-insert-iofog-type.js');"`, options);
70+
execSync(`sqlite3 ${prodDb} "insert into SequelizeMeta (name) values ('20180928121334-insert-catalog-item-image.js');"`, options);
71+
}
72+
73+
fs.unlinkSync(installationVariablesFile);
74+
} catch (e) {
75+
console.log('no previous version')
76+
}
77+
78+
//init db
79+
const options = {
80+
env: {
81+
'NODE_ENV': 'production',
82+
"PATH": process.env.PATH
83+
},
84+
stdio: [process.stdin, process.stdout, process.stderr]
85+
};
86+
87+
execSync('node ./src/main.js init', options);

scripts/postinstall.sh

Lines changed: 0 additions & 77 deletions
This file was deleted.

scripts/preuninstall.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const fs = require('fs');
1717
const version = require('../package').version;
1818

1919
const rootDir = `${__dirname}/../`;
20-
let installation_variables_file_name = 'iofogcontroller_install_variables';
21-
let installation_variables_file;
20+
let installationVariablesFileName = 'iofogcontroller_install_variables';
21+
let installationVariablesFile;
2222
let tempDir;
2323

2424
if (os.type() === 'Linux') {
@@ -31,9 +31,13 @@ if (os.type() === 'Linux') {
3131
throw new Error("Unsupported OS found: " + os.type());
3232
}
3333

34-
installation_variables_file = tempDir + installation_variables_file_name;
34+
installationVariablesFile = tempDir + installationVariablesFileName;
3535

36-
fs.writeFileSync(installation_variables_file, `prev_ver: ${version}`);
36+
const instalationVars = {
37+
prevVer: version
38+
};
39+
40+
fs.writeFileSync(installationVariablesFile, JSON.stringify(instalationVars));
3741

3842
const devDb = `${rootDir}/src/sequelize/dev_database.sqlite`;
3943
if (fs.existsSync(devDb)) {

src/cli/catalog.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,25 @@ const _createCatalogItemObject = function (catalogItem) {
263263
picture: catalogItem.picture,
264264
isPublic: AppHelper.validateBooleanCliOptions(catalogItem.public, catalogItem.private),
265265
registryId: catalogItem.registryId,
266-
images: [
266+
images: []
267+
};
268+
269+
if (catalogItem.x86Image) {
270+
catalogItemObj.images.push(
267271
{
268272
containerImage: catalogItem.x86Image,
269273
fogTypeId: 1
270-
},
274+
}
275+
);
276+
}
277+
if (catalogItem.armImage) {
278+
catalogItemObj.images.push(
271279
{
272280
containerImage: catalogItem.armImage,
273281
fogTypeId: 2
274282
}
275-
]
276-
};
283+
);
284+
}
277285

278286
if (catalogItem.inputType) {
279287
catalogItemObj.inputType = {

src/cli/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Config extends BaseCLIHandler {
6868
group: constants.CMD_ADD
6969
},
7070
{
71-
name: 'log-dir', alias: 'd', type: String, description: 'Log files directory',
71+
name: 'log-dir', alias: 'd', type: String, description: 'Path to log files directory',
7272
group: constants.CMD_ADD
7373
},
7474
{

src/cli/connector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Connector extends BaseCLIHandler {
4646
},
4747
{
4848
name: 'cert', alias: 'c', type: String,
49-
description: 'Certificate',
49+
description: 'Path to certificate file',
5050
group: [constants.CMD_ADD, constants.CMD_UPDATE]
5151
},
5252
{

src/cli/diagnostics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Diagnostics extends BaseCLIHandler {
4343
constants.CMD_IMAGE_SNAPSHOT_CREATE, constants.CMD_IMAGE_SNAPSHOT_GET]
4444
},
4545
{
46-
name: 'format', alias: 'f', type: String, description: 'Format of strace data to receive',
46+
name: 'format', alias: 'f', type: String, description: 'Format of strace data to receive. Possible values: string, file',
4747
group: [constants.CMD_STRACE_INFO]
4848
},
4949
{
@@ -128,7 +128,7 @@ const _executeCase = async function (diagnosticCommand, commandName, f, isUserRe
128128
const _changeMicroserviceStraceState = async function (obj) {
129129
logger.info(JSON.stringify(obj));
130130

131-
const enable = AppHelper.validateBooleanCliOptions(obj.disable, obj.enable);
131+
const enable = AppHelper.validateBooleanCliOptions(obj.enable, obj.disable);
132132
await DiagnosticService.changeMicroserviceStraceState(obj.microserviceId, {enable: enable}, {}, true);
133133
const msg = enable ? 'Microservice strace has been enabled' : 'Microservice strace has been disabled';
134134
logger.info(msg);

src/cli/iofog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class IOFog extends BaseCLIHandler {
9999
},
100100
{
101101
name: 'disk-directory', alias: 'T', type: String,
102-
description: 'ioFog node disk directory',
102+
description: 'Path to ioFog node disk directory',
103103
group: [constants.CMD_UPDATE, constants.CMD_ADD]
104104
},
105105
{
@@ -119,7 +119,7 @@ class IOFog extends BaseCLIHandler {
119119
},
120120
{
121121
name: 'log-directory', alias: 'Y', type: String,
122-
description: 'ioFog node log files directory',
122+
description: 'Path to ioFog node log files directory',
123123
group: [constants.CMD_UPDATE, constants.CMD_ADD]
124124
},
125125
{

0 commit comments

Comments
 (0)