Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kne lab #111

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 243 additions & 2 deletions do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# update for any release using
# curl -kLO https://github.com/open-traffic-generator/ixia-c/releases/download/v1.3.0-2/versions.yaml
VERSIONS_YAML="versions.yaml"
GITHUB_USER="give your github username"
GITHUB_PAT="give your github PAT"
VETH_A="veth-a"
VETH_Z="veth-z"
# additional member ports for LAG
Expand All @@ -23,10 +25,43 @@ NOKIA_SRL_OPERATOR_VERSION="0.4.6"
NOKIA_SRL_OPERATOR_YAML="https://github.com/srl-labs/srl-controller/config/default?ref=v${NOKIA_SRL_OPERATOR_VERSION}"
ARISTA_CEOS_OPERATOR_VERSION="2.0.1"
ARISTA_CEOS_OPERATOR_YAML="https://github.com/aristanetworks/arista-ceoslab-operator/config/default?ref=v${ARISTA_CEOS_OPERATOR_VERSION}"
ARISTA_CEOS_VERSION="4.29.1F-29233963"
ARISTA_CEOS_VERSION="4.30.1f-32091951"
ARISTA_CEOS_IMAGE="ghcr.io/open-traffic-generator/ceos"
ARISTA_TAR_PATH="./ceos-4.30.tar"
KNE_VERSION=v0.1.17

export OTG_HW_PATH=$(yq e '.images[] | select(.name == "otg-ixhw-c") | .path' ~/conformance/versions.yaml)
export OTG_HW_TAG=$(yq e '.images[] | select(.name == "otg-ixhw-c") | .tag' ~/conformance/versions.yaml)
export GNMI_SERVER_PATH=$(yq e '.images[] | select(.name == "gnmi-server") | .path' ~/conformance/versions.yaml)
export GNMI_SERVER_TAG=$(yq e '.images[] | select(.name == "gnmi-server") | .tag' ~/conformance/versions.yaml)
export CONTROLLER_PATH=$(yq e '.images[] | select(.name == "controller") | .path' ~/conformance/versions.yaml)
export CONTROLLER_TAG=$(yq e '.images[] | select(.name == "controller") | .tag' ~/conformance/versions.yaml)
export PROTOCOL_ENGINE_PATH=$(yq e '.images[] | select(.name == "protocol-engine") | .path' ~/conformance/versions.yaml)
export PROTOCOL_ENGINE_TAG=$(yq e '.images[] | select(.name == "protocol-engine") | .tag' ~/conformance/versions.yaml)

#-------------------------------------------------------------------------------------------------------------
#OTG_HW details
#-------------------------------------------------------------------------------------------------------------
OTG_HW_COMPOSE="docker-compose.with.license.yaml"

#otg-hw host
OTG_HW_HOST="https://0.0.0.0:8443"

#otg-hw ports(Chassis ports)
OTG_HW_PORT_1="10.36.87.207;1;1"
OTG_HW_PORT_2="10.36.87.207;1;2"
#----------------------------------------------------------------------------------------------------------------------
#UHD setup details
#----------------------------------------------------------------------------------------------------------------------
TRUNK_INTERFACE="ens192"
UHD_CONTROLLER_COMPOSE="docker-compose.controller.uhd.yaml"
PE_LIST="1 2"
UHD_HOST="10.36.87.205:40051"
#for example ports will look like :=
#"uhd://10.36.87.166:7531;1+0.0.0.0:50071"
#"uhd://10.36.87.166:7531;2+0.0.0.0:50072"
#-----------------------------------------------------------------------------------------------------------------------

OPENCONFIG_MODELS_REPO=https://github.com/openconfig/public.git
OPENCONFIG_MODELS_COMMIT=5ca6a36

Expand Down Expand Up @@ -337,6 +372,24 @@ gen_config_common() {
echo -n "$yml" | sed "s/^ //g" | tee -a ./test-config.yaml > /dev/null
}

gen_config_common_hw() {
yml="otg_speed: speed_400_gbps
otg_capture_check: true
otg_iterations: 100
otg_grpc_transport: false
"
echo -n "$yml" | sed "s/^ //g" | tee -a ./test-config.yaml > /dev/null
}

gen_config_common_uhd() {
yml="otg_speed: speed_400_gbps
otg_capture_check: true
otg_iterations: 100
otg_grpc_transport: true
"
echo -n "$yml" | sed "s/^ //g" | tee -a ./test-config.yaml > /dev/null
}

