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() { |
| 21 | imsi=$1 |
| 22 | msisdn=$2 |
| 23 | apn=$3 |
| 24 | key=$4 |
| 25 | opc=$5 |
Hyunsun Moon | 9257ef8 | 2019-10-16 15:26:30 -0700 | [diff] [blame] | 26 | sqn=$6 |
| 27 | cassandra_ip=$7 |
| 28 | mmeidentity=$8 |
| 29 | mmerealm=$9 |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 30 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 31 | echo "IMSI=$imsi MSISDN=$msisdn" |
Hyunsun Moon | 9257ef8 | 2019-10-16 15:26:30 -0700 | [diff] [blame] | 32 | 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\":[\"10.0.0.1\",\"10.0.0.2\"],\"Service-Selection\":\"apn1\",\"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] | 33 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 34 | if [ $? -ne 0 ];then |
| 35 | echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n" |
| 36 | exit 1 |
| 37 | fi |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 38 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 39 | cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');" |
| 40 | if [ $? -ne 0 ];then |
| 41 | echo -e "oops! Something went wrong adding $imsi to vhss.msisdn_imsi!\n" |
| 42 | exit 1 |
| 43 | fi |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 44 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 45 | echo -e "Added $imsi\n" |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | function provision_mme() { |
| 49 | id=$1 |
| 50 | isdn=$2 |
| 51 | host=$3 |
| 52 | realm=$4 |
| 53 | uereachability=$5 |
| 54 | cassandra_ip=$6 |
| 55 | |
| 56 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 57 | if [ $? -ne 0 ];then |
| 58 | echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n" |
| 59 | exit 1 |
| 60 | fi |
| 61 | |
| 62 | cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);" |
| 63 | if [ $? -ne 0 ];then |
| 64 | echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n" |
| 65 | exit 1 |
| 66 | fi |
| 67 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 68 | echo -e "Added mme $id\n" |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 69 | } |
| 70 | |
Hyunsun Moon | 2eede66 | 2019-10-11 13:11:44 -0600 | [diff] [blame] | 71 | mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }} |
| 72 | mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }} |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 73 | |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 74 | {{- range .Values.config.hss.bootstrap.users }} |
| 75 | provision_users \ |
| 76 | {{ .imsi }} \ |
| 77 | {{ .msisdn }} \ |
| 78 | {{ .apn }} \ |
| 79 | {{ .key }} \ |
| 80 | {{ .opc }} \ |
Hyunsun Moon | 9257ef8 | 2019-10-16 15:26:30 -0700 | [diff] [blame] | 81 | {{ .sqn }} \ |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 82 | {{ $.Values.config.hss.hssdb }} \ |
| 83 | $mme_identity \ |
| 84 | $mme_realm |
| 85 | {{- end }} |
| 86 | |
| 87 | {{- range .Values.config.hss.bootstrap.mmes }} |
Hyunsun Moon | ed24cac | 2019-08-26 20:52:20 -0500 | [diff] [blame] | 88 | provision_mme \ |
Hyunsun Moon | b7f9b4f | 2019-08-30 16:48:37 -0500 | [diff] [blame] | 89 | {{ .id }} \ |
| 90 | {{ .isdn }} \ |
| 91 | $mme_identity \ |
| 92 | $mme_realm \ |
| 93 | {{ .unreachability }} \ |
| 94 | {{ $.Values.config.hss.hssdb }} |
| 95 | {{- end }} |