Brinda Santh | a5ceb24 | 2019-10-22 20:47:12 -0400 | [diff] [blame] | 1 | # Copyright © 2018-2019 AT&T Intellectual Property. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 16 | # you may not use this file except in compliance with the License. |
| 17 | # You may obtain a copy of the License at |
| 18 | # |
| 19 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 20 | # |
| 21 | # Unless required by applicable law or agreed to in writing, software |
| 22 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 23 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 | # See the License for the specific language governing permissions and |
| 25 | # limitations under the License. |
| 26 | |
| 27 | import grpc |
Marek Szwalkiewicz | be4c464 | 2020-01-30 13:49:18 +0000 | [diff] [blame] | 28 | from proto.BluePrintCommon_pb2 import ActionIdentifiers, CommonHeader |
| 29 | from proto.BluePrintProcessing_pb2 import ExecutionServiceInput |
| 30 | from proto.BluePrintProcessing_pb2_grpc import BluePrintProcessingServiceStub |
Brinda Santh | a5ceb24 | 2019-10-22 20:47:12 -0400 | [diff] [blame] | 31 | |
| 32 | |
| 33 | def generate_messages(): |
| 34 | commonHeader = CommonHeader() |
| 35 | commonHeader.requestId = "1234" |
| 36 | commonHeader.subRequestId = "1234-1" |
| 37 | commonHeader.originatorId = "CDS" |
| 38 | |
| 39 | actionIdentifiers = ActionIdentifiers() |
| 40 | actionIdentifiers.blueprintName = "sample-cba" |
| 41 | actionIdentifiers.blueprintVersion = "1.0.0" |
| 42 | actionIdentifiers.actionName = "SampleScript" |
| 43 | |
| 44 | input = ExecutionServiceInput(commonHeader=commonHeader, actionIdentifiers=actionIdentifiers) |
| 45 | |
| 46 | commonHeader2 = CommonHeader() |
| 47 | commonHeader2.requestId = "1235" |
| 48 | commonHeader2.subRequestId = "1234-2" |
| 49 | commonHeader2.originatorId = "CDS" |
| 50 | input2 = ExecutionServiceInput(commonHeader=commonHeader2, actionIdentifiers=actionIdentifiers) |
| 51 | |
| 52 | inputs = [input, input2] |
| 53 | for input in inputs: |
| 54 | print(input) |
| 55 | yield input |
| 56 | |
| 57 | |
| 58 | if __name__ == '__main__': |
| 59 | with open('py-executor-chain.pem', 'rb') as f: |
| 60 | creds = grpc.ssl_channel_credentials(f.read()) |
| 61 | channel = grpc.secure_channel('localhost:50052', creds) |
| 62 | stub = BluePrintProcessingServiceStub(channel) |
| 63 | |
| 64 | messages = generate_messages() |
| 65 | responses = stub.process(messages) |
| 66 | for response in responses: |
| 67 | print(response) |