summaryrefslogtreecommitdiff
path: root/core/mongodb/mongo-init-opendc-db.sh
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-29 16:06:35 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 16:04:00 +0200
commit4a79cefdf5d71715b6c575d5c8bb4fea418c2ba6 (patch)
treefc68847d1e010e2962dac8345a0fd0cc9a2f0681 /core/mongodb/mongo-init-opendc-db.sh
parentad31b66503ec65e611ab96c2a540180ed25f5a6f (diff)
Prepare opendc repository for monorepo
This change prepares the opendc repository for a monorepo setup by moving all files to the core/ directory. After all repositories have been merged into this repository, we will move the correct files back.
Diffstat (limited to 'core/mongodb/mongo-init-opendc-db.sh')
-rw-r--r--core/mongodb/mongo-init-opendc-db.sh122
1 files changed, 122 insertions, 0 deletions
diff --git a/core/mongodb/mongo-init-opendc-db.sh b/core/mongodb/mongo-init-opendc-db.sh
new file mode 100644
index 00000000..e7a787fe
--- /dev/null
+++ b/core/mongodb/mongo-init-opendc-db.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+
+echo 'Creating opendc user and db'
+
+mongo opendc --host localhost \
+ --port 27017 \
+ -u "$MONGO_INITDB_ROOT_USERNAME" \
+ -p "$MONGO_INITDB_ROOT_PASSWORD" \
+ --authenticationDatabase admin \
+ --eval "db.createUser({user: '$OPENDC_DB_USERNAME', pwd: '$OPENDC_DB_PASSWORD', roles:[{role:'dbOwner', db: '$OPENDC_DB'}]});"
+
+MONGO_CMD="mongo $OPENDC_DB -u $OPENDC_DB_USERNAME -p $OPENDC_DB_PASSWORD --authenticationDatabase $OPENDC_DB"
+
+echo 'Creating collections'
+
+$MONGO_CMD --eval 'db.createCollection("users");'
+$MONGO_CMD --eval 'db.createCollection("simulations");'
+$MONGO_CMD --eval 'db.createCollection("topologies");'
+$MONGO_CMD --eval 'db.createCollection("experiments");'
+$MONGO_CMD --eval 'db.createCollection("prefabs");'
+
+echo 'Loading test data'
+
+$MONGO_CMD --eval 'db.users.insertOne(
+ {
+ "googleId": "23483578932789231",
+ "email": "jorgos.andreadis@gmail.com",
+ "givenName": "Jorgos",
+ "familyName": "Andreadis",
+ "authorizations": []
+ });'
+
+$MONGO_CMD --eval 'db.prefabs.insertOne(
+ {
+ "type": "rack",
+ "name": "testRack3",
+ "size": 42,
+ "depth": 42,
+ "author": "Jacob Burley",
+ "visibility": "public",
+ "children": [
+ {
+ "type": "switch",
+ "ports": 48,
+ "powerDraw": 150,
+ "psus": 1,
+ "size": 1
+ },
+ {
+ "type": "chassis",
+ "size": 4,
+ "children": [
+ {
+ "type": "mainboard",
+ "sockets": 1,
+ "dimmSlots": 4,
+ "nics": 1,
+ "pcieSlots": 2,
+ "children": [
+ {
+ "type": "CPU",
+ "coreCount": 4,
+ "SMT": true,
+ "baseClk": 3.5,
+ "boostClk": 3.9,
+ "brand": "Intel",
+ "SKU": "i7-3770K",
+ "socket": "LGA1155",
+ "TDP": 77
+ },
+ {
+ "type": "DDR3",
+ "capacity": 4096,
+ "memfreq": 1333,
+ "ecc": false
+ },
+ {
+ "type": "DDR3",
+ "capacity": 4096,
+ "memfreq": 1333,
+ "ecc": false
+ },
+ {
+ "type": "DDR3",
+ "capacity": 4096,
+ "memfreq": 1333,
+ "ecc": false
+ },
+ {
+ "type": "DDR3",
+ "capacity": 4096,
+ "memfreq": 1333,
+ "ecc": false
+ },
+ {
+ "type": "GPU",
+ "VRAM": 8192,
+ "coreCount": 2304,
+ "brand": "AMD",
+ "technologies": "OpenCL",
+ "pcieGen": "3x16",
+ "tdp": 169,
+ "slots": 2
+ }
+ ]
+ },
+ {
+ "type": "PSU",
+ "wattage": 550,
+ "ac": true
+ },
+ {
+ "type": "disk",
+ "size": 2000,
+ "interface": "SATA",
+ "media": "flash",
+ "formFactor": 2.5
+ }
+ ]
+ }
+ ]
+ });'