forked from edgexfoundry/developer-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_mongo.js
113 lines (107 loc) · 3.98 KB
/
init_mongo.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//###############################################################################
//# Copyright 2016-2017 Dell Inc.
//#
//# Licensed under the Apache License, Version 2.0 (the "License");
//# you may not use this file except in compliance with the License.
//# You may obtain a copy of the License at
//#
//# http://www.apache.org/licenses/LICENSE-2.0
//#
//# Unless required by applicable law or agreed to in writing, software
//# distributed under the License is distributed on an "AS IS" BASIS,
//# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//# See the License for the specific language governing permissions and
//# limitations under the License.
//#
//###############################################################################
//EdgeX Mongo DB initialization script
//version 1
//author: Jim White
//Create user for security service in Mongo
db=db.getSiblingDB('admin')
db=db.getSiblingDB('authorization')
db.createUser({ user: "admin",pwd: "password",roles: [ { role: "readWrite", db: "authorization" } ]});
//Create keystore collection
db.createCollection("keyStore");
db.keyStore.insert( { xDellAuthKey: "x-dell-auth-key", secretKey: "EDGEX_SECRET_KEY" } );
//Create Service Mapping
db.createCollection("serviceMapping");
db.serviceMapping.insert( { serviceName: "coredata", serviceUrl: "http://localhost:48080/" });
db.serviceMapping.insert( { serviceName: "metadata", serviceUrl: "http://localhost:48081/" });
db.serviceMapping.insert( { serviceName: "command", serviceUrl: "http://localhost:48082/" });
db.serviceMapping.insert( { serviceName: "rules", serviceUrl: "http://localhost:48084/" });
db.serviceMapping.insert( { serviceName: "notifications", serviceUrl: "http://localhost:48060/" });
db.serviceMapping.insert( { serviceName: "logging", serviceUrl: "http://localhost:48061/" });
db=db.getSiblingDB('admin')
db.system.users.remove({});
db.system.version.remove({});
db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 });
db=db.getSiblingDB('admin')
db.createUser({ user: "admin",
pwd: "password",
roles: [
{ role: "readWrite", db: "admin" }
]
});
db=db.getSiblingDB('metadata')
db.createUser({ user: "meta",
pwd: "password",
roles: [
{ role: "readWrite", db: "metadata" }
]
});
db.createCollection("addressable");
db.addressable.createIndex({name: 1}, {unique: true});
db.createCollection("command");
db.createCollection("device");
db.device.createIndex({name: 1}, {unique: true});
db.createCollection("deviceProfile");
db.deviceProfile.createIndex({name: 1}, {unique: true});
db.createCollection("deviceReport");
db.deviceReport.createIndex({name: 1}, {unique: true});
db.createCollection("deviceService");
db.deviceService.createIndex({name: 1}, {unique: true});
db.createCollection("provisionWatcher");
db.provisionWatcher.createIndex({name: 1}, {unique: true});
db.createCollection("schedule");
db.schedule.createIndex({name: 1}, {unique: true});
db.createCollection("scheduleEvent");
db.scheduleEvent.createIndex({name: 1}, {unique: true});
db=db.getSiblingDB('coredata')
db.createUser({ user: "core",
pwd: "password",
roles: [
{ role: "readWrite", db: "coredata" }
]
});
db.createCollection("event");
db.createCollection("reading");
db.createCollection("valueDescriptor");
db.valueDescriptor.createIndex({name: 1}, {unique: true});
db=db.getSiblingDB('rules_engine_db')
db.createUser({ user: "rules_engine_user",
pwd: "password",
roles: [
{ role: "readWrite", db: "rules_engine_db" }
]
});
db=db.getSiblingDB('notifications')
db.createUser({ user: "notifications",
pwd: "password",
roles: [
{ role: "readWrite", db: "notifications" }
]
});
db.createCollection("notification");
db.createCollection("transmission");
db.createCollection("subscription");
db.notification.createIndex({slug: 1}, {unique: true});
db.subscription.createIndex({slug: 1}, {unique: true});
db=db.getSiblingDB('logging')
db.createUser({ user: "logging",
pwd: "password",
roles: [
{ role: "readWrite", db: "logging" }
]
});
db.createCollection("logEntry");