forked from davidcc73/p4-srv6-INT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (97 loc) · 3.87 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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
curr_dir := $(patsubst %/,%,$(dir $(mkfile_path)))
include util/docker/Makefile.vars
onos_url := http://localhost:8181/onos
onos_curl := curl --fail -sSL --user onos:rocks --noproxy localhost
app_name := app.onosproject.srv6_usid
NGSDN_TUTORIAL_SUDO ?=
default:
$(error Please specify a make target (see README.md))
_docker_pull_all:
docker pull ${ONOS_IMG}@${ONOS_SHA}
docker tag ${ONOS_IMG}@${ONOS_SHA} ${ONOS_IMG}
docker pull ${P4RT_SH_IMG}@${P4RT_SH_SHA}
docker tag ${P4RT_SH_IMG}@${P4RT_SH_SHA} ${P4RT_SH_IMG}
docker pull ${P4C_IMG}@${P4C_SHA}
docker tag ${P4C_IMG}@${P4C_SHA} ${P4C_IMG}
docker pull ${STRATUM_BMV2_IMG}@${STRATUM_BMV2_SHA}
docker tag ${STRATUM_BMV2_IMG}@${STRATUM_BMV2_SHA} ${STRATUM_BMV2_IMG}
docker pull ${MVN_IMG}@${MVN_SHA}
docker tag ${MVN_IMG}@${MVN_SHA} ${MVN_IMG}
docker pull ${GNMI_CLI_IMG}@${GNMI_CLI_SHA}
docker tag ${GNMI_CLI_IMG}@${GNMI_CLI_SHA} ${GNMI_CLI_IMG}
docker pull ${YANG_IMG}@${YANG_SHA}
docker tag ${YANG_IMG}@${YANG_SHA} ${YANG_IMG}
docker pull ${SSHPASS_IMG}@${SSHPASS_SHA}
docker tag ${SSHPASS_IMG}@${SSHPASS_SHA} ${SSHPASS_IMG}
deps: _docker_pull_all
mn-host:
docker compose exec mininet m $@
start:
$(info *** Starting ONOS and Mininet... )
@mkdir -p tmp/onos
docker compose up -d
stop:
$(info *** Stopping ONOS...)
docker compose down
restart: reset start
onos-cli:
$(info *** Connecting to the ONOS CLI... password: rocks)
$(info *** Top exit press Ctrl-D)
$(info *** WARNING: NON SECURE CONNECTION, ADDED -o HostKeyAlgorithms=ssh-rsa TO AVOID ERROR***)
@sshpass -p 'rocks' ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o HostKeyAlgorithms=ssh-rsa -o LogLevel=ERROR -p 8101 onos@localhost
onos-log:
docker compose logs -f onos
onos-ui:
open ${onos_url}/ui
mn-cli:
$(info *** Attaching to Mininet CLI...)
$(info *** To detach press Ctrl-D (Mininet will keep running))
-@docker attach --detach-keys "ctrl-d" $(shell docker compose ps -q mininet) || echo "*** Detached from Mininet CLI"
mn-log:
docker logs -f mininet
netcfg:
$(info *** Pushing netcfg.json to ONOS...)
${onos_curl} -X POST -H 'Content-Type:application/json' \
${onos_url}/v1/network/configuration -d@./config/netcfg.json
@echo
reset: stop
-$(NGSDN_TUTORIAL_SUDO) rm -rf ./tmp
clean:
-$(NGSDN_TUTORIAL_SUDO) rm -rf p4src/build
-$(NGSDN_TUTORIAL_SUDO) rm -rf app/target
-$(NGSDN_TUTORIAL_SUDO) rm -rf app/src/main/resources/bmv2.json
-$(NGSDN_TUTORIAL_SUDO) rm -rf app/src/main/resources/p4info.txt
p4-build: p4src/main.p4
$(info *** Building P4 program...)
@mkdir -p p4src/build
docker run --rm -v ${curr_dir}:/workdir -w /workdir ${P4C_IMG} \
p4c-bm2-ss --arch v1model -o p4src/build/bmv2.json -DCPU_PORT=255 \
--p4runtime-files p4src/build/p4info.txt --Wdisable=unsupported \
p4src/main.p4
@echo "*** P4 program compiled successfully! Output files are in p4src/build"
_copy_p4c_out:
$(info *** Copying p4c outputs to app resources...)
@mkdir -p app/src/main/resources
cp -f p4src/build/p4info.txt app/src/main/resources/
cp -f p4src/build/bmv2.json app/src/main/resources/
_mvn_package:
$(info *** Building ONOS app...)
@mkdir -p app/target
@docker run --rm -v ${curr_dir}/app:/mvn-src -w /mvn-src ${MVN_IMG} mvn clean package
app-build: p4-build _copy_p4c_out _mvn_package
$(info *** ONOS app .oar package created succesfully)
@ls -1 app/target/*.oar
app-install:
$(info *** Installing and activating app in ONOS...)
${onos_curl} -X POST -HContent-Type:application/octet-stream \
'${onos_url}/v1/applications?activate=true' \
--data-binary @app/target/srv6_usid-1.0-SNAPSHOT.oar
@echo
app-uninstall:
$(info *** Uninstalling app from ONOS (if present)...)
-${onos_curl} -X DELETE ${onos_url}/v1/applications/${app_name}
@echo
app-reload: app-uninstall app-install
yang-tools:
docker run --rm -it -v ${curr_dir}/yang/demo-port.yang:/models/demo-port.yang ${YANG_IMG}