blob: ebbddf2a8bbe2f187ed9b4e9763a20d3c697c86d [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
Ajay Lotan Thakurbb5d9a82020-03-24 20:05:30 -060055function 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 Mooned24cac2019-08-26 20:52:20 -050074function 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 Moonb7f9b4f2019-08-30 16:48:37 -050094 echo -e "Added mme $id\n"
Hyunsun Mooned24cac2019-08-26 20:52:20 -050095}
96
Hyunsun Moon2eede662019-10-11 13:11:44 -060097mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }}
98mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }}
Hyunsun Mooned24cac2019-08-26 20:52:20 -050099
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -0500100{{- range .Values.config.hss.bootstrap.users }}
101provision_users \
Hyunsun Moon1f554c42020-03-05 13:00:12 -0800102 {{ .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 Moonb7f9b4f2019-08-30 16:48:37 -0500109 {{ $.Values.config.hss.hssdb }} \
110 $mme_identity \
111 $mme_realm
112{{- end }}
113
Ajay Lotan Thakurbb5d9a82020-03-24 20:05:30 -0600114{{- range .Values.config.hss.bootstrap.staticusers }}
115provision_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 Moonb7f9b4f2019-08-30 16:48:37 -0500128{{- range .Values.config.hss.bootstrap.mmes }}
Hyunsun Mooned24cac2019-08-26 20:52:20 -0500129provision_mme \
Hyunsun Moonb7f9b4f2019-08-30 16:48:37 -0500130 {{ .id }} \
131 {{ .isdn }} \
132 $mme_identity \
133 $mme_realm \
134 {{ .unreachability }} \
135 {{ $.Values.config.hss.hssdb }}
136{{- end }}