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