TT#186700 support for rtp instances

* add lib/get_all_rtp_for_instances

Change-Id: Ia746ea4c05de85d9104bb6ab1c5799e962f82427
mr11.0
ngcp-config 3 years ago committed by Víctor Seva
parent adda56e122
commit a35013facc

@ -0,0 +1,97 @@
[%
# vi: ft=tt2
# Returns a list of RTP-enabled interfaces for rtpengine.
#
# @param argv.instance instance
# @param argv.format The format of the returned list, one of:
# "list" for plain list of interfaces,
# "address" for plain list of addresses,
# blank or "rtpengine" for full CLI options.
# @param argv.status node status [ online, offline, inactive ]
# default value: ['online', 'inactive']
# @return out The array of interfaces.
X_format = argv.format;
IF ! X_format.defined || X_format == '';
X_format = 'rtpengine';
END;
IF !argv.status.size;
argv.status = ['online', 'inactive'];
END;
status = {
online = 0
offline = 0
inactive = 0
};
FOREACH val IN argv.status;
status.$val = 1;
END;
out = [];
RETURN UNLESS status.item(argv.instance.status);
FOREACH X_ifc IN argv.instance.interfaces;
X_types = X_ifc.type.grep('^rtp_.');
FOREACH X_type IN X_types;
X_type = X_type.remove('^rtp_');
IF X_format == 'list';
out.push(X_type);
NEXT;
END;
X_ips = X_ifc.shared_ip.list;
IF !X_ips.size() || !X_ips.0.defined;
X_ips = X_ifc.ip.list;
END;
X_adv_ips = X_ifc.advertised_ip.list;
X_suffix = 0;
IF X_ips.size() > 1;
X_suffix = 1;
END;
FOREACH X_ip IN X_ips;
X_adv_ip = X_adv_ips.shift();
IF X_format == 'address';
out.push(X_ip);
ELSE;
X_name = X_type;
IF X_suffix;
X_name = X_name _ ':' _ X_suffix;
X_suffix = X_suffix + 1;
END;
out.push(X_name _ '/' _ X_ip _ (X_adv_ip ? ('!' _ X_adv_ip) : ''));
END;
END;
X_ips = X_ifc.shared_v6ip.list;
IF !X_ips.size() || !X_ips.0.defined;
X_ips = X_ifc.v6ip.list;
END;
X_suffix = 0;
IF X_ips.size() > 1;
X_suffix = 1;
END;
FOREACH X_ip IN X_ips;
IF X_format == 'address';
out.push(X_ip);
ELSE;
X_name = X_type;
IF X_suffix;
X_name = X_name _ ':' _ X_suffix;
X_suffix = X_suffix + 1;
END;
out.push(X_name _ '/' _ X_ip);
END;
END;
END;
END;
-%]

@ -0,0 +1,57 @@
[%
hostname = ngcp.get_hostname();
peername = ngcp.get_peername(hostname);
argv.host = hostname;
argv.type = 'ha_int';
PROCESS '../lib/get_iface';
host_ha_iface = out;
argv.host = peername;
argv.type = 'ha_int';
PROCESS '../lib/get_iface';
peer_ha_iface = out;
IF !instance_info.defined;
argv.host = hostname;
argv.type = 'sip_int';
PROCESS '../lib/get_all_shared_ips_for_host';
sip_int_ips = out;
IF !sip_int_ips.size;
argv.host = hostname;
argv.type = 'sip_int';
PROCESS '../lib/get_all_ips_for_host';
sip_int_ips = out;
END;
argv.host = hostname;
PROCESS '../lib/get_all_rtp_for_host';
ELSE;
# instance
argv.instance = instance_info;
argv.type = 'sip_int';
PROCESS '../lib/get_all_ips_for_instance';
sip_int_ips = out;
argv.instance = instance_info;
PROCESS '../lib/get_all_rtp_for_instance';
END;
interfaces = [];
int_interfaces = [];
FOREACH interface IN out;
IF interface.match('^int\/');
int_interfaces.push(interface);
ELSE;
interfaces.push(interface);
END;
END;
-%]
[rtpengine[% instance_info.name %]]
host_ha_iface=[% host_ha_iface %]
peer_ha_iface=[% peer_ha_iface %]
[% FOR ip IN sip_int_ips.sort -%]
sip_int_ips=[% ip %]
[% END -%]
interface=[% interfaces.sort.join(';') %]

@ -0,0 +1,6 @@
[rtpengine]
host_ha_iface=vlan1721
peer_ha_iface=vlan1721
sip_int_ips=172.30.52.135
interface=ext/172.30.52.196