gen_config_b2b_dp() {
yml="otg_host: https://localhost:8443
otg_ports:
Expand Down Expand Up @@ -417,6 +470,33 @@ gen_config_kne() {
gen_config_common
}

gen_config_otg_hw() {
yml="otg_host: ${OTG_HW_HOST}
otg_ports:
- ${OTG_HW_PORT_1}
- ${OTG_HW_PORT_2}
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null

gen_config_common_hw
}

gen_config_uhd_b2b() {
ELEMENT1=""
ELEMENT2=""

ELEMENT1=$(echo "$PE_LIST" | awk '{print $1}')
ELEMENT2=$(echo "$PE_LIST" | awk '{print $2}')
yml="otg_host: ${UHD_HOST}
otg_ports:
- uhd://10.36.87.166:7531;$ELEMENT1+10.36.87.205:$((50070 + ELEMENT1))
- uhd://10.36.87.166:7531;$ELEMENT2+10.36.87.205:$((50070 + ELEMENT2))
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null

gen_config_common_uhd
}

gen_config_k8s() {
ADDR=$(kubectl get service -n ixia-c service-otg-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
ETH1=$(grep "location:" deployments/k8s/manifests/${1}.yaml -m 2 | head -n1 | cut -d\: -f2 | cut -d\ -f2)
Expand Down Expand Up @@ -990,7 +1070,19 @@ load_image_to_kind() {
}

load_arista_ceos_image() {
load_image_to_kind "${ARISTA_CEOS_IMAGE}:${ARISTA_CEOS_VERSION}" "local"
#load_image_to_kind "${ARISTA_CEOS_IMAGE}:${ARISTA_CEOS_VERSION}" "local"

if docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "${ARISTA_CEOS_IMAGE}:local"; then
kind load docker-image ${ARISTA_CEOS_IMAGE}:local
elif docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "${ARISTA_CEOS_IMAGE}:${ARISTA_CEOS_VERSION}"; then
docker tag ${ARISTA_CEOS_IMAGE}:${ARISTA_CEOS_VERSION} ${ARISTA_CEOS_IMAGE}:local
kind load docker-image ${ARISTA_CEOS_IMAGE}:local
else
docker load -i $ARISTA_TAR_PATH #constant
docker tag ${ARISTA_CEOS_IMAGE}:${ARISTA_CEOS_VERSION} ${ARISTA_CEOS_IMAGE}:local
kind load docker-image ${ARISTA_CEOS_IMAGE}:local
fi

}

load_ixia_c_images() {
Expand Down Expand Up @@ -1110,6 +1202,143 @@ rm_ixia_c_kne() {
&& wait_for_no_namespace ${ns}
}

create_otg_hw_b2b() {
login_ghcr

if docker-compose -f $OTG_HW_COMPOSE ps | grep -q "Up"; then
echo "OTG-HW topology is already running. Please bring it down first."
exit 1
else
echo "Creating OTG-HW topology using docker-compose ..."
docker-compose -f $OTG_HW_COMPOSE up -d

gen_config_otg_hw

docker ps
echo "Sucessfully deployed !"
fi
}

rm_otg_hw_b2b() {
echo "Removing OTG-HW topology ..."
docker-compose -f docker-compose.with.license.yaml down
echo "Removed successfully"
}

create_uhd() {

login_ghcr

if docker-compose -f $UHD_CONTROLLER_COMPOSE ps | grep -q "Up"; then
echo "UHD-B2B topology is already running. Please bring it down first."
exit 1
else
echo "Creating UHD-B2B topology using docker-compose ..."
#Deploying uhd controller and gnmi server
docker-compose -f $UHD_CONTROLLER_COMPOSE up -d
docker-compose -f $UHD_CONTROLLER_COMPOSE up -d otg-gnmi-server #as of now manual since with compose not gettin' up

#Deploying protocol engines
for port in $PE_LIST; do
deploy_ixia_c_protocol_engine "$port"
done


gen_config_uhd_b2b

docker ps
echo "Sucessfully deployed !"
fi
}



deploy_ixia_c_protocol_engine() {

port=$1
if [ $port -gt 32 ] || [ $port -lt 1 ]; then
echo "Port $port out of range"
return 1
fi
# check if trunk exists
if ! sudo ip link show "$TRUNK_INTERFACE" > /dev/null 2>&1; then
echo "Trunk interface: $TRUNK_INTERFACE doesn't exist"
return 1;
fi
# set trunk port up/promic mode
sudo ip link set $TRUNK_INTERFACE up promisc on
cleanup_protocol_engine "$port" > /dev/null 2>/dev/null || true
container_name="ixiape$port"
echo "starting container $container_name: for UHD Port $port"
#-e PE_MAX_CORE='4'
docker run \
--privileged \
-p $((50070 + $port)):50071 \
-e "OPT_NO_HUGEPAGES=Yes" \
-e ARG_IFACE_LIST="virtual@af_packet,eth1" \
-l controller=bash \
-l app=ixia-c-protocol-engine \
-l port="$port" \
-d \
--name "$container_name" \
"${PROTOCOL_ENGINE_PATH}:${PROTOCOL_ENGINE_TAG}"
# Create VLAN Interface
vlan_map="136 144 152 160 168 176 184 192 320 312 304 296 288 280 272 264"
pe_interface="ixiape$port"
vlan=$(get_vlan $port)
#vlan=${vlan_map[$(( port - 1 ))]}
echo "creating $pe_interface: for UHD Port $port $pe_interface=$TRUNK_INTERFACE vlan id $vlan"
# delete interface if exists
sudo ip link del "$pe_interface" 2>/dev/null || true
sudo ip link add link "$TRUNK_INTERFACE" name "$pe_interface" type vlan id "$vlan"
sudo ip link set "$pe_interface" up promisc on
# generate random mac address for the
sudo ip link set "$pe_interface" address "$(printf '00:60:2F:0A:0B:%02X\n' "${port}")"

# move ixiapeN interface into the container
echo "moving interface $pe_interface into $container_name"
pid=$(docker inspect "${container_name}" --format {{.State.Pid}})
# set name to network namespace
mkdir -p /var/run/netns/
sudo ln -sf /proc/"$pid"/ns/net "/var/run/netns/$container_name"

# move interface to container's network namespace
sudo ip link set "$pe_interface" netns "$container_name"
sudo ip netns exec "$pe_interface" sudo ip link set "$pe_interface" name eth1
sudo ip netns exec "$pe_interface" sudo ip link set eth1 up promisc on

}

get_vlan() {
local port=$1
local index=$((port - 1))
local vlan=$(echo $vlan_map | cut -d' ' -f$((index + 1)))
echo "$vlan"
}

cleanup_protocol_engine(){
port=$1
if [ $port -gt 16 ] || [ $port -lt 1 ]; then
echo "Port $port out of range"
return 1
fi
echo "Deleting Ixia-c-protocol-engine containers for port $port"
docker ps -q -f label=app=ixia-c-protocol-engine -f label=port=$port
# delete container
docker rm -f $(docker ps -q -f label=app=ixia-c-protocol-engine -f label=port=$port) > /dev/null 2>/dev/null || true
# delete vlan interface
pe_interface="ixiape$port"
sudo ip link delete "$pe_interface" 2>/dev/null
}

rm_uhd() {
docker-compose -f $UHD_CONTROLLER_COMPOSE down
for port in $PE_LIST; do
cleanup_protocol_engine "$port" > /dev/null 2>/dev/null || true
done
echo "Successfully removed topology"
}

k8s_namespace() {
grep namespace deployments/k8s/manifests/${1}.yaml -m 1 | cut -d \: -f2 | cut -d \ -f 2
}
Expand Down Expand Up @@ -1154,6 +1383,12 @@ topo() {
k8seth0 )
create_ixia_c_k8s ixia-c-b2b-eth0
;;
otghw_b2b )
create_otg_hw_b2b
;;
uhd )
create_uhd
;;
* )
echo "unsupported topo type: ${2}"
exit 1
Expand All @@ -1180,6 +1415,12 @@ topo() {
k8seth0 )
rm_ixia_c_k8s ixia-c-b2b-eth0
;;
otghw_b2b )
rm_otg_hw_b2b
;;
uhd )
rm_uhd
;;
* )
echo "unsupported topo type: ${2}"
exit 1
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.controller.uhd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "2"

