Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2019-present Open Networking Foundation |
| 4 | # Copyright 2018 Intel Corporation |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
| 18 | set -ex |
| 19 | |
| 20 | function provision_users() { |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 21 | count=${1} |
| 22 | imsi=${2} |
| 23 | msisdn=${3} |
| 24 | apn=${4} |
| 25 | key=${5} |
| 26 | opc=${6} |
| 27 | sqn=${7} |
| 28 | cassandra_ip=${8} |
| 29 | mmeidentity=${9} |
| 30 | mmerealm=${10} |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 31 | |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 32 | for (( i=1; i<=$count; i++ )) |
| 33 | do |
| 34 | echo "IMSI=$imsi MSISDN=$msisdn" |
| 35 | cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data) 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}}');" |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 36 | |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 37 | if [ $? -ne 0 ];then |
| 38 | echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n" |
| 39 | exit 1 |
| 40 | fi |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 41 | |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 42 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 43 | if [ $? -ne 0 ];then |
| 44 | echo -e "oops! Something went wrong adding $imsi to vhss.msisdn_imsi!\n" |
| 45 | exit 1 |
| 46 | fi |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 47 | |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 48 | echo -e "Added $imsi\n" |
| 49 | |
| 50 | imsi=`expr $imsi + 1`; |
| 51 | msisdn=`expr $msisdn + 1` |
| 52 | done |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Ajay Lotan Thakur | bb5d9a8 | 2020-03-24 20:05:30 -0600 | [diff] [blame] | 55 | function provision_staticusers() { |
| 56 | imsi=${1} |
| 57 | msisdn=${2} |
| 58 | apn=${3} |
| 59 | key=${4} |
| 60 | opc=${5} |
| 61 | sqn=${6} |
| 62 | cassandra_ip=${7} |
| 63 | mmeidentity=${8} |
| 64 | mmerealm=${9} |
| 65 | staticAddr=${10} |
| 66 | |
| 67 | echo "IMSI=$imsi MSISDN=$msisdn" |
| 68 | cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data) 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}}');" |
| 69 | |
| 70 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 71 | echo -e "Added $imsi\n" |
| 72 | } |
| 73 | |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 74 | function provision_mme() { |
| 75 | id=$1 |
| 76 | isdn=$2 |
| 77 | host=$3 |
| 78 | realm=$4 |
| 79 | uereachability=$5 |
| 80 | cassandra_ip=$6 |
| 81 | |
| 82 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 83 | if [ $? -ne 0 ];then |
| 84 | echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n" |
| 85 | exit 1 |
| 86 | fi |
| 87 | |
| 88 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 89 | if [ $? -ne 0 ];then |
| 90 | echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n" |
| 91 | exit 1 |
| 92 | fi |
| 93 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 94 | echo -e "Added mme $id\n" |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 95 | } |
| 96 | |
Hyunsun Moon | 2eede66 | 2019-10-11 13:11:44 -0600 | [diff] [blame] | 97 | mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }} |
| 98 | mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }} |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 99 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 100 | {{- range .Values.config.hss.bootstrap.users }} |
| 101 | provision_users \ |
Hyunsun Moon | 1f554c4 | 2020-03-05 13:00:12 -0800 | [diff] [blame] | 102 | {{ .count }} \ |
| 103 | {{ .imsiStart }} \ |
| 104 | {{ .msisdnStart }} \ |
| 105 | {{ $.Values.config.hss.bootstrap.apn }} \ |
| 106 | {{ $.Values.config.hss.bootstrap.key }} \ |
| 107 | {{ $.Values.config.hss.bootstrap.opc }} \ |
| 108 | {{ $.Values.config.hss.bootstrap.sqn }} \ |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 109 | {{ $.Values.config.hss.hssdb }} \ |
| 110 | $mme_identity \ |
| 111 | $mme_realm |
| 112 | {{- end }} |
| 113 | |
Ajay Lotan Thakur | bb5d9a8 | 2020-03-24 20:05:30 -0600 | [diff] [blame] | 114 | {{- range .Values.config.hss.bootstrap.staticusers }} |
| 115 | provision_staticusers \ |
| 116 | {{ .imsi }} \ |
| 117 | {{ .msisdn }} \ |
| 118 | {{ $.Values.config.hss.bootstrap.apn }} \ |
| 119 | {{ $.Values.config.hss.bootstrap.key }} \ |
| 120 | {{ $.Values.config.hss.bootstrap.opc }} \ |
| 121 | {{ $.Values.config.hss.bootstrap.sqn }} \ |
| 122 | {{ $.Values.config.hss.hssdb }} \ |
| 123 | $mme_identity \ |
| 124 | $mme_realm \ |
| 125 | {{ .staticAddr }} |
| 126 | {{- end }} |
| 127 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 128 | {{- range .Values.config.hss.bootstrap.mmes }} |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 129 | provision_mme \ |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 130 | {{ .id }} \ |
| 131 | {{ .isdn }} \ |
| 132 | $mme_identity \ |
| 133 | $mme_realm \ |
| 134 | {{ .unreachability }} \ |
| 135 | {{ $.Values.config.hss.hssdb }} |
| 136 | {{- end }} |