blob: ceb178f24d25e2cef4bffa0cbea9dbd9053abfc3 [file] [log] [blame]
srikanth116e6e82014-08-19 07:22:37 -07001#
2# Copyright (c) 2013 Big Switch Networks, Inc.
3#
4# Licensed under the Eclipse Public License, Version 1.0 (the
5# "License"); you may not use this file except in compliance with the
6# License. You may obtain a copy of the License at
7#
8# http://www.eclipse.org/legal/epl-v10.html
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied. See the License for the specific language governing
14# permissions and limitations under the License.
15
16SOURCE = $(shell pwd)
17WORKSPACE = $(SOURCE)/workspace
18VIRTUALENV = $(WORKSPACE)/ve
19TOOLS = $(WORKSPACE)/tools
20BUILD_DIR = $(SOURCE)/build
21FL_DIR = $(SOURCE)/sdnplatform
22
23all: build-sdnplatform
24
25clean-python:
26 printf 'import setuptools\nsetuptools.setup(name="django_cassandra", version="0.1", packages=["django_cassandra", "django_cassandra.db"])' >$(SOURCE)/django_cassandra_backend/setup.py
27 echo '$(SOURCE)' >$$(python -c 'import distutils; print distutils.sysconfig.get_python_lib()')/sdnplatform.pth
28 set -e; \
29 cd $(SOURCE); \
30 for p in django_cassandra_backend/setup.py sdncon/setup.py cli/setup.py; do \
31 echo "+++ Preparing Python virtualenv for $$p"; \
32 ( cd $$(dirname $$p); rm -rf *.egg-info; ARCHFLAGS="-arch i386 -arch x86_64" python $$(basename $$p) develop ); \
33 done
34 ( cd $(SOURCE)/cli ; tools/rebuild_model.sh )
35
36clean-sdnplatform:
37 cd $(FL_DIR); ant clean
38
39clean: reset-cassandra clean-sdnplatform clean-python
40
41stop-cassandra:
42 $(BUILD_DIR)/kill-port-wait.sh -p 9160
43 @echo "+++ Cassandra stopped"
44
45reset-cassandra: stop-cassandra
46 rm -rf $(VIRTUALENV)/cassandra
47 @echo "+++ Cassandra db deleted"
48
49cassandra: start-cassandra
50start-cassandra:
51 $(BUILD_DIR)/start-and-wait-for-port.sh -p 9160 -l $(VIRTUALENV)/log/cassandra.log $(TOOLS)/cassandra/bin/cassandra
52 @echo "+++ Cassandra running"
53
54stop-sdncon:
55 $(BUILD_DIR)/kill-port-wait.sh -p 8000
56 @echo "+++ sdncon stopped"
57
58reset-sdncon: stop-sdncon reset-cassandra start-cassandra
59
60start-sdncon: start-cassandra
61 if ! lsof -iTCP:8000 -sTCP:LISTEN >/dev/null; then \
62 ( \
63 cd $(SOURCE)/sdncon; \
64 [ -d $(VIRTUALENV)/cassandra/data/sdncon ] || python manage.py syncdb --noinput; \
65 $(BUILD_DIR)/start-and-wait-for-port.sh -p 8000 -l $(VIRTUALENV)/log/sdncon.log python manage.py runserver 0.0.0.0:8000; \
66 ); \
67 fi
68 @echo "+++ sdncon running"
69
70stop-sdnplatform:
71 while pid=$$(lsof -t -iTCP:6633 -sTCP:LISTEN); do kill $${pid}; sleep 1; done
72 @echo "+++ SDN Platform stopped"
73
74start-sdnplatform: start-cassandra
75 if ! lsof -iTCP:6633 -sTCP:LISTEN >/dev/null; then \
76 ( cd $(SOURCE)/sdnplatform; ant run &>$(VIRTUALENV)/log/sdnplatform.log & ); \
77 fi
78 while ! nc -z localhost 6633; do sleep 1; done
79 @echo "+++ SDN Platform running"
80
81eclipse:
82 cd $(FL_DIR); ant eclipse
83
84build-sdnplatform:
85 cd $(FL_DIR); ant dist