[CORD-1811]
Create a separate Vagrant SSH config file, check if it's included in
~/.ssh/config, rather than overwriting.

Add clean-openstack target

Change-Id: Ifcaf78c40ccb77ad2231cb2013cfdf540ffba365
(cherry picked from commit 32295d5534f170180b1febbd1158167c53598273)
diff --git a/Makefile b/Makefile
index f20bd84..fe2775e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@
 M                ?= $(BUILD)/milestones
 LOGS             ?= $(BUILD)/logs
 
-PREP_MS          ?= $(M)/prereqs-check $(M)/build-local-bootstrap $(M)/ciab-ovs $(M)/vagrant-up $(M)/copy-cord $(M)/cord-config $(M)/copy-config $(M)/prep-buildnode $(M)/prep-headnode $(M)/deploy-elasticstack $(M)/prep-computenode
+PREP_MS          ?= $(M)/prereqs-check $(M)/build-local-bootstrap $(M)/ciab-ovs $(M)/vagrant-up $(M)/vagrant-ssh-install $(M)/copy-cord $(M)/cord-config $(M)/copy-config $(M)/prep-buildnode $(M)/prep-headnode $(M)/deploy-elasticstack $(M)/prep-computenode
 MAAS_MS          ?= $(M)/build-maas-images $(M)/maas-prime $(M)/publish-maas-images $(M)/deploy-maas
 OPENSTACK_MS     ?= $(M)/glance-images $(M)/deploy-openstack  $(M)/deploy-computenode $(M)/onboard-openstack
 XOS_MS           ?= $(M)/docker-images $(M)/core-image $(M)/publish-docker-images $(M)/start-xos $(M)/onboard-profile
@@ -58,7 +58,7 @@
 VAGRANT_VMS      ?= $(HEADNODE)
 VAGRANT_SWITCHES ?= leaf1
 VAGRANT_CWD      ?= $(SCENARIOS_D)/$(SCENARIO)/
-SSH_CONFIG       ?= ~/.ssh/config  # Vagrant modifies this, should it always?
+VAGRANT_SSH_CONF ?= $(GENCONFIG_D)/vagrant.ssh_config
 
 # Virsh config
 VIRSH_CORDDEV_DOMAIN ?= cord_corddev
@@ -82,39 +82,33 @@
 .DEFAULT: help
 
 help:
-	@echo "Please specify a target (config, build, teardown, ...)"
+	@echo "Please specify a target (config, build, ...)"
 
 # Config file generation
 config: $(CONFIG_FILES)
+	@echo ""
+	@echo "CORD is configured with profile: '$(PROFILE)', scenario: '$(SCENARIO)'"
+	@echo "Run 'make -j4 build' to continue."
 
 $(CONFIG_FILES):
 	test -e "$(PODCONFIG_PATH)" || { echo "PODCONFIG file $(PODCONFIG_PATH) doesn't exist!" ; exit 1; }
 	ansible-playbook -i 'localhost,' --extra-vars="cord_podconfig='$(PODCONFIG_PATH)' genconfig_dir='$(GENCONFIG_D)' scenarios_dir='$(SCENARIOS_D)'" $(BUILD)/ansible/genconfig.yml $(LOGCMD)
 
 printconfig:
-	@echo "Scenario: $(SCENARIO)"
-	@echo "Profile: $(PROFILE)"
+	@echo "Scenario: '$(SCENARIO)'"
+	@echo "Profile: '$(PROFILE)'"
 
 # Primary Targets
-# Many of these targets use target-specific variables
-# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
-
 build: $(BUILD_TARGETS)
 
-# Utility targets
 
+# Utility targets
 ansible-ping:
 	$(ANSIBLE) -m ping all $(LOGCMD)
 
 ansible-setup:
 	$(ANSIBLE) -m setup all $(LOGCMD)
 
-collect-diag:
-	$(ANSIBLE_PB) $(PI)/collect-diag-playbook.yml $(LOGCMD)
-
-compute-node-refresh:
-	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) --private-key ~/.ssh/cord_rsa $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD)
-
 clean-images:
 	rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image $(M)/build-maas-images $(M)/build-onos-apps $(M)/publish-maas-images $(M)/publish-docker-images $(M)/publish-onos-apps
 
@@ -131,6 +125,20 @@
 clean-local: clean-profile clean-genconfig
 	rm -f $(LOCAL_MILESTONES)
 
