+########## sync
+# for use with the test framework; push local stuff on a test node
+# howto use: go on testmaster in the build you want to use and just run
+# $ exp
+# cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
+# $ export BUILD=2013.07.02--lxc18
+# $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
+# $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
+# $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
+# $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
+# $ export NODE=vnode01.pl.sophia.inria.fr
+# and then just run
+# $ make sync
+
+LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc'
+RSYNC_EXCLUDES := --exclude .git --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
+RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
+RSYNC := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
+
+ifdef NODE
+NODEURL:=root@$(NODE):/
+endif
+
+# this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
+# keep this in sync with setup-vs.spec
+LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py
+
+sync:synclxc
+
+synclxc: $(NODE).key.rsa
+ifeq (,$(NODEURL))
+ @echo "sync: You must define NODE on the command line"
+ @echo " e.g. make sync NODE=vnode01.inria.fr"
+ @exit 1
+else
+ @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ @echo WARNING : this target might not be very reliable - use with care
+ @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ +$(RSYNC) --exclude sshsh $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
+ +$(RSYNC) ./sshsh $(NODEURL)/bin/
+# +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
+ +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
+# ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
+endif
+
+### fetching the key
+
+TESTMASTER ?= testmaster.onelab.eu
+
+ifdef BUILD
+KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
+endif
+
+key: $(NODE).key.rsa
+
+$(NODE).key.rsa:
+ifeq (,$(KEYURL))
+ @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
+ @echo " e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
+ @echo " note that for now all test builds use the same key, so any BUILD would do"
+ @exit 1
+else
+ @echo "FETCHING key"
+ +scp $(KEYURL) $@
+endif