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