aboutsummaryrefslogtreecommitdiffstats
path: root/ui/imports/api/inventories
diff options
context:
space:
mode:
Diffstat (limited to 'ui/imports/api/inventories')
-rw-r--r--ui/imports/api/inventories/inventories.js11
-rw-r--r--ui/imports/api/inventories/server/methods.js137
-rw-r--r--ui/imports/api/inventories/server/publications.js250
3 files changed, 0 insertions, 398 deletions
diff --git a/ui/imports/api/inventories/inventories.js b/ui/imports/api/inventories/inventories.js
deleted file mode 100644
index 114f5ef..0000000
--- a/ui/imports/api/inventories/inventories.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// 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';
-
-export const Inventory = new Mongo.Collection('inventory', { idGeneration: 'MONGO' });
diff --git a/ui/imports/api/inventories/server/methods.js b/ui/imports/api/inventories/server/methods.js
deleted file mode 100644
index d7e3648..0000000
--- a/ui/imports/api/inventories/server/methods.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// 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 { check } from 'meteor/check';
-import * as R from 'ramda';
-import { Inventory } from '../inventories';
-import { Environments } from '/imports/api/environments/environments';
-import { regexEscape } from '/imports/lib/regex-utils';
-import { NodeHoverAttr, calcAttrsForItem } from '/imports/api/attributes_for_hover_on_data/attributes_for_hover_on_data';
-
-const AUTO_COMPLETE_RESULTS_LIMIT = 15;
-
-Meteor.methods({
- 'inventorySearch': function(searchTerm, envId, opCounter) {
- console.log('inventorySearch');
- console.log('searchTerm', R.toString(searchTerm));
- console.log('envId', R.toString(envId));
- console.log('opCounter', R.toString(opCounter));
-
- this.unblock();
-
- if (R.anyPass([R.isNil, R.isEmpty])(searchTerm)) {
- return {
- searchResults: [],
- opCounter: opCounter
- };
- }
-
- let searchExp = new RegExp(regexEscape(searchTerm), 'i');
-
- let query = {
- name: searchExp
- };
-
- if (! R.isNil(envId)) {
- let env = Environments.findOne({ _id: envId });
- query = R.merge(query, {
- environment: env.name
- });
- }
-
- let searchResults = Inventory.find(query, {
- limit: AUTO_COMPLETE_RESULTS_LIMIT
- }).fetch();
-
- searchResults = R.map((inventory) => {
- console.log('search result');
- console.log(R.toString(inventory));
-
- let itemEnv = Environments.findOne({ name: inventory.environment });
-
- return R.merge(inventory, {
- _envId: itemEnv._id
- });
- }, searchResults);
-
- return {
- opCounter: opCounter,
- searchResults: searchResults,
- };
- },
-
- 'expandNodePath': function(nodeId) {
- console.log('method server: expandNodePath', R.toString(nodeId));
-
- //check(nodeId, MongoI);
- this.unblock();
-
- let node = Inventory.findOne({ _id: nodeId });
- if (R.isNil(node)) {
- console.log('method server: expandNodePath - no node');
- return null;
- }
-
- let idList = R.pipe(R.split('/'), R.drop(2))(node.id_path);
- let result = R.map((partId) => {
- return Inventory.findOne({ environment: node.environment, id: partId });
- }, idList);
-
- console.log('method server: expandNodePath - results', result);
- return result;
- },
-
- 'inventoryFindNode?type&env&name': function(type, envName, nodeName) {
- console.log('method server: inventoryFindNode',
- R.toString(type), R.toString(envName), R.toString(nodeName));
-
- check(envName, String);
- check(nodeName, String);
- this.unblock();
-
- let query = { type: type, environment: envName, name: nodeName };
- let node = Inventory.findOne(query);
-
- return {
- node: node
- };
- },
-
- 'inventoryFindNode?env&id': function (envName, nodeId) {
- console.log('method server: inventoryFindNode?env&id',
- R.toString(envName), R.toString(nodeId));
-
- check(envName, String);
- check(nodeId, String);
- this.unblock();
-
- let query = { environment: envName, id: nodeId };
- let node = Inventory.findOne(query);
-
- return {
- node: node
- };
- },
-
- 'inventoryFindNode?DataAndAttrs': function (nodeId) {
- console.log(`method server: inventoryFindNode?DataAndAttrs. ${R.toString(nodeId)}`);
- //check(nodeId, ObjectId);
- this.unblock();
-
- let query = { _id: nodeId };
- let node = Inventory.findOne(query);
- let attrsDefs = NodeHoverAttr.findOne({ 'type': node.type });
- let attributes = calcAttrsForItem(node, attrsDefs);
-
- return {
- node: node,
- nodeName: node.name,
- attributes: attributes
- };
- },
-});
diff --git a/ui/imports/api/inventories/server/publications.js b/ui/imports/api/inventories/server/publications.js
deleted file mode 100644
index f35ff30..0000000
--- a/ui/imports/api/inventories/server/publications.js
+++ /dev/null
@@ -1,250 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// 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 { Counts } from 'meteor/tmeasday:publish-counts';
-import { check } from 'meteor/check';
-import * as R from 'ramda';
-
-import { Inventory } from '../inventories.js';
-import { regexEscape } from '/imports/lib/regex-utils';
-
-Meteor.publish('inventory', function () {
- console.log('server subscribtion to: inventory');
- //return Inventory.find({$where: 'this.id_path.match('^/WebEX-Mirantis@Cisco/')'});
- //return Inventory.find({ 'show_in_tree': true });
- return Inventory.find({});
-});
-
-Meteor.publish('inventory?_id', function (_id) {
- console.log('server subscribtion to: inventory?_id');
- console.log('_id:', R.toString(_id));
-
- return Inventory.find({ _id: _id });
-});
-
-Meteor.publish('inventory?id', function (id) {
- console.log('server subscribtion to: inventory?id');
- return Inventory.find({id: id});
-});
-
-Meteor.publish('inventory?env&id', function (env, id) {
- console.log('server subscribtion to: inventory?env&id');
- console.log(`-env: ${R.toString(env)}`);
- console.log(`-id: ${R.toString(id)}`);
-
- return Inventory.find({environment: env, id: id});
-});
-
-Meteor.publish('inventory?id_path', function (id_path) {
- console.log('server subscribtion to: inventory?id_path');
- return Inventory.find({id_path: id_path});
-});
-
-Meteor.publish('inventory?name&env&type', function (name, env, type) {
- console.log('server subscribtion to: inventory?name&env&type');
- console.log('-name:', R.toString(name));
- console.log('-env:', R.toString(env));
- console.log('-type:', R.toString(type));
-
- let query = {
- name: name,
- environment: env,
- type: type
- };
-
- console.log('query', R.toString(query));
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?_id-in', function (idsList) {
- var query = {
- _id: { $in: idsList }
- };
- /*
- var counterName = 'inventory?env+type!counter?env=' + env + '&type=' + type;
-
- console.log('server subscribing to counter: ' + counterName);
- Counts.publish(this, counterName, Inventory.find(query));
- */
- console.log('server subscribtion to: inventory?_id-in');
- console.log('- id-in: ' + idsList);
-
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?env+type', function (env, type) {
- var query = {
- environment: env,
- type: type
- };
- var counterName = 'inventory?env+type!counter?env=' + env + '&type=' + type;
-
- console.log('server subscribing to counter: ' + counterName);
- Counts.publish(this, counterName, Inventory.find(query));
-
- console.log('server subscribtion to: inventory-by-env-and-type');
- console.log('-env: ' + env);
- console.log('-type: ' + type);
-
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?env&binding:host_id&type', function (env, host_id, type) {
- var query = {
- environment: env,
- 'binding:host_id': host_id,
- type: type
- };
- console.log('server subscribtion to: inventory?env&binding:host_id&type');
- console.log('-env: ' + env);
- console.log('-binding:host_id: ' + host_id);
- console.log('-type: ' + type);
-
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?env+name', function (env, name) {
- var query = {
- name: name,
- environment: env
- };
-
- console.log('server subscribtion to: inventory?env+name');
- console.log('- name: ' + name);
- console.log('- env: ' + env);
-
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?type+host', function (type, host) {
- var query = {
- type: type,
- host: host
- };
-/*
- var counterName = 'inventory?env+type!counter?env=' + env + '&type=' + type;
-
- console.log('server subscribing to counter: ' + counterName);
- Counts.publish(this, counterName, Inventory.find(query));
-*/
-
- console.log('server subscribtion to: inventory?type+host');
- console.log('- type: ' + type);
- console.log('- host: ' + host);
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory?id_path_start&type', function (id_path, type) {
- check(id_path, String);
- check(type, String);
-
- let idPathExp = new RegExp(`^${regexEscape(id_path)}`);
-
- let query = {
- id_path: idPathExp,
- type: type
- };
-
- var counterName = 'inventory?id_path_start&type!counter?id_path_start=' +
- id_path + '&type=' + type;
-
- console.log('server subscribing to counter: ' + counterName);
- Counts.publish(this, counterName, Inventory.find(query));
-
- console.log('server subscribtion to: inventory?id_path_start&type');
- console.log('-id_path_start: ' + id_path);
- console.log('-type: ' + type);
- return Inventory.find(query);
-});
-
-
-Meteor.publish('inventory.children', function (id, type, name, env) {
- console.log('server subscribtion to: inventory.children');
- console.log('node id: ' + R.toString(id));
- console.log('node type: ' + R.toString(type));
- console.log('node name: ' + R.toString(name));
- console.log('node env: ' + R.toString(env));
-
- let query = {
- $or:
- [
- {
- environment: env,
- parent_id: id
- },
- ]
- };
-
- if (R.equals('host_ref', type)) {
- let realParent = Inventory.findOne({
- name: name,
- environment: env,
- type: 'host'
- });
-
- query = R.merge(query, {
- $or: R.append({
- environment: env,
- parent_id: realParent.id
- }, query.$or)
- });
- }
-
- console.log('query: ', R.toString(query));
-
- return Inventory.find(query);
-});
-
-Meteor.publish('inventory.first-child', function (id, type, name, env) {
- console.log('server subscribing to: inventory.first-child');
- console.log('node id: ' + R.toString(id));
- console.log('node type: ' + R.toString(type));
- console.log('node name: ' + R.toString(name));
- console.log('node env: ' + R.toString(env));
-
- var counterName = 'inventory.first-child!counter!id=' + id;
- var query = {
- $or: [
- {
- environment: env,
- parent_id: id
- }
- ]
- };
-
- if (R.equals('host_ref', type)) {
- let realParent = Inventory.findOne({
- name: name,
- environment: env,
- type: 'host'
- });
-
- query = R.merge(query, {
- $or: R.append({
- environment: env,
- parent_id: realParent.id
- }, query.$or)
- });
- }
-
- Counts.publish(this, counterName, Inventory.find(query, { limit: 1 }));
- console.log('server subscribing to counter: ' + counterName);
-
-// todo: eyaltask: all criteria
- console.log('query: ', R.toString(query));
- return Inventory.find(query, { limit: 1 });
-});
-
-Meteor.publish('inventoryByEnv', function (env) {
- console.log('server subscribtion to: inventoryByEnv');
- //return Inventory.find({$where: 'this.id_path.match('^/WebEX-Mirantis@Cisco/')'});
- //return Inventory.find({ 'show_in_tree': true });
- return Inventory.find({'environment':env});
-});
-