summaryrefslogtreecommitdiff
path: root/mongodb
diff options
context:
space:
mode:
Diffstat (limited to 'mongodb')
-rw-r--r--mongodb/Dockerfile6
-rw-r--r--mongodb/mongo-init-opendc-db.sh12
-rw-r--r--mongodb/mongo-init.js67
-rw-r--r--mongodb/mongo-opendc-schema.sh7
4 files changed, 92 insertions, 0 deletions
diff --git a/mongodb/Dockerfile b/mongodb/Dockerfile
new file mode 100644
index 00000000..e8dd98bc
--- /dev/null
+++ b/mongodb/Dockerfile
@@ -0,0 +1,6 @@
+FROM mongo:4.2.5
+MAINTAINER Jacob Burley <j.burley@vu.nl>
+
+# Import init script
+ADD mongo-init-opendc-db.sh /docker-entrypoint-initdb.d
+ADD mongo-opendc-schema.sh /docker-entrypoint-initdb.d \ No newline at end of file
diff --git a/mongodb/mongo-init-opendc-db.sh b/mongodb/mongo-init-opendc-db.sh
new file mode 100644
index 00000000..55e9ec68
--- /dev/null
+++ b/mongodb/mongo-init-opendc-db.sh
@@ -0,0 +1,12 @@
+#!/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', pwd: 'opendcpassword', roles:[{role:'dbOwner', db: 'opendc'}]});"
+$MONGO_CMD = "mongo opendc --host localhost --port 27017 -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin" \ No newline at end of file
diff --git a/mongodb/mongo-init.js b/mongodb/mongo-init.js
new file mode 100644
index 00000000..562bda6f
--- /dev/null
+++ b/mongodb/mongo-init.js
@@ -0,0 +1,67 @@
+db.auth('root', 'rootpassword')
+
+let error = true
+
+db.createUser(
+ {
+ user: "admin",
+ pwd: "adminpassword",
+ roles: [
+ {
+ role: "readWrite",
+ db: "admin"
+ }
+ ]
+ }
+)
+
+db = db.getSiblingDB('opendc')
+
+db.createUser(
+ {
+ user: "opendc",
+ pwd: "opendcpassword",
+ roles: [
+ {
+ role: "readWrite",
+ db: "opendc"
+ }
+ ]
+ }
+);
+
+db.createCollection(users)
+db.createCollection(authorizations)
+db.createCollection(authorization_levels)
+db.createCollection(simulations)
+db.createCollection(experiments)
+db.createCollection(paths)
+db.createCollection(sections)
+db.createCollection(schedulers)
+db.createCollection(traces)
+db.createCollection(jobs)
+db.createCollection(tasks)
+db.createCollection(task_dependencies)
+db.createCollection(task_states)
+db.createCollection(machine_states)
+db.createCollection(datacenters)
+db.createCollection(rooms)
+db.createCollection(room_types)
+db.createCollection(tiles)
+db.createCollection(objects)
+db.createCollection(object_types)
+db.createCollection(allowed_objects)
+db.createCollection(psus)
+db.createCollection(cooling_items)
+db.createCollection(racks)
+db.createCollection(machines)
+db.createCollection(machine_tags)
+db.createCollection(failure_models)
+db.createCollection(cpus)
+db.createCollection(machine_cpus)
+db.createCollection(gpus)
+db.createCollection(machine_gpus)
+db.createCollection(memories)
+db.createCollection(machine_memories)
+db.createCollection(storages)
+db.createCollection(machine_storages) \ No newline at end of file
diff --git a/mongodb/mongo-opendc-schema.sh b/mongodb/mongo-opendc-schema.sh
new file mode 100644
index 00000000..7fd9d10f
--- /dev/null
+++ b/mongodb/mongo-opendc-schema.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+echo 'Creating opendc db schema...'
+
+$MONGO_CMD = "mongo opendc --host localhost --port 27017 -u $OPENDC_DB_USERNAME -p $OPENDC_DB_PASSWORD --authenticationDatabase opendc"
+
+eval $MONGO_COMMAND --eval "db.createCollection('environments'); db.createCollection('rooms'); db.createCollection('datacenters');" \ No newline at end of file