blob: c8b6b76984d461888d253a2c9b6aa178bfeefc1b [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 Williams3670f442016-10-04 17:37:12 -07007# prerequisite software
Zack Williams7021ebd2016-10-28 16:06:44 -07008.PHONY: prereqs
9prereqs: /usr/bin/http /usr/bin/docker /usr/bin/curl /usr/local/bin/docker-compose
Zack Williams3670f442016-10-04 17:37:12 -070010
11apt-prereqs:
12 sudo apt-get update
13 sudo apt-get -y install apt-transport-https ca-certificates python-pip
Zack Williams7021ebd2016-10-28 16:06:44 -070014 touch $@
Zack Williams3670f442016-10-04 17:37:12 -070015
Zack Williams7021ebd2016-10-28 16:06:44 -070016/usr/bin/http: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070017 sudo apt-get -y install httpie
18
Zack Williams7021ebd2016-10-28 16:06:44 -070019/usr/bin/curl: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070020 sudo apt-get -y install curl
21
Zack Williams7021ebd2016-10-28 16:06:44 -070022/usr/bin/docker: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070023 sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Zack Williams7021ebd2016-10-28 16:06:44 -070024 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 -070025 sudo apt-get update
26 sudo apt-get -y install docker-engine
27 sudo usermod -aG docker $(shell whoami)
28
Zack Williams7021ebd2016-10-28 16:06:44 -070029/usr/local/bin/docker-compose: | apt-prereqs
Zack Williams3670f442016-10-04 17:37:12 -070030 sudo pip install docker-compose
31
32
33# configuration
34config_dirs:
35 mkdir -p $(CONFIG_DIR)/key_import
36 mkdir -p $(CONFIG_DIR)/onboarding-docker-compose
37 mkdir -p $(CONFIG_DIR)/images
38
Zack Williams3670f442016-10-04 17:37:12 -070039
40# download/clone xos and service repos
41GITOPTS ?= -c advice.detachedHead=false
42
43xos_download: $(XOS_DIR)
44
45$(XOS_DIR):
46 git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL)
47
48update_xos:
49 git -C $(XOS_DIR) pull
50
51cord_services: $(SERVICE_DIR) \
52 $(SERVICE_DIR)/exampleservice \
53 $(SERVICE_DIR)/fabric \
54 $(SERVICE_DIR)/hypercache \
55 $(SERVICE_DIR)/olt \
56 $(SERVICE_DIR)/onos-service \
57 $(SERVICE_DIR)/openstack \
58 $(SERVICE_DIR)/vrouter \
59 $(SERVICE_DIR)/vsg \
60 $(SERVICE_DIR)/vtn \
61 $(SERVICE_DIR)/vtr \
Rizwan Haider0bab5f42016-11-10 01:21:07 -050062 $(SERVICE_DIR)/metro-net \
63 $(SERVICE_DIR)/metronet-local
64
Zack Williams3670f442016-10-04 17:37:12 -070065
66$(SERVICE_DIR):
67 mkdir -p $(SERVICE_DIR)
68
69$(SERVICE_DIR)/exampleservice:
70 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL)
71
72$(SERVICE_DIR)/olt:
73 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL)
74
75$(SERVICE_DIR)/vsg:
76 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL)
77
78$(SERVICE_DIR)/vtn:
79 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL)
80
81$(SERVICE_DIR)/vrouter:
82 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL)
83
84$(SERVICE_DIR)/vtr:
85 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL)
86
87$(SERVICE_DIR)/onos-service:
88 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL)
89
90$(SERVICE_DIR)/fabric:
91 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL)
92
93$(SERVICE_DIR)/monitoring:
94 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL)
95
96$(SERVICE_DIR)/hypercache:
97 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL)
98
99$(SERVICE_DIR)/metro-net:
100 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL)
101
102$(SERVICE_DIR)/openstack:
103 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL)
104
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500105$(SERVICE_DIR)/metronet-local:
106 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VNODLOCAL_BRANCH) $(VNODLOCAL_GIT_URL)
107
Andy Bavier094e7162016-11-02 17:01:22 -0400108$(SERVICE_DIR)/globalxos:
109 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(GLOBALXOS_BRANCH) $(GLOBALXOS_GIT_URL)
110
Zack Williams3670f442016-10-04 17:37:12 -0700111update_services:
112 git -C $(SERVICE_DIR)/exampleservice pull
113 git -C $(SERVICE_DIR)/olt pull
114 git -C $(SERVICE_DIR)/vsg pull
115 git -C $(SERVICE_DIR)/vtn pull
116 git -C $(SERVICE_DIR)/vrouter pull
117 git -C $(SERVICE_DIR)/vtr pull
118 git -C $(SERVICE_DIR)/onos-service pull
119 git -C $(SERVICE_DIR)/fabric pull
120 git -C $(SERVICE_DIR)/hypercache pull
121 git -C $(SERVICE_DIR)/metro-net pull
122 git -C $(SERVICE_DIR)/openstack pull
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500123 git -C $(SERVICE_DIR)/metronet-local pull
Zack Williams3670f442016-10-04 17:37:12 -0700124
Scott Baker62d24282016-10-21 09:19:11 -0700125cord_libraries: $(LIBRARY_DIR) \
Matteo Scandoloa317b872017-01-10 12:02:41 -0800126 $(LIBRARY_DIR)/ng-xos-lib \
127 $(LIBRARY_DIR)/xos-rest-gw \
128 $(LIBRARY_DIR)/xos-gui
Scott Baker62d24282016-10-21 09:19:11 -0700129
130$(LIBRARY_DIR):
131 mkdir -p $(LIBRARY_DIR)
132
133$(LIBRARY_DIR)/ng-xos-lib:
134 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL)
135
Matteo Scandoloa317b872017-01-10 12:02:41 -0800136$(LIBRARY_DIR)/xos-rest-gw:
137 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_REST_GW_BRANCH) $(XOS_REST_GW_URL)
138
139$(LIBRARY_DIR)/xos-gui:
140 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_GUI_BRANCH) $(XOS_GUI_URL)
141
Zack Williams3670f442016-10-04 17:37:12 -0700142# bootstrap the containers
143
144RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
145RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
146
147bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml
148 @echo "[BOOTSTRAP]"
149 @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`"
150 @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`"
151 @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`"
152 sudo rm -f $(DOCKER_COMPOSE_YML)
Scott Baker91a0d2a2016-12-19 15:08:25 -0800153 sudo docker network inspect xos || sudo docker network create xos
Zack Williams3670f442016-10-04 17:37:12 -0700154 sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
155 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Scott Bakerd0c49fd2016-12-13 11:48:59 -0800156 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
157 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 -0700158 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Zack Williams3670f442016-10-04 17:37:12 -0700159 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml
160
Zack Williams3670f442016-10-04 17:37:12 -0700161# container creation targets
Scott Bakerd25ae9f2016-10-20 15:43:33 -0700162local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c
Zack Williams3670f442016-10-04 17:37:12 -0700163
Zack Williams253fec62016-10-21 14:04:53 -0700164test_containers: local_containers xos_test_c
165
Zack Williams3670f442016-10-04 17:37:12 -0700166update_certs:
167 echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
168 for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
169 echo Adding Certificate: $$CRT ;\
170 cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
171 echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
172 done
173
174xos_base_c:
Scott Baker9f23ac52016-11-04 14:48:09 -0700175 @[ -z "$(HAS_BASE)" ] || echo "skipping base container build"
Zack Williamscf1f9c82016-11-08 22:19:02 -0700176 @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base )
Scott Baker9f23ac52016-11-04 14:48:09 -0700177# cd $(XOS_DIR)/containers/xos; make base
Zack Williams3670f442016-10-04 17:37:12 -0700178
179xos_devel_c:
180 cd $(XOS_DIR)/containers/xos; make devel
181
182xos_test_c:
183 cd $(XOS_DIR)/containers/xos; make test
184
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800185xos_rest_gw_c:
186 # this folder is cloned by repo
Matteo Scandoloa317b872017-01-10 12:02:41 -0800187 cd $(LIBRARY_DIR)/xos-rest-gw; sudo docker build -t xosproject/xos-rest-gw .
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800188
189xos_gui_c:
190 # this folder is cloned by repo
Matteo Scandoloa317b872017-01-10 12:02:41 -0800191 cd $(LIBRARY_DIR)/xos-gui; sudo docker build -t xosproject/xos-gui .
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800192
Zack Williams253fec62016-10-21 14:04:53 -0700193
Zack Williams3670f442016-10-04 17:37:12 -0700194# utilties/convenience targets
Zack Williamsd7d58f12016-10-24 23:11:06 -0700195cleanup: stop rm $(CONFIG_DIR)/cleanup.sh
Zack Williams3670f442016-10-04 17:37:12 -0700196 $(CONFIG_DIR)/cleanup.sh
Zack Williamsd7d58f12016-10-24 23:11:06 -0700197 bash -c "source $(CONFIG_DIR)/admin-openrc.sh; nova list --all-tenants; neutron net-list"
Zack Williams3670f442016-10-04 17:37:12 -0700198
199cleanup_services: $(SERVICE_DIR)
200 rm -rf $(SERVICE_DIR)/*
201
202rebuild:
203 bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT)
204 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
205
206stop:
207 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
208 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
209
210rm: stop
211 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
212 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
213 [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true
214
215ps:
216 sudo docker ps
217
218showlogs_bootstrap:
219 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f
220
221showlogs:
222 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f
223
224enter-ui:
225 sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash
226
227enter-bootstrap-ui:
228 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash
229
230enter-db:
231 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash
232
233django-restart:
234 sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
235
Matteo Scandoloa317b872017-01-10 12:02:41 -0800236rest-gw: xos_rest_gw_c
237 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
238 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/xos-rest-gw.yaml
239 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
240 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
241 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
242
243ui: xos_gui_c
244 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
245 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos-gui.yaml
246 $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
247 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
248 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
249