Skip to content

Commit ea36108

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 4159824 commit ea36108

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

@@ -25,11 +32,57 @@ displayServices () {
2532
echo ""
2633
}
2734

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

3487
command="$1"
3588
case "${command}" in
@@ -45,6 +98,8 @@ case "${command}" in
4598
echo -e "- \033[1mMosquitto\033[0m acts as an MQTT Message Broker"
4699
echo ""
47100
docker-compose --log-level ERROR -p fiware up -d --remove-orphans
101+
addDatabaseIndex
102+
waitForOrion
48103
loadData
49104
displayServices
50105
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"

0 commit comments

Comments
 (0)