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) \ |
| 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 Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 134 | # bootstrap the containers |
| 135 | |
| 136 | RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 137 | RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 138 | |
| 139 | bootstrap: $(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) |
Scott Baker | 91a0d2a | 2016-12-19 15:08:25 -0800 | [diff] [blame^] | 145 | sudo docker network inspect xos || sudo docker network create xos |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 146 | 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 Baker | d0c49fd | 2016-12-13 11:48:59 -0800 | [diff] [blame] | 148 | 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 Williams | cf1f9c8 | 2016-11-08 22:19:02 -0700 | [diff] [blame] | 150 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT) |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 151 | $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml |
| 152 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 153 | # container creation targets |
Scott Baker | d25ae9f | 2016-10-20 15:43:33 -0700 | [diff] [blame] | 154 | 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] | 155 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 156 | test_containers: local_containers xos_test_c |
| 157 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 158 | update_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 | |
| 166 | xos_base_c: |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame] | 167 | @[ -z "$(HAS_BASE)" ] || echo "skipping base container build" |
Zack Williams | cf1f9c8 | 2016-11-08 22:19:02 -0700 | [diff] [blame] | 168 | @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base ) |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame] | 169 | # cd $(XOS_DIR)/containers/xos; make base |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 170 | |
| 171 | xos_devel_c: |
| 172 | cd $(XOS_DIR)/containers/xos; make devel |
| 173 | |
| 174 | xos_test_c: |
| 175 | cd $(XOS_DIR)/containers/xos; make test |
| 176 | |
Matteo Scandolo | 76d7bcd | 2016-11-30 17:08:17 -0800 | [diff] [blame] | 177 | xos_rest_gw_c: |
| 178 | # this folder is cloned by repo |
| 179 | cd $(REST_GW_DIR); docker build -t xosproject/xos-rest-gw . |
| 180 | |
| 181 | xos_gui_c: |
| 182 | # this folder is cloned by repo |
| 183 | cd $(GUI_DIR); docker build -t xosproject/xos-gui . |
| 184 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 185 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 186 | # utilties/convenience targets |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 187 | cleanup: stop rm $(CONFIG_DIR)/cleanup.sh |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 188 | $(CONFIG_DIR)/cleanup.sh |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 189 | 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] | 190 | |
| 191 | cleanup_services: $(SERVICE_DIR) |
| 192 | rm -rf $(SERVICE_DIR)/* |
| 193 | |
| 194 | rebuild: |
| 195 | bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT) |
| 196 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 197 | |
| 198 | stop: |
| 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 | |
| 202 | rm: 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 | |
| 207 | ps: |
| 208 | sudo docker ps |
| 209 | |
| 210 | showlogs_bootstrap: |
| 211 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f |
| 212 | |
| 213 | showlogs: |
| 214 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f |
| 215 | |
| 216 | enter-ui: |
| 217 | sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash |
| 218 | |
| 219 | enter-bootstrap-ui: |
| 220 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash |
| 221 | |
| 222 | enter-db: |
| 223 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash |
| 224 | |
| 225 | django-restart: |
| 226 | sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py |
| 227 | |