badhri85 | 4c028b3 | 2021-11-03 18:24:05 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2018 Intel Corporation |
| 4 | # Copyright 2019-present Open Networking Foundation |
| 5 | # |
| 6 | # SPDX-License-Identifier: Apache-2.0 |
badhri85 | 4c028b3 | 2021-11-03 18:24:05 -0500 | [diff] [blame] | 7 | |
| 8 | set -ex |
| 9 | |
| 10 | function provision_users() { |
| 11 | count=${1} |
| 12 | imsi=${2} |
| 13 | msisdn=${3} |
| 14 | apn=${4} |
| 15 | key=${5} |
| 16 | opc=${6} |
| 17 | sqn=${7} |
| 18 | cassandra_ip=${8} |
| 19 | mmeidentity=${9} |
| 20 | mmerealm=${10} |
| 21 | |
| 22 | for (( i=1; i<=$count; i++ )) |
| 23 | do |
| 24 | echo "IMSI=$imsi MSISDN=$msisdn" |
| 25 | cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data, supported_features) VALUES ('$imsi', $msisdn, 41, '$key', '$opc','$mmeidentity', 3, '$mmerealm', '2683b376d1056746de3b254012908e0e', $sqn, '{\"Subscription-Data\":{\"Access-Restriction-Data\":41,\"Subscriber-Status\":0,\"Network-Access-Mode\":2,\"Regional-Subscription-Zone-Code\":[\"0x0123\",\"0x4567\",\"0x89AB\",\"0xCDEF\",\"0x1234\",\"0x5678\",\"0x9ABC\",\"0xDEF0\",\"0x2345\",\"0x6789\"],\"MSISDN\":\"0x$msisdn\",\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"APN-Configuration-Profile\":{\"Context-Identifier\":0,\"All-APN-Configurations-Included-Indicator\":0,\"APN-Configuration\":{\"Context-Identifier\":0,\"PDN-Type\":0,\"Served-Party-IP-Address\":[\"0.0.0.0\"],\"Service-Selection\":\"$apn\",\"EPS-Subscribed-QoS-Profile\":{\"QoS-Class-Identifier\":9,\"Allocation-Retention-Priority\":{\"Priority-Level\":15,\"Pre-emption-Capability\":0,\"Pre-emption-Vulnerability\":0}},\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"PDN-GW-Allocation-Type\":0,\"MIP6-Agent-Info\":{\"MIP-Home-Agent-Address\":[\"172.26.17.183\"]}}},\"Subscribed-Periodic-RAU-TAU-Timer\":0}}', '{\"Supported-Features\":{\"Vendor-Id\": 10415, \"Feature-List-ID\": 2, \"Feature-List\": 134217728}}');" |
| 26 | |
| 27 | if [ $? -ne 0 ];then |
| 28 | echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n" |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 33 | if [ $? -ne 0 ];then |
| 34 | echo -e "oops! Something went wrong adding $imsi to vhss.msisdn_imsi!\n" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | echo -e "Added $imsi\n" |
| 39 | |
| 40 | imsi=`expr $imsi + 1`; |
| 41 | msisdn=`expr $msisdn + 1` |
| 42 | done |
| 43 | } |
| 44 | |
| 45 | function provision_staticusers() { |
| 46 | imsi=${1} |
| 47 | msisdn=${2} |
| 48 | apn=${3} |
| 49 | key=${4} |
| 50 | opc=${5} |
| 51 | sqn=${6} |
| 52 | cassandra_ip=${7} |
| 53 | mmeidentity=${8} |
| 54 | mmerealm=${9} |
| 55 | staticAddr=${10} |
| 56 | |
| 57 | echo "IMSI=$imsi MSISDN=$msisdn" |
| 58 | cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data, supported_features) VALUES ('$imsi', $msisdn, 41, '$key', '$opc','$mmeidentity', 3, '$mmerealm', '2683b376d1056746de3b254012908e0e', $sqn, '{\"Subscription-Data\":{\"Access-Restriction-Data\":41,\"Subscriber-Status\":0,\"Network-Access-Mode\":2,\"Regional-Subscription-Zone-Code\":[\"0x0123\",\"0x4567\",\"0x89AB\",\"0xCDEF\",\"0x1234\",\"0x5678\",\"0x9ABC\",\"0xDEF0\",\"0x2345\",\"0x6789\"],\"MSISDN\":\"0x$msisdn\",\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"APN-Configuration-Profile\":{\"Context-Identifier\":0,\"All-APN-Configurations-Included-Indicator\":0,\"APN-Configuration\":{\"Context-Identifier\":0,\"PDN-Type\":0,\"Served-Party-IP-Address\":[\"$staticAddr\"],\"Service-Selection\":\"$apn\",\"EPS-Subscribed-QoS-Profile\":{\"QoS-Class-Identifier\":9,\"Allocation-Retention-Priority\":{\"Priority-Level\":15,\"Pre-emption-Capability\":0,\"Pre-emption-Vulnerability\":0}},\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"PDN-GW-Allocation-Type\":0,\"MIP6-Agent-Info\":{\"MIP-Home-Agent-Address\":[\"172.26.17.183\"]}}},\"Subscribed-Periodic-RAU-TAU-Timer\":0}}', '{\"Supported-Features\":{\"Vendor-Id\": 10415, \"Feature-List-ID\": 2, \"Feature-List\": 134217728}}');" |
| 59 | |
| 60 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 61 | echo -e "Added $imsi\n" |
| 62 | } |
| 63 | |
| 64 | function provision_mme() { |
| 65 | id=$1 |
| 66 | isdn=$2 |
| 67 | host=$3 |
| 68 | realm=$4 |
| 69 | uereachability=$5 |
| 70 | cassandra_ip=$6 |
| 71 | |
| 72 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 73 | if [ $? -ne 0 ];then |
| 74 | echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n" |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 79 | if [ $? -ne 0 ];then |
| 80 | echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n" |
| 81 | exit 1 |
| 82 | fi |
| 83 | |
| 84 | echo -e "Added mme $id\n" |
| 85 | } |
| 86 | |
| 87 | until cqlsh --file /opt/c3po/hssdb/oai_db.cql {{ .Values.config.hss.hssdb }}; |
| 88 | do echo "Provisioning HSSDB"; |
| 89 | sleep 2; |
| 90 | done |
| 91 | |
| 92 | {{- if .Values.config.hss.bootstrap.enabled }} |
| 93 | {{- range .Values.config.hss.bootstrap.users }} |
| 94 | provision_users \ |
| 95 | {{ .count }} \ |
| 96 | {{ .imsiStart }} \ |
| 97 | {{ .msisdnStart }} \ |
| 98 | {{ .apn }} \ |
| 99 | {{ .key }} \ |
| 100 | {{ .opc }} \ |
| 101 | {{ .sqn }} \ |
| 102 | {{ $.Values.config.hss.hssdb }} \ |
| 103 | {{ .mme_identity }} \ |
| 104 | {{ .mme_realm }} |
| 105 | {{- end }} |
| 106 | |
| 107 | {{- range .Values.config.hss.bootstrap.staticusers }} |
| 108 | provision_staticusers \ |
| 109 | {{ .imsi }} \ |
| 110 | {{ .msisdn }} \ |
| 111 | {{ .apn }} \ |
| 112 | {{ .key }} \ |
| 113 | {{ .opc }} \ |
| 114 | {{ .sqn }} \ |
| 115 | {{ $.Values.config.hss.hssdb }} \ |
| 116 | {{ .mme_identity }} \ |
| 117 | {{ .mme_realm }} \ |
| 118 | {{ .staticAddr }} |
| 119 | {{- end }} |
| 120 | |
| 121 | {{- range .Values.config.hss.bootstrap.mmes }} |
| 122 | provision_mme \ |
| 123 | {{ .id }} \ |
| 124 | {{ .isdn }} \ |
| 125 | {{ .mme_identity }} \ |
| 126 | {{ .mme_realm }} \ |
| 127 | {{ .unreachability }} \ |
| 128 | {{ $.Values.config.hss.hssdb }} |
| 129 | {{- end }} |
| 130 | {{- end }} |
| 131 | |