services:
otg-gnmi-server:
image: ${GNMI_SERVER_PATH}:${GNMI_SERVER_TAG}
container_name: otg-gnmi-server
profiles: ["all", "gnmi"]
restart: always
ports:
- "50051:50051"
command:
- "-http-server"
- "https://keng-controller:8443"
- "--debug"
logging:
driver: "local"
options:
max-size: "10m"
max-file: "2"
mode: "non-blocking"

keng-controller:
image: ${CONTROLLER_PATH}:${CONTROLLER_TAG}
container_name: keng-controller
restart: always
ports:
- "8443:8443"
- "40051:40051"
command:
- "--accept-eula"
- "--debug"
environment:
- LICENSE_SERVERS=10.36.87.205
55 changes: 55 additions & 0 deletions docker-compose.with.license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: "2.4"

services:
otg-ixhw-c:
image: ${OTG_HW_PATH}:${OTG_HW_TAG}
restart: always
ports:
- "5001:5001"
command:
- "dotnet"
- "otg-ixhw.dll"
- "--trace"
- "--log-level"
- "trace"
logging:
driver: "local"
options:
max-size: "10m"
max-file: "2"
mode: "non-blocking"
ixia-c-gnmi-server:
image: ${GNMI_SERVER_PATH}:${GNMI_SERVER_TAG}
restart: always
ports:
- "50051:50051"
command:
- "-http-server"
- "https://ixia-c-controller:8443"
- "--debug"
logging:
driver: "local"
options:
max-size: "10m"
max-file: "2"
mode: "non-blocking"
ixia-c-controller:
image: ${CONTROLLER_PATH}:${CONTROLLER_TAG}
restart: always
ports:
- "8443:8443"
- "40051:40051"
command:
- "--accept-eula"
- "--keng-layer23-hw-server"
- "otg-ixhw-c:5001"
logging:
driver: "local"
options:
max-size: "10m"
max-file: "2"
mode: "non-blocking"
environment:
- LICENSE_SERVERS=10.36.87.205


Loading
Loading