Zsolt Haraszti | dafefe1 | 2016-11-14 21:29:58 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | """ |
| 3 | Write adapter data without any custom fields |
| 4 | """ |
| 5 | import sys |
| 6 | |
| 7 | import ext2_pb2 |
| 8 | from voltha.protos import adapter_pb2 |
| 9 | from google.protobuf import any_pb2 |
| 10 | |
| 11 | |
| 12 | def custom_config(): |
| 13 | any = any_pb2.Any() |
| 14 | any.Pack(ext2_pb2.AdapterConfig( |
| 15 | conf1=1, |
| 16 | conf2=42, |
| 17 | conf3=0, |
| 18 | conf4=11111111111, |
| 19 | conf5=11231231, |
| 20 | things = ['foo', 'bar', 'baz', 'zoo'] |
| 21 | )) |
| 22 | return any |
| 23 | |
| 24 | |
| 25 | def custom_description(): |
| 26 | any = any_pb2.Any() |
| 27 | any.Pack(ext2_pb2.AdapterDescription( |
| 28 | foo='hulu', |
| 29 | arg1=42, |
| 30 | arg2=42, |
| 31 | arg3=42, |
| 32 | arg4=42, |
| 33 | arg5=42 |
| 34 | )) |
| 35 | return any |
| 36 | |
| 37 | |
| 38 | adapter = adapter_pb2.Adapter( |
| 39 | id='42', |
| 40 | config=adapter_pb2.AdapterConfig( |
| 41 | additional_config=custom_config() |
| 42 | ), |
| 43 | additional_description=custom_description() |
| 44 | ) |
| 45 | |
| 46 | sys.stdout.write(adapter.SerializeToString()) |
| 47 | |