-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
180 lines (134 loc) · 6.73 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
.PHONY: builder images tester host-packages bash yang
ARCH ?= $(subst x86_64,amd64,$(shell uname -m))
DOCKER_CMD ?= bash
DOCKER_BUILD_OPTION ?= --platform linux/$(ARCH)
DOCKER_IMAGE ?= $(BUILDER)
GS_MGMT_IMAGE_PREFIX ?= ghcr.io/oopt-goldstone/mgmt/
GS_MGMT_IMAGE_TAG ?= latest
define image_name
$(GS_MGMT_IMAGE_PREFIX)$1:$(GS_MGMT_IMAGE_TAG)
endef
BUILDER ?= $(call image_name,builder)
GS_SAVE_AFTER_BUILD ?= 0
define save
if [ $(GS_SAVE_AFTER_BUILD) -eq 1 ]; then mkdir -p builds && docker save $(call image_name,$(1)) > builds/$(1)-$(ARCH).tar && gzip -f builds/$(1)-$(ARCH).tar; fi
endef
define build_image
DOCKER_BUILDKIT=1 docker build $(DOCKER_BUILD_OPTION) -f docker/$(2) \
--build-arg GS_MGMT_BUILDER_IMAGE=$(BUILDER) \
--target $(1) -t $(call image_name,$(1)) .
$(call save,$(1))
endef
define build_agent_image
$(call build_image,$(1),agent.Dockerfile)
endef
TAI_META_CUSTOM_FILES ?= $(abspath $(wildcard scripts/tai/*))
TRANSPONDER_YANG ?= ./yang/goldstone-transponder.yang
all: builder images tester host-packages
images: south-images north-images xlate-images system-images
GS_SOUTH_AGENTS ?= south-sonic south-tai south-onlp south-system south-gearbox south-dpll south-netlink south-ocnos
GS_NORTH_AGENTS ?= north-cli north-snmp north-netconf north-notif north-gnmi
GS_XLATE_AGENTS ?= xlate-oc xlate-or
GS_SYSTEM_AGENTS ?= system-telemetry
south-images: $(GS_SOUTH_AGENTS)
north-images: $(GS_NORTH_AGENTS)
xlate-images: $(GS_XLATE_AGENTS)
system-images: $(GS_SYSTEM_AGENTS)
$(GS_SOUTH_AGENTS) $(GS_NORTH_AGENTS) $(GS_XLATE_AGENTS) $(GS_SYSTEM_AGENTS):
$(call build_agent_image,$@)
north-snmp: snmpd
snmpd:
$(call build_image,$@,snmpd.Dockerfile)
tester:
$(call build_image,$@,builder.Dockerfile)
rust-tester:
$(call build_image,$@,builder.Dockerfile)
builder:
$(call build_image,$@,builder.Dockerfile)
host-packages:
$(call build_image,$@,builder.Dockerfile)
yang:
./tools/tai_yang_gen.py ./sm/oopt-tai/inc/tai.h $(TAI_META_CUSTOM_FILES) | pyang -f yang > $(TRANSPONDER_YANG)
bash:
DOCKER_RUN_OPTION='-it --cap-add IPC_OWNER --cap-add IPC_LOCK' $(MAKE) cmd
rust:
DOCKER_IMAGE=$(call image_name,rust-tester) DOCKER_RUN_OPTION='-it -v /var/lib/sysrepo:/var/lib/sysrepo -v /dev/shm:/dev/shm --privileged' $(MAKE) cmd
python:
DOCKER_IMAGE=$(call image_name,tester) DOCKER_RUN_OPTION='-it -v /var/lib/sysrepo:/var/lib/sysrepo -v /dev/shm:/dev/shm --privileged' $(MAKE) cmd
tester-bash:
DOCKER_RUN_OPTION='-it' DOCKER_IMAGE=$(call image_name,tester) $(MAKE) cmd
cmd:
docker run $(DOCKER_RUN_OPTION) -v `pwd`:/data -w /data -v /etc/onl/platform:/etc/onl/platform $(DOCKER_IMAGE) $(DOCKER_CMD)
lint:
which black && exit `black -q --diff --exclude "src/north/snmp/src|src/north/gnmi/goldstone/north/gnmi/proto" src | wc -l`
TRANSPONDER_YANG=/tmp/test.yang $(MAKE) yang && diff /tmp/test.yang $(TRANSPONDER_YANG)
scripts/gs-yang.py --lint south-sonic south-onlp south-tai south-system xlate-oc xlate-or system-telemetry --search-dirs yang /var/lib/goldstone/yang/or sm/openconfig
scripts/gs-yang.py --lint south-gearbox south-onlp south-tai south-system xlate-oc xlate-or system-telemetry --search-dirs yang /var/lib/goldstone/yang/or sm/openconfig
grep -rnI 'print(' src || exit 0 && exit 1
unittest: unittest-lib unittest-cli unittest-gearbox unittest-dpll unittest-openconfig unittest-openroadm unittest-tai unittest-ocnos unittest-sonic unittest-gnmi unittest-telemetry
rust-unittest: unittest-netlink
clean-sysrepo:
rm -rf /dev/shm/sr* /var/lib/sysrepo
unittest-lib:
$(MAKE) clean-sysrepo
sysrepoctl --search-dirs yang --install yang/goldstone-interfaces.yang
sysrepoctl --search-dirs yang --install yang/goldstone-transponder.yang
cd src/lib && python -m unittest -v -f $(TEST_CASE)
unittest-cli:
$(MAKE) clean-sysrepo
sysrepoctl --search-dirs yang --install yang/goldstone-interfaces.yang
sysrepoctl --search-dirs yang --install yang/goldstone-synce.yang
sysrepoctl --search-dirs yang --install yang/goldstone-static-macsec.yang
sysrepoctl --search-dirs yang --install yang/goldstone-vlan.yang
sysrepoctl --search-dirs yang --install yang/goldstone-uplink-failure-detection.yang
sysrepoctl --search-dirs yang --install yang/goldstone-portchannel.yang
sysrepoctl --search-dirs yang --install yang/goldstone-transponder.yang
sysrepoctl --search-dirs yang --install yang/goldstone-system.yang
sysrepoctl --search-dirs yang --install yang/goldstone-aaa.yang
sysrepoctl --search-dirs yang --install yang/goldstone-mgmt-interfaces.yang
sysrepoctl --search-dirs yang --install yang/goldstone-ipv4.yang
cd src/north/cli && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-gearbox:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install south-gearbox --search-dirs yang
cd src/south/gearbox && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-dpll:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install south-dpll --search-dirs yang
cd src/south/dpll && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-openconfig:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install xlate-oc south-onlp south-tai south-gearbox south-system system-telemetry --search-dirs yang sm/openconfig
cd src/xlate/openconfig && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-openroadm:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install xlate-or south-onlp south-tai south-gearbox south-system --search-dirs yang /var/lib/goldstone/yang/or
cd src/xlate/openroadm && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-telemetry:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install system-telemetry south-gearbox --search-dirs yang sm/openconfig
cd src/system/telemetry && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-tai:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install south-tai --search-dirs yang
cd src/south/tai && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-sonic:
$(MAKE) clean-sysrepo
cd src/south/sonic && make proto
scripts/gs-yang.py --install south-sonic --search-dirs yang
cd src/south/sonic && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
cd src/south/sonic && make clean
unittest-ocnos:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install south-ocnos --search-dirs yang --search-dirs yang sm/openconfig
cd src/south/ocnos && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
unittest-netlink:
$(MAKE) clean-sysrepo
scripts/gs-yang.py --install south-netlink --search-dirs yang
cd src/south/netlink && cargo test -- --nocapture
unittest-gnmi:
$(MAKE) clean-sysrepo
cd src/north/gnmi && make proto
scripts/gs-yang.py --install xlate-oc system-telemetry --search-dirs yang sm/openconfig
cd src/north/gnmi && PYTHONPATH=../../lib python -m unittest -v -f $(TEST_CASE)
cd src/north/gnmi && make clean