@ -0,0 +1,6 @@
[rtpengineA]
host_ha_iface=vlan1721
peer_ha_iface=vlan1721
sip_int_ips=172.30.52.146
interface=ext/172.30.52.199

@ -9,3 +9,6 @@ sources:
- orig: etc/momo
dest: etc/momo_${INSTANCE_NAME}
label: lb
- orig: etc/rtpengine
dest: etc/rtpengine_${INSTANCE_NAME}
label: rtp

@ -0,0 +1,768 @@
---
hosts:
db01a:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '1'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: db01b
role:
- db
status: online
vlan1721:
hwaddr: AA:7C:C0:DA:85:45
ip: 172.30.52.180
netmask: 255.255.255.224
shared_ip:
- 172.30.52.179
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.183
netmask: 255.255.255.0
shared_ip:
- 192.168.25.185
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
db01b:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '2'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: db01a
role:
- db
status: online
vlan1721:
hwaddr: BE:3A:47:A7:11:0D
ip: 172.30.52.181
netmask: 255.255.255.224
shared_ip:
- 172.30.52.179
type:
- ssh_ext
- ha_int
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.184
netmask: 255.255.255.0
shared_ip:
- 192.168.25.185
shared_v6ip: []
type:
- ssh_ext
- mon_ext
vlan_raw_device: bond0
lb01a:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '3'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1719
- vlan1720
- vlan1721
- vlan1722
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: lb01b
role:
- lb
status: online
vlan1719:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.104
netmask: 255.255.255.224
shared_ip:
- 172.30.52.103
type:
- sip_ext
vlan_raw_device: bond0
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.136
netmask: 255.255.255.224
shared_ip:
- 172.30.52.135
type:
- sip_int
- rtp_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 46:78:04:52:C2:6C
ip: 172.30.52.174
netmask: 255.255.255.224
shared_ip:
- 172.30.52.173
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan1722:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.197
netmask: 255.255.255.240
shared_ip:
- 172.30.52.196
type:
- rtp_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.186
netmask: 255.255.255.0
shared_ip:
- 192.168.25.188
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
lb01b:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '4'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1719
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: lb01a
role:
- lb
status: online
vlan1719:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.105
netmask: 255.255.255.224
shared_ip:
- 172.30.52.103
type:
- sip_ext
vlan_raw_device: bond0
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.137
netmask: 255.255.255.224
shared_ip:
- 172.30.52.135
type:
- sip_int
- rtp_int
vlan_raw_device: bond0
vlan1721:
hwaddr: F2:5A:F1:41:B7:57
ip: 172.30.52.175
netmask: 255.255.255.224
shared_ip:
- 172.30.52.173
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan1722:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.149
netmask: 255.255.255.240
shared_ip:
- 172.30.52.147
type:
- rtp_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.187
netmask: 255.255.255.0
shared_ip:
- 192.168.25.188
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
prx01a:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '5'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: prx01b
role:
- proxy
- rtp
status: online
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.133
netmask: 255.255.255.224
shared_ip:
- 172.30.52.132
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 1E:B7:5A:23:BD:FE
ip: 172.30.52.171
netmask: 255.255.255.224
shared_ip:
- 172.30.52.170
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.189
netmask: 255.255.255.0
shared_ip:
- 192.168.25.191
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
prx01b:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '6'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: prx01a
role:
- proxy
- rtp
status: online
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.139
netmask: 255.255.255.224
shared_ip:
- 172.30.52.138
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 1A:E6:67:D3:B3:34
ip: 172.30.52.145
netmask: 255.255.255.224
shared_ip:
- 172.30.52.144
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.190
netmask: 255.255.255.0
shared_ip:
- 192.168.25.191
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
prx02a:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '7'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: prx02b
role:
- proxy
- rtp
status: inactive
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.140
netmask: 255.255.255.224
shared_ip:
- 172.30.52.138
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 1E:B7:5A:23:BD:FA
ip: 172.30.52.146
netmask: 255.255.255.224
shared_ip:
- 172.30.52.144
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.192
netmask: 255.255.255.0
shared_ip:
- 192.168.25.194
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
prx02b:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
dbnode: '8'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: prx01a
role:
- proxy
- rtp
status: inactive
vlan1720:
cluster_sets:
- default
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.134
netmask: 255.255.255.224
shared_ip:
- 172.30.52.132
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 1A:E6:67:D3:B3:35
ip: 172.30.52.172
netmask: 255.255.255.224
shared_ip:
- 172.30.52.170
type:
- ha_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.193
netmask: 255.255.255.0
shared_ip:
- 192.168.25.194
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
web01a:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
hwaddr: 00:00:00:00:00:00
ip: 192.168.1.2
netmask: 255.255.255.0
shared_ip:
- 192.168.1.1
type:
- boot_int
dbnode: '9'
eth0:
hwaddr: 00:00:00:00:00:00
type:
- web_ext
- web_int
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1718
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: web01b
role:
- mgmt
status: online
vlan1718:
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.69
netmask: 255.255.255.224
shared_ip:
- 172.30.52.68
type:
- web_ext
vlan_raw_device: bond0
vlan1720:
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.142
netmask: 255.255.255.224
shared_ip:
- 172.30.52.141
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: E2:67:FE:AB:0B:DE
ip: 172.30.52.168
netmask: 255.255.255.224
shared_ip:
- 172.30.52.167
type:
- ha_int
- web_int
- ssh_ext
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.180
netmask: 255.255.255.0
shared_ip:
- 192.168.25.182
shared_v6ip: []
type:
- mon_ext
- ssh_ext
vlan_raw_device: bond0
web01b:
bond0:
bond_miimon: '100'
bond_mode: active-backup
bond_slaves: eth0 eth1
hwaddr: 00:00:00:00:00:00
ip: 192.168.1.3
netmask: 255.255.255.0
shared_ip:
- 192.168.1.1
type:
- boot_int
dbnode: '10'
eth0:
hwaddr: 00:00:00:00:00:00
eth1:
hwaddr: 00:00:00:00:00:00
interfaces:
- vlan300
- vlan1718
- vlan1720
- vlan1721
- lo
- eth0
- eth1
- bond0
lo:
advertised_ip: []
hwaddr: 00:00:00:00:00:00
ip: 127.0.0.1
netmask: 255.0.0.0
shared_ip: []
shared_v6ip: []
type:
- ssh_ext
- api_int
v6ip: ::1
peer: web01a
role:
- mgmt
status: online
vlan1718:
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.70
netmask: 255.255.255.224
shared_ip:
- 172.30.52.68
type:
- web_ext
vlan_raw_device: bond0
vlan1720:
hwaddr: 00:00:00:00:00:00
ip: 172.30.52.143
netmask: 255.255.255.224
shared_ip:
- 172.30.52.141
type:
- sip_int
vlan_raw_device: bond0
vlan1721:
hwaddr: 3A:79:8B:6A:A7:01
ip: 172.30.52.169
netmask: 255.255.255.224
shared_ip:
- 172.30.52.167
type:
- ssh_ext
- ha_int
- web_int
vlan_raw_device: bond0
vlan300:
dns_nameservers:
- 92.42.136.30
- 92.42.136.31
gateway: 192.168.25.1
hwaddr: 00:00:00:00:00:00
ip: 192.168.25.181
netmask: 255.255.255.0
shared_ip:
- 192.168.25.182
shared_v6ip: []
type:
- ssh_ext
- mon_ext
vlan_raw_device: bond0
instances:
- name: A
service: ngcp-rtpengine-daemon
host: lb01b
status: online
label: rtp
interfaces:
- name: vlan1720
ip: 172.30.52.146
type:
- sip_int
- rtp_int
- name: vlan1722
ip: 172.30.52.199
type:
- rtp_ext

