diff options
Diffstat (limited to 'mongodb/mongo-init-opendc-db.sh')
| -rw-r--r-- | mongodb/mongo-init-opendc-db.sh | 50 |
1 files changed, 46 insertions, 4 deletions
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 |
