blob: cfdda81e6f6ad2bfcc7ca40556d7e3bac3aaeca6 [file] [log] [blame]
Hyunsun Mooned24cac2019-08-26 20:52:20 -05001#!/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
18set -ex
19
20function provision_users() {
Hyunsun Moon1f554c42020-03-05 13:00:12 -080021 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 Mooned24cac2019-08-26 20:52:20 -050031
Hyunsun Moon1f554c42020-03-05 13:00:12 -080032 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 Mooned24cac2019-08-26 20:52:20 -050036
Hyunsun Moon1f554c42020-03-05 13:00:12 -080037 if [ $? -ne 0 ];then
38 echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n"
39 exit 1
40 fi
Hyunsun Mooned24cac2019-08-26 20:52:20 -050041
Hyunsun Moon1f554c42020-03-05 13:00:12 -080042 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 Mooned24cac2019-08-26 20:52:20 -050047
Hyunsun Moon1f554c42020-03-05 13:00:12 -080048 echo -e "Added $imsi\n"
49
50 imsi=`expr $imsi + 1`;
51 msisdn=`expr $msisdn + 1`
52 done
Hyunsun Mooned24cac2019-08-26 20:52:20 -050053}
54
55function provision_mme() {
56 id=$1
57 isdn=$2
58 host=$3
59 realm=$4
60 uereachability=$5
61 cassandra_ip=$6
62
63 cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);"
64 if [ $? -ne 0 ];then
65 echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n"
66 exit 1
67 fi
68
69 cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);"
70 if [ $? -ne 0 ];then
71 echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n"
72 exit 1
73 fi
74
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -050075 echo -e "Added mme $id\n"
Hyunsun Mooned24cac2019-08-26 20:52:20 -050076}
77
Hyunsun Moon2eede662019-10-11 13:11:44 -060078mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }}
79mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }}
Hyunsun Mooned24cac2019-08-26 20:52:20 -050080
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -050081{{- range .Values.config.hss.bootstrap.users }}
82provision_users \
Hyunsun Moon1f554c42020-03-05 13:00:12 -080083 {{ .count }} \
84 {{ .imsiStart }} \
85 {{ .msisdnStart }} \
86 {{ $.Values.config.hss.bootstrap.apn }} \
87 {{ $.Values.config.hss.bootstrap.key }} \
88 {{ $.Values.config.hss.bootstrap.opc }} \
89 {{ $.Values.config.hss.bootstrap.sqn }} \
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -050090 {{ $.Values.config.hss.hssdb }} \
91 $mme_identity \
92 $mme_realm
93{{- end }}
94
95{{- range .Values.config.hss.bootstrap.mmes }}
Hyunsun Mooned24cac2019-08-26 20:52:20 -050096provision_mme \
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -050097 {{ .id }} \
98 {{ .isdn }} \
99 $mme_identity \
100 $mme_realm \
101 {{ .unreachability }} \
102 {{ $.Values.config.hss.hssdb }}
103{{- end }}