blob: 482bcbdd330f4c3c8d8fc8db8b41558afe712122 [file] [log] [blame]
Brinda Santha5ceb242019-10-22 20:47:12 -04001# 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
27import grpc
Jozsef Csongvaidaab14b2021-07-26 12:00:59 -040028from proto.BluePrintCommon_pb2 import ActionIdentifiers, CommonHeader
29from proto.BluePrintProcessing_pb2 import ExecutionServiceInput
30from proto.BluePrintProcessing_pb2_grpc import BluePrintProcessingServiceStub
Brinda Santha5ceb242019-10-22 20:47:12 -040031
32
33def 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
58if __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)
Jozsef Csongvaidaab14b2021-07-26 12:00:59 -040062 stub = BluePrintProcessingServiceStub(channel)
Brinda Santha5ceb242019-10-22 20:47:12 -040063
64 messages = generate_messages()
65 responses = stub.process(messages)
66 for response in responses:
67 print(response)