1 # Copyright © 2018-2019 AT&T Intellectual Property.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
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
19 # http://www.apache.org/licenses/LICENSE-2.0
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.
28 from proto.BluePrintCommon_pb2 import ActionIdentifiers, CommonHeader
29 from proto.BluePrintProcessing_pb2 import ExecutionServiceInput
30 from proto.BluePrintProcessing_pb2_grpc import BluePrintProcessingServiceStub
33 def generate_messages():
34 commonHeader = CommonHeader()
35 commonHeader.requestId = "1234"
36 commonHeader.subRequestId = "1234-1"
37 commonHeader.originatorId = "CDS"
39 actionIdentifiers = ActionIdentifiers()
40 actionIdentifiers.blueprintName = "sample-cba"
41 actionIdentifiers.blueprintVersion = "1.0.0"
42 actionIdentifiers.actionName = "SampleScript"
44 input = ExecutionServiceInput(commonHeader=commonHeader, actionIdentifiers=actionIdentifiers)
46 commonHeader2 = CommonHeader()
47 commonHeader2.requestId = "1235"
48 commonHeader2.subRequestId = "1234-2"
49 commonHeader2.originatorId = "CDS"
50 input2 = ExecutionServiceInput(commonHeader=commonHeader2, actionIdentifiers=actionIdentifiers)
52 inputs = [input, input2]
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)
64 messages = generate_messages()
65 responses = stub.process(messages)
66 for response in responses: