On 09/19/2012 07:27 PM, Ben Pfaff wrote:
On Wed, Sep 19, 2012 at 07:22:59PM +0200, Andi wrote:
We have installed openvswitch in netkit(a user-mode linux front-end
let's say) after cross-compiling it for UML. During the startup of
the virtual machines we use a script to install openvswitch using
the commands reported in section 7 of INSTALL.Linux. The various
environment variables are exported in the script but as it turns out
they are not permanent after booting. After chroot-ing in the file
system of the virtual machines I have added the export of this
variables values in .bashrc.
Is the script something that might be useful to others?  If so, please
consider posting it.  If it's general-purpose enough, then perhaps it
might be useful to include it in the Open vSwitch repository.

Thanks,

Ben.
Hi Ben,

I think it(btw it is a makefile with different targets such as boot,
start, stop ...) could be useful for those who are using openvswitch
on netkit. If generalized only a little it can be used even for
other environments. So could you point me where to exactly put it?
If it's a reasonable size, you could post it here, to the mailing
list.

Btw we have also written a guide about installing openvswitch in
DD-WRT. We have reported the guide here: 
http://www.openflow.org/wk/index.php/UoR_:_Openflow_Kernel_space_on_DD-WRT
If you think it's the case that this should be added even in some
openvswitch wiki or repository let us know and we will add it.
Maybe.  Perhaps the decision should depend on what is more likely to
need changing: the Open vSwitch parts or the DD-WRT parts.  We can
maintain the Open vSwitch parts well, if the file is our tree, but we
are likely to not notice if the DD-WRT parts need to be updated, which
could frustrate users.  My guess, off-hand, is that it's better to
keep this in the openflow wiki.

Hi Ben,
one can save this as Makefile .
We make only two assumptions:
* Switch node names are set like this: "switch1, switch2, switch3, ...
      * The interfaces(ports) for the moment are only ethernet ones.
The only interesting targets are the final 4 ones: boot, start, restart, stop. Restart is needed when the kernel module or any other application is re-compiled.

Any improvement or suggestion is very welcome.

___________________________________________________________________________________
BRNAME = br0
CONTROLLER_IP = 192.168.0.1

# Export environment variables
PWD=$(shell pwd)
OVS_SRC=$(PWD)/openvswitch
OVS_KMODDIR=$(OVS_SRC)/datapath/linux
IFACES=$(shell ip link show|grep "^[0-9]: eth[1-9]"|awk '{ print $$2 }'|tr -d ":")
NODENUMBER=$(shell uname -n|tr -d "switch")
NODEIDX16=$(shell printf "%016x" $(NODENUMBER))

export OVS_SYSCONFDIR=/usr/local/etc
export OVS_RUNDIR=/var/run/openvswitch
export OVS_PKGDATADIR=$(OVS_SRC)/build/share/openvswitch
export OVS_LOGDIR=$(OVS_SRC)/build/var/log
export OVS_BINDIR=$(OVS_SRC)/build/bin
export OVS_SBINDIR=$(OVS_SRC)/build/sbin

insert-module:
    insmod $(OVS_KMODDIR)/openvswitch_mod.ko
    insmod $(OVS_KMODDIR)/brcompat_mod.ko

remove-module:
    -rmmod brcompat_mod
    -rmmod openvswitch_mod

create-db:
    mkdir -p $(OVS_SYSCONFDIR)/openvswitch
$(OVS_BINDIR)/ovsdb-tool create $(OVS_SYSCONFDIR)/openvswitch/conf.db $(OVS_PKGDATADIR)/vswitch.ovsschema

#Startup

start-server server:
    mkdir -p $(OVS_RUNDIR)
-$(OVS_SBINDIR)/ovsdb-server $(OVS_SYSCONFDIR)/openvswitch/conf.db --remote=punix:$(OVS_RUNDIR)/db.sock --remote=db:Open_vSwitch,manager_options --private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach
# Check DB daemon
    ps -ef | grep ovsdb-server

stop-server:
    -killall ovsdb-server

create_br:
    $(OVS_BINDIR)/ovs-vsctl --no-wait add-br $(BRNAME)
$(OVS_BINDIR)/ovs-vsctl --no-wait set Bridge $(BRNAME) other-config:datapath-id=$(NODEIDX16)


eth%:
    $(OVS_BINDIR)/ovs-vsctl --no-wait add-port $(BRNAME) eth$*

init: create_br $(IFACES)
$(OVS_BINDIR)/ovs-vsctl --no-wait set-controller $(BRNAME) tcp:$(CONTROLLER_IP):6633

end:
    -$(OVS_BINDIR)/ovs-vsctl --no-wait del-br $(BRNAME)


# Start
start-daemon daemon:
-$(OVS_SBINDIR)/ovs-vswitchd unix:$(OVS_RUNDIR)/db.sock --pidfile --detach

daemon-only:
    -$(OVS_SBINDIR)/ovs-vswitchd unix:$(OVS_RUNDIR)/db.sock

stop-daemon:
    -killall ovs-vswitchd


clean:
    rm -rf $(OVS_SYSCONFDIR)/openvswitch
    rm -rf $(OVS_RUNDIR)

remove-config: server daemon end stop-server stop-daemon

config: server init stop-server

#Start all configuration and openflow
start: config boot

#Use this target to restart openflow when it is running
restart: remove-config stop-daemon remove-module insert-module start-server init start-daemon

#Use this target to start openflow after the machine has booted. This supposes that the configuration exist
boot: start-server insert-module start-daemon

#Use this target is something goes bad, really bad!
stop:    remove-config remove-module
_____________________________________________________________________________________________


Regards,
Andi
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to