+clean-onos:
+	$(ANSIBLE_PB) $(PI)/teardown-onos.yml $(LOGCMD)
+	rm -f $(M)/deploy-onos $(M)/onos-debug
+
+clean-openstack:
+	$(SSH_HEAD) "/opt/cord/build/platform-install/scripts/clean_openstack.sh" $(LOGCMD)
+	rm -f $(M)/onboard-openstack
+
+collect-diag:
+	$(ANSIBLE_PB) $(PI)/collect-diag-playbook.yml $(LOGCMD)
+
+compute-node-refresh:
+	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) --private-key ~/.ssh/cord_rsa $(PI)/compute-node-refresh-playbook.yml" $(LOGCMD)
+
 .PHONY: docs
 docs:
 	cd docs; make
@@ -140,7 +148,7 @@
 
 vagrant-destroy:
 	$(VAGRANT) destroy -f $(LOGCMD)
-	rm -f $(M)/vagrant-up
+	rm -f $(M)/vagrant-up $(M)/vagrant-ssh-install $(VAGRANT_SSH_CONF)
 
 virsh-domain-destroy:
 	virsh destroy ${VIRSH_CORDDEV_DOMAIN} || true
@@ -186,19 +194,22 @@
 
 $(M)/vagrant-up: | $(VAGRANT_UP_PREREQS)
 	$(VAGRANT) up $(VAGRANT_VMS) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
-	@echo "Configuring SSH for VM's..."
-	$(VAGRANT) ssh-config $(VAGRANT_VMS) > $(SSH_CONFIG)
+	touch $@
+
+$(M)/vagrant-ssh-install: | $(M)/vagrant-up
+	$(VAGRANT) ssh-config $(VAGRANT_VMS) > $(VAGRANT_SSH_CONF) $(LOGCMD)
+	$(BUILD)/scripts/vagrant-ssh-install.sh "$(VAGRANT_SSH_CONF)" "Include $(abspath $(GENCONFIG_D))/*.ssh_config" $(LOGCMD)
 	touch $@
 
 $(M)/config-ssh-key: | $(M)/vagrant-up
 	$(ANSIBLE_PB) $(BUILD)/ansible/config-ssh-key.yml $(LOGCMD)
 	touch $@
 
-$(M)/copy-cord: | $(M)/vagrant-up $(COPY_CORD_PREREQS)
+$(M)/copy-cord: | $(M)/vagrant-ssh-install $(COPY_CORD_PREREQS)
 	$(ANSIBLE_PB) $(PI)/copy-cord-playbook.yml $(LOGCMD)
 	touch $@
 
-$(M)/cord-config: | $(M)/vagrant-up $(CORD_CONFIG_PREREQS)
+$(M)/cord-config: | $(M)/vagrant-ssh-install $(CORD_CONFIG_PREREQS)
 	$(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
 	cp -r $(GENCONFIG_D) $(CONFIG_CORD_PROFILE_DIR)/genconfig
 	touch $@
@@ -207,13 +218,13 @@
 	$(ANSIBLE_PB) $(PI)/copy-profile-playbook.yml $(LOGCMD)
 	touch $@
 
-$(M)/prep-buildnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_BUILDNODE_PREREQS)
+$(M)/prep-buildnode: | $(M)/vagrant-ssh-install $(M)/cord-config $(PREP_BUILDNODE_PREREQS)
 	$(ANSIBLE_PB) $(PI)/prep-buildnode-playbook.yml $(LOGCMD)
 	@echo Waiting 20 seconds to timeout SSH ControlPersist, and so future ansible commands gain docker group membership
 	sleep 20
 	touch $@
 
-$(M)/prep-headnode: | $(M)/vagrant-up $(M)/cord-config $(PREP_HEADNODE_PREREQS)
+$(M)/prep-headnode: | $(M)/vagrant-ssh-install $(M)/cord-config $(PREP_HEADNODE_PREREQS)
 	$(ANSIBLE_PB) $(PI)/prep-headnode-playbook.yml $(LOGCMD)
 	touch $@
 
@@ -261,6 +272,10 @@
 	$(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
 	touch $@
 
+$(M)/onos-debug: | $(M)/onboard-profile
+	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onos-debug-playbook.yml" $(LOGCMD)
+	touch $@
+
 
 # XOS targets
 $(M)/docker-images: | $(M)/prep-buildnode $(DOCKER_IMAGES_PREREQS)
@@ -298,10 +313,6 @@
 	$(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
 	touch $@
 
-$(M)/onos-debug: | $(M)/onboard-profile
-	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onos-debug-playbook.yml" $(LOGCMD)
-	touch $@
-
 $(M)/onboard-openstack: | $(M)/deploy-computenode $(M)/glance-images $(M)/deploy-onos $(M)/onboard-profile
 	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD)
 	touch $@
@@ -335,6 +346,7 @@
 fabric-pingtest: $(M)/refresh-fabric
 	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_MAAS) $(PI)/cord-fabric-pingtest.yml" $(LOGCMD)
 
+
 # Local Targets, bring up XOS containers without a VM
 $(M)/local-cord-config:
 	$(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)