-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add OVN snap demo #4
Open
fnordahl
wants to merge
1
commit into
master
Choose a base branch
from
ovn-snap
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
# This script lives on: | ||
# https://github.com/fnordahl/demos/blob/ovn-snap/ovn-snap/ovn-sandbox-singlenode.sh | ||
# | ||
# OVN Sandbox example commands freely adapted from: | ||
# https://github.com/ovn-org/ovn/blob/master/Documentation/tutorials/ovn-sandbox.rst | ||
# | ||
# OVN snap snapcraft.yaml source code available at: | ||
# https://github.com/fnordahl/ovn/tree/snap | ||
|
||
set -xe | ||
# TODO: request snap aliases for these | ||
NBCTL=ovn.nbctl | ||
SBCTL=ovn.sbctl | ||
|
||
# For the purpose of interactive demo flexibility install Open vSwitch on the | ||
# host and OVN in a confined snap. This is possible thanks to snapd interface | ||
# work done by jamespage. | ||
sudo apt install -y openvswitch-switch | ||
sudo snap install --edge ovn | ||
|
||
# Allow snap to talk to host Open vSwitch | ||
snap connect ovn:openvswitch | ||
|
||
# Allow host Open vSwitch and/or neighbouring Open vSwitch instances to talk | ||
# to OVN in the strictly confined snap. | ||
$SBCTL set-connection ptcp:6642 | ||
|
||
# Add config to the local OVSDB that the OVN local Controller looks for to talk | ||
# to OVN | ||
ovs-vsctl set Open_vSwitch . external-ids:ovn-encap-type=geneve | ||
ovs-vsctl set Open_vSwitch . external-ids:ovn-encap-ip=127.0.0.1 | ||
ovs-vsctl set Open_vSwitch . external-ids:ovn-remote="tcp:127.0.0.1:6642" | ||
snap restart ovn.controller | ||
|
||
# Create the first logical switch with one port | ||
$NBCTL ls-add sw0 | ||
$NBCTL lsp-add sw0 sw0-port1 | ||
$NBCTL lsp-set-addresses sw0-port1 "50:54:00:00:00:01 192.168.0.2" | ||
|
||
# Create the second logical switch with one port | ||
$NBCTL ls-add sw1 | ||
$NBCTL lsp-add sw1 sw1-port1 | ||
$NBCTL lsp-set-addresses sw1-port1 "50:54:00:00:00:03 11.0.0.2" | ||
|
||
# Create a logical router and attach both logical switches | ||
$NBCTL lr-add lr0 | ||
$NBCTL lrp-add lr0 lrp0 00:00:00:00:ff:01 192.168.0.1/24 | ||
$NBCTL lsp-add sw0 lrp0-attachment | ||
$NBCTL lsp-set-type lrp0-attachment router | ||
$NBCTL lsp-set-addresses lrp0-attachment 00:00:00:00:ff:01 | ||
$NBCTL lsp-set-options lrp0-attachment router-port=lrp0 | ||
$NBCTL lrp-add lr0 lrp1 00:00:00:00:ff:02 11.0.0.1/24 | ||
$NBCTL lsp-add sw1 lrp1-attachment | ||
$NBCTL lsp-set-type lrp1-attachment router | ||
$NBCTL lsp-set-addresses lrp1-attachment 00:00:00:00:ff:02 | ||
$NBCTL lsp-set-options lrp1-attachment router-port=lrp1 | ||
|
||
# Create host userspace interfaces so that we have something familiar to | ||
# interact with | ||
ip link add vrf0 type vrf table 1 | ||
ip link set vrf0 up | ||
ovs-vsctl add-port br-int sw0p1 -- \ | ||
set Interface sw0p1 external_ids:iface-id=sw0-port1 type=internal | ||
ip link set sw0p1 addr 50:54:00:00:00:01 vrf vrf0 up | ||
ip addr add 192.168.0.2/24 dev sw0p1 | ||
ip route add 11.0.0.0/24 via 192.168.0.1 vrf vrf0 | ||
|
||
ip link add vrf1 type vrf table 2 | ||
ip link set vrf1 up | ||
ovs-vsctl add-port br-int sw1p1 -- \ | ||
set Interface sw1p1 external_ids:iface-id=sw1-port1 type=internal | ||
ip link set sw1p1 addr 50:54:00:00:00:03 vrf vrf1 up | ||
ip addr add 11.0.0.2/24 dev sw1p1 | ||
ip route add 192.168.0.0/2 via 11.0.0.1 vrf vrf1 | ||
|
||
# View a summary of the configuration | ||
printf "\n=== ovn-nbctl show ===\n\n" | ||
$NBCTL show | ||
printf "\n=== ovn-nbctl show with wait hv ===\n\n" | ||
$NBCTL --wait=hv show | ||
printf "\n=== ovn-sbctl show ===\n\n" | ||
$SBCTL show |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javacruft ^