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 | |
| 39 | nodes.yaml: |
| 40 | export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-nodes-yaml.sh |
| 41 | |
| 42 | clean_nodes: |
| 43 | rm -f $(CONFIG_DIR)/nodes.yaml |
| 44 | |
| 45 | images.yaml: |
| 46 | export SETUPDIR=$(CONFIG_DIR); bash $(COMMON_DIR)/make-images-yaml.sh |
| 47 | |
| 48 | |
| 49 | # download/clone xos and service repos |
| 50 | GITOPTS ?= -c advice.detachedHead=false |
| 51 | |
| 52 | xos_download: $(XOS_DIR) |
| 53 | |
| 54 | $(XOS_DIR): |
| 55 | git -C $(HOME_DIR) $(GITOPTS) clone -b $(XOS_BRANCH) $(XOS_GIT_URL) |
| 56 | |
| 57 | update_xos: |
| 58 | git -C $(XOS_DIR) pull |
| 59 | |
| 60 | cord_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 \ |
| 71 | $(SERVICE_DIR)/metro-net |
| 72 | |
| 73 | $(SERVICE_DIR): |
| 74 | mkdir -p $(SERVICE_DIR) |
| 75 | |
| 76 | $(SERVICE_DIR)/exampleservice: |
| 77 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(EXAMPLESERVICE_BRANCH) $(EXAMPLESERVICE_GIT_URL) |
| 78 | |
| 79 | $(SERVICE_DIR)/olt: |
| 80 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OLT_BRANCH) $(OLT_GIT_URL) |
| 81 | |
| 82 | $(SERVICE_DIR)/vsg: |
| 83 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VSG_BRANCH) $(VSG_GIT_URL) |
| 84 | |
| 85 | $(SERVICE_DIR)/vtn: |
| 86 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTN_BRANCH) $(VTN_GIT_URL) |
| 87 | |
| 88 | $(SERVICE_DIR)/vrouter: |
| 89 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VROUTER_BRANCH) $(VROUTER_GIT_URL) |
| 90 | |
| 91 | $(SERVICE_DIR)/vtr: |
| 92 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(VTR_BRANCH) $(VTR_GIT_URL) |
| 93 | |
| 94 | $(SERVICE_DIR)/onos-service: |
| 95 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(ONOS_BRANCH) $(ONOS_GIT_URL) |
| 96 | |
| 97 | $(SERVICE_DIR)/fabric: |
| 98 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(FABRIC_BRANCH) $(FABRIC_GIT_URL) |
| 99 | |
| 100 | $(SERVICE_DIR)/monitoring: |
| 101 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(MONITORING_BRANCH) $(MONITORING_GIT_URL) |
| 102 | |
| 103 | $(SERVICE_DIR)/hypercache: |
| 104 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(HYPERCACHE_BRANCH) $(HYPERCACHE_GIT_URL) |
| 105 | |
| 106 | $(SERVICE_DIR)/metro-net: |
| 107 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(METRONETWORK_BRANCH) $(METRONETWORK_GIT_URL) |
| 108 | |
| 109 | $(SERVICE_DIR)/openstack: |
| 110 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(OPENSTACK_BRANCH) $(OPENSTACK_GIT_URL) |
| 111 | |
Andy Bavier | 094e716 | 2016-11-02 17:01:22 -0400 | [diff] [blame] | 112 | $(SERVICE_DIR)/globalxos: |
| 113 | git -C $(SERVICE_DIR) $(GITOPTS) clone -b $(GLOBALXOS_BRANCH) $(GLOBALXOS_GIT_URL) |
| 114 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 115 | update_services: |
| 116 | git -C $(SERVICE_DIR)/exampleservice pull |
| 117 | git -C $(SERVICE_DIR)/olt pull |
| 118 | git -C $(SERVICE_DIR)/vsg pull |
| 119 | git -C $(SERVICE_DIR)/vtn pull |
| 120 | git -C $(SERVICE_DIR)/vrouter pull |
| 121 | git -C $(SERVICE_DIR)/vtr pull |
| 122 | git -C $(SERVICE_DIR)/onos-service pull |
| 123 | git -C $(SERVICE_DIR)/fabric pull |
| 124 | git -C $(SERVICE_DIR)/hypercache pull |
| 125 | git -C $(SERVICE_DIR)/metro-net pull |
| 126 | git -C $(SERVICE_DIR)/openstack pull |
| 127 | |
Scott Baker | 62d2428 | 2016-10-21 09:19:11 -0700 | [diff] [blame] | 128 | cord_libraries: $(LIBRARY_DIR) \ |
| 129 | $(LIBRARY_DIR)/ng-xos-lib |
| 130 | |
| 131 | $(LIBRARY_DIR): |
| 132 | mkdir -p $(LIBRARY_DIR) |
| 133 | |
| 134 | $(LIBRARY_DIR)/ng-xos-lib: |
| 135 | git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL) |
| 136 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 137 | # bootstrap the containers |
| 138 | |
| 139 | RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 140 | RUN_TOSCA ?= python $(COMMON_DIR)/run_tosca.py $(XOS_UI_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD) |
| 141 | |
| 142 | bootstrap: $(BOOTSTRAP_YML) $(CONFIG_DIR)/xos.yaml |
| 143 | @echo "[BOOTSTRAP]" |
| 144 | @echo "XOS Image Build Date: `sudo docker inspect -f '{{ .Created }}' xosproject/xos`" |
| 145 | @echo "XOS Image Commit Hash: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_HASH }}' xosproject/xos`" |
| 146 | @echo "XOS Image Commit Date: `sudo docker inspect -f '{{ .Config.Labels.XOS_GIT_COMMIT_DATE }}' xosproject/xos`" |
| 147 | sudo rm -f $(DOCKER_COMPOSE_YML) |
| 148 | sudo CONFIG_DIR=$(CONFIG_DIR) docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) up -d |
| 149 | bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_BOOTSTRAP_PORT) |
| 150 | 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 |
| 151 | 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 |
| 152 | $(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos.yaml |
| 153 | |
| 154 | |
| 155 | # container creation targets |
| 156 | |
Scott Baker | d25ae9f | 2016-10-20 15:43:33 -0700 | [diff] [blame] | 157 | 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] | 158 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 159 | test_containers: local_containers xos_test_c |
| 160 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 161 | update_certs: |
| 162 | echo "" > $(XOS_DIR)/containers/xos/local_certs.crt |
| 163 | for CRT in $$(ls /usr/local/share/ca-certificates/*) ; do \ |
| 164 | echo Adding Certificate: $$CRT ;\ |
| 165 | cat $$CRT >> $(XOS_DIR)/containers/xos/local_certs.crt ;\ |
| 166 | echo "" >> $(XOS_DIR)/containers/xos/local_certs.crt ;\ |
| 167 | done |
| 168 | |
| 169 | xos_base_c: |
Scott Baker | 9f23ac5 | 2016-11-04 14:48:09 -0700 | [diff] [blame^] | 170 | @[ -z "$(HAS_BASE)" ] || echo "skipping base container build" |
| 171 | @[ -n "$(HAS_BASE)" ] || ( cd $(XOS_DIR)/containers/xos; make base ) |
| 172 | # cd $(XOS_DIR)/containers/xos; make base |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 173 | |
| 174 | xos_devel_c: |
| 175 | cd $(XOS_DIR)/containers/xos; make devel |
| 176 | |
| 177 | xos_test_c: |
| 178 | cd $(XOS_DIR)/containers/xos; make test |
| 179 | |
Zack Williams | 253fec6 | 2016-10-21 14:04:53 -0700 | [diff] [blame] | 180 | |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 181 | # image downloads |
| 182 | |
| 183 | $(CONFIG_DIR)images/trusty-server-multi-nic.img: config_dirs |
| 184 | curl -fLsS http://www.vicci.org/opencloud/trusty-server-cloudimg-amd64-disk1.img -o $@ |
| 185 | echo "c2d0ffc937aeb96016164881052a496658efeb98959dc68e73d9895c5d9920f7 $@" | sha256sum -c - |
| 186 | |
| 187 | $(CONFIG_DIR)images/vsg-1.1.img: config_dirs |
| 188 | curl -fLsS http://www.vicci.org/cord/vsg-1.1.img -o $@ |
| 189 | echo "16b0beb6778aed0f5feecb05f8d5750e6c262f98e6011e99ddadf7d46a177b6f $@" | sha256sum -c - |
| 190 | |
| 191 | $(CONFIG_DIR)images/ceilometer-trusty-server-multi-nic.img: config_dirs |
| 192 | curl -fLsS http://www.vicci.org/cord/ceilometer-trusty-server-multi-nic.compressed.qcow2 -o $@ |
| 193 | echo "afde3f0448483902693be4d52ae76bb683fd74b1c7728019094bf81b37d86105 $@" | sha256sum -c - |
| 194 | |
| 195 | |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 196 | # utilties/convenience targets |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 197 | cleanup: stop rm $(CONFIG_DIR)/cleanup.sh |
Zack Williams | 3670f44 | 2016-10-04 17:37:12 -0700 | [diff] [blame] | 198 | $(CONFIG_DIR)/cleanup.sh |
Zack Williams | d7d58f1 | 2016-10-24 23:11:06 -0700 | [diff] [blame] | 199 | 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] | 200 | |
| 201 | cleanup_services: $(SERVICE_DIR) |
| 202 | rm -rf $(SERVICE_DIR)/* |
| 203 | |
| 204 | rebuild: |
| 205 | bash $(COMMON_DIR)/rebuild.sh $(XOS_BOOTSTRAP_PORT) |
| 206 | bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos |
| 207 | |
| 208 | stop: |
| 209 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) stop |
| 210 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) stop |
| 211 | |
| 212 | rm: stop |
| 213 | test ! -s $(DOCKER_COMPOSE_YML) || sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) rm -f |
| 214 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) rm -f |
| 215 | [ -n "$(shell docker images -f \"dangling=true\" -q)" ] && docker rmi $(shell docker images -f "dangling=true" -q) || true |
| 216 | |
| 217 | ps: |
| 218 | sudo docker ps |
| 219 | |
| 220 | showlogs_bootstrap: |
| 221 | sudo docker-compose -p $(BOOTSTRAP_PROJECT) -f $(BOOTSTRAP_YML) logs -f |
| 222 | |
| 223 | showlogs: |
| 224 | sudo docker-compose -p $(DOCKER_PROJECT) -f $(DOCKER_COMPOSE_YML) logs -f |
| 225 | |
| 226 | enter-ui: |
| 227 | sudo docker exec -ti $(DOCKER_PROJECT)_xos_ui_1 bash |
| 228 | |
| 229 | enter-bootstrap-ui: |
| 230 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_bootstrap_ui_1 bash |
| 231 | |
| 232 | enter-db: |
| 233 | sudo docker exec -ti $(BOOTSTRAP_PROJECT)_xos_db_1 bash |
| 234 | |
| 235 | django-restart: |
| 236 | sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py |
| 237 | |