diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2013-11-20 18:02:09 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2013-11-21 01:27:10 -0600 |
| commit | 9062811d10f2ab660ce38f9bd20be9c52daa9479 (patch) | |
| tree | d01b271b1ae7c968c1c009cd6f7dada5ef1a3a37 /openstackclient/compute/client.py | |
| parent | d45187a0c163187649e29931d21c4607379d1e73 (diff) | |
| download | python-openstackclient-9062811d10f2ab660ce38f9bd20be9c52daa9479.tar.gz | |
Expand support for command extensions
Allows client libraries to have complete access to the rest of the
OSC ClientManager. In addition, extension libraries can define
global options (for API version options/env vars) and define
versioned API entry points similar to the in-repo commands.
The changes to ClientManager exposed some issues in the existing
object api tests that needed to be cleaned up.
Change-Id: Ic9662edf34c5dd130a2f1a69d2454adefc1f8a95
Diffstat (limited to 'openstackclient/compute/client.py')
| -rw-r--r-- | openstackclient/compute/client.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py index 4d3b1b71..4ccb2f6d 100644 --- a/openstackclient/compute/client.py +++ b/openstackclient/compute/client.py @@ -19,6 +19,8 @@ from openstackclient.common import utils LOG = logging.getLogger(__name__) +DEFAULT_COMPUTE_API_VERSION = '2' +API_VERSION_OPTION = 'os_compute_api_version' API_NAME = 'compute' API_VERSIONS = { '1.1': 'novaclient.v1_1.client.Client', @@ -60,3 +62,17 @@ def make_client(instance): client.client.service_catalog = instance._service_catalog client.client.auth_token = instance._token return client + + +def build_option_parser(parser): + """Hook to add global options""" + parser.add_argument( + '--os-compute-api-version', + metavar='<compute-api-version>', + default=utils.env( + 'OS_COMPUTE_API_VERSION', + default=DEFAULT_COMPUTE_API_VERSION), + help='Compute API version, default=' + + DEFAULT_COMPUTE_API_VERSION + + ' (Env: OS_COMPUTE_API_VERSION)') + return parser |
