close Warning: Can't synchronize with repository "(default)" (/common/SVN/wimax does not appear to be a Subversion repository.). Look in the Trac log for more information.

cLTE/eSoftware/cEpc: fill_sql.rb

File fill_sql.rb, 2.0 KB (added by msherman, 7 years ago)

script to populate database.

Line 
1#!/usr/bin/ruby
2
3require 'mysql'
4
5#this script adds the following
6#mmeidentity entry
7#user and pdn for each imsi, referencing the mme created
8#in this step, note that key is added with the UNHEX command
9
10#to use, set imsis, realm, mme, hss, and apn as needed to match configuration and sim cards. max_mme and max_ue reference the existing number of entries in the db.
11
12imsis=['001010000000001','001010000000002','001010000000003','001010000000004','001010000000005','001010000000006','001010000000007','001010000000008','001010000000009','001010000000010','001010000000011','001010000000012']
13realm = 'orbit-lab.org'
14mme = 'mme02.orbit-lab.org'
15hss = 'hss.orbit-lab.org'
16apn = 'orbitA'
17max_mme = 6 #number of existing mme entries in table mmeidentity
18max_ue = 59 #number of existing UEs in table users
19
20begin
21 con = Mysql.new 'localhost', 'root', 'linux', 'oai_db'
22
23 con.query("REPLACE INTO mmeidentity (`idmmeidentity`, `mmehost`, `mmerealm`, `UE-Reachability`) VALUES ('#{max_mme + 1}', '#{mme}','#{realm}', '0')")
24
25 imsis.each_with_index do |imsi, index|
26 puts "#{index + max_ue +1}" #due to existing entries in DB
27 puts "#{imsi}"
28 con.query("REPLACE INTO pdn (`id`, `apn`, `pdn_type`, `pdn_ipv4`, `pdn_ipv6`, `aggregate_ambr_ul`, `aggregate_ambr_dl`, `pgw_id`, `users_imsi`, `qci`, `priority_level`,`pre_emp_cap`,`pre_emp_vul`, `LIPA-Permissions`) VALUES ('#{index + max_ue + 1}', '#{apn}','IPV4', '0.0.0.0', '0:0:0:0:0:0:0:0', '50000000', '100000000', '1', '#{imsi}', '9', '15', 'DISABLED', 'ENABLED', 'LIPA-ONLY')")
29 con.query("REPLACE INTO users (`imsi`, `msisdn`, `imei`, `imei_sv`, `ms_ps_status`, `rau_tau_timer`, `ue_ambr_ul`, `ue_ambr_dl`, `access_restriction`, `mme_cap`, `mmeidentity_idmmeidentity`, `key`, `RFSP-Index`, `urrp_mme`, `sqn`, `rand`, `OPc`) VALUES ('#{imsi}', '33638060010', NULL, NULL, 'PURGED', '120', '50000000', '100000000', '47', '0000000000', '#{max_mme + 1}', UNHEX('8BAF473F2F8FD09487CCCBD7097C6862'), '1', '0', '0', 0x00000000000000000000000000000000, '')")
30 end
31
32rescue Mysql::Error => e
33 puts e.errno
34 puts e.error
35
36ensure
37 con.close if con
38end