CORD-1401 Make targets for CiaB

Change-Id: I2a59ed684b37854a98cf6e2f30ac90200703585c
diff --git a/Makefile b/Makefile
index c408ccd..2695f39 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,13 @@
 M                ?= $(BUILD)/milestones
 LOGS             ?= $(BUILD)/logs
 
-ALL_MILESTONES   ?= $(M)/prereqs-check $(M)/vagrant-up $(M)/copy-cord $(M)/cord-config $(M)/copy-config $(M)/prep-buildnode $(M)/prep-headnode $(M)/deploy-elasticstack $(M)/prep-computenode $(M)/glance-images $(M)/deploy-openstack $(M)/deploy-maas $(M)/deploy-computenode $(M)/docker-images $(M)/core-image $(M)/start-xos $(M)/onboard-profile $(M)/deploy-onos $(M)/onboard-openstack
+PREP_MS          ?= $(M)/prereqs-check $(M)/vagrant-up $(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
+ONOS_MS          ?= $(M)/build-onos-apps $(M)/publish-onos-apps $(M)/deploy-onos $(M)/deploy-mavenrepo
+POST_INSTALL_MS  ?= $(M)/setup-automation $(M)/setup-ciab-pcu $(M)/vagrant-up-switches $(M)/compute1-up $(M)/compute2-up $(M)/compute3-up
+ALL_MILESTONES   ?= $(PREP_MS) $(MAAS_MS) $(OPENSTACK_MS) $(XOS_MS) $(ONOS_MS) $(POST_INSTALL_MS)
 
 LOCAL_MILESTONES ?= $(M)/local-cord-config $(M)/local-docker-images $(M)/local-core-image $(M)/local-start-xos $(M)/local-onboard-profile
 
@@ -50,6 +56,7 @@
 # Vagrant config
 VAGRANT_PROVIDER ?= libvirt
 VAGRANT_VMS      ?= $(HEADNODE)
+VAGRANT_SWITCHES ?= leaf1
 VAGRANT_CWD      ?= $(SCENARIOS_D)/$(SCENARIO)/
 SSH_CONFIG       ?= ~/.ssh/config  # Vagrant modifies this, should it always?
 
@@ -116,7 +123,7 @@
 	rm -f $(M)/vagrant-up
 
 clean-images:
-	rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image
+	rm -f $(M)/docker-images $(M)/local-docker-images $(M)/core-image $(M)/local-core-image $(M)/build-maas-images $(M)/build-onos-apps
 
 clean-genconfig:
 	rm -f $(CONFIG_FILES)
@@ -134,6 +141,7 @@
 local-ubuntu-dev-env:
 	$(ANSIBLE_PB) $(PI)/bootstrap-dev-env.yml $(LOGCMD)
 
+
 # == PREREQS == #
 VAGRANT_UP_PREREQS     ?=
 CORD_CONFIG_PREREQS    ?=
@@ -143,10 +151,13 @@
 DOCKER_IMAGES_PREREQS  ?=
 START_XOS_PREREQS      ?=
 DEPLOY_ONOS_PREREQS    ?=
+DEPLOY_OPENSTACK_PREREQS ?=
+SETUP_AUTOMATION_PREREQS ?=
 
 # == MILESTONES == #
 # empty target files are touched in the milestones dir to indicate completion
 
+# Prep targets
 $(M)/prereqs-check:
 	$(ANSIBLE_PB) $(PI)/prereqs-check-playbook.yml $(LOGCMD)
 	touch $@
@@ -188,41 +199,77 @@
 	$(ANSIBLE_PB) $(PI)/prep-computenode-playbook.yml $(LOGCMD)
 	touch $@
 
-$(M)/glance-images: | $(M)/prep-headnode
-	$(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD)
+
+# MaaS targets
+$(M)/build-maas-images: | $(M)/prep-buildnode $(BUILD_MAAS_IMAGES_PREREQS)
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build/maas; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) build" $(LOGCMD)
 	touch $@
 
-$(M)/deploy-openstack: | $(M)/deploy-elasticstack $(M)/prep-headnode $(M)/prep-computenode
-	$(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD)
+$(M)/maas-prime: | $(M)/deploy-elasticstack
+	$(ANSIBLE_PB) $(MAAS)/prime-node.yml $(LOGCMD)
 	touch $@
 
-$(M)/deploy-maas: | $(M)/deploy-openstack
-	$(ANSIBLE_PB) $(MAAS)/head.yml $(LOGCMD)
+$(M)/publish-maas-images: | $(M)/maas-prime $(M)/build-maas-images
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build/maas; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) publish" $(LOGCMD)
 	touch $@
 
