-
Notifications
You must be signed in to change notification settings - Fork 9
/
vendors.js
46 lines (37 loc) · 1.25 KB
/
vendors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require('colors');
var MongoClient = require('mongodb').MongoClient,
OpenNebula = require('opennebula'),
config = require('./config'),
emailjs = require('emailjs');
MongoClient.connect(config.mongodb, function(err, db) {
if (err) throw err;
exports.mongo = db;
console.log('(SYSTEM) Connected to MongoDB.'.green);
});
exports.email = function(message, destination, subject, from, callback) {
var email = emailjs.server.connect({
user: config.email.user,
password: config.email.password,
host: config.email.smtp
});
email.send({
text: message,
'reply-to': from || config.email.user,
from: from || config.email.user,
to: destination,
subject: subject || 'Cloudash'
}, function(err, message) {
if (callback) callback(err, message);
});
};
var onehost = process.env.ONE_HOST_DEV || process.env.ONE_HOST;
var oneauth = process.env.ONE_CREDENTIALS_DEV || process.env.ONE_CREDENTIALS;
if(config.providers.one) {
onehost = config.providers.one.host;
oneauth = config.providers.one.auth;
}
exports.one = new OpenNebula(oneauth, onehost);
exports.onehost = onehost.replace(':2633/RPC2', '');
exports.oneauth = oneauth;
exports.onesunstone = config.providers.one.sunstone;
exports.onenetwork = config.providers.one.network;