-
Notifications
You must be signed in to change notification settings - Fork 0
/
renes_start.sh
115 lines (99 loc) · 4.74 KB
/
renes_start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# Requires the following variables
# KUBECTL: kubectl command
# OSMNS: OSM namespace in the cluster vim
# VACC: "pod_id" or "deploy/deployment_id" of the access vnf
# VCPE: "pod_id" or "deploy/deployment_id" of the cpd vnf
# HOMETUNIP: the ip address for the home side of the tunnel
# VNFTUNIP: the ip address for the vnf side of the tunnel
# VCPEPUBIP: the public ip address for the vcpe
# VCPEGW: the default gateway for the vcpe
set -u # to verify variables are defined
: $KUBECTL
: $OSMNS
: $VACC
: $VCPE
: $HOMETUNIP
: $VNFTUNIP
: $VCPEPUBIP
: $VCPEGW
if [[ ! $VACC =~ "helmchartrepo-accesschart" ]]; then
echo ""
echo "ERROR: incorrect <access_deployment_id>: $VACC"
exit 1
fi
if [[ ! $VCPE =~ "helmchartrepo-cpechart" ]]; then
echo ""
echo "ERROR: incorrect <cpe_deployment_id>: $VCPE"
exit 1
fi
ACC_EXEC="$KUBECTL exec -n $OSMNS $VACC --"
CPE_EXEC="$KUBECTL exec -n $OSMNS $VCPE --"
# Router por defecto en red residencial
VCPEPRIVIP="192.168.255.1"
# Router por defecto inicial en k8s (calico)
K8SGW="169.254.1.1"
## 1. Obtener IPs de las VNFs
echo "## 1. Obtener IPs de las VNFs"
IPACCESS=`$ACC_EXEC hostname -I | awk '{print $1}'`
echo "IPACCESS = $IPACCESS"
IPCPE=`$CPE_EXEC hostname -I | awk '{print $1}'`
echo "IPCPE = $IPCPE"
## 2. Iniciar el Servicio OpenVirtualSwitch en cada VNF:
echo "## 2. Iniciar el Servicio OpenVirtualSwitch en cada VNF"
$ACC_EXEC service openvswitch-switch start
$CPE_EXEC service openvswitch-switch start
## 3. En VNF:access agregar un bridge y configurar IPs y rutas
echo "## 3. En VNF:access agregar un bridge y configurar IPs y rutas"
$ACC_EXEC ovs-vsctl add-br brint
$ACC_EXEC ifconfig net1 $VNFTUNIP/24
#$ACC_EXEC ovs-vsctl add-port brint vxlanacc -- set interface vxlanacc type=vxlan options:remote_ip=$HOMETUNIP
#$ACC_EXEC ovs-vsctl add-port brint vxlanint -- set interface vxlanint type=vxlan options:remote_ip=$IPCPE options:key=inet options:dst_port=8742
$ACC_EXEC ip link add vxlanacc type vxlan id 0 remote $HOMETUNIP dstport 4789 dev net1
# En la siguiente línea se ha corregido el dispositivo, que debe ser eth0
$ACC_EXEC ip link add vxlanint type vxlan id 1 remote $IPCPE dstport 8742 dev eth0
$ACC_EXEC ovs-vsctl add-port brint vxlanacc
$ACC_EXEC ovs-vsctl add-port brint vxlanint
$ACC_EXEC ifconfig vxlanacc up
$ACC_EXEC ifconfig vxlanint up
$ACC_EXEC ip route add $IPCPE/32 via $K8SGW
## 4. En VNF:cpe agregar un bridge y configurar IPs y rutas
echo "## 4. En VNF:cpe agregar un bridge y configurar IPs y rutas"
$CPE_EXEC ovs-vsctl add-br brint
$CPE_EXEC ifconfig brint $VCPEPRIVIP/24
#$CPE_EXEC ovs-vsctl add-port brint vxlanint -- set interface vxlanint type=vxlan options:remote_ip=$IPACCESS options:key=inet options:dst_port=8742
$CPE_EXEC ovs-vsctl add-port brint vxlanint -- set interface vxlanint type=vxlan options:remote_ip=$IPACCESS options:key=1 options:dst_port=8742
$CPE_EXEC ifconfig brint mtu 1400
$CPE_EXEC ifconfig net1 $VCPEPUBIP/24
$CPE_EXEC ip route add $IPACCESS/32 via $K8SGW
$CPE_EXEC ip route del 0.0.0.0/0 via $K8SGW
$CPE_EXEC ip route add 0.0.0.0/0 via $VCPEGW
# ip -d link show vxlanacc
## 5. En VNF:cpe iniciar Servidor DHCP
echo "## 5. En VNF:cpe iniciar Servidor DHCP"
$CPE_EXEC sed -i 's/homeint/brint/' /etc/default/isc-dhcp-server
$CPE_EXEC service isc-dhcp-server restart
sleep 10
## 6. En VNF:cpe activar NAT para dar salida a Internet
echo "## 6. En VNF:cpe activar NAT para dar salida a Internet"
$CPE_EXEC /usr/bin/vnx_config_nat brint net1
## 7. En VNF:cpe activar arpwatch
echo "## 7. En VNF:cpe activar arpwatch"
$CPE_EXEC /etc/init.d/arpwatch start
# $CPE_EXEC /etc/init.d/arpwatch stop
## 8. En VNF:acc activar ryu
#echo "## 8. En VNF:acc activar ryu"
#$ACC_EXEC ovs-vsctl set bridge brint protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
#$ACC_EXEC ovs-vsctl set-fail-mode brint secure
#$ACC_EXEC ovs-vsctl set bridge brint other-config:datapath-id=0000000000000001
#$ACC_EXEC ovs-vsctl set-manager ptcp:6632
#$ACC_EXEC ovs-vsctl set-controller brint tcp:127.0.0.1:6633
#$ACC_EXEC ryu-manager ryu.app.rest_qos ryu.app.rest_conf_switch ./ryu/qos_simple_switch_13.py
# Manager
#$ACC_EXEC curl -X PUT -d '"tcp:127.0.0.1:6632"' http://localhost:8080/v1.0/conf/switches/0000000000000001/ovsdb_addr
# Cola 0: hX1 | min 8 Mbps
# Cola 1: hX2 | max 4 Mbps
#$ACC_EXEC curl -X POST -d '{"port_name": "vxlanacc", "type": "linux-htb", "max_rate": "12000000", "queues": [{"min_rate": "8000000"}, {"max_rate": "4000000"}]}' http://localhost:8080/qos/queue/0000000000000001
# Definir a que cola pertenece cada tráfico
#$ACC_EXEC curl -X POST -d '{"match": {"nw_dst": "'$hx1'"}, "actions":{"queue": "0"}}' http://localhost:8080/qos/rules/0000000000000001
#$ACC_EXEC curl -X POST -d '{"match": {"nw_dst": "'$hx2'"}, "actions":{"queue": "1"}}' http://localhost:8080/qos/rules/0000000000000001