MYFLATLANIF:=$(shell netstat -i |grep "flat"|awk '{print $$1}' )
MYFLATLANIP:=$(shell ifconfig $(MYFLATLANIF) | grep "inet addr" | awk -F: '{print $$2}' | awk '{print $$1}' )

all: prereqs admin-openrc flat_name nodes_yaml public_key private_key ceilometer_url node_key

prereqs:
	make -f Makefile.prereqs

admin-openrc:
	sudo cat /root/setup/admin-openrc.sh > admin-openrc.sh
	sudo cat /root/setup/settings > controller_settings
	echo 'CONTROLLER_FLAT_LAN_IP=$(MYFLATLANIP)' >> controller_settings

flat_name:
	sudo bash -c "source /root/setup/admin-openrc.sh ; neutron net-list" |grep flat|awk '{printf "%s",$$4}' > flat_net_name

nodes_yaml:
	bash ./make-cloudlab-nodes-yaml.sh

ceilometer_url:
	echo http://`hostname -i`/xosmetering/ > ceilometer_url

public_key: ~/.ssh/id_rsa.pub
	cp ~/.ssh/id_rsa.pub .

private_key: ~/.ssh/id_rsa
	cp ~/.ssh/id_rsa .

~/.ssh/id_rsa.pub:
	cat /dev/zero | ssh-keygen -q -N ""

node_key:
	sudo cat /root/setup/id_rsa > node_key
	sudo cat /root/setup/id_rsa.pub > node_key.pub
