mirror of
https://github.com/OpenKMIP/PyKMIP.git
synced 2025-05-31 04:00:07 +02:00
demos: 'versions' argument for 'discover-versions' demo
This commit is contained in:
parent
7b472b752b
commit
ecca9552d3
@ -16,6 +16,8 @@
|
|||||||
from kmip.core.enums import Operation
|
from kmip.core.enums import Operation
|
||||||
from kmip.core.enums import ResultStatus
|
from kmip.core.enums import ResultStatus
|
||||||
|
|
||||||
|
from kmip.core.messages.contents import ProtocolVersion
|
||||||
|
|
||||||
from kmip.demos import utils
|
from kmip.demos import utils
|
||||||
|
|
||||||
from kmip.services.kmip_client import KMIPProxy
|
from kmip.services.kmip_client import KMIPProxy
|
||||||
@ -23,6 +25,7 @@ from kmip.services.kmip_client import KMIPProxy
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -34,6 +37,13 @@ if __name__ == '__main__':
|
|||||||
password = opts.password
|
password = opts.password
|
||||||
config = opts.config
|
config = opts.config
|
||||||
|
|
||||||
|
protocol_versions = list()
|
||||||
|
if opts.protocol_versions is not None:
|
||||||
|
for version in re.split(',| ', opts.protocol_versions):
|
||||||
|
mm = re.split('\.', version)
|
||||||
|
protocol_versions.append(ProtocolVersion.create(int(mm[0]),
|
||||||
|
int(mm[1])))
|
||||||
|
|
||||||
# Build and setup logging
|
# Build and setup logging
|
||||||
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
f_log = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||||
'logconfig.ini')
|
'logconfig.ini')
|
||||||
@ -44,7 +54,7 @@ if __name__ == '__main__':
|
|||||||
client = KMIPProxy(config=config)
|
client = KMIPProxy(config=config)
|
||||||
client.open()
|
client.open()
|
||||||
|
|
||||||
result = client.discover_versions()
|
result = client.discover_versions(protocol_versions=protocol_versions)
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
# Display operation results
|
# Display operation results
|
||||||
|
@ -199,6 +199,16 @@ def build_cli_parser(operation=None):
|
|||||||
help=("Type of the object to register. Supported types include: "
|
help=("Type of the object to register. Supported types include: "
|
||||||
"CERTIFICATE, PRIVATE_KEY, PUBLIC_KEY, SYMMETRIC_KEY, "
|
"CERTIFICATE, PRIVATE_KEY, PUBLIC_KEY, SYMMETRIC_KEY, "
|
||||||
"SECRET_DATA"))
|
"SECRET_DATA"))
|
||||||
|
elif operation is Operation.DISCOVER_VERSIONS:
|
||||||
|
parser.add_option(
|
||||||
|
"-v",
|
||||||
|
"--protocol-versions",
|
||||||
|
action="store",
|
||||||
|
type="str",
|
||||||
|
default=None,
|
||||||
|
dest="protocol_versions",
|
||||||
|
help=("Protocol versions supported by client. "
|
||||||
|
"ex. '1.1,1.2 1.3'"))
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user