Skip to content

Commit f60b7df

Browse files
committed
Amending service provisioning
- Move service availability checks out of import-data and provision-devices - Add database indices - Update microservice versions for Ultralight, Cygnus, Orion-LD and Scorpio
1 parent 466c76d commit f60b7df

File tree

2 files changed

+61
-12
lines changed

2 files changed

+61
-12
lines changed

import-data

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ set -e
88

99

1010
curl () {
11-
docker run --network fiware_default --rm appropriate/curl -s \
11+
docker run --network fiware_default --rm appropriate/curl -s -o /dev/null \
1212
"$@"
1313
printf "."
1414
}
1515

16-
echo -e "⏳ Waiting for \033[1;34mOrion\033[0m to be available\n"
17-
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` -eq 000 ]
18-
do
19-
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` " (waiting for 200)"
20-
sleep 1
21-
done
2216
printf "⏳ Loading context data "
2317

2418
#

services

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77

88
set -e
99

10+
if (( $# != 1 )); then
11+
echo "Illegal number of parameters"
12+
echo "usage: services [create|start|stop]"
13+
exit 1
14+
fi
15+
1016
loadData () {
1117
./import-data
18+
waitForIoTAgent
1219
echo ""
1320
}
1421

@@ -23,11 +30,57 @@ displayServices () {
2330
echo ""
2431
}
2532

26-
if (( $# != 1 )); then
27-
echo "Illegal number of parameters"
28-
echo "usage: services [create|start|stop]"
29-
exit 1
30-
fi
33+
addDatabaseIndex () {
34+
printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;34mOrion\033[0m ..."
35+
docker exec db-mongo mongo --eval '
36+
conn = new Mongo();db.createCollection("orion");
37+
db = conn.getDB("orion");
38+
db.createCollection("entities");
39+
db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
40+
db.entities.createIndex({"_id.type": 1});
41+
db.entities.createIndex({"_id.id": 1});' > /dev/null
42+
43+
docker exec db-mongo mongo --eval '
44+
conn = new Mongo();db.createCollection("orion-openiot");
45+
db = conn.getDB("orion-openiot");
46+
db.createCollection("entities");
47+
db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
48+
db.entities.createIndex({"_id.type": 1});
49+
db.entities.createIndex({"_id.id": 1});' > /dev/null
50+
echo -e " \033[1;32mdone\033[0m"
51+
52+
printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;36mIoT-Agent\033[0m ..."
53+
docker exec db-mongo mongo --eval '
54+
conn = new Mongo();
55+
db = conn.getDB("iotagentul");
56+
db.createCollection("devices");
57+
db.devices.createIndex({"_id.service": 1, "_id.id": 1, "_id.type": 1});
58+
db.devices.createIndex({"_id.type": 1});
59+
db.devices.createIndex({"_id.id": 1});
60+
db.createCollection("groups");
61+
db.groups.createIndex({"_id.resource": 1, "_id.apikey": 1, "_id.service": 1});
62+
db.groups.createIndex({"_id.type": 1});' > /dev/null
63+
echo -e " \033[1;32mdone\033[0m"
64+
}
65+
66+
waitForOrion () {
67+
echo -e "\n⏳ Waiting for \033[1;34mOrion\033[0m to be available\n"
68+
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` -eq 000 ]
69+
do
70+
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:1026/version'` " (waiting for 200)"
71+
sleep 1
72+
done
73+
}
74+
75+
76+
waitForIoTAgent () {
77+
echo -e "\n⏳ Waiting for \033[1;36mIoT-Agent\033[0m to be available\n"
78+
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://iot-agent:4041/version'` -eq 000 ]
79+
do
80+
echo -e "IoT Agent HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:4041/version'` " (waiting for 200)"
81+
sleep 1
82+
done
83+
}
3184

3285
command="$1"
3386
case "${command}" in
@@ -42,6 +95,8 @@ case "${command}" in
4295
echo -e "- \033[1;30mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
4396
echo ""
4497
docker-compose --log-level ERROR -p fiware up -d --remove-orphans
98+
addDatabaseIndex
99+
waitForOrion
45100
loadData
46101
displayServices
47102
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"

0 commit comments

Comments
 (0)