1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#!/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_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("prefabs");'
$MONGO_CMD --eval 'db.prefabs.insertOne(
{
"type": "rack",
"name": "test_rack3",
"size": 42,
"depth": 42,
"author": "Jacob Burley",
"visibility": "public",
"children": [
{
"type": "switch",
"ports": 48,
"power_draw": 150,
"psus": 1,
"size": 1
},
{
"type": "chassis",
"size": 4,
"children": [
{
"type": "mainboard",
"sockets": 1,
"dimm_slots": 4,
"nics": 1,
"pcie_slots": 2,
"children": [
{
"type": "CPU",
"coreCount": 4,
"SMT": true,
"base_clk": 3.5,
"boost_clk": 3.9,
"brand": "Intel",
"SKU": "i7-3770K",
"socket": "LGA1155",
"TDP": 77
},
{
"type": "DDR3",
"capacity": 4096,
"memfreq": 1333,
"ecc": false
},
{
"type": "DDR3",
"capacity": 4096,
"memfreq": 1333,
"ecc": false
},
{
"type": "DDR3",
"capacity": 4096,
"memfreq": 1333,
"ecc": false
},
{
"type": "DDR3",
"capacity": 4096,
"memfreq": 1333,
"ecc": false
},
{
"type": "GPU",
"VRAM": 8192,
"coreCount": 2304,
"brand": "AMD",
"technologies": "OpenCL",
"pcie_gen": "3x16",
"tdp": 169,
"slots": 2
}
]
},
{
"type": "PSU",
"wattage": 550,
"ac": true
},
{
"type": "disk",
"size": 2000,
"interface": "SATA",
"media": "flash",
"form_factor": 2.5
}
]
}
]
});'
# $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"
# }
# }
# }
# }
# }
# }
# });'
|