diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-06-23 14:19:54 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-06-23 14:19:54 +0200 |
| commit | 239173c17b0cd314a3d515cfa46bccfec05402c2 (patch) | |
| tree | 12cbcf58d935d0b7c18dde8aebbc2085abc3282f | |
| parent | 3bd5d338634d596979bdd3a370d9033398b587f1 (diff) | |
Add all collections
| -rw-r--r-- | mongodb/mongo-init-opendc-db.sh | 66 | ||||
| -rw-r--r-- | mongodb/mongo-init.js | 67 | ||||
| -rw-r--r-- | opendc-api-spec.yml | 173 |
3 files changed, 115 insertions, 191 deletions
diff --git a/mongodb/mongo-init-opendc-db.sh b/mongodb/mongo-init-opendc-db.sh index 38a8d85d..e7a787fe 100644 --- a/mongodb/mongo-init-opendc-db.sh +++ b/mongodb/mongo-init-opendc-db.sh @@ -4,20 +4,36 @@ echo 'Creating opendc user and db' mongo opendc --host localhost \ --port 27017 \ - -u $MONGO_INITDB_ROOT_USERNAME \ - -p $MONGO_INITDB_ROOT_PASSWORD \ + -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_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" + +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": "test_rack3", + "name": "testRack3", "size": 42, "depth": 42, "author": "Jacob Burley", @@ -26,7 +42,7 @@ $MONGO_CMD --eval 'db.prefabs.insertOne( { "type": "switch", "ports": 48, - "power_draw": 150, + "powerDraw": 150, "psus": 1, "size": 1 }, @@ -37,16 +53,16 @@ $MONGO_CMD --eval 'db.prefabs.insertOne( { "type": "mainboard", "sockets": 1, - "dimm_slots": 4, + "dimmSlots": 4, "nics": 1, - "pcie_slots": 2, + "pcieSlots": 2, "children": [ { "type": "CPU", "coreCount": 4, "SMT": true, - "base_clk": 3.5, - "boost_clk": 3.9, + "baseClk": 3.5, + "boostClk": 3.9, "brand": "Intel", "SKU": "i7-3770K", "socket": "LGA1155", @@ -82,7 +98,7 @@ $MONGO_CMD --eval 'db.prefabs.insertOne( "coreCount": 2304, "brand": "AMD", "technologies": "OpenCL", - "pcie_gen": "3x16", + "pcieGen": "3x16", "tdp": 169, "slots": 2 } @@ -98,35 +114,9 @@ $MONGO_CMD --eval 'db.prefabs.insertOne( "size": 2000, "interface": "SATA", "media": "flash", - "form_factor": 2.5 + "formFactor": 2.5 } ] } ] });' - -$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 diff --git a/mongodb/mongo-init.js b/mongodb/mongo-init.js deleted file mode 100644 index 562bda6f..00000000 --- a/mongodb/mongo-init.js +++ /dev/null @@ -1,67 +0,0 @@ -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/opendc-api-spec.yml b/opendc-api-spec.yml index 3ad8add8..38ae2cc8 100644 --- a/opendc-api-spec.yml +++ b/opendc-api-spec.yml @@ -7,6 +7,7 @@ host: opendc.org basePath: /v1 schemes: - https + paths: '/users': get: @@ -761,91 +762,6 @@ paths: description: Trace not found. definitions: - Topology: - type: object - properties: - _id: - type: string - name: - type: string - rooms: - type: array - items: - type: object - properties: - _id: - type: string - name: - type: string - tiles: - type: array - items: - type: object - properties: - _id: - type: string - positionX: - type: integer - positionY: - type: integer - object: - type: object - properties: - capacity: - type: integer - powerCapacityW: - type: integer - machines: - type: array - items: - type: object - properties: - position: - type: integer - cpuItems: - type: array - items: - type: object - properties: - name: - type: string - clockRateMhz: - type: integer - numberOfCores: - type: integer - gpuItems: - type: array - items: - type: object - properties: - name: - type: string - clockRateMhz: - type: integer - numberOfCores: - type: integer - memoryItems: - type: array - items: - type: object - properties: - name: - type: string - speedMbPerS: - type: integer - sizeMb: - type: integer - storageItems: - type: array - items: - type: integer - properties: - name: - type: string - speedMbPerS: - type: integer - sizeMb: - type: integer Experiment: type: object properties: @@ -944,6 +860,91 @@ definitions: type: integer flopsLeft: type: integer + Topology: + type: object + properties: + _id: + type: string + name: + type: string + rooms: + type: array + items: + type: object + properties: + _id: + type: string + name: + type: string + tiles: + type: array + items: + type: object + properties: + _id: + type: string + positionX: + type: integer + positionY: + type: integer + object: + type: object + properties: + capacity: + type: integer + powerCapacityW: + type: integer + machines: + type: array + items: + type: object + properties: + position: + type: integer + cpuItems: + type: array + items: + type: object + properties: + name: + type: string + clockRateMhz: + type: integer + numberOfCores: + type: integer + gpuItems: + type: array + items: + type: object + properties: + name: + type: string + clockRateMhz: + type: integer + numberOfCores: + type: integer + memoryItems: + type: array + items: + type: object + properties: + name: + type: string + speedMbPerS: + type: integer + sizeMb: + type: integer + storageItems: + type: array + items: + type: integer + properties: + name: + type: string + speedMbPerS: + type: integer + sizeMb: + type: integer Trace: type: object properties: @@ -982,7 +983,7 @@ definitions: type: string familyName: type: string - simulations: + authorizations: type: array items: type: object |
