blob: 0c39093bdaff548539bd55321a63375ce5f1197a [file] [log] [blame]
Zack Williams7828f222016-10-19 14:04:51 -07001# common/Makefile
2
Zack Williams3670f442016-10-04 17:37:12 -07003include $(COMMON_DIR)/Makedefs
4
Scott Baker9f23ac52016-11-04 14:48:09 -07005HAS_BASE=$(shell docker images | grep xos-base )
6
Zack Williamsd0fde1a2017-02-10 09:12:49 -07007deprecation_warning:
8 cat ../README.md
9 sleep 300
10
Zack Williams3670f442016-10-04 17:37:12 -070011# prerequisite software
Zack Williams7021ebd2016-10-28 16:06:44 -070012.PHONY: prereqs
Zack Williamsd0fde1a2017-02-10 09:12:49 -070013prereqs: deprecation_warning /usr/local/bin/http /usr/bin/docker /usr/bin/curl /usr/local/bin/docker-compose
Zack Williams3670f442016-10-04 17:37:12 -070014
Zack Williamsd0fde1a2017-02-10 09:12:49 -070015apt-prereqs: deprecation_warning
Zack Williams3670f442016-10-04 17:37:12 -070016 sudo apt-get update
17 sudo apt-get -y install apt-transport-https ca-certificates python-pip
Zack Williams7021ebd2016-10-28 16:06:44 -070018 touch $@
Zack Williams3670f442016-10-04 17:37:12 -070019
Andy Bavierde59c0a2017-01-26 07:34:08 -050020/usr/local/bin/http: | apt-prereqs
21 sudo pip install httpie
Zack Williams3670f442016-10-04 17:37:12 -070022
Zack Williams7021ebd2016-10-28 16:06:44 -070023/usr/bin/curl: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070024 sudo apt-get -y install curl
25
Zack Williams7021ebd2016-10-28 16:06:44 -070026/usr/bin/docker: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070027 sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Zack Williams7021ebd2016-10-28 16:06:44 -070028 echo "deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $$2}'` main" | sudo tee /etc/apt/sources.list.d/docker.list
Zack Williams3670f442016-10-04 17:37:12 -070029 sudo apt-get update
30 sudo apt-get -y install docker-engine
31 sudo usermod -aG docker $(shell whoami)
32
Zack Williams7021ebd2016-10-28 16:06:44 -070033/usr/local/bin/docker-compose: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070034 sudo pip install docker-compose
35
36
37# configuration
38config_dirs:
39 mkdir -p $(CONFIG_DIR)/key_import
40 mkdir -p $(CONFIG_DIR)/onboarding-docker-compose
41 mkdir -p $(CONFIG_DIR)/images
42
Zack Williams3670f442016-10-04 17:37:12 -070043
44# download/clone xos and service repos
45GITOPTS ?= -c advice.detachedHead=false
46
47xos_download: $(XOS_DIR)
48
49$(XOS_DIR):
50 git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL)
51
52update_xos:
53 git -C $(XOS_DIR) pull
54
55cord_services: $(SERVICE_DIR) \
56 $(SERVICE_DIR)/exampleservice \
57 $(SERVICE_DIR)/fabric \
58 $(SERVICE_DIR)/hypercache \
59 $(SERVICE_DIR)/olt \
60 $(SERVICE_DIR)/onos-service \
61 $(SERVICE_DIR)/openstack \
62 $(SERVICE_DIR)/vrouter \
63 $(SERVICE_DIR)/vsg \
64 $(SERVICE_DIR)/vtn \
65 $(SERVICE_DIR)/vtr \
Rizwan Haider0bab5f42016-11-10 01:21:07 -050066 $(SERVICE_DIR)/metro-net \
67 $(SERVICE_DIR)/metronet-local
68
Zack Williams3670f442016-10-04 17:37:12 -070069
70$(SERVICE_DIR):
71 mkdir -p $(SERVICE_DIR)
72
73$(SERVICE_DIR)/exampleservice:
74 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL)
75
76$(SERVICE_DIR)/olt:
77 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL)
78
79$(SERVICE_DIR)/vsg:
80 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL)
81
82$(SERVICE_DIR)/vtn:
83 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL)
84
85$(SERVICE_DIR)/vrouter:
86 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL)
87
88$(SERVICE_DIR)/vtr:
89 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL)
90
91$(SERVICE_DIR)/onos-service:
92 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL)
93
94$(SERVICE_DIR)/fabric:
95 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL)
96
97$(SERVICE_DIR)/monitoring:
98 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL)
99
100$(SERVICE_DIR)/hypercache:
101 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL)
102
103$(SERVICE_DIR)/metro-net:
104 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL)
105
106$(SERVICE_DIR)/openstack:
107 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL)
108
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500109$(SERVICE_DIR)/metronet-local:
110 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VNODLOCAL_BRANCH) $(VNODLOCAL_GIT_URL)
111
Andy Bavier094e7162016-11-02 17:01:22 -0400112$(SERVICE_DIR)/globalxos:
113 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(GLOBALXOS_BRANCH) $(GLOBALXOS_GIT_URL)
114
Zack Williams3670f442016-10-04 17:37:12 -0700115update_services:
116 git -C $(SERVICE_DIR)/exampleservice pull
117 git -C $(SERVICE_DIR)/olt pull
118 git -C $(SERVICE_DIR)/vsg pull
119 git -C $(SERVICE_DIR)/vtn pull
120 git -C $(SERVICE_DIR)/vrouter pull
121 git -C $(SERVICE_DIR)/vtr pull
122 git -C $(SERVICE_DIR)/onos-service pull
123 git -C $(SERVICE_DIR)/fabric pull
124 git -C $(SERVICE_DIR)/hypercache pull
125 git -C $(SERVICE_DIR)/metro-net pull
126 git -C $(SERVICE_DIR)/openstack pull
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500127 git -C $(SERVICE_DIR)/metronet-local pull
Zack Williams3670f442016-10-04 17:37:12 -0700128
Scott Baker62d24282016-10-21 09:19:11 -0700129cord_libraries: $(LIBRARY_DIR) \
Matteo Scandoloa317b872017-01-10 12:02:41 -0800130 $(LIBRARY_DIR)/ng-xos-lib \
131 $(LIBRARY_DIR)/xos-rest-gw \
132 $(LIBRARY_DIR)/xos-gui
Scott Baker62d24282016-10-21 09:19:11 -0700133
134$(LIBRARY_DIR):
135 mkdir -p $(LIBRARY_DIR)
136
137$(LIBRARY_DIR)/ng-xos-lib:
138 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL)
139
Matteo Scandoloa317b872017-01-10 12:02:41 -0800140$(LIBRARY_DIR)/xos-rest-gw:
141 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_REST_GW_BRANCH) $(XOS_REST_GW_URL)
142
143$(LIBRARY_DIR)/xos-gui:
144 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_GUI_BRANCH) $(XOS_GUI_URL)
145
Zack Williams3670f442016-10-04 17:37:12 -0700146# bootstrap the containers
147
148RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
149RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
150
151bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml
152 @echo "[BOOTSTRAP]"
153 @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`"
154 @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`"
155 @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`"
156 sudo rm -f $(DOCKER_COMPOSE_YML)
Scott Baker91a0d2a2016-12-19 15:08:25 -0800157 sudo docker network inspect xos || sudo docker network create xos
Zack Williams3670f442016-10-04 17:37:12 -0700158 sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
159 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Scott Bakerd0c49fd2016-12-13 11:48:59 -0800160 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none /opt/xos/bootstrap_tosca/fixtures.yaml
161 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none /opt/xos/bootstrap_tosca/deployment.yaml
Zack Williamscf1f9c82016-11-08 22:19:02 -0700162 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Zack Williams3670f442016-10-04 17:37:12 -0700163 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml
164
Zack Williams3670f442016-10-04 17:37:12 -0700165# container creation targets
Scott Bakerd25ae9f2016-10-20 15:43:33 -0700166local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c
Zack Williams3670f442016-10-04 17:37:12 -0700167
Zack Williams253fec62016-10-21 14:04:53 -0700168test_containers: local_containers xos_test_c
169
Zack Williams3670f442016-10-04 17:37:12 -0700170update_certs:
171 echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
172 for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
173 echo Adding Certificate: $$CRT ;\
174 cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
175 echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
176 done
177
178xos_base_c:
Scott Baker9f23ac52016-11-04 14:48:09 -0700179 @[ -z "$(HAS_BASE)" ] || echo "skipping base container build"
Zack Williamscf1f9c82016-11-08 22:19:02 -0700180 @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base )
Scott Baker9f23ac52016-11-04 14:48:09 -0700181# cd $(XOS_DIR)/containers/xos; make base
Zack Williams3670f442016-10-04 17:37:12 -0700182
183xos_devel_c:
184 cd $(XOS_DIR)/containers/xos; make devel
185
186xos_test_c:
187 cd $(XOS_DIR)/containers/xos; make test
188
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800189xos_rest_gw_c:
190 # this folder is cloned by repo
Matteo Scandolo2dad22d2017-01-12 15:43:44 -0800191 cd $(LIBRARY_DIR)/xos-rest-gw; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-rest-gw .
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800192
193xos_gui_c:
194 # this folder is cloned by repo
Matteo Scandolo2dad22d2017-01-12 15:43:44 -0800195 cd $(LIBRARY_DIR)/xos-gui; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-gui .
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800196
Zack Williams253fec62016-10-21 14:04:53 -0700197
Zack Williams3670f442016-10-04 17:37:12 -0700198# utilties/convenience targets
Zack Williamsd7d58f12016-10-24 23:11:06 -0700199cleanup: stop rm $(CONFIG_DIR)/cleanup.sh
Zack Williams3670f442016-10-04 17:37:12 -0700200 $(CONFIG_DIR)/cleanup.sh
Zack Williamsd7d58f12016-10-24 23:11:06 -0700201 bash -c "source $(CONFIG_DIR)/admin-openrc.sh; nova list --all-tenants; neutron net-list"
Zack Williams3670f442016-10-04 17:37:12 -0700202
203cleanup_services: $(SERVICE_DIR)
204 rm -rf $(SERVICE_DIR)/*
205
206rebuild:
207 bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT)
208 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
209
210stop:
211 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
212 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
213
214rm: stop
215 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
216 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
217 [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true
218
219ps:
220 sudo docker ps
221
222showlogs_bootstrap:
223 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f
224
225showlogs:
226 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f
227
228enter-ui:
229 sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash
230
231enter-bootstrap-ui:
232 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash
233
234enter-db:
235 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash
236
237django-restart:
238 sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
239
Matteo Scandoloa317b872017-01-10 12:02:41 -0800240rest-gw: xos_rest_gw_c
241 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
Matteo Scandolo82d64ac2017-01-13 09:49:35 -0800242 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos-rest-gw.yaml
Matteo Scandoloa317b872017-01-10 12:02:41 -0800243 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
244 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
245 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
246
Matteo Scandolo13aab532017-01-13 14:46:04 -0800247ui: xos_gui_c rest-gw
Matteo Scandoloa317b872017-01-10 12:02:41 -0800248 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
249 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos-gui.yaml
250 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
251 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
252 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
253
Matteo Scandolobb11ab52017-02-02 12:10:49 -0800254xos_gui_sample_extension_c:
255 # this folder is cloned by repo
256 cd $(HOME_DIR)/xos-sample-gui-extension; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-sample-gui-extension .
257
258ui-sample-extension: xos_gui_sample_extension_c
259 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
260 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/xos-gui-extension.yaml
261 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
262 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
263 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
264