summaryrefslogtreecommitdiffstats
path: root/kud
diff options
context:
space:
mode:
Diffstat (limited to 'kud')
-rw-r--r--kud/sites/examples/provider_nw_setup.sh65
-rw-r--r--kud/tests/ovn_provider_nw_test.sh191
2 files changed, 256 insertions, 0 deletions
diff --git a/kud/sites/examples/provider_nw_setup.sh b/kud/sites/examples/provider_nw_setup.sh
new file mode 100644
index 00000000..fbe0011d
--- /dev/null
+++ b/kud/sites/examples/provider_nw_setup.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+map_list=""
+function create_vlan {
+ local dev=$1
+ local id=$2
+ local name=$3
+
+ # Create VLAN for device
+ sudo ip link add link $dev name $name type vlan id $id
+ #sudo ip addr add $ip dev $name
+ sudo ip link set $name up
+}
+
+# Create provider network for interface
+function create_provider_network {
+ local provider_name=$1
+ local interface=$2
+
+ bridge_name=br-$provider_name
+ network_name=nw_$provider_name
+ port_name=server-localnet_$provider_name
+
+ # Create OVS bridge and move the interface to the bridge
+ sudo ovs-vsctl --may-exist add-br $bridge_name
+ sudo ovs-vsctl --may-exist add-port $bridge_name $interface
+
+ #Create OVN Switch
+ sudo ovn-nbctl --may-exist ls-add $provider_name
+ # Add port of type localnet to the Switch
+ sudo ovn-nbctl --may-exist lsp-add $provider_name $port_name
+ sudo ovn-nbctl lsp-set-addresses $port_name unknown
+ sudo ovn-nbctl lsp-set-type $port_name localnet
+ #Set port with the network name to map to ovs bridge
+ sudo ovn-nbctl lsp-set-options $port_name network_name=$network_name
+ # Prepare bridge to network mapping for OVS
+ map_list=${map_list}${network_name}:${bridge_name},
+}
+
+create_vlan eth1 100 eth1.100
+create_vlan eth1 200 eth1.200
+
+provider_net1=prod-net1
+provider_net2=prod-net2
+
+create_provider_network $provider_net1 eth1.100
+create_provider_network $provider_net2 eth1.200
+
+#Set OVS with the bridge to network mapping
+map_list=${map_list%?}
+sudo ovs-vsctl set open . external-ids:ovn-bridge-mappings=$map_list
+
+
diff --git a/kud/tests/ovn_provider_nw_test.sh b/kud/tests/ovn_provider_nw_test.sh
new file mode 100644
index 00000000..9b32d904
--- /dev/null
+++ b/kud/tests/ovn_provider_nw_test.sh
@@ -0,0 +1,191 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+source _common.sh
+source _functions.sh
+
+# populate_CSAR_ovn4nfv() - Create content used for OVN4NFV functional test
+function populate_CSAR_provider_network {
+ local csar_id=$1
+
+ _checks_args $csar_id
+ pushd ${CSAR_DIR}/${csar_id}
+
+ cat << MULTUS_NET > onap-ovn4nfvk8s-network.yaml
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+ name: $ovn_multus_network_name
+spec:
+ config: '{
+ "cniVersion": "0.3.1",
+ "name": "ovn4nfv-k8s-plugin",
+ "type": "ovn4nfvk8s-cni"
+ }'
+MULTUS_NET
+
+ cat << NETWORK > ovn-virt-net1.yaml
+apiVersion: v1
+kind: onapNetwork
+metadata:
+ name: ovn-virt-net1
+ cnitype : ovn4nfvk8s
+spec:
+ name: ovn-virt-net1
+ subnet: 10.1.20.0/24
+ gateway: 10.1.20.1/24
+NETWORK
+
+ cat << NETWORK > ovn-virt-net2.yaml
+apiVersion: v1
+kind: onapNetwork
+metadata:
+ name: ovn-virt-net2
+ cnitype : ovn4nfvk8s
+spec:
+ name: ovn-virt-net2
+ subnet: 10.1.21.0/24
+ gateway: 10.1.21.1/24
+NETWORK
+
+ cat << DEPLOYMENT > firewall.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: firewall
+ labels:
+ app: ovn4nfv
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ovn4nfv
+ template:
+ metadata:
+ labels:
+ app: ovn4nfv
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
+ ovnNetwork: '[ { "name": ""ovn-virt-net1"", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.20.2"},
+ { "name": "prod-net1", "interface": "net1", "defaultGateway": "false", "ipAddress":"10.1.5.1/24"}]'
+ ovnNetworkRoutes: '[{ "dst": "0.0.0.0/0", "gw": "10.1.20.3", "dev": "net0" }]'
+
+ spec:
+ containers:
+ - name: firewall
+ image: "busybox"
+ command: ["top"]
+ stdin: true
+ tty: true
+DEPLOYMENT
+
+ cat << DEPLOYMENT > webcache.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: webcache
+ labels:
+ app: ovn4nfv
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ovn4nfv
+ template:
+ metadata:
+ labels:
+ app: ovn4nfv
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
+ ovnNetwork: '[{ "name": "ovn-virt-net1", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.20.3"},
+ { "name": "ovn-virt-net2", "interface": "net1" , "defaultGateway": "false", "ipAddress":"10.1.21.2"}]'
+ ovnNetworkRoutes: '[{ "dst": "10.1.5.0/24", "gw": "10.1.20.2", "dev": "net0" },
+ { "dst": "0.0.0.0/0", "gw": "10.1.21.3", "dev": "net1" }]'
+
+ spec:
+ containers:
+ - name: webcache
+ image: "busybox"
+ command: ["top"]
+ stdin: true
+ tty: true
+DEPLOYMENT
+
+ cat << DEPLOYMENT > sdwan.yaml
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: sdwan
+ labels:
+ app: ovn4nfv
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ovn4nfv
+ template:
+ metadata:
+ labels:
+ app: ovn4nfv
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[{ "name": "$ovn_multus_network_name"}]'
+ ovnNetwork: '[ { "name": ""ovn-virt-net2"", "interface": "net0" , "defaultGateway": "false", "ipAddress":"10.1.21.3"},
+ { "name": "prod-net2", "interface": "net1", "defaultGateway": "false", "ipAddress":"10.1.10.2/24"}]'
+ ovnNetworkRoutes: '[{ "dst": "0.0.0.0/0", "gw": "10.1.10.1", "dev": "net1" },
+ { "dst": "10.1.5.0/24", "gw": "10.1.21.2", "dev": "net0" },
+ { "dst": "10.1.20.0/24", "gw": "10.1.21.2", "dev": "net0" }]'
+
+ spec:
+ containers:
+ - name: sdwan
+ image: "busybox"
+ command: ["top"]
+ stdin: true
+ tty: true
+DEPLOYMENT
+ popd
+}
+
+csar_id=d5718572-3b9a-11e9-b210-d663bd873dda
+# Setup
+install_ovn_deps
+populate_CSAR_provider_network $csar_id
+
+pushd ${CSAR_DIR}/${csar_id}
+for net in ovn-virt-net1 ovn-virt-net2; do
+ cleanup_network $net.yaml
+ echo "Create OVN Network $net network"
+ init_network $net.yaml
+done
+kubectl apply -f onap-ovn4nfvk8s-network.yaml
+setup firewall webcache sdwan
+
+# Test
+deployment_pod=$(kubectl get pods | grep firewall | awk '{print $1}')
+echo "===== $deployment_pod details ====="
+kubectl exec -it $deployment_pod -- ip a
+multus_nic=$(kubectl exec -it $deployment_pod -- ifconfig | grep "net1")
+if [ -z "$multus_nic" ]; then
+ echo "The $deployment_pod pod doesn't contain the net1 nic"
+ exit 1
+fi
+
+# Teardown
+teardown firewall webcache sdwan
+cleanup_network ovn-virt-net1.yaml
+cleanup_network ovn-virt-net2.yaml
+popd
+
+
+