-$(M)/deploy-computenode: | $(M)/deploy-openstack
-	$(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
+$(M)/deploy-maas: | $(M)/publish-maas-images $(M)/cord-config $(M)/copy-config
+	$(ANSIBLE_PB) $(MAAS)/head-node.yml $(LOGCMD)
 	touch $@
 
+
+# ONOS targets
+$(M)/build-onos-apps: | $(M)/prep-buildnode $(BUILD_ONOS_APPS_PREREQS)
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/onos-apps; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) build" $(LOGCMD)
+	touch $@
+
+$(M)/publish-onos-apps: | $(M)/maas-prime $(M)/build-onos-apps
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/onos-apps; make MAKE_CONFIG=../$(MAKEFILE_CONFIG) publish" $(LOGCMD)
+	touch $@
+
+$(M)/deploy-mavenrepo: | $(M)/publish-onos-apps
+	$(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD)
+	touch $@
+
+$(M)/deploy-onos: | $(M)/docker-images $(DEPLOY_ONOS_PREREQS)
+	$(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
+	touch $@
+
+
+# XOS targets
 $(M)/docker-images: | $(M)/prep-buildnode $(DOCKER_IMAGES_PREREQS)
-	$(SSH_BUILD) "cd /opt/cord/build; $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml " $(LOGCMD)
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build; $(IMAGEBUILDER) -f $(MASTER_CONFIG) -l $(BUILD)/image_logs -g $(BUILD)/ib_graph.dot -a $(BUILD)/ib_actions.yml " $(LOGCMD)
 	touch $@
 
-$(M)/core-image: | $(M)/docker-images $(M)/prep-headnode
+$(M)/core-image: | $(M)/docker-images
 	$(ANSIBLE_PB) $(PI)/build-core-image-playbook.yml $(LOGCMD)
 	touch $@
 
+# Requires ib_actions.yml file which is on the build host
+$(M)/publish-docker-images: | $(M)/maas-prime $(M)/docker-images $(M)/core-image
+	$(SSH_BUILD) "cd $(BUILD_CORD_DIR)/build; $(ANSIBLE_PB_LOCAL) $(PI)/publish-images-playbook.yml" $(LOGCMD)
+	touch $@
+
 $(M)/start-xos: | $(M)/prep-headnode $(M)/core-image $(START_XOS_PREREQS)
 	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/start-xos-playbook.yml" $(LOGCMD)
 	touch $@
 
-$(M)/build-onos-apps: | $(M)/prep-buildnode
-	$(SSH_BUILD) "cd /opt/cord/onos-apps; make images" $(LOGCMD)
+$(M)/onboard-profile: | $(M)/start-xos
+	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-profile-playbook.yml" $(LOGCMD)
 	touch $@
 
-$(M)/deploy-onos: | $(M)/prep-headnode $(M)/docker-images $(M)/build-onos-apps $(DEPLOY_ONOS_PREREQS)
-	$(ANSIBLE_PB) $(PI)/deploy-mavenrepo-playbook.yml $(LOGCMD)
-	$(ANSIBLE_PB) $(PI)/deploy-onos-playbook.yml $(LOGCMD)
+
+# OpenStack targets
+$(M)/glance-images: | $(M)/prep-headnode
+	$(ANSIBLE_PB) $(PI)/glance-images-playbook.yml $(LOGCMD)
+	touch $@
+
+$(M)/deploy-openstack: | $(M)/deploy-elasticstack $(M)/prep-headnode $(M)/prep-computenode $(DEPLOY_OPENSTACK_PREREQS)
+	$(ANSIBLE_PB) $(PI)/deploy-openstack-playbook.yml $(LOGCMD)
+	touch $@
+
+$(M)/deploy-computenode: | $(M)/deploy-openstack
+	$(ANSIBLE_PB) $(PI)/deploy-computenode-playbook.yml $(LOGCMD)
 	touch $@
 
 $(M)/onboard-profile: | $(M)/start-xos $(M)/deploy-onos
@@ -237,12 +284,34 @@
 	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/onboard-openstack-playbook.yml" $(LOGCMD)
 	touch $@
 
+
+# Post-onboarding targets
+$(M)/setup-automation: | $(M)/onboard-profile $(M)/deploy-onos $(SETUP_AUTOMATION_PREREQS)
+	$(ANSIBLE_PB) $(PI)/cord-automation-playbook.yml $(LOGCMD)
+	touch $@
+
+
+# Additional CiaB targets
+$(M)/vagrant-up-switches: | $(M)/setup-automation
+	$(VAGRANT) up $(VAGRANT_SWITCHES) --provider $(VAGRANT_PROVIDER) $(LOGCMD)
+	touch $@
+
+$(M)/setup-ciab-pcu: | $(M)/setup-automation
+	$(ANSIBLE_PB) $(MAAS)/setup-ciab-pcu.yml
+	touch $@
+
+$(M)/compute%-up: | $(M)/setup-ciab-pcu $(M)/vagrant-up-switches
+	$(VAGRANT) up compute$* --provider $(VAGRANT_PROVIDER) $(LOGCMD)
+	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) ansible/maas-provision.yml --extra-vars='maas_user=maas vagrant_name=cord_compute$*'" $(LOGCMD)
+	touch $@
+
+
 # Testing targets
-pod-test: $(M)/onboard-openstack collect-diag
-	$(ANSIBLE_PB) $(PI)/pod-test-playbook.yml $(LOGCMD)
+pod-test: $(M)/setup-automation collect-diag
+	$(SSH_HEAD) "cd /opt/cord/build; $(ANSIBLE_PB_LOCAL) $(PI)/pod-test-playbook.yml" $(LOGCMD)
+
 
 # Local Targets, bring up XOS containers without a VM
-
 $(M)/local-cord-config:
 	$(ANSIBLE_PB) $(PI)/cord-config-playbook.yml $(LOGCMD)
 	touch $@