4 proj1=$(word 1,$(subst @, ,$(1)))
7 proj2=$(word 2,$(subst @, ,$(1)))
11 get=$(word $(call proj2,$(1)),$(subst -, ,$(call proj1,$(1))))
15 flip=$(if $(findstring 1,$(1)),2,1)
19 opp=$(call proj1,$(1))@$(call flip,$(call proj2,$(1)))
23 rget=$(call get,$(call opp,$(1)))
28 all: $(addprefix L/,$(shell cat links))
32 @echo "IP lookup for host $*"
33 @host $(HOST_$*) | sed -n 's/^.*has address *//p' > $@
36 @echo "Starting db server on host $*"
37 @ssh -l $(SLICE) $(HOST_$*) \
38 sudo start_ovsdb-server > $@ \
41 cache/switchd.%: cache/db.%
42 @echo "Starting vswitchd on host $*"
43 @ssh -l $(SLICE) $(HOST_$*) \
44 sudo start_vswitchd > $@ \
47 cache/bridge.%: cache/switchd.%
48 @echo "Creating bridge on host $*"
49 @ssh -l $(SLICE) $(HOST_$*) \
50 sudo create_bridge $(IP_$*) > $@ \
54 L/%: cache/link.%@1 cache/link.%@2
56 @echo "Created link $*"
58 del.%: del-iface.%@1 del-iface.%@2
60 @echo "Deleted link $*"
63 @echo "Removing interface for link $(call proj1,$*) from host $(call get,$*)"
64 @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
65 sudo ovs-vsctl del-port L$(call proj1,$*)
66 @rm -f cache/iface.$* cache/link.$* cache/link.$(call opp,$*)
69 @echo "Deleting bridge on host $*"
70 @if [ -f cache/bridge.$* ]; then \
71 ssh -l $(SLICE) $(HOST_$*) \
72 sudo del_bridge $$(cat cache/bridge.$*);\
74 @rm -f cache/bridge.$* \
75 cache/iface.$*-*@1 cache/iface.*-$*@2 \
76 cache/link.$*-*@? cache/link.*-$*@? \
80 ( echo "digraph $(SLICE) {"; ls L | sed 's/-/->/;s/$$/;/'; echo "}" ) > $@
85 .PHONY: clean del-links graph.dot
88 clean: $(addprefix del-,$(notdir $(wildcard cache/bridge.*)))
90 del-links: $(addprefix del.,$(notdir $(wildcard L/*)))
94 cache/iface.%: cache/bridge.$$(call get,%)
95 @echo "Creating iterface for link $(call proj1,$*) on host $(call get,$*)"
96 @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
97 sudo create_port $$(cat $^) L$(call proj1,$*) > $@ \
100 cache/link.%: cache/host.$$(call rget,$$*) cache/iface.% cache/iface.$$(call opp,$$*)
101 @echo "Setting port number of link $(call proj1,$*) on host $(call get,$*)"
102 @ssh -l $(SLICE) $(HOST_$(call get,$*)) \
103 sudo ovs-vsctl set interface L$(call proj1,$*) \
104 options:remote_ip=$$(cat cache/host.$(call rget,$*)) \
105 options:remote_port=$$(cat cache/iface.$(call opp,$*)) \