Zack Williams | 7828f22 | 2016-10-19 14:04:51 -0700 | [diff] [blame] | 1 | # common/Makefile |
| 2 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 3 | include $(COMMON_DIR)/Makedefs |
| 4 | |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame] | 5 | HAS_BASE=$(shell docker images | grep xos-base ) |
| 6 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 7 | # prerequisite software |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 8 | .PHONY: prereqs |
| 9 | prereqs: /usr/bin/http /usr/bin/docker /usr/bin/curl /usr/local/bin/docker-compose |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 10 | |
| 11 | apt-prereqs: |
| 12 | sudo apt-get update |
| 13 | sudo apt-get -y install apt-transport-https ca-certificates python-pip |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 14 | touch $@ |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 15 | |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 16 | /usr/bin/http: | apt-prereqs |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 17 | sudo apt-get -y install httpie |
| 18 | |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 19 | /usr/bin/curl: | apt-prereqs |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 20 | sudo apt-get -y install curl |
| 21 | |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 22 | /usr/bin/docker: | apt-prereqs |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 23 | sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 24 | 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 Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 25 | sudo apt-get update |
| 26 | sudo apt-get -y install docker-engine |
| 27 | sudo usermod -aG docker $(shell whoami) |
| 28 | |
Zack Williams | 7021ebd | 2016-10-28 16:06:44 -0700 | [diff] [blame] | 29 | /usr/local/bin/docker-compose: | apt-prereqs |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 30 | sudo pip install docker-compose |
| 31 | |
| 32 | |
| 33 | # configuration |
| 34 | config_dirs: |
| 35 | mkdir -p $(CONFIG_DIR)/key_import |
| 36 | mkdir -p $(CONFIG_DIR)/onboarding-docker-compose |
| 37 | mkdir -p $(CONFIG_DIR)/images |
| 38 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 39 | |
| 40 | # download/clone xos and service repos |
| 41 | GITOPTS ?= -c advice.detachedHead=false |
| 42 | |
| 43 | xos_download: $(XOS_DIR) |
| 44 | |
| 45 | $(XOS_DIR): |
| 46 | git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL) |
| 47 | |
| 48 | update_xos: |
| 49 | git -C $(XOS_DIR) pull |
| 50 | |
| 51 | cord_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 Haider | 0bab5f4 | 2016-11-10 01:21:07 -0500 | [diff] [blame] | 62 | $(SERVICE_DIR)/metro-net \ |
| 63 | $(SERVICE_DIR)/metronet-local |
| 64 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 65 | |
| 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 Haider | 0bab5f4 | 2016-11-10 01:21:07 -0500 | [diff] [blame] | 105 | $(SERVICE_DIR)/metronet-local: |
| 106 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VNODLOCAL_BRANCH) $(VNODLOCAL_GIT_URL) |
| 107 | |
Andy Bavier | 094e716 | 2016-11-02 17:01:22 -0400 | [diff] [blame] | 108 | $(SERVICE_DIR)/globalxos: |
| 109 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(GLOBALXOS_BRANCH) $(GLOBALXOS_GIT_URL) |
| 110 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 111 | update_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 Haider | 0bab5f4 | 2016-11-10 01:21:07 -0500 | [diff] [blame] | 123 | git -C $(SERVICE_DIR)/metronet-local pull |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 124 | |
Scott Baker | 62d2428 | 2016-10-21 09:19:11 -0700 | [diff] [blame] | 125 | cord_libraries: $(LIBRARY_DIR) \ |
Matteo Scandolo | a317b87 | 2017-01-10 12:02:41 -0800 | [diff] [blame] | 126 | $(LIBRARY_DIR)/ng-xos-lib \ |
| 127 | $(LIBRARY_DIR)/xos-rest-gw \ |
| 128 | $(LIBRARY_DIR)/xos-gui |
Scott Baker | 62d2428 | 2016-10-21 09:19:11 -0700 | [diff] [blame] | 129 | |
| 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 Scandolo | a317b87 | 2017-01-10 12:02:41 -0800 | [diff] [blame] | 136 | $(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 Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 142 | # bootstrap the containers |
| 143 | |
| 144 | RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 145 | RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 146 | |
| 147 | bootstrap: $(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 Baker | 91a0d2a | 2016-12-19 15:08:25 -0800 | [diff] [blame] | 153 | sudo docker network inspect xos || sudo docker network create xos |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 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) |
Scott Baker | d0c49fd | 2016-12-13 11:48:59 -0800 | [diff] [blame] | 156 | 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 Williams | cf1f9c8 | 2016-11-08 22:19:02 -0700 | [diff] [blame] | 158 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT) |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 159 | $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml |
| 160 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 161 | # container creation targets |
Scott Baker | d25ae9f | 2016-10-20 15:43:33 -0700 | [diff] [blame] | 162 | local_containers: prereqs xos_download update_certs xos_base_c xos_devel_c |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 163 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 164 | test_containers: local_containers xos_test_c |
| 165 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 166 | update_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 | |
| 174 | xos_base_c: |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame] | 175 | @[ -z "$(HAS_BASE)" ] || echo "skipping base container build" |
Zack Williams | cf1f9c8 | 2016-11-08 22:19:02 -0700 | [diff] [blame] | 176 | @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base ) |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame] | 177 | # cd $(XOS_DIR)/containers/xos; make base |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 178 | |
| 179 | xos_devel_c: |
| 180 | cd $(XOS_DIR)/containers/xos; make devel |
| 181 | |
| 182 | xos_test_c: |
| 183 | cd $(XOS_DIR)/containers/xos; make test |
| 184 | |
Matteo Scandolo | 76d7bcd | 2016-11-30 17:08:17 -0800 | [diff] [blame] | 185 | xos_rest_gw_c: |
| 186 | # this folder is cloned by repo |
Matteo Scandolo | 2dad22d | 2017-01-12 15:43:44 -0800 | [diff] [blame] | 187 | cd $(LIBRARY_DIR)/xos-rest-gw; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-rest-gw . |
Matteo Scandolo | 76d7bcd | 2016-11-30 17:08:17 -0800 | [diff] [blame] | 188 | |
| 189 | xos_gui_c: |
| 190 | # this folder is cloned by repo |
Matteo Scandolo | 2dad22d | 2017-01-12 15:43:44 -0800 | [diff] [blame] | 191 | cd $(LIBRARY_DIR)/xos-gui; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-gui . |
Matteo Scandolo | 76d7bcd | 2016-11-30 17:08:17 -0800 | [diff] [blame] | 192 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 193 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 194 | # utilties/convenience targets |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 195 | cleanup: stop rm $(CONFIG_DIR)/cleanup.sh |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 196 | $(CONFIG_DIR)/cleanup.sh |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 197 | bash -c "source $(CONFIG_DIR)/admin-openrc.sh; nova list --all-tenants; neutron net-list" |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 198 | |
| 199 | cleanup_services: $(SERVICE_DIR) |
| 200 | rm -rf $(SERVICE_DIR)/* |
| 201 | |
| 202 | rebuild: |
| 203 | bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT) |
| 204 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 205 | |
| 206 | stop: |
| 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 | |
| 210 | rm: 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 | |
| 215 | ps: |
| 216 | sudo docker ps |
| 217 | |
| 218 | showlogs_bootstrap: |
| 219 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f |
| 220 | |
| 221 | showlogs: |
| 222 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f |
| 223 | |
| 224 | enter-ui: |
| 225 | sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash |
| 226 | |
| 227 | enter-bootstrap-ui: |
| 228 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash |
| 229 | |
| 230 | enter-db: |
| 231 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash |
| 232 | |
| 233 | django-restart: |
| 234 | sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py |
| 235 | |
Matteo Scandolo | a317b87 | 2017-01-10 12:02:41 -0800 | [diff] [blame] | 236 | rest-gw: xos_rest_gw_c |
| 237 | $(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml |
Matteo Scandolo | 82d64ac | 2017-01-13 09:49:35 -0800 | [diff] [blame] | 238 | $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos-rest-gw.yaml |
Matteo Scandolo | a317b87 | 2017-01-10 12:02:41 -0800 | [diff] [blame] | 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 | |
| 243 | ui: 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 | |