-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (115 loc) · 3.72 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
PACKAGES = nano
PY_FOLDERS = packages/nano/python/nano_helper
PY_FOLDERS_TESTS = packages/nano/python/nano_helper
.PHONY: all
all: clean build start
include make-python.mk
.PHONY: build
build: compile netsim ncs-setup
.PHONY: clean
clean: stop cleanncs
.PHONY: reload
reload: compile
./tools/pkgreload.sh
.PHONY: stop
stop:
@printf -- "\n\033[33;1m>>> Stoping NCS... \033[0m\n"
-ncs --stop
-ncs-netsim stop --dir netsim
.PHONY: compile
compile:
@printf -- "\n\033[33;1m>>> Compiling YANG models... \033[0m\n"
@for pkg in $(PACKAGES) ; do \
printf -- "\033[36;1mCompiling $$pkg... \033[0m \n"; \
$(MAKE) -C "packages/$$pkg/src/" clean all || exit 1; \
done
.PHONY: reset
reset:
@printf -- "\n\033[33;1m>>> Resetting NCS configuration... \033[0m\n"
ncs --stop
rm -fr ./ncs-cdb/*.cdb
ncs
.PHONY: netsim
netsim:
@printf -- "\n\033[33;1m>>> Creating netsim network... \033[0m\n"
ncs-netsim create-network cisco-ios-cli-3.8 2 r
@for package in $(PACKAGES) ; do \
printf -- "\033[37;1m$$package... \033[0m \n"; \
if [ -d packages/$$package/netsim ]; then \
$(MAKE) -C "packages/$$package/netsim" netsim || exit 1; \
fi; \
done
ncs-netsim ncs-xml-init > configs/netsim-init.xml
.PHONY: ncs-setup
ncs-setup:
@printf -- "\n\033[33;1m>>> Setting up NCS... \033[0m\n"
ncs-setup --netsim-dir ./netsim --dest .
@printf -- "\033[36;1mCoping configs... \033[0m \n"
cp -v configs/*.xml ncs-cdb/
python3 tools/update_ncsconf.py
.PHONY: cleanncs
cleanncs:
@printf -- "\n\033[33;1m>>> Cleaning up... \033[0m \n"
@for pkg in $(PACKAGES) ; do \
printf -- "\033[36;1mCleaning up $$pkg... \033[0m \n"; \
$(MAKE) -C "packages/$$pkg/src/" clean || exit 1; \
done
@printf -- "\033[36;1mDeleting ncs-setup folders and files... \033[0m \n"
rm -rf ./logs ./ncs-cdb ./netsim ./scripts ./state ./target ./.ipython ./Library
rm -rf ./packages/cisco-ios-cli-3.8
rm -fr ncs.conf README.ncs README.netsim storedstate
@printf -- "\033[36;1mDeleting lux logs... \033[0m \n"
@find ./tests -type d -name "lux_logs" -exec rm -fr {} \; || exit 0
.PHONY: start
start:
ncs-netsim start
ncs
./tools/sync-from.sh
@printf -- "\n\033[32;1mUse 'make cli' or 'make webui' for accessing NSO. \033[0m\n"
@printf -- "\n\033[32;1mUse 'make nsotest' for running tests. \033[0m\n"
.PHONY: startint
startint:
@printf -- "\n\033[33;1m>>> Starting NCS interactively.. \033[0m \n"
@printf -- "\n\033[32;1mUse ctrl-d to gracefully exit. \033[0m\n"
-ncs --stop
ncs --foreground --verbose --stop-on-eof
.PHONY: cli
cli:
ncs_cli -C -u admin
# for testing NACM rules, because a default console connection skips checks
.PHONY: cli-en
cli-en:
ssh engineer@0.0.0.0 -p 2024 -o PreferredAuthentications=password -o PasswordAuthentication=yes -o PubkeyAuthentication=no
# for testing NACM rules, because a default console connection skips checks
.PHONY: cli-app
cli-app:
ssh approver@0.0.0.0 -p 2024 -o PreferredAuthentications=password -o PasswordAuthentication=yes -o PubkeyAuthentication=no
.PHONY: webui
webui:
open http://0.0.0.0:8080/login.html
.PHONY: logs
logs:
tail -f -n0 ./logs/*.log
.PHONY: traces
traces:
tail -f -n0 ./logs/*.trace
.PHONY: backupncs
backupncs:
./tools/backup-ncs.sh
.PHONY: lint-yanger
lint-yanger:
@printf -- "\n\033[33;1m>>> Linting YANG models with yanger... \033[0m\n"
@for pkg in $(PACKAGES) ; do \
printf -- "\033[36;1mLinting $$pkg... \033[0m \n"; \
./tools/lint-yanger.sh packages/$$pkg || echo "failed, continue..."; \
done
.PHONY: lint-pyang
lint-pyang:
@printf -- "\n\033[33;1m>>> Linting YANG models with pyang... \033[0m\n"
@for pkg in $(PACKAGES) ; do \
printf -- "\033[36;1mLinting $$pkg... \033[0m \n"; \
./tools/lint-pyang.sh packages/$$pkg || echo "failed, continue..."; \
done
.PHONY: nsotest
nsotest:
$(MAKE) -C tests test || exit 1