Skip to content

Instantly share code, notes, and snippets.

@putnopvut
Created July 18, 2019 17:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save putnopvut/3df7156b6d44b81d75a598262c5e959b to your computer and use it in GitHub Desktop.
Save putnopvut/3df7156b6d44b81d75a598262c5e959b to your computer and use it in GitHub Desktop.
#!/bin/bash
export OVN_NB_DAEMON=$(ovn-nbctl --pidfile --detach)
# Create router
ovn-nbctl lr-add router
# Create switches
for i in $(seq 1 159); do
j=$(printf '%02x' $i)
ovn-nbctl ls-add ls$i
ovn-nbctl lsp-add ls$i lsp-ro$i
ovn-nbctl lrp-add router ro-lsp$i 00:00:00:00:00:$j 10.0.0.$i/16
ovn-nbctl set Logical_Switch_Port lsp-ro$i options:router-port=ro-lsp$i type=router addresses=router
done
for i in $(seq 1 92); do
for j in $(seq 1 159); do
k=$(printf '%02x' $i)
l=$(printf '%02x' $j)
create_pg=$((($j - 1) % 4))
pg_index=$((($j - 1) / 4))
pg_name=${i}_${pg_index}
lsp_name=lsp${j}_10.$i.0.$j
#echo "lsp-add ls$j ${lsp_name}"
lsp_uuid=$(ovn-nbctl --id=@id create logical_switch_port name=${lsp_name} -- add logical_switch ls$j ports @id)
#echo "lsp-set-addresses ${lsp_name} \"00:00:00:00:$k:$l 10.$i.0.$j\""
ovn-nbctl lsp-set-addresses ${lsp_name} "00:00:00:00:$k:$l 10.$i.0.$j"
if [ $create_pg -eq 0 ]; then
#echo "ovn-nbctl create Port_Group name=${pg_name} ports=${lsp_uuid}"
ovn-nbctl create Port_Group name=${pg_name} ports=${lsp_uuid} 1> /dev/null
#echo "Create in-pod acl allow"
ovn-nbctl --type=port-group acl-add ${pg_name} to-lport 1000 "outport == \@${pg_name} && ip4.src == \$${pg_name}_ip4" allow
#echo "Create drop acl"
ovn-nbctl --wait=sb --type=port-group acl-add ${pg_name} to-lport 900 "outport == \@${pg_name}" drop
else
#echo "ovn-nbctl add Port_group ${pg_name} ports ${lsp_uuid}"
ovn-nbctl --wait=sb add Port_group ${pg_name} ports ${lsp_uuid}
fi
done
done
@ryzhyk
Copy link

ryzhyk commented Jul 18, 2019

How do you change the script to run with DDlog?

@putnopvut
Copy link
Author

putnopvut commented Jul 18, 2019 via email

@ryzhyk
Copy link

ryzhyk commented Jul 19, 2019

Thanks! I was able to reproduce the experiment by following your instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment