Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame] | 2 | |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 3 | # Copyright 2018 Intel Corporation |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame] | 4 | # Copyright 2019-present Open Networking Foundation |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 5 | # |
Jeremy Ronquillo | ec2d3e4 | 2020-06-05 11:33:39 -0700 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 |
Jeremy Ronquillo | 6046ce3 | 2020-06-18 11:06:29 -0700 | [diff] [blame] | 7 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 8 | |
| 9 | set -ex |
| 10 | |
| 11 | function provision_users() { |
| 12 | count=${1} |
| 13 | imsi=${2} |
| 14 | msisdn=${3} |
| 15 | apn=${4} |
| 16 | key=${5} |
| 17 | opc=${6} |
| 18 | sqn=${7} |
| 19 | cassandra_ip=${8} |
| 20 | mmeidentity=${9} |
| 21 | mmerealm=${10} |
| 22 | |
| 23 | for (( i=1; i<=$count; i++ )) |
| 24 | do |
| 25 | echo "IMSI=$imsi MSISDN=$msisdn" |
Ajay Lotan Thakur | 0aa8349 | 2020-11-02 13:22:10 -0600 | [diff] [blame] | 26 | 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}}');" |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 27 | |
| 28 | if [ $? -ne 0 ];then |
| 29 | echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n" |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 34 | if [ $? -ne 0 ];then |
| 35 | echo -e "oops! Something went wrong adding $imsi to vhss.msisdn_imsi!\n" |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | echo -e "Added $imsi\n" |
| 40 | |
| 41 | imsi=`expr $imsi + 1`; |
| 42 | msisdn=`expr $msisdn + 1` |
| 43 | done |
| 44 | } |
| 45 | |
| 46 | function provision_staticusers() { |
| 47 | imsi=${1} |
| 48 | msisdn=${2} |
| 49 | apn=${3} |
| 50 | key=${4} |
| 51 | opc=${5} |
| 52 | sqn=${6} |
| 53 | cassandra_ip=${7} |
| 54 | mmeidentity=${8} |
| 55 | mmerealm=${9} |
| 56 | staticAddr=${10} |
| 57 | |
| 58 | echo "IMSI=$imsi MSISDN=$msisdn" |
Ajay Lotan Thakur | 0aa8349 | 2020-11-02 13:22:10 -0600 | [diff] [blame] | 59 | 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}}');" |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 60 | |
| 61 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 62 | echo -e "Added $imsi\n" |
| 63 | } |
| 64 | |
| 65 | function provision_mme() { |
| 66 | id=$1 |
| 67 | isdn=$2 |
| 68 | host=$3 |
| 69 | realm=$4 |
| 70 | uereachability=$5 |
| 71 | cassandra_ip=$6 |
| 72 | |
| 73 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 74 | if [ $? -ne 0 ];then |
| 75 | echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n" |
| 76 | exit 1 |
| 77 | fi |
| 78 | |
| 79 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 80 | if [ $? -ne 0 ];then |
| 81 | echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n" |
| 82 | exit 1 |
| 83 | fi |
| 84 | |
| 85 | echo -e "Added mme $id\n" |
| 86 | } |
| 87 | |
Hyunsun Moon | d60f50c | 2020-10-06 15:09:01 -0500 | [diff] [blame] | 88 | until cqlsh --file /opt/c3po/hssdb/oai_db.cql {{ .Values.config.hss.hssdb }}; |
| 89 | do echo "Provisioning HSSDB"; |
| 90 | sleep 2; |
| 91 | done |
| 92 | |
| 93 | {{- if .Values.config.hss.bootstrap.enabled }} |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 94 | {{- range .Values.config.hss.bootstrap.users }} |
| 95 | provision_users \ |
| 96 | {{ .count }} \ |
| 97 | {{ .imsiStart }} \ |
| 98 | {{ .msisdnStart }} \ |
Hyunsun Moon | a1c4c98 | 2020-07-22 15:01:29 -0700 | [diff] [blame] | 99 | {{ .apn }} \ |
| 100 | {{ .key }} \ |
| 101 | {{ .opc }} \ |
| 102 | {{ .sqn }} \ |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 103 | {{ $.Values.config.hss.hssdb }} \ |
Ajay Lotan Thakur | ac5c181 | 2021-02-22 12:23:20 -0600 | [diff] [blame] | 104 | {{ .mme_identity }} \ |
| 105 | {{ .mme_realm }} |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 106 | {{- end }} |
| 107 | |
| 108 | {{- range .Values.config.hss.bootstrap.staticusers }} |
| 109 | provision_staticusers \ |
| 110 | {{ .imsi }} \ |
| 111 | {{ .msisdn }} \ |
Hyunsun Moon | a1c4c98 | 2020-07-22 15:01:29 -0700 | [diff] [blame] | 112 | {{ .apn }} \ |
| 113 | {{ .key }} \ |
| 114 | {{ .opc }} \ |
| 115 | {{ .sqn }} \ |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 116 | {{ $.Values.config.hss.hssdb }} \ |
Ajay Lotan Thakur | ac5c181 | 2021-02-22 12:23:20 -0600 | [diff] [blame] | 117 | {{ .mme_identity }} \ |
| 118 | {{ .mme_realm }} \ |
Hyunsun Moon | 83ff735 | 2020-07-09 11:03:52 -0700 | [diff] [blame] | 119 | {{ .staticAddr }} |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 120 | {{- end }} |
| 121 | |
| 122 | {{- range .Values.config.hss.bootstrap.mmes }} |
| 123 | provision_mme \ |
| 124 | {{ .id }} \ |
| 125 | {{ .isdn }} \ |
Hyunsun Moon | 83ff735 | 2020-07-09 11:03:52 -0700 | [diff] [blame] | 126 | {{ .mme_identity }} \ |
| 127 | {{ .mme_realm }} \ |
Jeremy Ronquillo | 223db00 | 2020-06-05 10:28:22 -0700 | [diff] [blame] | 128 | {{ .unreachability }} \ |
| 129 | {{ $.Values.config.hss.hssdb }} |
| 130 | {{- end }} |
Hyunsun Moon | d60f50c | 2020-10-06 15:09:01 -0500 | [diff] [blame] | 131 | {{- end }} |
| 132 | |