blob: 58dcb0c565a2f7232d7ed2b9afc1199452cb7693 [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) \
126 $(LIBRARY_DIR)/ng-xos-lib
127
128$(LIBRARY_DIR):
129 mkdir -p $(LIBRARY_DIR)
130
131$(LIBRARY_DIR)/ng-xos-lib:
132 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL)
133
Zack Williams3670f442016-10-04 17:37:12 -0700134# bootstrap the containers
135
136RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
137RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
138
139bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml
140 @echo "[BOOTSTRAP]"
141 @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`"
142 @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`"
143 @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`"
144 sudo rm -f $(DOCKER_COMPOSE_YML)
Zack Williamsb74c9142016-12-14 17:07:12 -0700145 sudo docker network create xos
Zack Williams3670f442016-10-04 17:37:12 -0700146 sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d
147 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Scott Bakerd0c49fd2016-12-13 11:48:59 -0800148 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
149 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 -0700150 bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT)
Zack Williams3670f442016-10-04 17:37:12 -0700151 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml
152
Zack Williams3670f442016-10-04 17:37:12 -0700153# container creation targets
Scott Bakerd25ae9f2016-10-20 15:43:33 -0700154local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c
Zack Williams3670f442016-10-04 17:37:12 -0700155
Zack Williams253fec62016-10-21 14:04:53 -0700156test_containers: local_containers xos_test_c
157
Zack Williams3670f442016-10-04 17:37:12 -0700158update_certs:
159 echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
160 for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
161 echo Adding Certificate: $$CRT ;\
162 cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
163 echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
164 done
165
166xos_base_c:
Scott Baker9f23ac52016-11-04 14:48:09 -0700167 @[ -z "$(HAS_BASE)" ] || echo "skipping base container build"
Zack Williamscf1f9c82016-11-08 22:19:02 -0700168 @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base )
Scott Baker9f23ac52016-11-04 14:48:09 -0700169# cd $(XOS_DIR)/containers/xos; make base
Zack Williams3670f442016-10-04 17:37:12 -0700170
171xos_devel_c:
172 cd $(XOS_DIR)/containers/xos; make devel
173
174xos_test_c:
175 cd $(XOS_DIR)/containers/xos; make test
176
Matteo Scandolo76d7bcd2016-11-30 17:08:17 -0800177xos_rest_gw_c:
178 # this folder is cloned by repo
179 cd $(REST_GW_DIR); docker build -t xosproject/xos-rest-gw .
180
181xos_gui_c:
182 # this folder is cloned by repo
183 cd $(GUI_DIR); docker build -t xosproject/xos-gui .
184
Zack Williams253fec62016-10-21 14:04:53 -0700185
Zack Williams3670f442016-10-04 17:37:12 -0700186# utilties/convenience targets
Zack Williamsd7d58f12016-10-24 23:11:06 -0700187cleanup: stop rm $(CONFIG_DIR)/cleanup.sh
Zack Williams3670f442016-10-04 17:37:12 -0700188 $(CONFIG_DIR)/cleanup.sh
Zack Williamsd7d58f12016-10-24 23:11:06 -0700189 bash -c "source $(CONFIG_DIR)/admin-openrc.sh; nova list --all-tenants; neutron net-list"
Zack Williams3670f442016-10-04 17:37:12 -0700190
191cleanup_services: $(SERVICE_DIR)
192 rm -rf $(SERVICE_DIR)/*
193
194rebuild:
195 bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT)
196 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
197
198stop:
199 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
200 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
201
202rm: stop
203 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
204 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
205 [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true
206
207ps:
208 sudo docker ps
209
210showlogs_bootstrap:
211 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f
212
213showlogs:
214 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f
215
216enter-ui:
217 sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash
218
219enter-bootstrap-ui:
220 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash
221
222enter-db:
223 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash
224
225django-restart:
226 sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
227