-
Notifications
You must be signed in to change notification settings - Fork 74
/
generate_bundles.sh
executable file
·125 lines (110 loc) · 4.15 KB
/
generate_bundles.sh
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
#!/bin/bash
# ----------------------------------------------------------------
# Copyright 2018 Cisco Systems
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------
#
# generate-bundles.sh script designed to generate YDK bundles
# for the lates versions of cisco devices YANG models
#
# ------------------------------------------------------------------
######################################################################
# Utility functions
######################################################################
function print_msg {
echo -e "${MSG_COLOR}*** $(date): generate-bundles.sh | $@ ${NOCOLOR}"
}
function run_cmd {
print_msg "Running command: $@"
$@
local status=$?
if [[ ${status} -ne 0 ]]; then
MSG_COLOR=$RED
print_msg "Exiting '$@' with status=${status}"
exit ${status}
fi
return ${status}
}
########################## EXECUTION STARTS HERE #############################
#
# Terminal colors
RED="\033[0;31m"
NOCOLOR="\033[0m"
YELLOW='\033[1;33m'
MSG_COLOR=${YELLOW}
######################################
# Set up env
os_type=$(uname)
print_msg "Running OS type: $os_type"
export YDKGEN_HOME="$(pwd)"
args=$(getopt p:d $*)
set -- $args
PYTHON_VERSION=${2}
PYTHON_BIN=python${PYTHON_VERSION}
if [[ ${PYTHON_VERSION} = "2"* ]]; then
PIP_BIN=pip
elif [[ ${PYTHON_VERSION} = "3.5"* ]]; then
PIP_BIN=pip3
else
PIP_BIN=pip${PYTHON_VERSION}
fi
print_msg "Checking installation of ${PYTHON_BIN}"
${PYTHON_BIN} -V
status=$?
if [[ ${status} -ne 0 ]]; then
print_msg "Could not locate ${PYTHON_BIN}"
exit ${status}
fi
print_msg "Checking installation of ${PIP_BIN}"
${PIP_BIN} -V
status=$?
if [[ ${status} -ne 0 ]]; then
print_msg "Could not locate ${PIP_BIN}"
exit ${status}
fi
print_msg "Python location: $(which ${PYTHON_BIN})"
print_msg "Pip location: $(which ${PIP_BIN})"
CMAKE_BIN=cmake
which cmake3
status=$?
if [[ ${status} == 0 ]] ; then
CMAKE_BIN=cmake3
fi
print_msg "Generating Python core and bundles"
run_cmd rm -rf gen-api/python
run_cmd ./generate.py --core --generate-doc
run_cmd ./generate.py --service profiles/services/gnmi-0.4.0.json
run_cmd ./generate.py --bundle profiles/bundles/ietf_0_1_5_post2.json
run_cmd ./generate.py --bundle profiles/bundles/openconfig_0_1_6_post1.json
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xe_16_9_3.json
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xr_6_5_3.json
run_cmd ./generate.py --bundle profiles/bundles/cisco-nx-os-9_3_1.json
print_msg "Generating C++ core and bundles"
run_cmd rm -rf gen-api/cpp
run_cmd ./generate.py --core --cpp --generate-doc
run_cmd ./generate.py --service profiles/services/gnmi-0.4.0.json --cpp
run_cmd ./generate.py --bundle profiles/bundles/ietf_0_1_5_post2.json --cpp
run_cmd ./generate.py --bundle profiles/bundles/openconfig_0_1_6_post1.json --cpp
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xe_16_9_3.json --cpp
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xr_6_5_3.json --cpp
run_cmd ./generate.py --bundle profiles/bundles/cisco-nx-os-9_3_1.json --cpp
print_msg "Generating Go core and bundles"
run_cmd rm -rf gen-api/go
run_cmd ./generate.py --core --go --generate-doc
run_cmd ./generate.py --service profiles/services/gnmi-0.4.0.json --go
run_cmd ./generate.py --bundle profiles/bundles/ietf_0_1_5_post2.json --go
run_cmd ./generate.py --bundle profiles/bundles/openconfig_0_1_6_post1.json --go
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xe_16_9_3.json --go
run_cmd ./generate.py --bundle profiles/bundles/cisco-ios-xr_6_5_3.json --go
run_cmd ./generate.py --bundle profiles/bundles/cisco-nx-os-9_3_1.json --go