Skip to content

Commit 4fd5dd3

Browse files
author
Dean Troyer
committed
Add a simple extension hook
This enables stand-alone modules to hook in to the command-line handler in a dedicated API namespace. These extensions have access to the existing clients via the client manager but no way to add another client to the manager is provided.. blueprint client-extensions Change-Id: I4b2eaa780d8ba881db23d950d09b8702e9e314ef
1 parent 6fae83b commit 4fd5dd3

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎openstackclient/shell.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ def initialize_app(self, argv):
298298
super(OpenStackShell, self).initialize_app(argv)
299299

300300
# stash selected API versions for later
301-
# TODO(dtroyer): how do extenstions add their version requirements?
302301
self.api_version = {
303302
'compute': self.options.os_compute_api_version,
304303
'identity': self.options.os_identity_api_version,
@@ -312,6 +311,19 @@ def initialize_app(self, argv):
312311
self.command_manager.add_command_group(
313312
'openstack.' + api + version)
314313

314+
# This is the naive extension implementation referred to in
315+
# blueprint 'client-extensions'
316+
# Extension modules can register their commands in an
317+
# 'openstack.extension' entry point group:
318+
# entry_points={
319+
# 'openstack.extension': [
320+
# 'list_repo=qaz.github.repo:ListRepo',
321+
# 'show_repo=qaz.github.repo:ShowRepo',
322+
# ],
323+
# }
324+
self.command_manager.add_command_group(
325+
'openstack.extension')
326+
315327
# Handle deferred help and exit
316328
if self.options.deferred_help:
317329
self.DeferredHelpAction(self.parser, self.parser, None, None)

0 commit comments

Comments
 (0)