summaryrefslogtreecommitdiffstats
path: root/ui/imports/api
diff options
context:
space:
mode:
Diffstat (limited to 'ui/imports/api')
-rw-r--r--ui/imports/api/accounts/methods.js9
-rw-r--r--ui/imports/api/connection-tests/connection-tests.js41
-rw-r--r--ui/imports/api/connection-tests/methods.js52
-rw-r--r--ui/imports/api/connection-tests/server/publications.js21
-rw-r--r--ui/imports/api/environments/configuration-groups/monitoring-configuration.js7
-rw-r--r--ui/imports/api/environments/environments.js25
-rw-r--r--ui/imports/api/environments/methods.js3
-rw-r--r--ui/imports/api/scheduled-scans/scheduled-scans.js3
-rw-r--r--ui/imports/api/scheduled-scans/server/publications.js16
-rw-r--r--ui/imports/api/supported_environments/supported_environments.js18
-rw-r--r--ui/imports/api/user-settings/methods.js (renamed from ui/imports/api/configurations/methods.js)16
-rw-r--r--ui/imports/api/user-settings/server/publications.js (renamed from ui/imports/api/configurations/server/publications.js)8
-rw-r--r--ui/imports/api/user-settings/user-settings.js (renamed from ui/imports/api/configurations/configurations.js)6
13 files changed, 197 insertions, 28 deletions
diff --git a/ui/imports/api/accounts/methods.js b/ui/imports/api/accounts/methods.js
index 4e1c40a..f6c271c 100644
--- a/ui/imports/api/accounts/methods.js
+++ b/ui/imports/api/accounts/methods.js
@@ -11,6 +11,7 @@ import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import * as R from 'ramda';
import { Roles } from 'meteor/alanning:roles';
import { Environments } from '/imports/api/environments/environments';
+import { UserSettings } from '/imports/api/user-settings/user-settings';
let userSchema = new SimpleSchema({
_id: { type: String },
@@ -48,6 +49,12 @@ export const insert = new ValidatedMethod({
addRole(viewEnvs, 'view-env', userId);
addRole(editEnvs, 'edit-env', userId);
+
+ let userSettings = UserSettings.schema.clean({});
+ userSettings = R.merge(userSettings, {
+ user_id: userId,
+ });
+ UserSettings.insert(userSettings);
}
});
@@ -58,7 +65,7 @@ export const update = new ValidatedMethod({
validate: userSchema
.pick([
'_id',
- // 'password',
+ // 'password',
'viewEnvs',
'viewEnvs.$',
'editEnvs',
diff --git a/ui/imports/api/connection-tests/connection-tests.js b/ui/imports/api/connection-tests/connection-tests.js
new file mode 100644
index 0000000..7acb549
--- /dev/null
+++ b/ui/imports/api/connection-tests/connection-tests.js
@@ -0,0 +1,41 @@
+/////////////////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
+// /
+// All rights reserved. This program and the accompanying materials /
+// are made available under the terms of the Apache License, Version 2.0 /
+// which accompanies this distribution, and is available at /
+// http://www.apache.org/licenses/LICENSE-2.0 /
+/////////////////////////////////////////////////////////////////////////////////////////
+import { Mongo } from 'meteor/mongo';
+import { SimpleSchema } from 'meteor/aldeed:simple-schema';
+//import * as R from 'ramda';
+
+export const ConnectionTests = new Mongo.Collection('connection_tests', { idGeneration: 'MONGO' });
+
+let simpleSchema = new SimpleSchema({
+ _id: { type: { _str: { type: String, regEx: SimpleSchema.RegEx.Id } } },
+ environment: {
+ type: String,
+ },
+
+ test_targets: {
+ type: [String],
+ },
+
+ test_configurations: {
+ type: [Object],
+ blackbox: true
+ },
+
+ submit_timestamp: {
+ type: String,
+ },
+
+ status: {
+ type: String,
+ defaultValue: 'request'
+ }
+});
+
+ConnectionTests.schema = simpleSchema;
+ConnectionTests.attachSchema(ConnectionTests.schema);
diff --git a/ui/imports/api/connection-tests/methods.js b/ui/imports/api/connection-tests/methods.js
new file mode 100644
index 0000000..7badfb1
--- /dev/null
+++ b/ui/imports/api/connection-tests/methods.js
@@ -0,0 +1,52 @@
+/////////////////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
+// /
+// All rights reserved. This program and the accompanying materials /
+// are made available under the terms of the Apache License, Version 2.0 /
+// which accompanies this distribution, and is available at /
+// http://www.apache.org/licenses/LICENSE-2.0 /
+/////////////////////////////////////////////////////////////////////////////////////////
+
+import * as R from 'ramda';
+import { ValidatedMethod } from 'meteor/mdg:validated-method';
+import { ConnectionTests } from './connection-tests';
+import { getSchemaForGroupName } from '/imports/api/environments/environments';
+
+export const insert = new ValidatedMethod({
+ name: 'connection_tests.insert',
+ validate: ConnectionTests.simpleSchema()
+ .pick([
+ 'environment',
+ 'test_configurations',
+ 'test_configurations.$',
+ ]).validator({ clean: true, filter: false }),
+ run({
+ environment,
+ test_configurations,
+ }) {
+ let connection_test = ConnectionTests.schema.clean({});
+
+ test_configurations = R.filter((config) => {
+ let validationContext = getSchemaForGroupName(config.name).newContext();
+ try {
+ let result = validationContext.validate(config);
+ return result;
+ } catch (_e) {
+ return false;
+ }
+ }, test_configurations);
+
+ let test_targets = R.map((config) => config.name, test_configurations);
+ let submit_timestamp = moment().format();
+
+ connection_test = R.merge(connection_test, {
+ environment,
+ test_targets,
+ test_configurations,
+ submit_timestamp
+ });
+
+ let insertResult = ConnectionTests.insert(connection_test);
+ return insertResult;
+ },
+});
diff --git a/ui/imports/api/connection-tests/server/publications.js b/ui/imports/api/connection-tests/server/publications.js
new file mode 100644
index 0000000..4a092b5
--- /dev/null
+++ b/ui/imports/api/connection-tests/server/publications.js
@@ -0,0 +1,21 @@
+/////////////////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others /
+// /
+// All rights reserved. This program and the accompanying materials /
+// are made available under the terms of the Apache License, Version 2.0 /
+// which accompanies this distribution, and is available at /
+// http://www.apache.org/licenses/LICENSE-2.0 /
+/////////////////////////////////////////////////////////////////////////////////////////
+import { Meteor } from 'meteor/meteor';
+import * as R from 'ramda';
+import { ConnectionTests } from '../connection-tests.js';
+
+Meteor.publish('connection_tests?_id', function (_id) {
+ console.log('server subscribtion to: connection_tests?_id');
+ console.log('-_id: ', R.toString(_id));
+
+ let query = {
+ _id: _id,
+ };
+ return ConnectionTests.find(query);
+});
diff --git a/ui/imports/api/environments/configuration-groups/monitoring-configuration.js b/ui/imports/api/environments/configuration-groups/monitoring-configuration.js
index 2b27f8a..edeaaad 100644
--- a/ui/imports/api/environments/configuration-groups/monitoring-configuration.js
+++ b/ui/imports/api/environments/configuration-groups/monitoring-configuration.js
@@ -51,7 +51,10 @@ export const MonitoringSchema = new SimpleSchema({
defaultValue: 'sensu'
},
- rabbitmq_pass: { type: String },
+ rabbitmq_pass: {
+ type: String,
+ defaultValue: 'osdna'
+ },
server_ip: {
type: String,
@@ -108,7 +111,7 @@ export const MonitoringSchema = new SimpleSchema({
ssh_password: {
type: String,
- defaultValue: 'calipso',
+ defaultValue: 'osdna',
optional: true
},
diff --git a/ui/imports/api/environments/environments.js b/ui/imports/api/environments/environments.js
index 22e49cf..e196a69 100644
--- a/ui/imports/api/environments/environments.js
+++ b/ui/imports/api/environments/environments.js
@@ -180,7 +180,7 @@ let simpleSchema = new SimpleSchema({
},
distribution: {
type: String,
- defaultValue: 'Mirantis-8.0',
+ defaultValue: 'Mirantis',
custom: function () {
let that = this;
let constsDist = Constants.findOne({ name: 'distributions' });
@@ -193,6 +193,20 @@ let simpleSchema = new SimpleSchema({
}
},
},
+ distribution_version: {
+ type: String,
+ custom: function () {
+ let that = this;
+ let constsDist = Constants.findOne({ name: 'distribution_versions' });
+
+ if (R.isNil(constsDist.data)) { return 'notAllowed'; }
+ let dist_versions = constsDist.data;
+
+ if (R.isNil(R.find(R.propEq('value', that.value), dist_versions))) {
+ return 'notAllowed';
+ }
+ },
+ },
last_scanned: {
type: String, defaultValue: ''
},
@@ -219,7 +233,7 @@ let simpleSchema = new SimpleSchema({
mechanism_drivers: {
type: [String],
- defaultValue: ['ovs'],
+ defaultValue: ['OVS'],
minCount: 1,
custom: function () {
let that = this;
@@ -325,7 +339,7 @@ SimpleSchema.messages({
Environments.schema = simpleSchema;
Environments.attachSchema(Environments.schema);
-function getSchemaForGroupName(groupName) {
+export function getSchemaForGroupName(groupName) {
switch (groupName) {
case 'mysql':
return MysqlSchema;
@@ -440,13 +454,14 @@ function extractCalcEnvSupportedRelatedValues(schemaHelper) {
let dbNode = getDbNode(schemaHelper);
let dist = extractValue('distribution', schemaHelper, dbNode);
+ let dist_version = extractValue('distribution_version', schemaHelper, dbNode);
let typeDrivers = extractValue('type_drivers', schemaHelper, dbNode);
let mechDrivers = extractValue('mechanism_drivers', schemaHelper, dbNode);
let enable_monitoring = extractValue('enable_monitoring', schemaHelper, dbNode);
let listen = extractValue('listen', schemaHelper, dbNode);
- let isMonitoringSupportedRes = isMonitoringSupported(dist, typeDrivers, mechDrivers);
- let isListeningSupportedRes = isListeningSupported(dist, typeDrivers, mechDrivers);
+ let isMonitoringSupportedRes = isMonitoringSupported(dist, dist_version, typeDrivers, mechDrivers);
+ let isListeningSupportedRes = isListeningSupported(dist, dist_version, typeDrivers, mechDrivers);
return {
enable_monitoring,
diff --git a/ui/imports/api/environments/methods.js b/ui/imports/api/environments/methods.js
index 6d5e73e..66d1557 100644
--- a/ui/imports/api/environments/methods.js
+++ b/ui/imports/api/environments/methods.js
@@ -28,6 +28,7 @@ export const insert = new ValidatedMethod({
'configuration',
'configuration.$',
'distribution',
+ 'distribution_version',
'name',
'type_drivers',
'mechanism_drivers',
@@ -40,6 +41,7 @@ export const insert = new ValidatedMethod({
run({
configuration,
distribution,
+ distribution_version,
name,
type_drivers,
mechanism_drivers,
@@ -64,6 +66,7 @@ export const insert = new ValidatedMethod({
environment = R.merge(environment, {
configuration,
distribution,
+ distribution_version,
name,
type_drivers,
mechanism_drivers,
diff --git a/ui/imports/api/scheduled-scans/scheduled-scans.js b/ui/imports/api/scheduled-scans/scheduled-scans.js
index 54d4565..4d06a33 100644
--- a/ui/imports/api/scheduled-scans/scheduled-scans.js
+++ b/ui/imports/api/scheduled-scans/scheduled-scans.js
@@ -54,7 +54,6 @@ let schema = new SimpleSchema({
},
scheduled_timestamp: {
type: Date,
- defaultValue: null,
optional: true,
}
});
@@ -81,3 +80,5 @@ export const subsScheduledScansPageAmountSorted = 'scheduled_scans?page&amount&s
export const subsScheduledScansPageAmountSortedCounter = `${subsScheduledScansPageAmountSorted}!counter`;
export const subsScheduledScansId = 'scheduled_scans?_id';
+
+export const subsScheduledScansEnv = 'scheduled_scans?env';
diff --git a/ui/imports/api/scheduled-scans/server/publications.js b/ui/imports/api/scheduled-scans/server/publications.js
index 9359c20..f4c5b9b 100644
--- a/ui/imports/api/scheduled-scans/server/publications.js
+++ b/ui/imports/api/scheduled-scans/server/publications.js
@@ -2,10 +2,12 @@ import { Meteor } from 'meteor/meteor';
import * as R from 'ramda';
import { Counts } from 'meteor/tmeasday:publish-counts';
-import { ScheduledScans,
+import {
+ ScheduledScans,
subsScheduledScansPageAmountSorted,
subsScheduledScansPageAmountSortedCounter,
subsScheduledScansId,
+ subsScheduledScansEnv,
} from '../scheduled-scans.js';
Meteor.publish(subsScheduledScansPageAmountSorted, function (
@@ -24,7 +26,7 @@ Meteor.publish(subsScheduledScansPageAmountSorted, function (
let sortParams = {};
sortParams = R.ifElse(R.isNil, R.always(sortParams),
- R.assoc(R.__, sortDirection, sortParams))(sortField);
+ R.assoc(R.__, sortDirection, sortParams))(sortField);
console.log('sort params:', sortParams);
@@ -50,3 +52,13 @@ Meteor.publish(subsScheduledScansId, function (_id) {
let query = { _id: _id };
return ScheduledScans.find(query);
});
+
+Meteor.publish(subsScheduledScansEnv, function (env) {
+ console.log(`server subscribtion: ${subsScheduledScansEnv}`);
+ console.log('-env: ', env);
+
+ //let that = this;
+
+ let query = { environment: env };
+ return ScheduledScans.find(query);
+});
diff --git a/ui/imports/api/supported_environments/supported_environments.js b/ui/imports/api/supported_environments/supported_environments.js
index 55c5745..6637b74 100644
--- a/ui/imports/api/supported_environments/supported_environments.js
+++ b/ui/imports/api/supported_environments/supported_environments.js
@@ -14,14 +14,21 @@ export const SupportedEnvironments = new Mongo.Collection(
export const subsNameSupportedEnvs = 'supported-environments';
-export function isMonitoringSupported(distribution, type_drivers, mechanism_drivers) {
+export function isMonitoringSupported(
+ distribution,
+ distribution_version,
+ type_drivers,
+ mechanism_drivers
+) {
console.log('isMonitoringSupported');
console.log(`distribution: ${R.toString(distribution)}`);
+ console.log(`distribution_version: ${R.toString(distribution_version)}`);
console.log(`type_drivers: ${R.toString(type_drivers)}`);
console.log(`mechanism_drivers: ${R.toString(mechanism_drivers)}`);
let result = SupportedEnvironments.find({
'environment.distribution': distribution,
+ 'environment.distribution_version': { $in: [ distribution_version ] },
'environment.type_drivers': type_drivers,
'environment.mechanism_drivers': { $in: mechanism_drivers },
'features.monitoring': true
@@ -31,14 +38,21 @@ export function isMonitoringSupported(distribution, type_drivers, mechanism_driv
return result;
}
-export function isListeningSupported(distribution, type_drivers, mechanism_drivers) {
+export function isListeningSupported(
+ distribution,
+ distribution_version,
+ type_drivers,
+ mechanism_drivers
+) {
console.log('isListeningSupported');
console.log(`distribution: ${R.toString(distribution)}`);
+ console.log(`distribution: ${R.toString(distribution)}`);
console.log(`type_drivers: ${R.toString(type_drivers)}`);
console.log(`mechanism_drivers: ${R.toString(mechanism_drivers)}`);
let result = SupportedEnvironments.find({
'environment.distribution': distribution,
+ 'environment.distribution_version': { $in: [ distribution_version ] },
'environment.type_drivers': type_drivers,
'environment.mechanism_drivers': { $in: mechanism_drivers },
'features.listening': true
diff --git a/ui/imports/api/configurations/methods.js b/ui/imports/api/user-settings/methods.js
index 7366e3e..e948c1e 100644
--- a/ui/imports/api/configurations/methods.js
+++ b/ui/imports/api/user-settings/methods.js
@@ -7,12 +7,12 @@
// http://www.apache.org/licenses/LICENSE-2.0 /
/////////////////////////////////////////////////////////////////////////////////////////
import { ValidatedMethod } from 'meteor/mdg:validated-method';
-import { Configurations } from '/imports/api/configurations/configurations';
+import { UserSettings } from '/imports/api/user-settings/user-settings';
import * as R from 'ramda';
export const save = new ValidatedMethod({
- name: 'configurations.save',
- validate: Configurations.simpleSchema()
+ name: 'user-settings.save',
+ validate: UserSettings.simpleSchema()
.pick([
'messages_view_backward_delta'
]).validator({ clean: true, filter: false }),
@@ -21,19 +21,19 @@ export const save = new ValidatedMethod({
}) {
let userId = this.userId;
- let conf = Configurations.findOne({ user_id: userId });
+ let userSettings = UserSettings.findOne({ user_id: userId });
- if (conf) {
- Configurations.update({ _id: conf._id}, { $set: {
+ if (userSettings) {
+ UserSettings.update({ _id: userSettings._id}, { $set: {
messages_view_backward_delta: messages_view_backward_delta
}});
} else {
- let item = Configurations.schema.clean({});
+ let item = UserSettings.schema.clean({});
item = R.merge(item, {
user_id: userId,
messages_view_backward_delta: messages_view_backward_delta
});
- Configurations.insert(item);
+ UserSettings.insert(item);
}
}
});
diff --git a/ui/imports/api/configurations/server/publications.js b/ui/imports/api/user-settings/server/publications.js
index fe9f6fd..c53146c 100644
--- a/ui/imports/api/configurations/server/publications.js
+++ b/ui/imports/api/user-settings/server/publications.js
@@ -8,14 +8,14 @@
/////////////////////////////////////////////////////////////////////////////////////////
import { Meteor } from 'meteor/meteor';
-import { Configurations } from '../configurations.js';
+import { UserSettings } from '../user-settings.js';
-Meteor.publish('configurations?user', function () {
- console.log('server subscribtion: configurations?user');
+Meteor.publish('user_settings?user', function () {
+ console.log('server subscribtion: user_settings?user');
let userId = this.userId;
let query = { user_id: userId };
console.log('-query: ', query);
- return Configurations.find(query);
+ return UserSettings.find(query);
});
diff --git a/ui/imports/api/configurations/configurations.js b/ui/imports/api/user-settings/user-settings.js
index 44cf4ee..2e553aa 100644
--- a/ui/imports/api/configurations/configurations.js
+++ b/ui/imports/api/user-settings/user-settings.js
@@ -10,7 +10,7 @@ import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
//import * as R from 'ramda';
-export const Configurations = new Mongo.Collection('configurations', { idGeneration: 'MONGO' });
+export const UserSettings = new Mongo.Collection('user_settings', { idGeneration: 'MONGO' });
let schema = {
_id: { type: { _str: { type: String, regEx: SimpleSchema.RegEx.Id } } },
@@ -25,5 +25,5 @@ let schema = {
};
let simpleSchema = new SimpleSchema(schema);
-Configurations.schema = simpleSchema;
-Configurations.attachSchema(Configurations.schema);
+UserSettings.schema = simpleSchema;
+UserSettings.attachSchema(UserSettings.schema);