diff options
| author | jc0b <j.burley@vu.nl> | 2020-05-11 20:43:03 +0200 |
|---|---|---|
| committer | jc0b <j.burley@vu.nl> | 2020-06-09 14:51:50 +0200 |
| commit | 4f8612501ed5cf9653aa6ab14c8455605f56464b (patch) | |
| tree | 754a3ae7e1822184be5a195a90e30108bcebe24f /mongodb | |
| parent | 3e182d0476637fca2ee618d26aa6776f0e20b2c7 (diff) | |
Added mongodb dockerfile, removed tests being added to sql db
Diffstat (limited to 'mongodb')
| -rw-r--r-- | mongodb/Dockerfile | 3 | ||||
| -rw-r--r-- | mongodb/mongo-init-opendc-db.sh | 50 | ||||
| -rw-r--r-- | mongodb/mongo-opendc-schema.sh | 7 |
3 files changed, 47 insertions, 13 deletions
diff --git a/mongodb/Dockerfile b/mongodb/Dockerfile index e8dd98bc..b4eb9dd1 100644 --- a/mongodb/Dockerfile +++ b/mongodb/Dockerfile @@ -2,5 +2,4 @@ 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 +ADD mongo-init-opendc-db.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 index 55e9ec68..ed33e955 100644 --- a/mongodb/mongo-init-opendc-db.sh +++ b/mongodb/mongo-init-opendc-db.sh @@ -2,11 +2,53 @@ echo 'Creating opendc user and db' -mongo opendc \ - --host localhost \ +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 + --eval "db.createUser({user: '$OPENDC_DB_USERNAME', pwd: '$OPENDC_DB_PASSWORD', roles:[{role:'dbOwner', db: '$OPENDC_DB'}]});" +MONGO_ROOT_CMD="mongo $OPENDC_DB --host localhost --port 27017 -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin" + +#echo 'Creating opendc db schema...' +MONGO_CMD="mongo $OPENDC_DB -u $OPENDC_DB_USERNAME -p $OPENDC_DB_PASSWORD --authenticationDatabase $OPENDC_DB" +$MONGO_CMD --eval 'db.createCollection("environments", { + validator: { + $jsonSchema: { + bsonType: "object", + required: ["name"], + properties: { + name: { + bsonType: "string", + description: "The name of the environment i.e. Production, or Compute Cluster" + }, + datacenters: { + bsonType: "object", + required: ["name, location, length, width, height"], + properties: { + name: { + bsonType: "string", + description: "The name of the datacenter i.e. eu-west-1, or Science Building" + }, + location: { + bsonType: "string", + description: "The location of the datacenter i.e. Frankfurt, or De Boelelaan 1105" + }, + length: { + bsonType: "double", + description: "The physical length of the datacenter, in centimetres" + }, + width: { + bsonType: "double", + description: "The physical width of the datacenter, in centimetres" + }, + height: { + bsonType: "double", + description: "The physical height of the datacenter, in centimetres" + } + } + } + } + } + } +});'
\ No newline at end of file diff --git a/mongodb/mongo-opendc-schema.sh b/mongodb/mongo-opendc-schema.sh deleted file mode 100644 index 7fd9d10f..00000000 --- a/mongodb/mongo-opendc-schema.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 |