@ -0,0 +1,34 @@
#!/usr/bin/env py.test-3
import re
from fixtures.fs import check_output
filepath = "etc/rtpengine{}/rtpengine.conf"
msg = r"Generating {}/{}: OK"
env = {
"NGCP_HOSTNAME": "lb01a",
"TEMPLATE_POOL_BASE": "fixtures/build_instances",
"TEMPLATE_INSTANCES": "fixtures/repos/instances.yml",
"NGCPCFG": "fixtures/ngcpcfg_carrier_instances.cfg",
"NETWORK_CONFIG": "fixtures/repos/network_carrier_instances_rtp.yml",
}
def test_carrier_instances(ngcpcfgcli):
out = ngcpcfgcli(
"build",
"--ignore-branch-check",
"/etc/rtpengine/rtpengine.conf",
env=env,
)
rstr = msg.format(out.env["OUTPUT_DIRECTORY"], filepath.format(""))
assert re.search(rstr, out.stdout)
output_file = out.env["OUTPUT_DIRECTORY"].joinpath(filepath.format(""))
test_file = "fixtures/output/rtpengine.conf_carrier"
check_output(str(output_file), test_file)
rstr = msg.format(out.env["OUTPUT_DIRECTORY"], filepath.format("_A"))
assert re.search(rstr, out.stdout)
output_file = out.env["OUTPUT_DIRECTORY"].joinpath(filepath.format("_A"))
test_file = "fixtures/output/rtpengine.conf_instances_A"
check_output(str(output_file), test_file)
Loading…
Cancel
Save