Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1849 support ssl to mce cli.py #1857

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions metadata-ingestion/mce-cli/kafka.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://github.com/edenhill/librdkafka/wiki/Using-SSL-with-librdkafka
# Kafka Brokers Certs
#security.protocol=ssl
ssl.ca.location=certificate_ca.pem
ssl.certificate.location=certificate.pem
ssl.key.location=private_key.pem
ssl.key.password=XXXXXXX

# Schema Registry Certs
schema.registry.ssl.ca.location=certificate_ca.pem
schema.registry.ssl.certificate.location=certificate.pem
schema.registry.ssl.key.location=private_key.pem
schema.registry.ssl.key.password=XXXXXXX

22 changes: 22 additions & 0 deletions metadata-ingestion/mce-cli/mce_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,30 @@ def consume(conf, schema_record):
c.close()


def convert_config_to_dict(file_location):
#print("converting: " + file_location)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

result = {}
f = open(file_location, "r")
fl =f.readlines()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after =

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for line in fl:
if line[0] == '#' or line == '\n':
continue
key, value = line.split("=", 1)
if value is not None:
result = {**result, **{key : value.rsplit("\n")[0]}}
else:
result = {**result, **{key : None}}
return result


def main(args):
# Handle common configs
conf = {'bootstrap.servers': args.bootstrap_servers,
'schema.registry.url': args.schema_registry}

if args.command_config is not None:
conf.update(convert_config_to_dict(args.command_config))

if args.mode == "produce":
produce(conf, args.data_file, args.schema_record)
else:
Expand All @@ -104,4 +123,7 @@ def main(args):
help="Avro schema record; required if running 'producer' mode")
parser.add_argument('-d', dest="data_file", default="bootstrap_mce.dat",
help="MCE data file; required if running 'producer' mode")
parser.add_argument('-c', dest="command_config",
default="None", help="Kafka SSL details")
main(parser.parse_args())