Index: db/default.sql
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>PRAGMA foreign_keys = OFF;\nBEGIN TRANSACTION;\nCREATE TABLE routing (\n  `ID`                      INTEGER PRIMARY KEY AUTOINCREMENT,\n  `publishing_instance_id`  TEXT,\n  `publishing_element_id`   TEXT,\n  `destination_instance_id` TEXT,\n  `destination_element_id`  TEXT,\n  `is_network_connection`   TINYINT(1)\n);\nCREATE TABLE config (\n  `ID`    INTEGER PRIMARY KEY AUTOINCREMENT,\n  `key`   TEXT,\n  `value` TEXT\n);\nCREATE TABLE satellite (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `name`       TEXT,\n  `domain`     TEXT,\n  `public_ip`  TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL\n);\nINSERT INTO satellite VALUES (2, 'ComSat4', 'comsat4.iotracks.com', '104.130.135.213', '2016-09-21 15:21:31.898 +00:00',\n                              '2016-09-21 15:21:31.898 +00:00');\nCREATE TABLE data_tracks (\n  `ID`           INTEGER PRIMARY KEY AUTOINCREMENT,\n  `name`         TEXT,\n  `instance_id`  TEXT,\n  `updated_by`   BIGINT,\n  `description`  TEXT,\n  `is_selected`  INTEGER,\n  `is_activated` INTEGER,\n  `created_at`   DATETIME NOT NULL,\n  `updated_at`   DATETIME NOT NULL,\n  `user_id`      INTEGER REFERENCES `users` (`ID`)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_instance_port (\n  `ID`            INTEGER PRIMARY KEY AUTOINCREMENT,\n  `port_internal` BIGINT,\n  `port_external` BIGINT,\n  `updated_by`    BIGINT,\n  `created_at`    DATETIME NOT NULL,\n  `updated_at`    DATETIME NOT NULL,\n  `elementId`     TEXT\n);\nCREATE TABLE iofog_console (\n  ID           INTEGER PRIMARY KEY AUTOINCREMENT,\n  org_id       BIGINT,\n  version      BIGINT,\n  api_base_url TEXT,\n  element_id   TEXT,\n  access_token TEXT,\n  iofog_uuid   TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE stream_viewer (\n  ID           INTEGER PRIMARY KEY AUTOINCREMENT,\n  orgId        BIGINT,\n  version      BIGINT,\n  api_base_url TEXT,\n  element_id   TEXT,\n  access_token TEXT,\n  iofog_uuid   TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE instance_track (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  name                TEXT,\n  description         TEXT,\n  last_updated        DATETIME,\n  is_selected         TINYINT(1),\n  is_activated        TINYINT(1),\n  updated_by          BIGINT,\n  created_at          DATETIME NOT NULL,\n  updated_at          DATETIME NOT NULL,\n  element_instance_id INTEGER REFERENCES element_instance (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_advertised_port (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  port_number BIGINT,\n  name        TEXT,\n  description TEXT,\n  element_id  INTEGER REFERENCES element (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_users (\n  ID      INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id INTEGER REFERENCES users (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  fog_id  TEXT REFERENCES iofogs (UUID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  UNIQUE (user_id, fog_id)\n);\nINSERT INTO iofog_users VALUES (193, 43, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nCREATE TABLE element_fog_types (\n  ID            INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_id    INTEGER REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  iofog_type_id INTEGER REFERENCES iofog_type (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO element_fog_types VALUES (1, 1, 1);\nINSERT INTO element_fog_types VALUES (2, 2, 1);\nINSERT INTO element_fog_types VALUES (3, 3, 1);\nINSERT INTO element_fog_types VALUES (4, 4, 1);\nINSERT INTO element_fog_types VALUES (5, 5, 1);\nINSERT INTO element_fog_types VALUES (6, 8, 1);\nINSERT INTO element_fog_types VALUES (7, 49, 1);\nINSERT INTO element_fog_types VALUES (8, 58, 1);\nCREATE TABLE network_pairing (\n  ID                INTEGER PRIMARY KEY AUTOINCREMENT,\n  IsPublicPort      TINYINT(1),\n  instanceId1       TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  instanceId2       TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elementId1        TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elementId2        TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  networkElementId1 TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  networkElementId2 TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elemen1PortId     INTEGER REFERENCES element_instance_port (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  satellitePortId   INTEGER REFERENCES satellite_port (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_instance_connections (\n  ID                           INTEGER PRIMARY KEY AUTOINCREMENT,\n  source_element_instance      TEXT,\n  destination_element_instance TEXT\n);\nCREATE TABLE element (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  name            TEXT,\n  description     TEXT,\n  category        TEXT,\n  container_image TEXT,\n  publisher       TEXT,\n  diskRequired    BIGINT,\n  ram_required    BIGINT,\n  picture         BIGINT,\n  config          TEXT,\n  is_public       TINYINT(1),\n  org_id          BIGINT,\n  registry_id     INTEGER REFERENCES registry (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO element VALUES\n  (1, 'Stream Viewer', 'The built-in stream viewer for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:stream-viewer-1.0', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (2, 'Debug Console', 'The built-in debug console for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:debug', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (3, 'Networking Tool', 'The built-in networking tool for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:core-networking-1-12', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (4, 'Hello Web Demo', 'A simple web server for you to test your ioFog', 'Demos', 'iotracks/catalog:hello-web-1',\n      'iotracks', 0, 0, 'images/build/4.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (5, 'RESTBlue', 'Bluetooth RESTful API', 'Utilities', 'iotracks/catalog:bluetooth-rest-api-v0.5', 'SYSTEM', 0, 0,\n      'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (6, 'HAL', 'HAL container', 'Utilities', 'iotracks/catalog:hal-0.1', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (7, 'HAL ARM', 'ARM HAL container', 'Utilities', 'iotracks/catalog:hal-0.1-arm', 'SYSTEM', 0, 0, 'none.png', NULL,\n      1, 0, 1);\nINSERT INTO element VALUES\n  (8, 'Open Weather Map Data', 'A stream of data from the Open Weather Map API in JSON format', 'Sensors',\n      'iotracks/catalog:open-weather-map-v1.06', 'iotracks', 0, 0, 'images/build/8.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES (49, 'JSON REST API', 'A configurable REST API that gives JSON output', 'Utilities',\n                                'iotracks/catalog:json-rest-api-v1.04', 'iotracks', 0, 0, 'images/build/49.png', NULL,\n                                1, 0, 1);\nINSERT INTO element VALUES (58, 'Temperature Converter', 'A simple temperature format converter', 'Utilities',\n                                'iotracks/catalog:temperature-conversion-v1.03', 'iotracks', 0, 0,\n                                'images/build/58.png', NULL, 1, 0, 1);\nCREATE TABLE element_input_type (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_key BIGINT REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  info_type   TEXT,\n  info_format TEXT\n);\nCREATE TABLE element_output_type (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_key BIGINT REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  info_type   TEXT,\n  info_format TEXT\n);\nCREATE TABLE satellite_port (\n  ID                                INTEGER PRIMARY KEY AUTOINCREMENT,\n  port1                             BIGINT,\n  port2                             BIGINT,\n  max_connections_port1             BIGINT,\n  max_connection_port2              BIGINT,\n  passcode_port1                    TEXT,\n  passcode_port2                    TEXT,\n  heartbeat_absence_threshold_port1 BIGINT,\n  heartbeat_absence_threshold_port2 BIGINT,\n  updated_by                        BIGINT,\n  created_at                        DATETIME NOT NULL,\n  updated_at                        DATETIME NOT NULL,\n  satellite_id                      INTEGER REFERENCES satellite (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  mapping_id                        TEXT\n);\nCREATE TABLE iofog_provision_keys (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  provisioning_string VARCHAR(100),\n  expiration_time     BIGINT,\n  iofog_uuid          TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO iofog_provision_keys VALUES (79, 'jX3QfQvQ', 1517402261932, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nCREATE TABLE iofogs (\n  UUID                    TEXT PRIMARY KEY,\n  Name                    TEXT    DEFAULT ('Unnamed ioFog 1'),\n  Location                TEXT,\n  Latitude                TEXT,\n  Longitude               TEXT,\n  OrgID                   BIGINT,\n  Description             TEXT,\n  created_at              DATETIME,\n  updated_at              DATETIME,\n  LastActive              BIGINT,\n  Token                   TEXT,\n  DaemonStatus            TEXT    DEFAULT 'UNKNOWN',\n  DaemonOperatingDuration BIGINT  DEFAULT 0,\n  DaemonLastStart         BIGINT,\n  MemoryUsage             FLOAT   DEFAULT 0,\n  DiskUsage               FLOAT   DEFAULT 0,\n  CPUUsage                FLOAT   DEFAULT 0,\n  MemoryViolation         TEXT,\n  DiskViolation           TEXT,\n  CPUViolation            TEXT,\n  ElementStatus           TEXT,\n  RepositoryCount         BIGINT,\n  RepositoryStatus        TEXT,\n  SystemTime              BIGINT,\n  LastStatusTime          BIGINT,\n  IPAddress               TEXT    DEFAULT '0.0.0.0',\n  ProcessedMessages       BIGINT  DEFAULT 0,\n  ElementMessageCounts    TEXT,\n  MessageSpeed            BIGINT,\n  LastCommandTime         BIGINT,\n  NetworkInterface        TEXT    DEFAULT 'eth0',\n  DockerURL               TEXT    DEFAULT 'unix:///var/run/docker.sock',\n  DiskLimit               FLOAT   DEFAULT 50,\n  DiskDirectory           TEXT    DEFAULT ('/var/lib/iofog/'),\n  MemoryLimit             FLOAT   DEFAULT 4096,\n  CPULimit                FLOAT   DEFAULT 80,\n  LogLimit                FLOAT   DEFAULT 10,\n  LogDirectory            TEXT    DEFAULT ('/var/log/iofog/'),\n  Debug                   INTEGER,\n  Viewer                  INTEGER,\n  Bluetooth               INTEGER,\n  hal                     INTEGER DEFAULT (0),\n  IsolatedDockerContainer INTEGER DEFAULT (1),\n  LogFileCount            BIGINT  DEFAULT 10,\n  Version                 TEXT,\n  StatusFrequency         INTEGER DEFAULT (10),\n  ChangeFrequency         INTEGER DEFAULT (20),\n  Proxy                   TEXT DEFAULT (''),\n  typeKey                 INTEGER REFERENCES iofog_type (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_type (\n  ID                     INTEGER PRIMARY KEY AUTOINCREMENT,\n  Name                   TEXT,\n  Image                  TEXT,\n  Description            TEXT,\n  StreamViewerElementKey BIGINT,\n  consoleElementKey      BIGINT,\n  NetworkElementKey      BIGINT,\n  HalElementKey          BIGINT,\n  BluetoothElementKey    BIGINT\n);\nINSERT INTO iofog_type VALUES (1, 'Standard Linux (x86)', 'iointegrator1.png',\n                               'A standard Linux server of at least moderate processing power and capacity. Compatible with common Linux types such as Ubuntu, Red Hat, and CentOS.',\n                               1, 2, 3, 6, 5);\nINSERT INTO iofog_type VALUES (2, 'ARM Linux', 'iointegrator2.png',\n                               'A version of ioFog meant to run on Linux systems with ARM processors. Microservices for this ioFog type will be tailored to ARM systems.',\n                               1, 2, 3, 7, 5);\nCREATE TABLE element_instance (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  UUID                TEXT UNIQUE,\n  track_id            BIGINT,\n  element_key         BIGINT,\n  config              BIGINT,\n  name                TEXT,\n  updated_by          BIGINT,\n  config_last_updated BIGINT,\n  is_stream_viewer    TINYINT(1),\n  is_debug_console    TINYINT(1),\n  is_hal              TINYINT(1),\n  is_manager          TINYINT(1),\n  is_network          TINYINT(1),\n  registry_id         BIGINT,\n  rebuild             TINYINT(1),\n  root_host_access    TINYINT(1),\n  log_size            TINYINT(1),\n  created_at          DATETIME NOT NULL,\n  updated_at          DATETIME NOT NULL,\n  volume_mappings     TEXT,\n  element_id          INTEGER REFERENCES element (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  iofog_uuid          TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_access_tokens (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id         INTEGER,\n  expiration_time BIGINT,\n  token           TEXT,\n  iofog_uuid      TEXT REFERENCES iofogs (UUID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE\n);\nCREATE TABLE users (\n  ID                INTEGER PRIMARY KEY AUTOINCREMENT,\n  first_name        VARCHAR(100),\n  last_name         VARCHAR(100),\n  email             VARCHAR(100),\n  password          VARCHAR(100),\n  temp_password     TEXT,\n  email_activated   INTEGER,\n  user_access_token TEXT\n);\nINSERT INTO users VALUES (43, 'Admin', 'Admin', 'admin@admin.admin', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b6');\nCREATE TABLE email_activation_code (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id         INTEGER REFERENCES users (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  activation_code TEXT,\n  expiration_time BIGINT\n);\nINSERT INTO email_activation_code VALUES (35, 43, 'XPMDjGP6fbQdB4py', 1517495034248);\nCREATE TABLE registry (\n  ID            INTEGER PRIMARY KEY AUTOINCREMENT,\n  url           TEXT,\n  is_public     INTEGER,\n  secure        INTEGER,\n  certificate   TEXT,\n  requires_cert INTEGER,\n  user_name     TEXT,\n  password      TEXT,\n  user_email    BIGINT,\n  iofog_uuid    TEXT REFERENCES iofogs (UUID)\n);\nINSERT INTO registry VALUES (1, 'registry.hub.docker.com', 1, 1, '', 0, 'iointegrator', '0nTh3Edge2015', 'admin@iotracks.com', NULL);\nCREATE TABLE iofog_change_tracking (\n\t`ID`\tINTEGER PRIMARY KEY AUTOINCREMENT,\n\t`container_config`\tBIGINT,\n\t`reboot`\tBOOLEAN,\n\t`container_list`\tBIGINT,\n\t`config`\tBIGINT,\n\t`routing`\tBIGINT,\n\t`registries`\tBIGINT,\n\t`proxy` BIGINT,\n\t`iofog_uuid`\tTEXT,\n\tFOREIGN KEY(`iofog_uuid`) REFERENCES iofogs ( UUID ) ON DELETE SET NULL ON UPDATE CASCADE\n);\nCREATE TABLE proxy (\n  `ID`          INTEGER PRIMARY KEY AUTOINCREMENT,\n  `username`    TEXT,\n  `password`    TEXT,\n  `host`        TEXT,\n  `remote_port` INTEGER,\n  `local_port`  INTEGER             DEFAULT 22,\n  `rsa_key`     TEXT,\n  `close`       BOOLEAN             DEFAULT FALSE,\n  `iofog_uuid`  TEXT,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE hw_info (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `info`       TEXT,\n  `iofog_uuid` TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE usb_info (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `info`       TEXT,\n  `iofog_uuid` TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO iofog_change_tracking VALUES(1,1517401049283,0,1517472938429,1517472938429,1517401049283,1517401049283, 1517401049283, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nDELETE FROM sqlite_sequence;\nINSERT INTO sqlite_sequence VALUES ('config', 52);\nINSERT INTO sqlite_sequence VALUES ('satellite', 9);\nINSERT INTO sqlite_sequence VALUES ('data_tracks', 90);\nINSERT INTO sqlite_sequence VALUES ('routing', 196);\nINSERT INTO sqlite_sequence VALUES ('element_instance_port', 650);\nINSERT INTO sqlite_sequence VALUES ('iofog_console', 256);\nINSERT INTO sqlite_sequence VALUES ('stream_viewer', 257);\nINSERT INTO sqlite_sequence VALUES ('instance_track', 0);\nINSERT INTO sqlite_sequence VALUES ('element_advertised_port', 0);\nINSERT INTO sqlite_sequence VALUES ('iofog_users', 193);\nINSERT INTO sqlite_sequence VALUES ('element_fog_types', 181);\nINSERT INTO sqlite_sequence VALUES ('network_pairing', 644);\nINSERT INTO sqlite_sequence VALUES ('element_instance_connections', 68);\nINSERT INTO sqlite_sequence VALUES ('element', 226);\nINSERT INTO sqlite_sequence VALUES ('element_input_type', 100);\nINSERT INTO sqlite_sequence VALUES ('element_output_type', 92);\nINSERT INTO sqlite_sequence VALUES ('satellite_port', 639);\nINSERT INTO sqlite_sequence VALUES ('iofog_provision_keys', 79);\nINSERT INTO sqlite_sequence VALUES ('iofog_type', 2);\nINSERT INTO sqlite_sequence VALUES ('element_instance', 1048);\nINSERT INTO sqlite_sequence VALUES ('iofog_access_tokens', 21);\nINSERT INTO sqlite_sequence VALUES ('users', 43);\nINSERT INTO sqlite_sequence VALUES ('email_activation_code', 35);\nINSERT INTO sqlite_sequence VALUES ('registry', 1);\nINSERT INTO sqlite_sequence VALUES ('iofog_change_tracking', 1);\n\nINSERT INTO config (key, value) VALUES ('port', '4443');\nINSERT INTO config (key, value) VALUES ('ssl_key', 'privkey.pem');\nINSERT INTO config (key, value) VALUES ('intermediate_cert', 'my-private-root-ca.cert.pem');\nINSERT INTO config (key, value) VALUES ('ssl_cert', 'fullchain.pem');\n\nCOMMIT;\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- db/default.sql	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ db/default.sql	(date 1518773416000)
@@ -289,7 +289,8 @@
   Version                 TEXT,
   StatusFrequency         INTEGER DEFAULT (10),
   ChangeFrequency         INTEGER DEFAULT (20),
-  Proxy                   TEXT DEFAULT (''),
+  ScanFrequency           INTEGER DEFAULT (20),
+  Proxy                   TEXT    DEFAULT (''),
   typeKey                 INTEGER REFERENCES iofog_type (ID)
     ON DELETE SET NULL
     ON UPDATE CASCADE
Index: src/server/controllers/api/fogController.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file fogController.js\n * @author Zishan Iqbal\n * @description This file includes the implementation of the status end-point\n */\n\nimport async from 'async';\nimport express from 'express';\n\nimport ChangeTrackingService from '../../services/changeTrackingService';\nimport ComsatService from '../../services/comsatService';\nimport ConsoleService from '../../services/consoleService';\nimport ElementService from '../../services/elementService'\nimport ElementInstanceService from '../../services/elementInstanceService';\nimport ElementInstancePortService from '../../services/elementInstancePortService';\nimport FogAccessTokenService from '../../services/fogAccessTokenService';\nimport FogProvisionKeyService from '../../services/fogProvisionKeyService';\nimport FogService from '../../services/fogService';\nimport FogTypeService from '../../services/fogTypeService';\nimport FogUserService from '../../services/fogUserService';\nimport NetworkPairingService from '../../services/networkPairingService';\nimport SatelliteService from '../../services/satelliteService';\nimport SatellitePortService from '../../services/satellitePortService';\nimport StreamViewerService from '../../services/streamViewerService';\nimport UserService from '../../services/userService';\n\nimport AppUtils from '../../utils/appUtils';\nimport logger from '../../utils/winstonLogs';\n\n\n/********************************************* EndPoints ******************************************************/\n\n/**************************** Fog-Controller Status EndPoint (Get: /api/v2/status) ***************************/\nconst getFogControllerStatusEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n  let milliseconds = new Date().getTime();\n  logger.info(\"Endpoint served successfully\");\n  res.status(200);\n  res.send({\n    \"status\": \"ok\",\n    \"timestamp\": milliseconds\n  });\n};\n\n/******** Fog Instances List By UserID EndPoint (Get: /api/v2/authoring/integrator/instances/list/:t\n Post: /api/v2/authoring/fabric/instances/list  ) *******/\nconst fogInstancesListEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n  let params = {},\n\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n\n    fogInstanceForUserProps = {\n      userId: 'user.id',\n      setProperty: 'fogInstance'\n    };\n\n  params.bodyParams = req.params;\n\n  if (req.body.t) {\n    params.bodyParams = req.body;\n  }\n\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n    async.apply(UserService.getUser, userProps, params),\n    async.apply(FogService.getFogInstanceForUser, fogInstanceForUserProps)\n\n  ], function (err, result) {\n    AppUtils.sendResponse(res, err, 'instances', params.fogInstance, result);\n  })\n};\n\n/******************** Fog Instance Create EndPoint (Get: /api/v2/instance/create/type/:type) ******************/\nconst fogInstanceCreateEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    fogTypeProps = {\n      fogTypeId: 'bodyParams.type',\n      setProperty: 'fogType'\n    },\n\n    createFogProps = {\n      name: 'bodyParams.name',\n      location: 'bodyParams.location',\n      latitude: 'bodyParams.latitude',\n      longitude: 'bodyParams.longitude',\n      description: 'bodyParams.description',\n      fogType: 'bodyParams.type',\n      setProperty: 'fogInstance'\n    },\n    createChangeTrackingProps = {\n      fogInstanceId: 'fogInstance.uuid',\n      setProperty: null\n    },\n\n    createFogUserProps = {\n      userId: 'user.id',\n      instanceId: 'fogInstance.uuid',\n      setProperty: 'fogUser'\n    };\n\n  params.bodyParams = req.params;\n  params.bodyParams.t = req.query.t;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(FogTypeService.getFogTypeDetail, fogTypeProps),\n      async.apply(FogService.createFogInstance, createFogProps),\n      async.apply(ChangeTrackingService.createFogChangeTracking, createChangeTrackingProps),\n      async.apply(FogUserService.createFogUser, createFogUserProps),\n    ],\n    function (err, result) {\n      let output;\n      if (!err) {\n        output = params.fogInstance.uuid;\n      }\n      AppUtils.sendResponse(res, err, 'instanceId', output, result);\n    });\n};\n\n/******************** Get Fog List EndPoint (Get: /api/v2/instance/getfabriclist) ******************/\n// const getFogListEndPoint = function(req, res){\n//   logger.info(\"Endpoint hit: \"+ req.originalUrl);\n// \tlet params = {},\n// \t\tuserProps = {\n//       \t\tuserId: 'bodyParams.t',\n//       \t\tsetProperty: 'user'\n//     \t},\n//     \tfogListProps = {\n//       \t\tsetProperty: 'fogList'\n//     \t};\n\n// \tparams.bodyParams = req.params;\n// \tparams.bodyParams.t = req.query.t;\n// \tlogger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n// \tasync.waterfall([\n// \t\tasync.apply(UserService.getUser, userProps, params),\n// \t\tasync.apply(FogService.getFogList, fogListProps)\n// \t],\n// \tfunction(err, result) {\n// \t\tlet errMsg = 'Internal error: ' + result;\n// \t\tAppUtils.sendResponse(res, err, 'fogList', params.fogList, errMsg);\n// \t});\n// };\n\n/******************** Get Fog Types EndPoint (Get: /api/v2/authoring/fabric/types/list) ******************/\nconst getFogTypesEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    fogTypesListProps = {\n      setProperty: 'fogTypesList'\n    };\n\n  params.bodyParams = req.params;\n  params.bodyParams.t = req.query.t;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(FogTypeService.getFogTypesList, fogTypesListProps)\n    ],\n    function (err, result) {\n      let errMsg = 'Internal error: ' + result;\n      AppUtils.sendResponse(res, err, 'fogTypes', params.fogTypesList, errMsg);\n    });\n};\n\n/***************** Fog Instance Delete EndPoint (Post: /api/v2/authoring/fabric/instance/delete) *************/\nconst fogInstanceDeleteEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    instanceProps = {\n      instanceId: 'bodyParams.instanceId'\n    };\n\n  params.bodyParams = req.body;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(ChangeTrackingService.deleteChangeTracking, instanceProps),\n      async.apply(FogUserService.deleteFogUserByInstanceId, instanceProps),\n      async.apply(StreamViewerService.deleteStreamViewerByFogInstanceId, instanceProps),\n      async.apply(ConsoleService.deleteConsoleByFogInstanceId, instanceProps),\n      async.apply(FogProvisionKeyService.deleteProvisonKeyByInstanceId, instanceProps),\n      async.apply(FogService.deleteFogInstance, instanceProps)\n    ],\n    function (err, result) {\n      let errMsg = 'Internal error: ' + result;\n      AppUtils.sendResponse(res, err, 'instanceId', params.bodyParams.instanceId, errMsg);\n    });\n};\n\n/*********** Integrator Instance Delete EndPoint (Post: /api/v2/authoring/integrator/instance/delete) **********/\nconst integratorInstanceDeleteEndPoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    instanceProps = {\n      instanceId: 'bodyParams.instanceId'\n    },\n    updateByFogUuIdProps = {\n      fogInstanceId: 'bodyParams.instanceId',\n      updatedFogId: null\n    },\n    fogProps = {\n      fogId: 'bodyParams.instanceId'\n    },\n    fogUserProps = {\n      instanceId: 'bodyParams.instanceId',\n      setProperty: 'fogUser'\n    },\n    deleteFogUserProps = {\n      userId: 'fogUser.user_id',\n      instanceId: 'bodyParams.instanceId'\n    };\n\n  params.bodyParams = req.body;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(FogService.getFogInstance, fogProps),\n      async.apply(ElementInstanceService.updateElemInstanceByFogUuId, updateByFogUuIdProps),\n      async.apply(ChangeTrackingService.deleteChangeTracking, instanceProps),\n      async.apply(FogUserService.getFogUserByInstanceId, fogUserProps),\n      async.apply(FogAccessTokenService.deleteFogAccessTokenByFogId, fogProps),\n      async.apply(FogUserService.deleteFogUserByInstanceIdAndUserId, deleteFogUserProps),\n      //async.apply(UserService.deleteByUserId, instanceProps),\n      async.apply(StreamViewerService.deleteStreamViewerByFogInstanceId, instanceProps),\n      async.apply(ConsoleService.deleteConsoleByFogInstanceId, instanceProps),\n      async.apply(FogProvisionKeyService.deleteProvisonKeyByInstanceId, instanceProps),\n      async.apply(FogService.deleteFogInstance, instanceProps)\n    ],\n    function (err, result) {\n      let errMsg = 'Internal error: ' + result;\n      AppUtils.sendResponse(res, err, 'instanceid', params.bodyParams.instanceId, errMsg);\n    });\n};\n\n/*********** Get Fog Details EndPoint (Post: /api/v2/authoring/fabric/details) **********/\nconst getFogDetailsEndpoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    instanceProps = {\n      instanceId: 'bodyParams.instanceId',\n      setProperty: 'fogInstances'\n    };\n\n  params.bodyParams = req.body;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(FogService.getFogInstanceDetails, instanceProps)\n    ],\n    function (err, result) {\n      AppUtils.sendResponse(res, err, 'fog', params.fogInstances, result);\n    });\n};\n\n/*********** Update Fog settings EndPoint (Post: /api/v2/authoring/fabric/instances/settings/update) **********/\nconst updateFogSettingsEndpoint = function (req, res) {\n  logger.info(\"Endpoint hit: \" + req.originalUrl);\n\n  let params = {},\n    userProps = {\n      userId: 'bodyParams.t',\n      setProperty: 'user'\n    },\n    instanceProps = {\n      fogId: 'bodyParams.instanceId',\n      setProperty: 'fogInstance'\n    },\n    fogTypeProps = {\n      fogTypeId: 'fogInstance.typeKey',\n      setProperty: 'fogTypeData'\n    };\n\n  params.bodyParams = req.body;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n      async.apply(UserService.getUser, userProps, params),\n      async.apply(FogService.getFogInstance, instanceProps),\n      async.apply(FogTypeService.getFogTypeDetail, fogTypeProps),\n      bluetoothElementForFog,\n      debugConsoleForFog,\n      streamViewerForFog,\n      halForFog,\n      updateFog,\n      updateChangeTracking\n    ],\n    function (err, result) {\n      if (!err) {\n        let successLabelArr, successValueArr;\n\n        successLabelArr = ['ppp', 'ttt'],\n          successValueArr = [params.bodyParams.bluetooth, '1'];\n\n        AppUtils.sendMultipleResponse(res, err, successLabelArr, successValueArr, result);\n      } else {\n        AppUtils.sendResponse(res, err, '', '', result);\n      }\n    });\n}\n\nconst updateFog = function (params, callback) {\n  let fogProps = {\n    instanceId: 'bodyParams.instanceId',\n    updatedFog: {\n      name: params.bodyParams.name,\n      description: params.bodyParams.description,\n      location: params.bodyParams.location,\n      networkinterface: params.bodyParams.networkInterface,\n      dockerurl: params.bodyParams.dockerUrl,\n      disklimit: params.bodyParams.diskLimit,\n      diskdirectory: params.bodyParams.diskDirectory,\n      memorylimit: params.bodyParams.memoryLimit,\n      cpulimit: params.bodyParams.cpuLimit,\n      loglimit: params.bodyParams.logLimit,\n      logdirectory: params.bodyParams.logDirectory,\n      logfilecount: params.bodyParams.logFileCount,\n      debug: params.bodyParams.debug,\n      viewer: params.bodyParams.viewer,\n      bluetooth: params.bodyParams.bluetooth,\n      statusfrequency: params.bodyParams.statusFrequency,\n      changefrequency: params.bodyParams.changeFrequency,\n      proxy: params.bodyParams.proxy,\n      isolateddockercontainer: params.bodyParams.docker\n    }\n  };\n  FogService.updateFogInstance(fogProps, params, callback);\n}\n\nconst streamViewerForFog = function (params, callback) {\n  if (params.bodyParams.viewer && (params.bodyParams.viewer != params.fogInstance.viewer)) {\n    params.isViewer = 1;\n    if (params.bodyParams.viewer > 0) {\n      let elementProps = {\n          networkElementId: 'fogTypeData.streamViewerElementKey',\n          setProperty: 'streamViewerElement'\n        },\n        streamViewerProps = {\n          elementKey: 'fogTypeData.streamViewerElementKey',\n          userId: 'user.id',\n          fogInstanceId: 'fogInstance.uuid',\n          registryId: 'streamViewerElement.registry_id',\n          setProperty: 'streamViewerElementInstnace'\n        },\n        streamViewerPortProps = {\n          userId: 'user.id',\n          internalPort: 80,\n          externalPort: 60400,\n          elementId: 'streamViewerElementInstnace.uuid',\n          setProperty: 'streamViewerPort'\n        },\n        elementInstanceProps = {\n          updatedData: {\n            last_updated: new Date().getTime(),\n            updatedBy: params.user.id\n          },\n          elementId: 'streamViewerElementInstnace.uuid'\n        },\n        satelliteProps = {\n          satelliteId: 'streamViewerSatellitePort.satellite_id',\n          setProperty: 'streamViewerSatellite'\n        },\n        networkElementProps = {\n          networkElementId: 'fogTypeData.networkElementKey',\n          setProperty: 'streamViewerNetworkElement'\n        },\n        networkPairingProps = {\n          instanceId1: 'fogInstance.uuid',\n          instanceId2: null,\n          elementId1: 'streamViewerElementInstnace.uuid',\n          elementId2: null,\n          networkElementId1: 'newStreamViewerNetworkElementInstance.uuid',\n          networkElementId2: null,\n          isPublic: true,\n          elementPortId: 'streamViewerPort.id',\n          satellitePortId: 'streamViewerSatellitePort.id',\n          setProperty: 'streamViewerNetworkPairingObj'\n        },\n        changeTrackingProps = {\n          fogInstanceId: 'bodyParams.instanceId',\n          changeObject: {\n            containerConfig: new Date().getTime(),\n            containerList: new Date().getTime()\n          }\n        };\n\n      async.waterfall([\n          async.apply(ElementService.getNetworkElement, elementProps, params),\n          async.apply(ElementInstanceService.createStreamViewerElement, streamViewerProps),\n          async.apply(ElementInstancePortService.createElementInstancePortByPortValue, streamViewerPortProps),\n          async.apply(ElementInstanceService.updateElemInstance, elementInstanceProps),\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps),\n          ComsatService.openPortOnRadomComsat,\n          createStreamViewerSatellitePort,\n          async.apply(SatelliteService.getSatelliteById, satelliteProps),\n          async.apply(ElementService.getNetworkElement, networkElementProps),\n          createStreamViewerNetworkElementInstance,\n          async.apply(NetworkPairingService.createNetworkPairing, networkPairingProps),\n          createStreamViewerConsole,\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps)\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    }\n    else {\n      let elementInstanceProps = {\n        instanceId: 'bodyParams.instanceId',\n      };\n      async.waterfall([\n          async.apply(ElementInstanceService.deleteStreamViewerInstances, elementInstanceProps, params),\n          async.apply(StreamViewerService.deleteStreamViewerByFogInstanceId, elementInstanceProps)\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    }\n  }\n  else {\n    callback(null, params);\n  }\n}\nconst createStreamViewerConsole = function (params, callback) {\n  let createStreamProps = {\n    streamViewerObj: {\n      version: 1,\n      apiBaseUrl: 'https://' + params.streamViewerSatellite.domain + ':' + params.streamViewerSatellitePort.port2,\n      accessToken: JSON.parse(params.streamViewerElementInstnace.config).accesstoken,\n      elementId: params.streamViewerElementInstnace.uuid,\n      iofog_uuid: params.fogInstance.uuid\n    }\n  };\n  StreamViewerService.createStreamViewer(createStreamProps, params, callback);\n}\n\nconst createStreamViewerNetworkElementInstance = function (params, callback) {\n  let config = {\n      'mode': 'public',\n      'host': params.streamViewerSatellite.domain,\n      'port': params.streamViewerSatellitePort.port1,\n      'connectioncount': 60,\n      'passcode': params.comsatPort.passcode1,\n      'localhost': 'iofog',\n      'localport': 60400,\n      'heartbeatfrequency': 20000,\n      'heartbeatabsencethreshold': 60000\n    },\n    elementInstanceProps = {\n      elementInstance: {\n        uuid: AppUtils.generateInstanceId(32),\n        trackId: 0,\n        element_key: params.fogTypeData.networkElementKey,\n        config: JSON.stringify(config),\n        name: 'Network for Stream Viewer',\n        last_updated: new Date().getTime(),\n        updatedBy: params.user.id,\n        configLastUpdated: new Date().getTime(),\n        isStreamViewer: false,\n        isDebugConsole: false,\n        isManager: false,\n        isNetwork: true,\n        registryId: params.streamViewerNetworkElement.registry_id,\n        rebuild: false,\n        rootHostAccess: false,\n        logSize: 50,\n        iofog_uuid: params.bodyParams.instanceId,\n        volumeMappings: '{\"volumemappings\": []}'\n      },\n      setProperty: 'newStreamViewerNetworkElementInstance'\n    };\n\n  ElementInstanceService.createElementInstanceObj(elementInstanceProps, params, callback);\n}\n\nconst createStreamViewerSatellitePort = function (params, callback) {\n  let satellitePortProps = {\n    satellitePortObj: {\n      port1: params.comsatPort.port1,\n      port2: params.comsatPort.port2,\n      maxConnectionsPort1: 60,\n      maxConnectionsPort2: 0,\n      passcodePort1: params.comsatPort.passcode1,\n      passcodePort2: params.comsatPort.passcode2,\n      heartBeatAbsenceThresholdPort1: 60000,\n      heartBeatAbsenceThresholdPort2: 0,\n      satellite_id: params.satellite.id,\n      mappingId: params.comsatPort.id\n    },\n    setProperty: 'streamViewerSatellitePort'\n  };\n  SatellitePortService.createSatellitePort(satellitePortProps, params, callback);\n}\n\nconst debugConsoleForFog = function (params, callback) {\n  if (params.bodyParams.debug && (params.bodyParams.debug != params.fogInstance.debug)) {\n    params.isDebug = 1;\n    if (params.bodyParams.debug > 0) {\n      let elementProps = {\n          networkElementId: 'fogTypeData.consoleElementKey',\n          setProperty: 'debugElement'\n        },\n        debugConsoleProps = {\n          elementKey: 'fogTypeData.consoleElementKey',\n          userId: 'user.id',\n          fogInstanceId: 'fogInstance.uuid',\n          registryId: 'debugElement.registry_id',\n          setProperty: 'debugConsole'\n        },\n        debugConsolePortProps = {\n          userId: 'user.id',\n          internalPort: 80,\n          externalPort: 60401,\n          elementId: 'debugConsole.uuid',\n          setProperty: 'debugConsolePort'\n        },\n        elementInstanceProps = {\n          updatedData: {\n            last_updated: new Date().getTime(),\n            updatedBy: params.user.id\n          },\n          elementId: 'debugConsole.uuid'\n        },\n        satelliteProps = {\n          satelliteId: 'satellitePort.satellite_id',\n          setProperty: 'satellite'\n        },\n        networkElementProps = {\n          networkElementId: 'fogTypeData.networkElementKey',\n          setProperty: 'networkElement'\n        },\n        networkPairingProps = {\n          instanceId1: 'fogInstance.uuid',\n          instanceId2: null,\n          elementId1: 'debugConsole.uuid',\n          elementId2: null,\n          networkElementId1: 'newNetworkElementInstance.uuid',\n          networkElementId2: null,\n          isPublic: true,\n          elementPortId: 'debugConsolePort.id',\n          satellitePortId: 'satellitePort.id',\n          setProperty: 'networkPairingObj'\n        },\n        changeTrackingProps = {\n          fogInstanceId: 'bodyParams.instanceId',\n          changeObject: {\n            containerConfig: new Date().getTime(),\n            containerList: new Date().getTime()\n          }\n        };\n\n      async.waterfall([\n          async.apply(ElementService.getNetworkElement, elementProps, params),\n          async.apply(ElementInstanceService.createDebugConsole, debugConsoleProps),\n          async.apply(ElementInstancePortService.createElementInstancePortByPortValue, debugConsolePortProps),\n          async.apply(ElementInstanceService.updateElemInstance, elementInstanceProps),\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps),\n          ComsatService.openPortOnRadomComsat,\n          createSatellitePort,\n          async.apply(SatelliteService.getSatelliteById, satelliteProps),\n          async.apply(ElementService.getNetworkElement, networkElementProps),\n          createNetworkElementInstance,\n          async.apply(NetworkPairingService.createNetworkPairing, networkPairingProps),\n          createConsole,\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps)\n\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    }\n    else {\n      let elementInstanceProps = {\n        instanceId: 'bodyParams.instanceId',\n      };\n\n      async.waterfall([\n          async.apply(ElementInstanceService.deleteDebugConsoleInstances, elementInstanceProps, params),\n          async.apply(ConsoleService.deleteConsoleByFogInstanceId, elementInstanceProps)\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    }\n  }\n  else {\n    callback(null, params);\n  }\n}\n\nconst createConsole = function (params, callback) {\n  let createConsoleProps = {\n    consoleObj: {\n      version: 1,\n      apiBaseUrl: 'https://' + params.satellite.domain + ':' + params.satellitePort.port2,\n      accessToken: JSON.parse(params.debugConsole.config).accesstoken,\n      elementId: params.debugConsole.uuid,\n      iofog_uuid: params.fogInstance.uuid\n    }\n  };\n  ConsoleService.createConsole(createConsoleProps, params, callback)\n}\n\nconst createNetworkElementInstance = function (params, callback) {\n  let config = {\n      'mode': 'public',\n      'host': params.satellite.domain,\n      'port': params.satellitePort.port1,\n      'connectioncount': 60,\n      'passcode': params.comsatPort.passcode1,\n      'localhost': 'iofog',\n      'localport': 60401,\n      'heartbeatfrequency': 20000,\n      'heartbeatabsencethreshold': 60000\n    },\n    elementInstanceProps = {\n      elementInstance: {\n        uuid: AppUtils.generateInstanceId(32),\n        trackId: 0,\n        element_key: params.fogTypeData.networkElementKey,\n        config: JSON.stringify(config),\n        name: 'Network for Debug Console',\n        last_updated: new Date().getTime(),\n        updatedBy: params.user.id,\n        configLastUpdated: new Date().getTime(),\n        isStreamViewer: false,\n        isDebugConsole: false,\n        isManager: false,\n        isNetwork: true,\n        registryId: params.networkElement.registry_id,\n        rebuild: false,\n        rootHostAccess: false,\n        logSize: 50,\n        iofog_uuid: params.bodyParams.instanceId,\n        volumeMappings: '{\"volumemappings\": []}'\n      },\n      setProperty: 'newNetworkElementInstance'\n    };\n\n  ElementInstanceService.createElementInstanceObj(elementInstanceProps, params, callback);\n}\n\n\nconst createSatellitePort = function (params, callback) {\n  let satellitePortProps = {\n    satellitePortObj: {\n      port1: params.comsatPort.port1,\n      port2: params.comsatPort.port2,\n      maxConnectionsPort1: 60,\n      maxConnectionsPort2: 0,\n      passcodePort1: params.comsatPort.passcode1,\n      passcodePort2: params.comsatPort.passcode2,\n      heartBeatAbsenceThresholdPort1: 60000,\n      heartBeatAbsenceThresholdPort2: 0,\n      satellite_id: params.satellite.id,\n      mappingId: params.comsatPort.id\n    },\n    setProperty: 'satellitePort'\n  };\n  SatellitePortService.createSatellitePort(satellitePortProps, params, callback);\n}\n\nconst halForFog = (params, callback) => {\n  if (params.bodyParams.hal != params.fogInstance.hal) {\n    params.isHal = 1;\n    if (params.bodyParams.hal > 0) {\n      let elementProps = {\n          networkElementId: 'fogTypeData.halElementKey',\n          setProperty: 'halElement'\n        },\n        changeTrackingProps = {\n          fogInstanceId: 'bodyParams.instanceId',\n          changeObject: {\n            containerConfig: new Date().getTime(),\n            containerList: new Date().getTime()\n          }\n        };\n\n      async.waterfall([\n          async.apply(ElementService.getNetworkElement, elementProps, params),\n          createHalElementInstance,\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps)\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    } else {\n      let elementInstanceProps = {\n        instanceId: 'bodyParams.instanceId',\n        elementKey: 'fogTypeData.halElementKey'\n      };\n      ElementInstanceService.deleteElementInstancesByInstanceIdAndElementKey(elementInstanceProps, params, callback);\n    }\n  } else {\n    callback(null, params);\n  }\n}\n\nconst bluetoothElementForFog = function (params, callback) {\n  if (params.bodyParams.bluetooth != params.fogInstance.bluetooth) {\n    params.isBluetooth = 1;\n    if (params.bodyParams.bluetooth > 0) {\n      let elementProps = {\n          networkElementId: 'fogTypeData.bluetoothElementKey',\n          setProperty: 'bluetoothElement'\n        },\n        changeTrackingProps = {\n          fogInstanceId: 'bodyParams.instanceId',\n          changeObject: {\n            containerConfig: new Date().getTime(),\n            containerList: new Date().getTime()\n          }\n        };\n\n      async.waterfall([\n          async.apply(ElementService.getNetworkElement, elementProps, params),\n          createBluetoothElementInstance,\n          async.apply(ChangeTrackingService.updateChangeTracking, changeTrackingProps)\n        ],\n        function (err, result) {\n          if (!err) {\n            callback(null, params);\n          } else {\n            callback('Error', result);\n          }\n        });\n    } else {\n      let elementInstanceProps = {\n        instanceId: 'bodyParams.instanceId',\n        elementKey: 'fogTypeData.bluetoothElementKey'\n      };\n      ElementInstanceService.deleteElementInstancesByInstanceIdAndElementKey(elementInstanceProps, params, callback);\n    }\n  } else {\n    callback(null, params);\n  }\n}\n\nconst updateChangeTracking = function (params, callback) {\n\tvar changeTrackingProps = {\n\t\tfogInstanceId: 'bodyParams.instanceId',\n\t\tchangeObject: {\n\t\t\tcontainerList: new Date().getTime(),\n\t\t\tconfig: new Date().getTime(),\n            reboot: params.bodyParams.reboot\n\t\t}\n    };\n\n\tChangeTrackingService.updateChangeTracking(changeTrackingProps, params, callback);\n};\n\nconst createBluetoothElementInstance = function (params, callback) {\n  let elementInstanceProps = {\n    elementInstance: {\n      uuid: AppUtils.generateInstanceId(32),\n      trackId: 0,\n      element_key: params.fogTypeData.bluetoothElementKey,\n      config: '{}',\n      configLastUpdated: new Date().getTime(),\n      name: params.bluetoothElement.name,\n      updatedBy: params.user.id,\n      iofog_uuid: params.bodyParams.instanceId,\n      isStreamViewer: false,\n      isDebugConsole: false,\n      isManager: false,\n      isNetwork: false,\n      rootHostAccess: true,\n      logSize: 50,\n      volumeMappings: '{\"volumemappings\": []}',\n      registryId: params.bluetoothElement.registry_id,\n      rebuild: false\n    },\n    setProperty: 'newBluetoothElementInstance'\n  };\n\n  ElementInstanceService.createElementInstanceObj(elementInstanceProps, params, callback);\n}\n\nconst createHalElementInstance = function (params, callback) {\n  let elementInstanceProps = {\n    elementInstance: {\n      uuid: AppUtils.generateInstanceId(32),\n      trackId: 0,\n      element_key: params.fogTypeData.halElementKey,\n      config: '{}',\n      configLastUpdated: new Date().getTime(),\n      name: params.halElement.name,\n      updatedBy: params.user.id,\n      iofog_uuid: params.bodyParams.instanceId,\n      isStreamViewer: false,\n      isDebugConsole: false,\n      isManager: false,\n      isNetwork: false,\n      rootHostAccess: true,\n      logSize: 50,\n      volumeMappings: '{\"volumemappings\": []}',\n      registryId: params.halElement.registry_id,\n      rebuild: false\n    },\n    setProperty: 'newBluetoothElementInstance'\n  };\n\n  ElementInstanceService.createElementInstanceObj(elementInstanceProps, params, callback);\n}\n\n/****************** Add Bluebox EndPoint (Post: /api/v2/authoring/fabric/instance/bluebox/add) ***************/\n// const addBlueboxEndpoint = function (req, res){\n// \tlogger.info(\"Endpoint hit: \"+ req.originalUrl);\n\n// \tlet params = {},\n// \t\tuserProps = {\n// \t\t\tuserId : 'bodyParams.t',\n// \t\t\tsetProperty: 'user'\n// \t\t},\n// \t\tgeneratedIdsProps = {\n// \t\t \tbbid: 'bodyParams.token',\n// \t\t \tsetProperty:'tokenData'\n// \t\t},\n// \t\tfogControllerProps = {\n// \t\t\tuuid: 'tokenData.controllerId',\n// \t\t\tsetProperty: 'fogControllerData'\n// \t\t},\n// \t\tinstanceProps = {\n// \t\t\tfogId: 'tokenData.iofog_uuid',\n// \t\t\tsetProperty: 'fogData'\n// \t\t},\n// \t\tgetTrackingProps = {\n// \t\t\tinstanceId: 'tokenData.iofog_uuid',\n// \t\t\tsetProperty: 'changeTrackingData'\n// \t\t};\n\n// \tparams.bodyParams = req.body;\t\n// \tlogger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n// \tasync.waterfall([\n// \t\tasync.apply(UserService.getUser, userProps, params),\n// \t\tasync.apply(GeneratedIdsService.findGeneratedIdsByBBID, generatedIdsProps),\n// \t\tasync.apply(FogControllerService.findFogControllersByUUID, fogControllerProps),\n// \t\tvalidateFogInstance,\n// \t\tasync.apply(FogService.getFogInstanceOptional, instanceProps),\n// \t\tcreateFogInstanceWithUUID,\n// \t\tupdateGeneratedIdsByBBID,\n// \t\tasync.apply(ChangeTrackingService.getChangeTrackingByInstanceId, getTrackingProps),\n// \t\tcreateChangeTracking,\n\n// \t],\n// \tfunction(err, result) {\n// \t\tAppUtils.sendResponse(res, err, 'test', params, result);\n// \t});\n// }\n\n// const createChangeTracking = function(params, callback){\n// \tif(!params.changeTrackingData){\n// \t\tlet changeTrackingProps = {\n//       \t\tfogInstanceId: 'tokenData.iofog_uuid',\n//       \t\tsetProperty: 'newChangeTracking'\n//     \t};\n\n// \t\tChangeTrackingService.createFogChangeTracking(changeTrackingProps, params, callback);\n// \t}else{\n// \t\tcallback(null, params);\n// \t}\n// }\n\n// const createFogInstanceWithUUID = function(params, callback){\n// \tif (!params.fogData){\n// \t\tlet fogProps = {\n// \t\t\tfogObj :{\n//     \t\t\tuuid: params.tokenData.iofog_uuid,\n//     \t\t\tname: 'My BlueBox',\n//     \t\t\tlocation: '',\n//     \t\t\tlatitude: '',\n//     \t\t\tlongitude: '',\n//     \t\t\tdescription: '',\n//     \t\t\ttoken: '',\n//     \t\t\ttypeKey: '2',\n//     \t\t\tdaemonstatus: 'Not provisioned',\n//     \t\t\tdaemonlaststart: 0,\n//     \t\t\tlastactive: 0,\n//     \t\t\telementstatus: 0,\n//     \t\t\tmemoryviolation: 'no',\n//     \t\t\tdiskviolation: 'no',\n//     \t\t\tcpuviolation: 'no',\n//     \t\t\trepositorycount: 0,\n// \t    \t\trepositorystatus: '',\n//     \t\t\tsystemtime: 0,\n//     \t\t\tlaststatustime: 0,\n//     \t\t\telementmessagecounts: '',\n// \t    \t\tmessagespeed: 0,\n//     \t\t\tlastcommandtime: 0,\n//     \t\t\tversion: ''\n// \t\t\t},\n// \t\t\tsetProperty: 'blueBoxFogIntance'\n// \t\t};\n// \t\tFogService.createFogInstanceWithUUID(fogProps, params, callback);\n// \t}else{\n// \t\tcallback('Error', 'Registration failed: Unable to create fog instance.')\n// \t}\n// }\n\n// const validateFogInstance = function(params, callback){ \n// \tif(params.tokenData.iofog_uuid){\n// \t\tif(params.tokenData.iofog_uuid.length == 32){\n// \t\t\tcallback(null, params);\n// \t\t}else{\n// \t\t\tcallback('Error', 'Registration failed: Unable to create fog instance.')\n// \t\t}\n// \t}else{\n// \t\tcallback('Error', 'Registration failed: Unable to create fog instance.')\n// \t}\n// }\n\n\n// const updateGeneratedIdsByBBID = function(params, callback){ \n// \tlet updateProps = {\n// \t\tupdatedObj: {\n// \t\t\temail: params.user.email,\n// \t\t\tfirstName: params.user.firstName,\n// \t\t\tlastName: params.user.lastName,\n// \t\t\tactivated: 1\n// \t\t},\n// \t\tbbid: 'bodyParams.token'\n// \t};\t\n\n// \tGeneratedIdsService.updateGeneratedIdsByBBID(updateProps, params, callback);\n// }\n\n\nexport default {\n  //  addBlueboxEndpoint: addBlueboxEndpoint,\n  getFogDetailsEndpoint: getFogDetailsEndpoint,\n  getFogControllerStatusEndPoint: getFogControllerStatusEndPoint,\n  fogInstancesListEndPoint: fogInstancesListEndPoint,\n  fogInstanceCreateEndPoint: fogInstanceCreateEndPoint,\n  // getFogListEndPoint: getFogListEndPoint,\n  getFogTypesEndPoint: getFogTypesEndPoint,\n  fogInstanceDeleteEndPoint: fogInstanceDeleteEndPoint,\n  integratorInstanceDeleteEndPoint: integratorInstanceDeleteEndPoint,\n  updateFogSettingsEndpoint: updateFogSettingsEndpoint\n};
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/controllers/api/fogController.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/controllers/api/fogController.js	(date 1518773416000)
@@ -355,6 +355,7 @@
       bluetooth: params.bodyParams.bluetooth,
       statusfrequency: params.bodyParams.statusFrequency,
       changefrequency: params.bodyParams.changeFrequency,
+        scanfrequency: params.bodyParams.scanFrequency,
       proxy: params.bodyParams.proxy,
       isolateddockercontainer: params.bodyParams.docker
     }
Index: src/server/controllers/api/instanceConfigController.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file instanceConfigController.js\n * @author Zishan Iqbal\n * @description This file includes the implementation of instance-config and config-changes end-points\n */\nimport async from 'async';\n\nimport BaseApiController from './baseApiController';\nimport FogService from '../../services/fogService';\nimport AppUtils from '../../utils/appUtils';\nimport logger from '../../utils/winstonLogs';\nimport Constants from '../../constants.js';\n\n/********************************************* EndPoints ******************************************************/\n\n/********* Instance Configurations EndPoint (Get/Post: /api/v2/instance/config/id/:ID/token/:Token) **********/\nconst instanceConfigEndPoint = function(req, res){\n  logger.info(\"Endpoint hit: \"+ req.originalUrl);\n  let params = {},\n\n    fogProps = {\n      fogId: 'bodyParams.ID',\n      setProperty: 'fogData'\n    };\n\n  params.bodyParams = req.params;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n    async.apply(BaseApiController.checkUserExistance, req, res),\n    async.apply(FogService.getFogInstance, fogProps, params),\n    processConfigData\n\n  ], function(err, result) {\n    AppUtils.sendResponse(res, err, 'config', params.config, result);\n  })\n};\n\n/***** Instance Configuration Changes EndPoint (Post: /api/v2/instance/config/changes/id/:ID/token/:Token) ******/\nconst instanceConfigChangesEndPoint = function(req, res){\n  logger.info(\"Endpoint hit: \"+ req.originalUrl);\n  let params = {};\n\n  params.bodyParams = req.body;\n  params.bodyParams.instanceId = req.params.ID;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n  \n  async.waterfall([\n    async.apply(BaseApiController.checkUserExistance, req, res),\n    async.apply(updateFogInstance, params)\n\n  ], function(err, result) {\n    AppUtils.sendResponse(res, err, '', '', result);\n  })\n};\n\n\n/************************************* Extra Functions **************************************************/\nconst processConfigData = function(params, callback){\n  let config = {\n      networkinterface: params.fogData.networkinterface,\n      dockerurl: params.fogData.dockerurl,\n      disklimit: params.fogData.disklimit.toString(),\n      diskdirectory: params.fogData.diskdirectory,\n      memorylimit: params.fogData.memorylimit.toString(),\n      cpulimit: params.fogData.cpulimit.toString(),\n      loglimit: params.fogData.loglimit.toString(),\n      logdirectory: params.fogData.logdirectory,\n      logfilecount: params.fogData.logfilecount.toString(),\n      poststatusfreq: params.fogData.statusfrequency.toString(),\n      getchangesfreq: params.fogData.changefrequency.toString(),\n      isolateddockercontainer: params.fogData.isolateddockercontainer === 1 ? 'on' : 'off'\n    };\n\n    params.config = config;\n    callback (null, params);\n}\n\nconst updateFogInstance = function(params, callback){\n\n   let fogConfigProps = {\n      instanceId: 'bodyParams.instanceId',\n      updatedFog: {\n        networkinterface: params.bodyParams.networkinterface,\n        dockerurl: params.bodyParams.dockerurl,\n        disklimit: params.bodyParams.disklimit,\n        diskdirectory: params.bodyParams.diskdirectory,\n        memorylimit: params.bodyParams.memorylimit,\n        cpulimit: params.bodyParams.cpulimit,\n        loglimit: params.bodyParams.loglimit,\n        logdirectory: params.bodyParams.logdirectory,\n        logfilecount: params.bodyParams.logfilecount,\n        statusfrequency: params.bodyParams.poststatusfreq,\n        changefrequency: params.bodyParams.getchangesfreq,\n        isolatedDockerContainer: params.bodyParams.isolateddockercontainer\n      }\n    };\n  FogService.updateFogInstance(fogConfigProps, params, callback);\n}\n\nexport default {\n  instanceConfigEndPoint: instanceConfigEndPoint,\n  instanceConfigChangesEndPoint: instanceConfigChangesEndPoint\n};
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/controllers/api/instanceConfigController.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/controllers/api/instanceConfigController.js	(date 1518773416000)
@@ -69,6 +69,7 @@
       logfilecount: params.fogData.logfilecount.toString(),
       poststatusfreq: params.fogData.statusfrequency.toString(),
       getchangesfreq: params.fogData.changefrequency.toString(),
+      scandevicesfreq: params.fogData.scandevicesfreq.toString(),
       isolateddockercontainer: params.fogData.isolateddockercontainer === 1 ? 'on' : 'off'
     };
 
@@ -92,6 +93,7 @@
         logfilecount: params.bodyParams.logfilecount,
         statusfrequency: params.bodyParams.poststatusfreq,
         changefrequency: params.bodyParams.getchangesfreq,
+          scanfrequency: params.bodyParams.scandevicesfreq,
         isolatedDockerContainer: params.bodyParams.isolateddockercontainer
       }
     };
Index: src/server/managers/HWInfoManager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file HWInfoManager.js\n * @author elukashick\n * @description\n */\n\nimport HWInfo from './../models/hwInfo';\nimport BaseManager from './../managers/baseManager';\nimport sequelize from './../utils/sequelize';\n\nclass HWInfoManager extends BaseManager {\n    getEntity() {\n        return HWInfoManager;\n    }\n\n    /**\n     * @desc - finds info based on the uuid\n     * @param Integer - uuid\n     * @return JSON - returns a JSON object of hwInfo\n     */\n    findByInstanceId(uuid) {\n        return HWInfo.find({\n            where: {\n                iofog_uuid: uuid\n            }\n        });\n    }\n\n    /**\n     * @desc - updates\n     * @param Integer, JSON object - uuid, infoObj\n     * @return Integer - returns the number of rows updated\n     */\n    updateInfo(uuid, infoObj) {\n        return HWInfo.update(infoObj, {\n            where: {\n                iofog_uuid: uuid\n            }\n        });\n    }\n\n    /**\n     * @desc - saves infoObj\n     * @param JSON object - infoObj\n     * @return Integer - returns the number of rows created\n     */\n    saveInfo(infoObj) {\n        return HWInfo.create(infoObj);\n    }\n\n    /**\n     * @desc - deletes the info based on the uuid\n     * @param String - uuid\n     * @return  Integer - returns the number of rows deleted\n     */\n    deleteByInstanceId(uuid) {\n        return HWInfo.destroy({\n            where: {\n                iofog_uuid: uuid\n            }\n        });\n    }\n}\n\nconst instance = new HWInfoManager();\nexport default instance;
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/managers/HWInfoManager.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/managers/HWInfoManager.js	(date 1518705069000)
@@ -31,7 +31,7 @@
      * @param Integer, JSON object - uuid, infoObj
      * @return Integer - returns the number of rows updated
      */
-    updateInfo(uuid, infoObj) {
+    update(uuid, infoObj) {
         return HWInfo.update(infoObj, {
             where: {
                 iofog_uuid: uuid
@@ -44,7 +44,7 @@
      * @param JSON object - infoObj
      * @return Integer - returns the number of rows created
      */
-    saveInfo(infoObj) {
+    save(infoObj) {
         return HWInfo.create(infoObj);
     }
 
Index: src/server/managers/usbInfoManager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @author elukashick\n */\n\nimport USBInfo from './../models/usbInfo';\nimport BaseManager from './../managers/baseManager';\nimport sequelize from './../utils/sequelize';\nimport sequelizeUtils from \"../utils/sequelizeUtils\";\n\nclass USBInfoManager extends BaseManager {\n    getEntity() {\n        return USBInfoManager;\n    }\n\n    /**\n     * @desc - finds usbInfoObj based on the uuid\n     * @param uuid Integer\n     * @return JSON - returns a JSON object of usbInfoObj\n     */\n    findByInstanceId(uuid) {\n        return USBInfo.find({\n            where: {\n                iofog_uuid: uuid\n            }\n        });\n    }\n\n    /**\n     * @desc - updates if usbInfoObj exists in db otherwise creates it\n     * @param Integer - uuid\n     * @return JSON - returns a JSON usbInfoObj\n     */\n    upsert(infoObj) {\n        return this.findByInstanceId(infoObj.iofog_uuid)\n            .then((dbObj) => {\n                return null == dbObj ? this.saveInfo(infoObj) : this.updateInfo(infoObj)\n            });\n    }\n\n    /**\n     * @desc - updates\n     * @param Integer, JSON object - uuid, usbInfoObj\n     * @return Integer - returns the number of rows updated\n     */\n    updateInfo(infoObj) {\n        return USBInfo.update(infoObj, {\n            where: {\n                iofog_uuid: infoObj.iofog_uuid\n            }\n        });\n    }\n\n    /**\n     * @desc - saves info\n     * @param JSON object - usbInfoObj\n     * @return Integer - returns the number of rows created\n     */\n    saveInfo(infoObj) {\n        return USBInfo.create(infoObj);\n    }\n\n    /**\n     * @desc - deletes usbInfoObj based on the uuid\n     * @param String - uuid\n     * @return  Integer - returns the number of rows deleted\n     */\n    deleteByInstanceId(uuid) {\n        return USBInfo.destroy({\n            where: {\n                iofog_uuid: uuid\n            }\n        });\n    }\n}\n\nconst instance = new USBInfoManager();\nexport default instance;
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/managers/usbInfoManager.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/managers/usbInfoManager.js	(date 1518705069000)
@@ -33,7 +33,7 @@
     upsert(infoObj) {
         return this.findByInstanceId(infoObj.iofog_uuid)
             .then((dbObj) => {
-                return null == dbObj ? this.saveInfo(infoObj) : this.updateInfo(infoObj)
+                return null == dbObj ? this.save(infoObj) : this.update(infoObj)
             });
     }
 
@@ -42,7 +42,7 @@
      * @param Integer, JSON object - uuid, usbInfoObj
      * @return Integer - returns the number of rows updated
      */
-    updateInfo(infoObj) {
+    update(infoObj) {
         return USBInfo.update(infoObj, {
             where: {
                 iofog_uuid: infoObj.iofog_uuid
@@ -55,7 +55,7 @@
      * @param JSON object - usbInfoObj
      * @return Integer - returns the number of rows created
      */
-    saveInfo(infoObj) {
+    save(infoObj) {
         return USBInfo.create(infoObj);
     }
 
Index: src/server/models/fog.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file fog.js\n * @author Zishan Iqbal\n * @description This file includes a iofogs model used by sequalize for ORM;\n */\n\nimport Sequelize from 'sequelize';\nimport sequelize from './../utils/sequelize';\nimport Registry from './../models/registry';\nimport FogProvisionKey from './fogProvisionKey';\nimport ChangeTracking from './changeTracking';\nimport FogType from './fogType';\n\nconst Fog = sequelize.define('iofogs', {\n  uuid: {\n    type: Sequelize.TEXT,\n    primaryKey: true,\n    field: 'UUID'\n  },\n  name: {\n    type: Sequelize.TEXT,\n    defaultValue: \"Unnamed ioFog 1\",\n    field: 'Name'\n  },\n  location: {\n    type: Sequelize.TEXT,\n    field: 'Location'\n  },\n  latitude: {\n    type: Sequelize.TEXT,\n    field: 'Latitude'\n  },\n  longitude: {\n    type: Sequelize.TEXT,\n    field: 'Longitude'\n  },\n  description: {\n    type: Sequelize.TEXT,\n    field: 'Description'\n  },\n  lastactive: {\n    type: Sequelize.BIGINT,\n    field: 'LastActive'\n  },\n  token: {\n    type: Sequelize.TEXT,\n    field: 'Token'\n  },\n  daemonstatus: {\n    type: Sequelize.TEXT,\n    defaultValue: \"UNKNOWN\",\n    field: 'DaemonStatus'\n  },\n  daemonoperatingduration: {\n    type: Sequelize.BIGINT,\n    defaultValue: 0,\n    field: 'DaemonOperatingDuration'\n  },\n  daemonlaststart: {\n    type: Sequelize.BIGINT,\n    field: 'DaemonLastStart'\n  },\n  memoryusage: {\n    type: Sequelize.FLOAT,\n    defaultValue: 0.000,\n    field: 'MemoryUsage'\n  },\n  diskusage: {\n    type: Sequelize.FLOAT,\n    defaultValue: 0.000,\n    field: 'DiskUsage'\n  },\n  cpuusage: {\n    type: Sequelize.FLOAT,\n    defaultValue: 0.00,\n    field: 'CPUUsage'\n  },\n  memoryviolation: {\n    type: Sequelize.TEXT,\n    field: 'MemoryViolation'\n  },\n  diskviolation: {\n    type: Sequelize.TEXT,\n    field: 'DiskViolation'\n  },\n  cpuviolation: {\n    type: Sequelize.TEXT,\n    field: 'CPUViolation'\n  },\n  elementstatus: {\n    type: Sequelize.TEXT,\n    field: 'ElementStatus'\n  },\n  repositorycount: {\n    type: Sequelize.BIGINT,\n    field: 'RepositoryCount'\n  },\n  repositorystatus: {\n    type: Sequelize.TEXT,\n    field: 'RepositoryStatus'\n  },\n  systemtime: {\n    type: Sequelize.BIGINT,\n    field: 'SystemTime'\n  },\n  laststatustime: {\n    type: Sequelize.BIGINT,\n    field: 'LastStatusTime'\n  },\n  ipaddress: {\n    type: Sequelize.TEXT,\n    defaultValue: \"0.0.0.0\",\n    field: 'IPAddress'\n  },\n  processedmessages: {\n    type: Sequelize.BIGINT,\n    defaultValue: 0,\n    field: 'ProcessedMessages'\n  },\n  elementmessagecounts: {\n    type: Sequelize.TEXT,\n    field: 'ElementMessageCounts'\n  },\n  messagespeed: {\n    type: Sequelize.BIGINT,\n    field: 'MessageSpeed'\n  },\n  lastcommandtime: {\n    type: Sequelize.BIGINT,\n    field: 'LastCommandTime'\n  },\n  networkinterface: {\n    type: Sequelize.TEXT,\n    defaultValue: \"eth0\",\n    field: 'NetworkInterface'\n  },\n  dockerurl: {\n    type: Sequelize.TEXT,\n    defaultValue: \"unix:///let/run/docker.sock\",\n    field: 'DockerURL'\n  },\n  disklimit: {\n    type: Sequelize.FLOAT,\n    defaultValue: 50,\n    field: 'DiskLimit'\n  },\n  diskdirectory: {\n    type: Sequelize.TEXT,\n    defaultValue: '/let/lib/iofog/',\n    field: 'DiskDirectory'\n  },\n  memorylimit: {\n    type: Sequelize.FLOAT,\n    defaultValue: 4096,\n    field: 'MemoryLimit'\n  },\n  cpulimit: {\n    type: Sequelize.FLOAT,\n    defaultValue: 80,\n    field: 'CPULimit'\n  },\n  loglimit: {\n    type: Sequelize.FLOAT,\n    defaultValue: 10,\n    field: 'LogLimit'\n  },\n  logdirectory: {\n    type: Sequelize.TEXT,\n    defaultValue: \"/let/log/iofog/\",\n    field: 'LogDirectory'\n  },\n  debug: {\n    type: Sequelize.INTEGER,\n    defaultValue: 0,\n    field: 'Debug'\n  },\n  viewer: {\n    type: Sequelize.INTEGER,\n    defaultValue: 0,\n    field: 'Viewer'\n  },\n  bluetooth: {\n    type: Sequelize.INTEGER,\n    defaultValue: 0,\n    field: 'Bluetooth'\n  },\n  hal: {\n    type: Sequelize.INTEGER,\n    defaultValue: 0,\n    field: 'hal'\n  },\n  logfilecount: {\n    type: Sequelize.BIGINT,\n    defaultValue: 10,\n    field: 'LogFileCount'\n  },\n  version: {\n    type: Sequelize.TEXT,\n    field: 'Version'\n  },\n  statusfrequency: {\n    type: Sequelize.INTEGER,\n    defaultValue: 10,\n    field: 'StatusFrequency'\n  },\n  changefrequency: {\n    type: Sequelize.INTEGER,\n    defaultValue: 20,\n    field: 'ChangeFrequency'\n  },\n  proxy: {\n    type: Sequelize.TEXT,\n    defaultValue: \"\",\n    field: 'Proxy'\n  },\n  isolateddockercontainer: {\n    type: Sequelize.INTEGER,\n    defaultValue: 1,\n    field: 'IsolatedDockerContainer'\n  }\n}, {\n    // don't add the timestamp attributes (updatedAt, createdAt)\n    timestamps: true,\n    // disable the modification of table names\n    freezeTableName: true,\n    // don't use camelcase for automatically added attributes but underscore style\n    // so updatedAt will be updated_at\n    underscored: true\n});\n\nRegistry.belongsTo(Fog, {\n    foreignKey: 'iofog_uuid'\n});\n\nFogProvisionKey.belongsTo(Fog, {\n    foreignKey: 'iofog_uuid'\n});\n\nFog.belongsTo(FogType, {\n    foreignKey: 'typeKey'\n});\n\nexport default Fog;
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/models/fog.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/models/fog.js	(date 1518717210000)
@@ -12,212 +12,217 @@
 import FogType from './fogType';
 
 const Fog = sequelize.define('iofogs', {
-  uuid: {
-    type: Sequelize.TEXT,
-    primaryKey: true,
-    field: 'UUID'
-  },
-  name: {
-    type: Sequelize.TEXT,
-    defaultValue: "Unnamed ioFog 1",
-    field: 'Name'
-  },
-  location: {
-    type: Sequelize.TEXT,
-    field: 'Location'
-  },
-  latitude: {
-    type: Sequelize.TEXT,
-    field: 'Latitude'
-  },
-  longitude: {
-    type: Sequelize.TEXT,
-    field: 'Longitude'
-  },
-  description: {
-    type: Sequelize.TEXT,
-    field: 'Description'
-  },
-  lastactive: {
-    type: Sequelize.BIGINT,
-    field: 'LastActive'
-  },
-  token: {
-    type: Sequelize.TEXT,
-    field: 'Token'
-  },
-  daemonstatus: {
-    type: Sequelize.TEXT,
-    defaultValue: "UNKNOWN",
-    field: 'DaemonStatus'
-  },
-  daemonoperatingduration: {
-    type: Sequelize.BIGINT,
-    defaultValue: 0,
-    field: 'DaemonOperatingDuration'
-  },
-  daemonlaststart: {
-    type: Sequelize.BIGINT,
-    field: 'DaemonLastStart'
-  },
-  memoryusage: {
-    type: Sequelize.FLOAT,
-    defaultValue: 0.000,
-    field: 'MemoryUsage'
-  },
-  diskusage: {
-    type: Sequelize.FLOAT,
-    defaultValue: 0.000,
-    field: 'DiskUsage'
-  },
-  cpuusage: {
-    type: Sequelize.FLOAT,
-    defaultValue: 0.00,
-    field: 'CPUUsage'
-  },
-  memoryviolation: {
-    type: Sequelize.TEXT,
-    field: 'MemoryViolation'
-  },
-  diskviolation: {
-    type: Sequelize.TEXT,
-    field: 'DiskViolation'
-  },
-  cpuviolation: {
-    type: Sequelize.TEXT,
-    field: 'CPUViolation'
-  },
-  elementstatus: {
-    type: Sequelize.TEXT,
-    field: 'ElementStatus'
-  },
-  repositorycount: {
-    type: Sequelize.BIGINT,
-    field: 'RepositoryCount'
-  },
-  repositorystatus: {
-    type: Sequelize.TEXT,
-    field: 'RepositoryStatus'
-  },
-  systemtime: {
-    type: Sequelize.BIGINT,
-    field: 'SystemTime'
-  },
-  laststatustime: {
-    type: Sequelize.BIGINT,
-    field: 'LastStatusTime'
-  },
-  ipaddress: {
-    type: Sequelize.TEXT,
-    defaultValue: "0.0.0.0",
-    field: 'IPAddress'
-  },
-  processedmessages: {
-    type: Sequelize.BIGINT,
-    defaultValue: 0,
-    field: 'ProcessedMessages'
-  },
-  elementmessagecounts: {
-    type: Sequelize.TEXT,
-    field: 'ElementMessageCounts'
-  },
-  messagespeed: {
-    type: Sequelize.BIGINT,
-    field: 'MessageSpeed'
-  },
-  lastcommandtime: {
-    type: Sequelize.BIGINT,
-    field: 'LastCommandTime'
-  },
-  networkinterface: {
-    type: Sequelize.TEXT,
-    defaultValue: "eth0",
-    field: 'NetworkInterface'
-  },
-  dockerurl: {
-    type: Sequelize.TEXT,
-    defaultValue: "unix:///let/run/docker.sock",
-    field: 'DockerURL'
-  },
-  disklimit: {
-    type: Sequelize.FLOAT,
-    defaultValue: 50,
-    field: 'DiskLimit'
-  },
-  diskdirectory: {
-    type: Sequelize.TEXT,
-    defaultValue: '/let/lib/iofog/',
-    field: 'DiskDirectory'
-  },
-  memorylimit: {
-    type: Sequelize.FLOAT,
-    defaultValue: 4096,
-    field: 'MemoryLimit'
-  },
-  cpulimit: {
-    type: Sequelize.FLOAT,
-    defaultValue: 80,
-    field: 'CPULimit'
-  },
-  loglimit: {
-    type: Sequelize.FLOAT,
-    defaultValue: 10,
-    field: 'LogLimit'
-  },
-  logdirectory: {
-    type: Sequelize.TEXT,
-    defaultValue: "/let/log/iofog/",
-    field: 'LogDirectory'
-  },
-  debug: {
-    type: Sequelize.INTEGER,
-    defaultValue: 0,
-    field: 'Debug'
-  },
-  viewer: {
-    type: Sequelize.INTEGER,
-    defaultValue: 0,
-    field: 'Viewer'
-  },
-  bluetooth: {
-    type: Sequelize.INTEGER,
-    defaultValue: 0,
-    field: 'Bluetooth'
-  },
-  hal: {
-    type: Sequelize.INTEGER,
-    defaultValue: 0,
-    field: 'hal'
-  },
-  logfilecount: {
-    type: Sequelize.BIGINT,
-    defaultValue: 10,
-    field: 'LogFileCount'
-  },
-  version: {
-    type: Sequelize.TEXT,
-    field: 'Version'
-  },
-  statusfrequency: {
-    type: Sequelize.INTEGER,
-    defaultValue: 10,
-    field: 'StatusFrequency'
-  },
-  changefrequency: {
-    type: Sequelize.INTEGER,
-    defaultValue: 20,
-    field: 'ChangeFrequency'
-  },
-  proxy: {
-    type: Sequelize.TEXT,
-    defaultValue: "",
-    field: 'Proxy'
-  },
-  isolateddockercontainer: {
-    type: Sequelize.INTEGER,
-    defaultValue: 1,
-    field: 'IsolatedDockerContainer'
-  }
+    uuid: {
+        type: Sequelize.TEXT,
+        primaryKey: true,
+        field: 'UUID'
+    },
+    name: {
+        type: Sequelize.TEXT,
+        defaultValue: "Unnamed ioFog 1",
+        field: 'Name'
+    },
+    location: {
+        type: Sequelize.TEXT,
+        field: 'Location'
+    },
+    latitude: {
+        type: Sequelize.TEXT,
+        field: 'Latitude'
+    },
+    longitude: {
+        type: Sequelize.TEXT,
+        field: 'Longitude'
+    },
+    description: {
+        type: Sequelize.TEXT,
+        field: 'Description'
+    },
+    lastactive: {
+        type: Sequelize.BIGINT,
+        field: 'LastActive'
+    },
+    token: {
+        type: Sequelize.TEXT,
+        field: 'Token'
+    },
+    daemonstatus: {
+        type: Sequelize.TEXT,
+        defaultValue: "UNKNOWN",
+        field: 'DaemonStatus'
+    },
+    daemonoperatingduration: {
+        type: Sequelize.BIGINT,
+        defaultValue: 0,
+        field: 'DaemonOperatingDuration'
+    },
+    daemonlaststart: {
+        type: Sequelize.BIGINT,
+        field: 'DaemonLastStart'
+    },
+    memoryusage: {
+        type: Sequelize.FLOAT,
+        defaultValue: 0.000,
+        field: 'MemoryUsage'
+    },
+    diskusage: {
+        type: Sequelize.FLOAT,
+        defaultValue: 0.000,
+        field: 'DiskUsage'
+    },
+    cpuusage: {
+        type: Sequelize.FLOAT,
+        defaultValue: 0.00,
+        field: 'CPUUsage'
+    },
+    memoryviolation: {
+        type: Sequelize.TEXT,
+        field: 'MemoryViolation'
+    },
+    diskviolation: {
+        type: Sequelize.TEXT,
+        field: 'DiskViolation'
+    },
+    cpuviolation: {
+        type: Sequelize.TEXT,
+        field: 'CPUViolation'
+    },
+    elementstatus: {
+        type: Sequelize.TEXT,
+        field: 'ElementStatus'
+    },
+    repositorycount: {
+        type: Sequelize.BIGINT,
+        field: 'RepositoryCount'
+    },
+    repositorystatus: {
+        type: Sequelize.TEXT,
+        field: 'RepositoryStatus'
+    },
+    systemtime: {
+        type: Sequelize.BIGINT,
+        field: 'SystemTime'
+    },
+    laststatustime: {
+        type: Sequelize.BIGINT,
+        field: 'LastStatusTime'
+    },
+    ipaddress: {
+        type: Sequelize.TEXT,
+        defaultValue: "0.0.0.0",
+        field: 'IPAddress'
+    },
+    processedmessages: {
+        type: Sequelize.BIGINT,
+        defaultValue: 0,
+        field: 'ProcessedMessages'
+    },
+    elementmessagecounts: {
+        type: Sequelize.TEXT,
+        field: 'ElementMessageCounts'
+    },
+    messagespeed: {
+        type: Sequelize.BIGINT,
+        field: 'MessageSpeed'
+    },
+    lastcommandtime: {
+        type: Sequelize.BIGINT,
+        field: 'LastCommandTime'
+    },
+    networkinterface: {
+        type: Sequelize.TEXT,
+        defaultValue: "eth0",
+        field: 'NetworkInterface'
+    },
+    dockerurl: {
+        type: Sequelize.TEXT,
+        defaultValue: "unix:///let/run/docker.sock",
+        field: 'DockerURL'
+    },
+    disklimit: {
+        type: Sequelize.FLOAT,
+        defaultValue: 50,
+        field: 'DiskLimit'
+    },
+    diskdirectory: {
+        type: Sequelize.TEXT,
+        defaultValue: '/let/lib/iofog/',
+        field: 'DiskDirectory'
+    },
+    memorylimit: {
+        type: Sequelize.FLOAT,
+        defaultValue: 4096,
+        field: 'MemoryLimit'
+    },
+    cpulimit: {
+        type: Sequelize.FLOAT,
+        defaultValue: 80,
+        field: 'CPULimit'
+    },
+    loglimit: {
+        type: Sequelize.FLOAT,
+        defaultValue: 10,
+        field: 'LogLimit'
+    },
+    logdirectory: {
+        type: Sequelize.TEXT,
+        defaultValue: "/let/log/iofog/",
+        field: 'LogDirectory'
+    },
+    debug: {
+        type: Sequelize.INTEGER,
+        defaultValue: 0,
+        field: 'Debug'
+    },
+    viewer: {
+        type: Sequelize.INTEGER,
+        defaultValue: 0,
+        field: 'Viewer'
+    },
+    bluetooth: {
+        type: Sequelize.INTEGER,
+        defaultValue: 0,
+        field: 'Bluetooth'
+    },
+    hal: {
+        type: Sequelize.INTEGER,
+        defaultValue: 0,
+        field: 'hal'
+    },
+    logfilecount: {
+        type: Sequelize.BIGINT,
+        defaultValue: 10,
+        field: 'LogFileCount'
+    },
+    version: {
+        type: Sequelize.TEXT,
+        field: 'Version'
+    },
+    statusfrequency: {
+        type: Sequelize.INTEGER,
+        defaultValue: 10,
+        field: 'StatusFrequency'
+    },
+    changefrequency: {
+        type: Sequelize.INTEGER,
+        defaultValue: 20,
+        field: 'ChangeFrequency'
+    },
+    scanfrequency: {
+        type: Sequelize.INTEGER,
+        defaultValue: 20,
+        field: 'ScanFrequency'
+    },
+    proxy: {
+        type: Sequelize.TEXT,
+        defaultValue: "",
+        field: 'Proxy'
+    },
+    isolateddockercontainer: {
+        type: Sequelize.INTEGER,
+        defaultValue: 1,
+        field: 'IsolatedDockerContainer'
+    }
 }, {
     // don't add the timestamp attributes (updatedAt, createdAt)
     timestamps: true,
Index: src/server/services/instanceResourcesService.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @author elukashick\n */\n\nimport HWInfoManager from '../managers/HWInfoManager';\nimport USBInfoManager from '../managers/usbInfoManager';\nimport AppUtils from \"../utils/appUtils\";\n\nconst saveHWInfo = function (props, params, callback) {\n\n    let info = AppUtils.getProperty(params, props.fogInfo),\n        uuid = AppUtils.getProperty(params, props.uuid);\n\n    let config = {\n        info: info,\n        iofog_uuid: uuid\n    };\n\n    HWInfoManager\n        .saveInfo(config)\n        .then(AppUtils.onCreate.bind(null, params, props.setProperty, 'Unable to save HW Info.', callback));\n};\n\nconst saveUSBInfo = function (props, params, callback) {\n\n    let info = AppUtils.getProperty(params, props.fogInfo),\n        uuid = AppUtils.getProperty(params, props.uuid);\n\n    let config = {\n        info: info,\n        iofog_uuid: uuid\n    };\n\n    USBInfoManager\n        .upsert(config)\n        .then(AppUtils.onCreate.bind(null, params, props.setProperty, 'Unable to save USB Info.', callback));\n};\n\nconst getFogHwInfo = function (props, params, callback) {\n    let instanceId = AppUtils.getProperty(params, props.instanceId);\n\n    HWInfoManager\n        .findByInstanceId(instanceId)\n        .then(AppUtils.onFindOptional.bind(null, params, props.setProperty, callback));\n};\n\nconst getFogUsbInfo = function (props, params, callback) {\n    let instanceId = AppUtils.getProperty(params, props.instanceId);\n\n    USBInfoManager\n        .findByInstanceId(instanceId)\n        .then(AppUtils.onFindOptional.bind(null, params, props.setProperty, callback));\n};\n\nexport default {\n    saveHWInfo: saveHWInfo,\n    saveUSBInfo: saveUSBInfo,\n    getFogHwInfo: getFogHwInfo,\n    getFogUsbInfo: getFogUsbInfo\n};
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/services/instanceResourcesService.js	(revision 6687888b2cbd80b1ca82c6692dd06a3c4bdb840c)
+++ src/server/services/instanceResourcesService.js	(date 1518705069000)
@@ -17,7 +17,7 @@
     };
 
     HWInfoManager
-        .saveInfo(config)
+        .save(config)
         .then(AppUtils.onCreate.bind(null, params, props.setProperty, 'Unable to save HW Info.', callback));
 };
 
