blob: 9f410d4a70c2713b909b812c62ad8ec4c6a61aeb [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
39nodes.yaml:
40 export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-nodes-yaml.sh
41
42clean_nodes:
43 rm -f $(CONFIG_DIR)/nodes.yaml
44
45images.yaml:
46 export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-images-yaml.sh
47
48
49# download/clone xos and service repos
50GITOPTS ?= -c advice.detachedHead=false
51
52xos_download: $(XOS_DIR)
53
54$(XOS_DIR):
55 git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL)
56
57update_xos:
58 git -C $(XOS_DIR) pull
59
60cord_services: $(SERVICE_DIR) \
61 $(SERVICE_DIR)/exampleservice \
62 $(SERVICE_DIR)/fabric \
63 $(SERVICE_DIR)/hypercache \
64 $(SERVICE_DIR)/olt \
65 $(SERVICE_DIR)/onos-service \
66 $(SERVICE_DIR)/openstack \
67 $(SERVICE_DIR)/vrouter \
68 $(SERVICE_DIR)/vsg \
69 $(SERVICE_DIR)/vtn \
70 $(SERVICE_DIR)/vtr \
Rizwan Haider0bab5f42016-11-10 01:21:07 -050071 $(SERVICE_DIR)/metro-net \
72 $(SERVICE_DIR)/metronet-local
73
Zack Williams3670f442016-10-04 17:37:12 -070074
75$(SERVICE_DIR):
76 mkdir -p $(SERVICE_DIR)
77
78$(SERVICE_DIR)/exampleservice:
79 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL)
80
81$(SERVICE_DIR)/olt:
82 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL)
83
84$(SERVICE_DIR)/vsg:
85 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL)
86
87$(SERVICE_DIR)/vtn:
88 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL)
89
90$(SERVICE_DIR)/vrouter:
91 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL)
92
93$(SERVICE_DIR)/vtr:
94 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL)
95
96$(SERVICE_DIR)/onos-service:
97 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL)
98
99$(SERVICE_DIR)/fabric:
100 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL)
101
102$(SERVICE_DIR)/monitoring:
103 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL)
104
105$(SERVICE_DIR)/hypercache:
106 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL)
107
108$(SERVICE_DIR)/metro-net:
109 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL)
110
111$(SERVICE_DIR)/openstack:
112 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL)
113
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500114$(SERVICE_DIR)/metronet-local:
115 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VNODLOCAL_BRANCH) $(VNODLOCAL_GIT_URL)
116
Andy Bavier094e7162016-11-02 17:01:22 -0400117$(SERVICE_DIR)/globalxos:
118 git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(GLOBALXOS_BRANCH) $(GLOBALXOS_GIT_URL)
119
Zack Williams3670f442016-10-04 17:37:12 -0700120update_services:
121 git -C $(SERVICE_DIR)/exampleservice pull
122 git -C $(SERVICE_DIR)/olt pull
123 git -C $(SERVICE_DIR)/vsg pull
124 git -C $(SERVICE_DIR)/vtn pull
125 git -C $(SERVICE_DIR)/vrouter pull
126 git -C $(SERVICE_DIR)/vtr pull
127 git -C $(SERVICE_DIR)/onos-service pull
128 git -C $(SERVICE_DIR)/fabric pull
129 git -C $(SERVICE_DIR)/hypercache pull
130 git -C $(SERVICE_DIR)/metro-net pull
131 git -C $(SERVICE_DIR)/openstack pull
Rizwan Haider0bab5f42016-11-10 01:21:07 -0500132 git -C $(SERVICE_DIR)/metronet-local pull
Zack Williams3670f442016-10-04 17:37:12 -0700133
Scott Baker62d24282016-10-21 09:19:11 -0700134cord_libraries: $(LIBRARY_DIR) \
135 $(LIBRARY_DIR)/ng-xos-lib
136
137$(LIBRARY_DIR):
138 mkdir -p $(LIBRARY_DIR)
139
140$(LIBRARY_DIR)/ng-xos-lib:
141 git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL)
142
Zack Williams3670f442016-10-04 17:37:12 -0700143# bootstrap the containers
144
145RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
146RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
147
148bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml
149 @echo "[BOOTSTRAP]"
150 @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`"
151 @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`"
152 @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`"
153 sudo rm -f $(DOCKER_COMPOSE_YML)
154 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)
156 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/fixtures.yaml
157 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < $(COMMON_DIR)/tosca/mydeployment.yaml
158 $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml
159
160
161# container creation targets
162
Scott Bakerd25ae9f2016-10-20 15:43:33 -0700163local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c
Zack Williams3670f442016-10-04 17:37:12 -0700164
Zack Williams253fec62016-10-21 14:04:53 -0700165test_containers: local_containers xos_test_c
166
Zack Williams3670f442016-10-04 17:37:12 -0700167update_certs:
168 echo "" > $(XOS_DIR)/containers/xos/local_certs.crt
169 for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \
170 echo Adding Certificate: $$CRT ;\
171 cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
172 echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\
173 done
174
175xos_base_c:
Scott Baker9f23ac52016-11-04 14:48:09 -0700176 @[ -z "$(HAS_BASE)" ] || echo "skipping base container build"
177 @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base )
178# cd $(XOS_DIR)/containers/xos; make base
Zack Williams3670f442016-10-04 17:37:12 -0700179
180xos_devel_c:
181 cd $(XOS_DIR)/containers/xos; make devel
182
183xos_test_c:
184 cd $(XOS_DIR)/containers/xos; make test
185
Zack Williams253fec62016-10-21 14:04:53 -0700186
Zack Williamsd7d58f12016-10-24 23:11:06 -0700187# image downloads
188
189$(CONFIG_DIR)images/trusty-server-multi-nic.img: config_dirs
190 curl -fLsS http://www.vicci.org/opencloud/trusty-server-cloudimg-amd64-disk1.img -o $@
191 echo "c2d0ffc937aeb96016164881052a496658efeb98959dc68e73d9895c5d9920f7 $@" | sha256sum -c -
192
193$(CONFIG_DIR)images/vsg-1.1.img: config_dirs
194 curl -fLsS http://www.vicci.org/cord/vsg-1.1.img -o $@
195 echo "16b0beb6778aed0f5feecb05f8d5750e6c262f98e6011e99ddadf7d46a177b6f $@" | sha256sum -c -
196
Srikanth Vavilapalli0fc7de72016-11-03 17:49:11 +0000197$(CONFIG_DIR)images/ceilometer-trusty-server-multi-nic.img: | config_dirs
Zack Williamsd7d58f12016-10-24 23:11:06 -0700198 curl -fLsS http://www.vicci.org/cord/ceilometer-trusty-server-multi-nic.compressed.qcow2 -o $@
199 echo "afde3f0448483902693be4d52ae76bb683fd74b1c7728019094bf81b37d86105 $@" | sha256sum -c -
200
Srikanth Vavilapalli0fc7de72016-11-03 17:49:11 +0000201$(CONFIG_DIR)images/ceilometer-service-trusty-server-multi-nic.img: | config_dirs
202 curl -fLsS http://www.vicci.org/cord/ceilometer-service-trusty-server-multi-nic.compressed.qcow2 -o $@
203 echo "9c346ff15727e9a98942835d6bd34b3d033f868234425f517e53d64b5a124a13 $@" | sha256sum -c -
Zack Williamsd7d58f12016-10-24 23:11:06 -0700204
Zack Williams3670f442016-10-04 17:37:12 -0700205# utilties/convenience targets
Zack Williamsd7d58f12016-10-24 23:11:06 -0700206cleanup: stop rm $(CONFIG_DIR)/cleanup.sh
Zack Williams3670f442016-10-04 17:37:12 -0700207 $(CONFIG_DIR)/cleanup.sh
Zack Williamsd7d58f12016-10-24 23:11:06 -0700208 bash -c "source $(CONFIG_DIR)/admin-openrc.sh; nova list --all-tenants; neutron net-list"
Zack Williams3670f442016-10-04 17:37:12 -0700209
210cleanup_services: $(SERVICE_DIR)
211 rm -rf $(SERVICE_DIR)/*
212
213rebuild:
214 bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT)
215 bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
216
217stop:
218 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop
219 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop
220
221rm: stop
222 test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f
223 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f
224 [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true
225
226ps:
227 sudo docker ps
228
229showlogs_bootstrap:
230 sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f
231
232showlogs:
233 sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f
234
235enter-ui:
236 sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash
237
238enter-bootstrap-ui:
239 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash
240
241enter-db:
242 sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash
243
244django-restart:
245 sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
246