Skip to content
Snippets Groups Projects
Commit 4d33b6b1 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'fix/proto-issues' into 'develop'

Fix policy-related proto issues, unify in a single folder generated code for the different languages, and adapt generation scripts

See merge request teraflow-h2020/controller!124
parents f5e60f2f a9614511
No related branches found
No related tags found
1 merge request!54Release 2.0.0
src/
src/*/*
# used to prevent breaking symbolic links from source code folders
!src/*/.gitignore
!src/python/__init__.py
uml/generated
......@@ -20,9 +20,9 @@ import "policy.proto";
// created as a separate service to prevent import-loops in context and policy
service ContextPolicyService {
rpc ListPolicyRuleIds (context.Empty ) returns ( policy.PolicyRuleIdList) {}
rpc ListPolicyRules (context.Empty ) returns ( policy.PolicyRuleList ) {}
rpc GetPolicyRule (policy.PolicyRuleId) returns ( policy.PolicyRule ) {}
rpc SetPolicyRule (policy.PolicyRule ) returns ( policy.PolicyRuleId ) {}
rpc RemovePolicyRule (policy.PolicyRuleId) returns ( context.Empty ) {}
rpc ListPolicyRuleIds(context.Empty ) returns (policy.PolicyRuleIdList) {}
rpc ListPolicyRules (context.Empty ) returns (policy.PolicyRuleList ) {}
rpc GetPolicyRule (policy.PolicyRuleId ) returns (policy.PolicyRuleBasic ) {}
rpc SetPolicyRule (policy.PolicyRuleBasic) returns (policy.PolicyRuleId ) {}
rpc RemovePolicyRule (policy.PolicyRuleId ) returns (context.Empty ) {}
}
#!/bin/bash -eu
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
# Make folder containing the script the root folder for its execution
cd $(dirname $0)
mkdir -p src/python
rm -rf src/python/*.py
tee src/python/__init__.py << EOF > /dev/null
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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
# Generate Python code
python3 -m grpc_tools.protoc -I=./ --python_out=src/python/ --grpc_python_out=src/python/ *.proto
# Arrange generated code imports to enable imports from arbitrary subpackages
find src/python -type f -iname *.py -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \;
......@@ -13,12 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
python3 -m grpc_tools.protoc -I=./ --python_out=../src/ --grpc_python_out=../src/ *.proto
#requires installation of protoc-gen-uml
export PATH=${HOME}/protoc-gen-uml/target/universal/stage/bin:$PATH
protoc --uml_out=uml/ -I ./ *.proto
cd uml
java -jar plantuml.7997.jar *.puml
rm *.puml
......@@ -98,7 +98,7 @@ message PolicyRuleDeviceList {
repeated PolicyRuleDevice policyRuleDeviceList = 1;
}
// A list of policy rule Ids
message PolicyRuleIdList {
repeated PolicyRuleId policyRuleIds = 1;
// A list of policy rules
message PolicyRuleList {
repeated PolicyRuleId policyRules = 1;
}
*
# used to prevent breaking symbolic links from source code folders
!.gitignore
!__init__.py
*
# used to prevent breaking symbolic links from source code folders
!.gitignore
!__init__.py
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# 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.
../../proto/src/python
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment