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 | |
| 5 | # prerequisite software |
| 6 | prereqs: apt-prereqs /usr/bin/http /usr/bin/docker /usr/bin/curl /usr/local/bin/docker-compose |
| 7 | |
| 8 | apt-prereqs: |
| 9 | sudo apt-get update |
| 10 | sudo apt-get -y install apt-transport-https ca-certificates python-pip |
| 11 | |
| 12 | /usr/bin/http: |
| 13 | sudo apt-get -y install httpie |
| 14 | |
| 15 | /usr/bin/curl: |
| 16 | sudo apt-get -y install curl |
| 17 | |
| 18 | /usr/bin/docker: |
| 19 | sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
| 20 | echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /tmp/docker.list |
| 21 | sudo mv /tmp/docker.list /etc/apt/sources.list.d/docker.list |
| 22 | sudo apt-get update |
| 23 | sudo apt-get -y install docker-engine |
| 24 | sudo usermod -aG docker $(shell whoami) |
| 25 | |
| 26 | /usr/local/bin/docker-compose: |
| 27 | sudo pip install docker-compose |
| 28 | |
| 29 | |
| 30 | # configuration |
| 31 | config_dirs: |
| 32 | mkdir -p $(CONFIG_DIR)/key_import |
| 33 | mkdir -p $(CONFIG_DIR)/onboarding-docker-compose |
| 34 | mkdir -p $(CONFIG_DIR)/images |
| 35 | |
| 36 | nodes.yaml: |
| 37 | export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-nodes-yaml.sh |
| 38 | |
| 39 | clean_nodes: |
| 40 | rm -f $(CONFIG_DIR)/nodes.yaml |
| 41 | |
| 42 | images.yaml: |
| 43 | export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-images-yaml.sh |
| 44 | |
| 45 | |
| 46 | # download/clone xos and service repos |
| 47 | GITOPTS ?= -c advice.detachedHead=false |
| 48 | |
| 49 | xos_download: $(XOS_DIR) |
| 50 | |
| 51 | $(XOS_DIR): |
| 52 | git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL) |
| 53 | |
| 54 | update_xos: |
| 55 | git -C $(XOS_DIR) pull |
| 56 | |
| 57 | cord_services: $(SERVICE_DIR) \ |
| 58 | $(SERVICE_DIR)/exampleservice \ |
| 59 | $(SERVICE_DIR)/fabric \ |
| 60 | $(SERVICE_DIR)/hypercache \ |
| 61 | $(SERVICE_DIR)/olt \ |
| 62 | $(SERVICE_DIR)/onos-service \ |
| 63 | $(SERVICE_DIR)/openstack \ |
| 64 | $(SERVICE_DIR)/vrouter \ |
| 65 | $(SERVICE_DIR)/vsg \ |
| 66 | $(SERVICE_DIR)/vtn \ |
| 67 | $(SERVICE_DIR)/vtr \ |
| 68 | $(SERVICE_DIR)/metro-net |
| 69 | |
| 70 | $(SERVICE_DIR): |
| 71 | mkdir -p $(SERVICE_DIR) |
| 72 | |
| 73 | $(SERVICE_DIR)/exampleservice: |
| 74 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL) |
| 75 | |
| 76 | $(SERVICE_DIR)/olt: |
| 77 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL) |
| 78 | |
| 79 | $(SERVICE_DIR)/vsg: |
| 80 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL) |
| 81 | |
| 82 | $(SERVICE_DIR)/vtn: |
| 83 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL) |
| 84 | |
| 85 | $(SERVICE_DIR)/vrouter: |
| 86 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL) |
| 87 | |
| 88 | $(SERVICE_DIR)/vtr: |
| 89 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL) |
| 90 | |
| 91 | $(SERVICE_DIR)/onos-service: |
| 92 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL) |
| 93 | |
| 94 | $(SERVICE_DIR)/fabric: |
| 95 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL) |
| 96 | |
| 97 | $(SERVICE_DIR)/monitoring: |
| 98 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL) |
| 99 | |
| 100 | $(SERVICE_DIR)/hypercache: |
| 101 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL) |
| 102 | |
| 103 | $(SERVICE_DIR)/metro-net: |
| 104 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL) |
| 105 | |
| 106 | $(SERVICE_DIR)/openstack: |
| 107 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL) |
| 108 | |
| 109 | update_services: |
| 110 | git -C $(SERVICE_DIR)/exampleservice pull |
| 111 | git -C $(SERVICE_DIR)/olt pull |
| 112 | git -C $(SERVICE_DIR)/vsg pull |
| 113 | git -C $(SERVICE_DIR)/vtn pull |
| 114 | git -C $(SERVICE_DIR)/vrouter pull |
| 115 | git -C $(SERVICE_DIR)/vtr pull |
| 116 | git -C $(SERVICE_DIR)/onos-service pull |
| 117 | git -C $(SERVICE_DIR)/fabric pull |
| 118 | git -C $(SERVICE_DIR)/hypercache pull |
| 119 | git -C $(SERVICE_DIR)/metro-net pull |
| 120 | git -C $(SERVICE_DIR)/openstack pull |
| 121 | |
Scott Baker | 62d2428 | 2016-10-21 09:19:11 -0700 | [diff] [blame] | 122 | cord_libraries: $(LIBRARY_DIR) \ |
| 123 | $(LIBRARY_DIR)/ng-xos-lib |
| 124 | |
| 125 | $(LIBRARY_DIR): |
| 126 | mkdir -p $(LIBRARY_DIR) |
| 127 | |
| 128 | $(LIBRARY_DIR)/ng-xos-lib: |
| 129 | git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL) |
| 130 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 131 | # bootstrap the containers |
| 132 | |
| 133 | RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 134 | RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 135 | |
| 136 | bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml |
| 137 | @echo "[BOOTSTRAP]" |
| 138 | @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`" |
| 139 | @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`" |
| 140 | @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`" |
| 141 | sudo rm -f $(DOCKER_COMPOSE_YML) |
| 142 | sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d |
| 143 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT) |
| 144 | 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 |
| 145 | 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 |
| 146 | $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml |
| 147 | |
| 148 | |
| 149 | # container creation targets |
| 150 | |
Scott Baker | d25ae9f | 2016-10-20 15:43:33 -0700 | [diff] [blame] | 151 | 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] | 152 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 153 | test_containers: local_containers xos_test_c |
| 154 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 155 | update_certs: |
| 156 | echo "" > $(XOS_DIR)/containers/xos/local_certs.crt |
| 157 | for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \ |
| 158 | echo Adding Certificate: $$CRT ;\ |
| 159 | cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\ |
| 160 | echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\ |
| 161 | done |
| 162 | |
| 163 | xos_base_c: |
| 164 | cd $(XOS_DIR)/containers/xos; make base |
| 165 | |
| 166 | xos_devel_c: |
| 167 | cd $(XOS_DIR)/containers/xos; make devel |
| 168 | |
| 169 | xos_test_c: |
| 170 | cd $(XOS_DIR)/containers/xos; make test |
| 171 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 172 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 173 | # utilties/convenience targets |
| 174 | cleanup: stop rm |
| 175 | $(CONFIG_DIR)/cleanup.sh |
| 176 | bash -c "source ./admin-openrc.sh; nova list --all-tenants; neutron net-list" |
| 177 | |
| 178 | cleanup_services: $(SERVICE_DIR) |
| 179 | rm -rf $(SERVICE_DIR)/* |
| 180 | |
| 181 | rebuild: |
| 182 | bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT) |
| 183 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 184 | |
| 185 | stop: |
| 186 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop |
| 187 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop |
| 188 | |
| 189 | rm: stop |
| 190 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f |
| 191 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f |
| 192 | [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true |
| 193 | |
| 194 | ps: |
| 195 | sudo docker ps |
| 196 | |
| 197 | showlogs_bootstrap: |
| 198 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f |
| 199 | |
| 200 | showlogs: |
| 201 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f |
| 202 | |
| 203 | enter-ui: |
| 204 | sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash |
| 205 | |
| 206 | enter-bootstrap-ui: |
| 207 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash |
| 208 | |
| 209 | enter-db: |
| 210 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash |
| 211 | |
| 212 | django-restart: |
| 213 | sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py |
| 214 | |