osmith submitted this change.
testenv: vendor the open5gs-dbctl script
Fix that in jenkins the logic for downloading open5gs-dbctl started
failing with "429 Too Many Requests" errors.
I have also considered mirroring the repository and fetching the file
from there instead. But I think downloading scripts with wget while
preparing the testsuite is a hack and this is a more elegant solution.
Imported version:
https://github.com/open5gs/open5gs/blob/ee596937d540d10ece2ae7f4557490d68f20eb14/misc/db/open5gs-dbctl
The license is AGPL-3.0-or-later:
* https://github.com/open5gs/open5gs/blob/ee596937d540d10ece2ae7f4557490d68f20eb14/LICENSE
* https://github.com/open5gs/open5gs/blob/ee596937d540d10ece2ae7f4557490d68f20eb14/meson.build#L20
Change-Id: If30273899d7ee498c160b723f2425a033ae4d971
---
M 5gc/create_test_subscribers.sh
A _testenv/data/scripts/open5gs-dbctl
M hss/create_test_subscribers.sh
M pcrf/create_test_subscribers.sh
4 files changed, 880 insertions(+), 33 deletions(-)
diff --git a/5gc/create_test_subscribers.sh b/5gc/create_test_subscribers.sh
index 28a7b6f..f57b29a 100755
--- a/5gc/create_test_subscribers.sh
+++ b/5gc/create_test_subscribers.sh
@@ -1,16 +1,6 @@
#!/bin/sh -ex
DB_URI="mongodb://127.0.0.103/open5gs"
-DBCTL="$TESTENV_CACHE_DIR/open5gs-dbctl"
-DBCTL_CMD="$DBCTL --db_uri=$DB_URI"
-
-if ! [ -e "$DBCTL" ]; then
- wget "https://raw.githubusercontent.com/open5gs/open5gs/v2.7.1/misc/db/open5gs-dbctl" \
- -O "$DBCTL"
-fi
-
-if ! [ -x "$DBCTL" ]; then
- chmod +x "$DBCTL"
-fi
+DBCTL_CMD="open5gs-dbctl --db_uri=$DB_URI"
# mongod needs some time to bootstrap...
while ! mongosh --quiet $DB_URI</dev/null; do
diff --git a/_testenv/data/scripts/open5gs-dbctl b/_testenv/data/scripts/open5gs-dbctl
new file mode 100755
index 0000000..e7de1f1
--- /dev/null
+++ b/_testenv/data/scripts/open5gs-dbctl
@@ -0,0 +1,877 @@
+#!/bin/bash
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# Upstream: https://github.com/open5gs/open5gs/blob/main/misc/db/open5gs-dbctl
+
+version=0.10.3
+
+display_help() {
+ echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)"
+ echo "FLAGS: --db_uri=mongodb://localhost"
+ echo "COMMANDS:" >&2
+ echo " add {imsi key opc}: adds a user to the database with default values"
+ echo " add {imsi ip key opc}: adds a user to the database with default values and a IPv4 address for the UE"
+ echo " addT1 {imsi key opc}: adds a user to the database with 3 differents apns"
+ echo " addT1 {imsi ip key opc}: adds a user to the database with 3 differents apns and the same IPv4 address for the each apn"
+ echo " remove {imsi}: removes a user from the database"
+ echo " reset: WIPES OUT the database and restores it to an empty default"
+ echo " static_ip {imsi ip4}: adds a static IP assignment to an already-existing user"
+ echo " static_ip6 {imsi ip6}: adds a static IPv6 assignment to an already-existing user"
+ echo " type {imsi type}: changes the PDN-Type of the first PDN: 1 = IPv4, 2 = IPv6, 3 = IPv4v6"
+ echo " help: displays this message and exits"
+ echo " default values are as follows: APN \"internet\", dl_bw/ul_bw 1 Gbps, PGW address is 127.0.0.3, IPv4 only"
+ echo " add_ue_with_apn {imsi key opc apn}: adds a user to the database with a specific apn,"
+ echo " add_ue_with_slice {imsi key opc apn sst sd}: adds a user to the database with a specific apn, sst and sd"
+ echo " update_apn {imsi apn slice_num}: adds an APN to the slice number slice_num of an existent UE"
+ echo " update_slice {imsi apn sst sd}: adds an slice to an existent UE"
+ echo " showall: shows the list of subscriber in the db"
+ echo " showpretty: shows the list of subscriber in the db in a pretty json tree format"
+ echo " showfiltered: shows {imsi key opc apn ip} information of subscriber"
+ echo " ambr_speed {imsi dl_value dl_unit ul_value ul_unit}: Change AMBR speed from a specific user and the unit values are \"[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ]\""
+ echo " subscriber_status {imsi subscriber_status_val={0,1} operator_determined_barring={0..8}}: Change TS 29.272 values for Subscriber-Status (7.3.29) and Operator-Determined-Barring (7.3.30)"
+ echo " lbo_roaming_allowed {imsi lbo_roaming_allowed={0,1}}: Change roaming type for a specific subscriber: 0 = LBO roaming (default), 1 = HR roaming"
+
+}
+
+while test $# -gt 0; do
+ case "$1" in
+ --db_uri*)
+ DB_URI=`echo $1 | sed -e 's/^[^=]*=//g'`
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+DB_URI="${DB_URI:-mongodb://localhost/open5gs}"
+
+if [ "$#" -lt 1 ]; then
+ display_help
+ exit 1
+fi
+
+if [ "$1" = "help" ]; then
+ display_help
+ exit 1
+fi
+
+if [ "$1" = "add" ]; then
+ if [ "$#" -eq 4 ]; then
+ IMSI=$2
+ KI=$3
+ OPC=$4
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt(1),
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"internet\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ if [ "$#" -eq 5 ]; then
+ IMSI=$2
+ IP=$3
+ KI=$4
+ OPC=$5
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt(1),
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"internet\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"ue\":
+ {
+ \"ipv4\": \"$IP\"
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add imsi key opc\""
+ exit 1
+fi
+
+if [ "$1" = "addT1" ]; then
+ if [ "$#" -eq 4 ]; then
+ IMSI=$2
+ KI=$3
+ OPC=$4
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt(1),
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"internet\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ },{
+ \"name\" : \"internet1\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ },{
+ \"name\" : \"internet2\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }
+ ],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ if [ "$#" -eq 5 ]; then
+ IMSI=$2
+ IP=$3
+ KI=$4
+ OPC=$5
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt(1),
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"internet\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"ue\":
+ {
+ \"ipv4\": \"$IP\"
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ },{
+ \"name\" : \"internet1\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"ue\":
+ {
+ \"ipv4\": \"$IP\"
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ },{
+ \"name\" : \"internet2\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"ue\":
+ {
+ \"ipv4\": \"$IP\"
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }
+ ],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add imsi key opc\""
+ exit 1
+fi
+
+if [ "$1" = "remove" ]; then
+ if [ "$#" -ne 2 ]; then
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl remove imsi\""
+ exit 1
+ fi
+
+ IMSI=$2
+ mongosh --eval "db.subscribers.deleteOne({\"imsi\": \"$IMSI\"});" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "reset" ]; then
+ if [ "$#" -ne 1 ]; then
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl reset\""
+ exit 1
+ fi
+
+ mongosh --eval "db.subscribers.deleteMany({});" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "static_ip" ]; then
+ if [ "$#" -ne 3 ]; then
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl static_ip imsi ip\""
+ exit 1
+ fi
+ IMSI=$2
+ IP=$3
+
+ mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.ue.ipv4\": \"$IP\" }});" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "static_ip6" ]; then
+ if [ "$#" -ne 3 ]; then
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl static_ip6 imsi ip\""
+ exit 1
+ fi
+ IMSI=$2
+ IP=$3
+
+ mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.ue.ipv6\": \"$IP\" }});" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "type" ]; then
+ if [ "$#" -ne 3 ]; then
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl type imsi type\""
+ exit 1
+ fi
+ IMSI=$2
+ TYPE=$3
+
+ mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.type\": NumberInt($TYPE) }});" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "add_ue_with_apn" ]; then
+ if [ "$#" -eq 5 ]; then
+ IMSI=$2
+ KI=$3
+ OPC=$4
+ APN=$5
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt(1),
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"$APN\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_apn imsi key opc apn\""
+ exit 1
+fi
+
+if [ "$1" = "add_ue_with_slice" ]; then
+ if [ "$#" -eq 7 ]; then
+ IMSI=$2
+ KI=$3
+ OPC=$4
+ APN=$5
+ SST=$6
+ SD=$7
+
+ mongosh --eval "db.subscribers.insertOne(
+ {
+ \"_id\": new ObjectId(),
+ \"schema_version\": NumberInt(1),
+ \"imsi\": \"$IMSI\",
+ \"msisdn\": [],
+ \"imeisv\": [],
+ \"mme_host\": [],
+ \"mm_realm\": [],
+ \"purge_flag\": [],
+ \"slice\":[
+ {
+ \"sst\": NumberInt($SST),
+ \"sd\": \"$SD\",
+ \"default_indicator\": true,
+ \"session\": [
+ {
+ \"name\" : \"$APN\",
+ \"type\" : NumberInt(3),
+ \"qos\" :
+ { \"index\": NumberInt(9),
+ \"arp\":
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\": NumberInt(1),
+ \"pre_emption_vulnerability\": NumberInt(2)
+ }
+ },
+ \"ambr\":
+ {
+ \"downlink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ },
+ \"uplink\":
+ {
+ \"value\": NumberInt(1000000000),
+ \"unit\": NumberInt(0)
+ }
+ },
+ \"pcc_rule\": [],
+ \"_id\": new ObjectId(),
+ }],
+ \"_id\": new ObjectId(),
+ }],
+ \"security\":
+ {
+ \"k\" : \"$KI\",
+ \"op\" : null,
+ \"opc\" : \"$OPC\",
+ \"amf\" : \"8000\",
+ },
+ \"ambr\" :
+ {
+ \"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
+ \"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
+ },
+ \"access_restriction_data\": 32,
+ \"network_access_mode\": 0,
+ \"subscriber_status\": 0,
+ \"operator_determined_barring\": 0,
+ \"subscribed_rau_tau_timer\": 12,
+ \"__v\": 0
+ }
+ );" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_slice imsi key opc apn sst sd\""
+ exit 1
+fi
+
+if [ "$1" = "update_apn" ]; then
+ if [ "$#" -eq 4 ]; then
+ IMSI=$2
+ APN=$3
+ SLICE_NUM=$4
+
+ mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
+ {\$push: { \"slice.$SLICE_NUM.session\":
+ {
+ \"name\" : \"$APN\",
+ \"type\" : NumberInt(3),
+ \"_id\" : new ObjectId(),
+ \"pcc_rule\" : [],
+ \"ambr\" :
+ {
+ \"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
+ \"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
+ },
+ \"qos\" :
+ {
+ \"index\" : NumberInt(9),
+ \"arp\" :
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\" : NumberInt(1),
+ \"pre_emption_vulnerability\" : NumberInt(1),
+ },
+ },
+ }
+ }
+ });" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_apn imsi apn num_slice\""
+ exit 1
+fi
+
+if [ "$1" = "update_slice" ]; then
+ if [ "$#" -eq 5 ]; then
+ IMSI=$2
+ APN=$3
+ SST=$4
+ SD=$5
+
+ mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
+ {\$push: { \"slice\":
+
+ {
+ \"sst\" : NumberInt($SST),
+ \"sd\" : \"$SD\",
+ \"default_indicator\" : false,
+ \"_id\" : new ObjectId(),
+ \"session\" :
+ [{
+ \"name\" : \"$APN\",
+ \"type\" : NumberInt(3),
+ \"_id\" : new ObjectId(),
+ \"pcc_rule\" : [],
+ \"ambr\" :
+ {
+ \"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
+ \"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
+ },
+ \"qos\" :
+ {
+ \"index\" : NumberInt(9),
+ \"arp\" :
+ {
+ \"priority_level\" : NumberInt(8),
+ \"pre_emption_capability\" : NumberInt(1),
+ \"pre_emption_vulnerability\" : NumberInt(1),
+ },
+ },
+ }]
+ }
+ }
+ });" $DB_URI
+ exit $?
+ fi
+
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_slice imsi apn sst sd\""
+ exit 1
+fi
+if [ "$1" = "subscriber_status" ]; then
+ if [ "$#" -eq 4 ]; then
+ IMSI=$2
+ SUB_STATUS=$3
+ OP_DET_BARRING=$4
+ mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
+ {\$set: { \"subscriber_status\": $SUB_STATUS,
+ \"operator_determined_barring\": $OP_DET_BARRING
+ }
+ });" $DB_URI
+ exit $?
+ fi
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl subscriber_status imsi subscriber_status_val={0,1} operator_determined_barring={0..8}"
+ exit 1
+fi
+if [ "$1" = "lbo_roaming_allowed" ]; then
+ if [ "$#" -eq 3 ]; then
+ IMSI=$2
+ LBO_ALLOWED=$3
+ if [ $LBO_ALLOWED = "1" ]; then
+ LBO_ALLOWED_BOOL=true
+ else
+ LBO_ALLOWED_BOOL=false
+ fi
+ mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
+ {\$set: { \"slice.0.session.0.lbo_roaming_allowed\": $LBO_ALLOWED_BOOL
+ }
+ });" $DB_URI
+ exit $?
+ fi
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl lbo_roaming_allowed imsi lbo_roaming_allowed={0,1}"
+ exit 1
+fi
+if [ "$1" = "showall" ]; then
+ mongosh --eval "db.subscribers.find()" $DB_URI
+ exit $?
+fi
+if [ "$1" = "showpretty" ]; then
+ mongosh --eval "db.subscribers.find().pretty()" $DB_URI
+ exit $?
+fi
+if [ "$1" = "showfiltered" ]; then
+ mongosh --eval "db.subscribers.find({},{'_id':0,'imsi':1,'security.k':1, 'security.opc':1,'slice.session.name':1,'slice.session.ue.ipv4':1})" $DB_URI
+ exit $?
+fi
+
+if [ "$1" = "ambr_speed" ]; then
+ if [ "$#" -eq 6 ]; then
+ IMSI=$2
+ DL_VALUE=$3
+ DL_UNIT=$4
+ UL_VALUE=$5
+ UL_UNIT=$6
+ mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},
+ {\$set: {
+ \"ambr\" : {
+ \"downlink\" : {
+ \"value\" : NumberInt($DL_VALUE),
+ \"unit\" : NumberInt($DL_UNIT)
+ },
+ \"uplink\" :{
+ \"value\": NumberInt($UL_VALUE),
+ \"unit\" : NumberInt($UL_UNIT)
+ }
+ },
+ \"slice.0.session.0.ambr\": {
+ \"downlink\" : {
+ \"value\" : NumberInt($DL_VALUE),
+ \"unit\" : NumberInt($DL_UNIT)
+ },
+ \"uplink\" :{
+ \"value\": NumberInt($UL_VALUE),
+ \"unit\" : NumberInt($UL_UNIT)
+ }
+ }
+ }
+ });" $DB_URI
+
+
+ exit $?
+ fi
+ echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl ambr_speed imsi dl_value dl_unit ul_value ul_unit dl is for download and ul is for upload and the unit values are[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ] \""
+ exit 1
+fi
+
+
+display_help
diff --git a/hss/create_test_subscribers.sh b/hss/create_test_subscribers.sh
index f5b6c5b..babd6e6 100755
--- a/hss/create_test_subscribers.sh
+++ b/hss/create_test_subscribers.sh
@@ -1,16 +1,6 @@
#!/bin/sh -ex
DB_URI="mongodb://127.0.0.103/open5gs"
-DBCTL="$TESTENV_CACHE_DIR/open5gs-dbctl"
-DBCTL_CMD="$DBCTL --db_uri=$DB_URI"
-
-if ! [ -e "$DBCTL" ]; then
- wget "https://raw.githubusercontent.com/open5gs/open5gs/v2.7.1/misc/db/open5gs-dbctl" \
- -O "$DBCTL"
-fi
-
-if ! [ -x "$DBCTL" ]; then
- chmod +x "$DBCTL"
-fi
+DBCTL_CMD="open5gs-dbctl --db_uri=$DB_URI"
# mongod needs some time to bootstrap...
while ! mongosh --quiet $DB_URI</dev/null; do
diff --git a/pcrf/create_test_subscribers.sh b/pcrf/create_test_subscribers.sh
index f5b6c5b..babd6e6 100755
--- a/pcrf/create_test_subscribers.sh
+++ b/pcrf/create_test_subscribers.sh
@@ -1,16 +1,6 @@
#!/bin/sh -ex
DB_URI="mongodb://127.0.0.103/open5gs"
-DBCTL="$TESTENV_CACHE_DIR/open5gs-dbctl"
-DBCTL_CMD="$DBCTL --db_uri=$DB_URI"
-
-if ! [ -e "$DBCTL" ]; then
- wget "https://raw.githubusercontent.com/open5gs/open5gs/v2.7.1/misc/db/open5gs-dbctl" \
- -O "$DBCTL"
-fi
-
-if ! [ -x "$DBCTL" ]; then
- chmod +x "$DBCTL"
-fi
+DBCTL_CMD="open5gs-dbctl --db_uri=$DB_URI"
# mongod needs some time to bootstrap...
while ! mongosh --quiet $DB_URI</dev/null; do
To view, visit change 43262. To unsubscribe, or for help writing mail filters, visit settings.