Commit c582c928 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

software/ors-amarisoft: Add fixed-ips option for core network

This option will give fixed IP to each SIM card.
parent cd05ce47
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 9b7ced53c256fa5b60c679c75ed03727 md5sum = 521c6ca69d512b318d48af4ba3271951
[amarisoft-stats.jinja2.py] [amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py _update_hash_filename_ = amarisoft-stats.jinja2.py
...@@ -64,7 +64,7 @@ md5sum = 2d7558e4799818a5546850f735fbb399 ...@@ -64,7 +64,7 @@ md5sum = 2d7558e4799818a5546850f735fbb399
[template-core-network] [template-core-network]
_update_hash_filename_ = instance-core-network.jinja2.cfg _update_hash_filename_ = instance-core-network.jinja2.cfg
md5sum = ed92a5762932220e0337d6c254f18024 md5sum = 406580f0f28e22589edcbe8eee75783d
[template-ue-lte] [template-ue-lte]
_update_hash_filename_ = instance-ue-lte.jinja2.cfg _update_hash_filename_ = instance-ue-lte.jinja2.cfg
...@@ -80,7 +80,7 @@ md5sum = c5f581ba01654b2aec46000abf8d0e35 ...@@ -80,7 +80,7 @@ md5sum = c5f581ba01654b2aec46000abf8d0e35
[ue_db.jinja2.cfg] [ue_db.jinja2.cfg]
filename = config/ue_db.jinja2.cfg filename = config/ue_db.jinja2.cfg
md5sum = d5afe12aa3e2e93d30455da51540cfdb md5sum = eedea5eb1f0b7b9bd7834e0c15ed9555
[enb.jinja2.cfg] [enb.jinja2.cfg]
filename = config/enb.jinja2.cfg filename = config/enb.jinja2.cfg
...@@ -96,7 +96,7 @@ md5sum = 003bf8098175415c975a10c102df6b8c ...@@ -96,7 +96,7 @@ md5sum = 003bf8098175415c975a10c102df6b8c
[mme.jinja2.cfg] [mme.jinja2.cfg]
filename = config/mme.jinja2.cfg filename = config/mme.jinja2.cfg
md5sum = 3d7833ddba3242cedcd74c7db52390c6 md5sum = 713504eb854d5ca1067ca566cf70341b
[dnsmasq.jinja2.cfg] [dnsmasq.jinja2.cfg]
filename = config/dnsmasq.jinja2.cfg filename = config/dnsmasq.jinja2.cfg
......
{ {
log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,s1ap.level=debug,s1ap.max_size=1,ngap.level=debug,ngap.max_size=1,file.rotate=1G,file.path=/dev/null", log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,s1ap.level=debug,s1ap.max_size=1,ngap.level=debug,ngap.max_size=1,file.rotate=1G,file.path=/dev/null",
log_filename: "{{ directory['log'] }}/mme.log", log_filename: "{{ directory['log'] }}/mme.log",
{% if slapparameter_dict.get('external_enb_gnb', '') %} {% if slapparameter_dict.get('external_enb_gnb', '') %}
{% if slapparameter_dict.get('use_ipv4', False) %} {% if slapparameter_dict.get('use_ipv4', False) %}
gtp_addr: "{{ gtp_addr_v4 }}", gtp_addr: "{{ gtp_addr_v4 }}",
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
mme_group_id: 32769, mme_group_id: 32769,
mme_code: 1, mme_code: 1,
ims_vops_eps: true, ims_vops_eps: true,
ims_vops_5gs_3gpp: true, ims_vops_5gs_3gpp: true,
ims_vops_5gs_n3gpp: true, ims_vops_5gs_n3gpp: true,
emergency_number_list: [ emergency_number_list: [
{ category: 0x1f, digits: "911" }, { category: 0x1f, digits: "911" },
{ category: 0x1f, digits: "112" }, { category: 0x1f, digits: "112" },
], ],
...@@ -29,16 +29,16 @@ ...@@ -29,16 +29,16 @@
qci: {audio: 1, video: 2}, qci: {audio: 1, video: 2},
}, },
network_name: "{{ slapparameter_dict.get('network_name', 'RAPIDSPACE') }}", network_name: "{{ slapparameter_dict.get('network_name', 'RAPIDSPACE') }}",
network_short_name: "{{ slapparameter_dict.get('network_short_name', 'RAPIDSPACE') }}", network_short_name: "{{ slapparameter_dict.get('network_short_name', 'RAPIDSPACE') }}",
cp_ciot_opt: true, cp_ciot_opt: true,
nr_support: true, nr_support: true,
eps_5gs_interworking: "with_n26", eps_5gs_interworking: "with_n26",
fifteen_bearers: false, fifteen_bearers: false,
ims_list: [ ims_list: [
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
bind_addr: "{{ slap_configuration['configuration.ims_bind'] }}" bind_addr: "{{ slap_configuration['configuration.ims_bind'] }}"
} }
], ],
pdn_list: [ pdn_list: [
{ {
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
first_ip_addr: "{{ netaddr.IPAddress(netaddr.IPNetwork(slap_configuration.get('tun-ipv4-network', '')).first) + 2 }}", first_ip_addr: "{{ netaddr.IPAddress(netaddr.IPNetwork(slap_configuration.get('tun-ipv4-network', '')).first) + 2 }}",
last_ip_addr: "{{ netaddr.IPAddress(netaddr.IPNetwork(slap_configuration.get('tun-ipv4-network', '')).last) - 1 }}", last_ip_addr: "{{ netaddr.IPAddress(netaddr.IPNetwork(slap_configuration.get('tun-ipv4-network', '')).last) - 1 }}",
{% endif %} {% endif %}
ip_addr_shift: 2,
p_cscf_addr: ["{{ slap_configuration.get('tun-ipv4-addr', '') }}"], p_cscf_addr: ["{{ slap_configuration.get('tun-ipv4-addr', '') }}"],
erabs: [ erabs: [
......
...@@ -13,6 +13,13 @@ ue_db: [ ...@@ -13,6 +13,13 @@ ue_db: [
K: "{{ slave.get('k', '') }}", K: "{{ slave.get('k', '') }}",
impu: "{{ slave.get('impu', '') }}", impu: "{{ slave.get('impu', '') }}",
impi: "{{ slave.get('impi', '') }}", impi: "{{ slave.get('impi', '') }}",
{%- if "ip" in slave %}
pdn_list:[{
access_point_name: "internet",
default: true,
ipv4_addr: "{{ slave['ip'] }}"
}]
{%- endif %}
} }
{%- endfor -%} {%- endfor -%}
] ]
......
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
"title": "Use IPv4", "title": "Use IPv4",
"description": "Set to true to use IPv4 for AMF / MME addresses", "description": "Set to true to use IPv4 for AMF / MME addresses",
"type": "boolean" "type": "boolean"
},
"fixed_ips": {
"default": false,
"title": "Fixed IP for the UE",
"description": "Set to true to force a static IPv4 for each UE. If true, you cannot use more than 256 UE.",
"type": "boolean"
} }
} }
} }
{%- set dns_slave_instance_list = [] %} {%- set dns_slave_instance_list = [] %}
{%- set sim_slave_instance_list = [] %} {%- set sim_slave_instance_list = [] %}
{%- set fixed_ip = slapparameter_dict.get("fixed_ips", False) %}
{%- for slave in slave_instance_list %} {%- for slave in slave_instance_list %}
{%- set slave_parameters = json_module.loads(slave['_']) %} {%- set slave_parameters = json_module.loads(slave['_']) %}
{%- if slave_parameters.get('subdomain', '') != '' %} {%- if slave_parameters.get('subdomain', '') != '' %}
...@@ -19,8 +20,39 @@ ...@@ -19,8 +20,39 @@
recipe = slapos.cookbook:publish.serialised recipe = slapos.cookbook:publish.serialised
-slave-reference = {{ slave_reference }} -slave-reference = {{ slave_reference }}
info = Your SIM card with IMSI {{ slave_parameters.get('imsi', '') }} has been attached to service ${slap-configuration:instance-title}. info = Your SIM card with IMSI {{ slave_parameters.get('imsi', '') }} has been attached to service ${slap-configuration:instance-title}.
{%- if fixed_ip %}
ipv4 = ${sim-ip-configuration:{{slave_reference}}}
{%- endif %}
{%- endfor %} {%- endfor %}
[sim-ip-configuration]
recipe = slapos.recipe.build
sim-slave-instance-list = {{ dumps(sim_slave_instance_list) }}
ipv4-network = {{ slap_configuration.get('tun-ipv4-network', '') }}
init =
import netaddr
import json
network = netaddr.IPNetwork(options['ipv4-network'])
slave_list = options['sim-slave-instance-list']
# if we don't have enough IPv4 addresses in the network, don't force it
# should we make a promise fail ?
if len(slave_list) + 2 > network.size:
options['sim-with-ip-list'] = [json.loads(x['_']) for x in slave_list]
for s in slave_list:
options[s['slave_reference']] = "Too many SIM for the IPv4 network"
else:
# calculate the IP addresses of each SIM
sim_list = []
first_addr = netaddr.IPAddress(network.first)
for i, s in enumerate(sorted(slave_list, key=lambda x: json.loads(x['_'])['imsi'])):
ip = str(first_addr + 2 + i)
options[s['slave_reference']] = ip
slave_parameters = json.loads(s['_'])
slave_parameters['ip'] = ip
sim_list.append(slave_parameters)
options['sim-with-ip-list'] = sim_list
{%- for slave in dns_slave_instance_list %} {%- for slave in dns_slave_instance_list %}
{%- set slave_parameters = json_module.loads(slave['_']) %} {%- set slave_parameters = json_module.loads(slave['_']) %}
{% set slave_reference = slave.get('slave_reference', '') %} {% set slave_reference = slave.get('slave_reference', '') %}
...@@ -70,7 +102,11 @@ configuration.gtp_addr = 127.0.1.100 ...@@ -70,7 +102,11 @@ configuration.gtp_addr = 127.0.1.100
configuration.ims_addr = 127.0.0.1 configuration.ims_addr = 127.0.0.1
configuration.ims_bind = 127.0.0.2 configuration.ims_bind = 127.0.0.2
ue_db_path = ${ue-db-config:output} ue_db_path = ${ue-db-config:output}
{%- if fixed_ip %}
sim_list = ${sim-ip-configuration:sim-with-ip-list}
{%- else %}
sim_list = {{ dumps(sim_slave_instance_list) }} sim_list = {{ dumps(sim_slave_instance_list) }}
{%- endif %}
[monitor-httpd-conf-parameter] [monitor-httpd-conf-parameter]
httpd-include-file = {{ buildout_directory }}/etc/httpd-include-file.conf httpd-include-file = {{ buildout_directory }}/etc/httpd-include-file.conf
...@@ -195,14 +231,11 @@ url = {{ ims_template }} ...@@ -195,14 +231,11 @@ url = {{ ims_template }}
output = ${directory:etc}/ims.cfg output = ${directory:etc}/ims.cfg
[ue-db-config] [ue-db-config]
recipe = slapos.recipe.template:jinja2 <= config-base
url = {{ ue_db_template }} url = {{ ue_db_template }}
filename = ue_db.cfg output = ${directory:etc}/ue_db.cfg
extensions = jinja2.ext.do
output = ${directory:etc}/${:filename}
context = context =
import json_module json section slap_configuration slap-configuration
section slap_configuration slap-configuration
[mme-config] [mme-config]
<= config-base <= config-base
......
...@@ -335,6 +335,7 @@ extra-context = ...@@ -335,6 +335,7 @@ extra-context =
raw dnsmasq_location ${dnsmasq:location} raw dnsmasq_location ${dnsmasq:location}
key dnsmasq_config_path dnsmasq-config:output key dnsmasq_config_path dnsmasq-config:output
key slave_instance_list slap-configuration:slave-instance-list key slave_instance_list slap-configuration:slave-instance-list
section slap_configuration slap-configuration
[dynamic-template-ue-lte] [dynamic-template-ue-lte]
< = jinja2-template-base < = jinja2-template-base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment