7c7ee59026
This commit introduce the python-binding for iteracting with CRI runtime via GRPC. The client code is generated by protocol buffer [1] by using api.proto in kubernetes/cri-api repo. The generated CRI client code couldn't pass the pep8 check so this commit also configure flake8 to skip the zun/criapi directory. [1] https://developers.google.com/protocol-buffers/docs/pythontutorial Implements: blueprint add-support-cri-runtime Change-Id: I2e1a20b47fec5af1f4977148431e1135abd49812
50 lines
1.6 KiB
Bash
Executable File
50 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function add_license_header {
|
|
file=$1
|
|
license=$(mktemp)
|
|
cat << EOF > $license
|
|
# 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.
|
|
|
|
EOF
|
|
newfile=$(mktemp)
|
|
cat $license $file > $newfile
|
|
mv $newfile $file
|
|
}
|
|
|
|
ZUNROOT=${ZUNROOT:-/opt/stack/zun}
|
|
|
|
curl -o ${ZUNROOT}/zun/criapi/api.proto https://raw.githubusercontent.com/kubernetes/cri-api/master/pkg/apis/runtime/v1alpha2/api.proto
|
|
curl -o ${ZUNROOT}/zun/criapi/gogo.proto https://raw.githubusercontent.com/gogo/protobuf/master/gogoproto/gogo.proto
|
|
|
|
sed -i 's/github.com\/gogo\/protobuf\/gogoproto\/gogo.proto/zun\/criapi\/gogo.proto/' ${ZUNROOT}/zun/criapi/api.proto
|
|
|
|
python3 -m grpc_tools.protoc \
|
|
-I${ZUNROOT} \
|
|
--python_out=${ZUNROOT} \
|
|
${ZUNROOT}/zun/criapi/gogo.proto
|
|
python3 -m grpc_tools.protoc \
|
|
-I${ZUNROOT} \
|
|
--python_out=${ZUNROOT} \
|
|
--grpc_python_out=${ZUNROOT} \
|
|
${ZUNROOT}/zun/criapi/api.proto
|
|
|
|
for i in ${ZUNROOT}/zun/criapi/*.py; do
|
|
if [[ $i != *__init__.py ]]; then
|
|
add_license_header $i
|
|
fi
|
|
done
|
|
|
|
rm -f ${ZUNROOT}/zun/criapi/api.proto
|
|
rm -f ${ZUNROOT}/zun/criapi/gogo.proto
|