summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjc0b <j.burley@vu.nl>2020-06-09 14:19:54 +0200
committerjc0b <j.burley@vu.nl>2020-06-09 14:54:51 +0200
commit0e01f7118fb265f6f6558fd9c63eb516581c1bee (patch)
treebedd88f8c547c118e784acfc81940277bcba4b2a
parent9b382805740e6f7ecd57a1b4568bd98470f7666e (diff)
progress so far (for remote)
-rw-r--r--Dockerfile12
-rwxr-xr-xbuild/configure.sh20
-rw-r--r--docker-compose.yml15
-rw-r--r--mongodb/mongo-init-opendc-db.sh65
4 files changed, 54 insertions, 58 deletions
diff --git a/Dockerfile b/Dockerfile
index 32b790c5..f7f36d87 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,18 @@
FROM node:14.2.0
MAINTAINER Sacheendra Talluri <sacheendra.t@gmail.com>
+# Adding the mongodb repo and installing the client
+RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - \
+ && echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \
+ && apt-get update \
+ && apt-get install -y mongodb-org
+
# Installing python and web-server dependencies
RUN echo "deb http://ftp.debian.org/debian stretch main" >> /etc/apt/sources.list \
&& apt-get update \
- && apt-get install -y python python-pip yarn git sed mysql-client \
+ && apt-get install -y python3 python3-pip yarn git sed mysql-client pymongo \
+ && pip3 install oauth2client eventlet flask-socketio flask-compress mysql-connector-python-rf \
+ && pip3 install --upgrade pyasn1-modules \
&& rm -rf /var/lib/apt/lists/*
# Copy OpenDC directory
@@ -24,4 +32,4 @@ RUN pip install -e /opendc/opendc-web-server \
# Set working directory
WORKDIR /opendc
-CMD ["sh", "-c", "./build/configure.sh && python2.7 opendc-web-server/main.py keys.json"]
+CMD ["sh", "-c", "./build/configure.sh && python3 opendc-web-server/main.py keys.json"]
diff --git a/build/configure.sh b/build/configure.sh
index eb7324d2..fcb33b1a 100755
--- a/build/configure.sh
+++ b/build/configure.sh
@@ -22,20 +22,20 @@ done
echo "MariaDB available"
-NUM_TABLES=$(eval "$MYSQL_COMMAND -B --disable-column-names -e \"SELECT count(*) FROM information_schema.tables WHERE table_schema='$MYSQL_DATABASE';\"")
+#NUM_TABLES=$(eval "$MYSQL_COMMAND -B --disable-column-names -e \"SELECT count(*) FROM information_schema.tables WHERE table_schema='$MYSQL_DATABASE';\"")
# Check if database is empty
-if [ "$NUM_TABLES" -eq 0 ]; then
- eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/schema.sql
- eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/test.sql
-fi
+#if [ "$NUM_TABLES" -eq 0 ]; then
+# eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/schema.sql
+# eval $MYSQL_COMMAND "$MYSQL_DATABASE" < ./database/test.sql
+#fi
# Writing databse config values to keys.json
cat keys.json | python -c "import os, sys, json; ks = json.load(sys.stdin); \
- ks['MYSQL_HOST'] = 'mariadb'; \
- ks['MYSQL_PORT'] = '3306'; \
- ks['MYSQL_DATABASE'] = os.environ['MYSQL_DATABASE']; \
- ks['MYSQL_USER'] = os.environ['MYSQL_USER']; \
- ks['MYSQL_PASSWORD'] = os.environ['MYSQL_PASSWORD']; \
+ ks['MONGODB_HOST'] = 'mongo'; \
+ ks['MONGODB_PORT'] = '27017'; \
+ ks['MONGODB_DATABASE'] = os.environ['MONGO_DB']; \
+ ks['MYSQL_USER'] = os.environ['MONGO_DB_USER']; \
+ ks['MYSQL_PASSWORD'] = os.environ['MONGO_DB_PASSWORD']; \
print json.dumps(ks, indent=4)" > new_keys.json
mv new_keys.json keys.json
diff --git a/docker-compose.yml b/docker-compose.yml
index 9f3cf805..a36611a1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -14,6 +14,9 @@ services:
- MYSQL_DATABASE=opendc
- MYSQL_USER=opendc
- MYSQL_PASSWORD=opendcpassword
+ - MONGO_DB=opendc
+ - MONGO_DB_USERNAME=opendc
+ - MONGO_DB_PASSWORD=opendcpassword
simulator:
build:
context: ./opendc-simulator
@@ -53,12 +56,12 @@ services:
context: ./mongodb
restart: on-failure
environment:
- MONGO_INITDB_ROOT_USERNAME: root
- MONGO_INITDB_ROOT_PASSWORD: rootpassword
- MONGO_INITDB_DATABASE: admin
- OPENDC_DB: opendc
- OPENDC_DB_USERNAME: opendc
- OPENDC_DB_PASSWORD: opendcpassword
+ - MONGO_INITDB_ROOT_USERNAME=root
+ - MONGO_INITDB_ROOT_PASSWORD=rootpassword
+ - MONGO_INITDB_DATABASE=admin
+ - OPENDC_DB=opendc
+ - OPENDC_DB_USERNAME=opendc
+ - OPENDC_DB_PASSWORD=opendcpassword
ports:
- 27017:27017
#volumes:
diff --git a/mongodb/mongo-init-opendc-db.sh b/mongodb/mongo-init-opendc-db.sh
index 965698e7..38a8d85d 100644
--- a/mongodb/mongo-init-opendc-db.sh
+++ b/mongodb/mongo-init-opendc-db.sh
@@ -105,43 +105,28 @@ $MONGO_CMD --eval 'db.prefabs.insertOne(
]
});'
-# $MONGO_CMD --eval 'db.createCollection("prefabs", {
-# 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
+$MONGO_CMD --eval 'db.createCollection("topologies");'
+
+$MONGO_CMD --eval 'db.createCollection("users");'
+
+$MONGO_CMD --eval 'db.users.insertOne(
+ {
+ "google_id": "23483578932789231",
+ "email": "jorgos.andreadis@gmail.com",
+ "given_name": "Jorgos",
+ "family_name": "Andreadis",
+ "authorizations": [
+ {
+ "simulation_id": 1,
+ "authorization_level": "OWN"
+ },
+ {
+ "simulation_id": 2,
+ "authorization_level": "READ"
+ },
+ {
+ "simulation_id": 3,
+ "authorization_level": "READWRITE"
+ }
+ ]
+ });' \ No newline at end of file