2016-06-14 09:49:24 -05:00
|
|
|
# Copyright 2012-2013 OpenStack Foundation
|
2012-05-10 14:58:16 -05:00
|
|
|
#
|
2013-01-24 12:00:30 -06:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
2012-05-10 14:58:16 -05:00
|
|
|
#
|
2013-01-24 12:00:30 -06:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2012-05-10 14:58:16 -05:00
|
|
|
#
|
2013-01-24 12:00:30 -06:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2012-05-10 14:58:16 -05:00
|
|
|
#
|
|
|
|
|
2012-05-02 17:02:08 -04:00
|
|
|
import logging
|
|
|
|
|
2016-05-13 16:14:09 -05:00
|
|
|
from osc_lib import utils
|
2016-06-08 14:17:14 -05:00
|
|
|
|
2016-06-03 10:23:58 +08:00
|
|
|
from openstackclient.i18n import _
|
2012-05-02 17:02:08 -04:00
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
2016-09-28 16:49:59 +08:00
|
|
|
DEFAULT_API_VERSION = '2.1'
|
2013-11-20 18:02:09 -06:00
|
|
|
API_VERSION_OPTION = 'os_compute_api_version'
|
2012-05-10 16:25:31 -05:00
|
|
|
API_NAME = 'compute'
|
2015-04-13 16:21:50 -06:00
|
|
|
API_VERSIONS = {
|
2024-05-09 17:51:02 +01:00
|
|
|
'2': 'openstack.connection.Connection',
|
|
|
|
'2.1': 'openstack.connection.Connection',
|
2014-09-18 00:55:58 -05:00
|
|
|
}
|
|
|
|
|
2012-05-02 17:02:08 -04:00
|
|
|
|
|
|
|
def make_client(instance):
|
2013-01-31 13:31:41 -06:00
|
|
|
"""Returns a compute service client."""
|
2024-05-09 17:51:02 +01:00
|
|
|
LOG.debug(
|
|
|
|
'Compute client initialized using OpenStack SDK: %s',
|
|
|
|
instance.sdk_connection.compute,
|
2014-05-08 22:42:21 -05:00
|
|
|
)
|
2024-05-09 17:51:02 +01:00
|
|
|
return instance.sdk_connection.compute
|
2013-11-20 18:02:09 -06:00
|
|
|
|
|
|
|
|
|
|
|
def build_option_parser(parser):
|
|
|
|
"""Hook to add global options"""
|
|
|
|
parser.add_argument(
|
|
|
|
'--os-compute-api-version',
|
|
|
|
metavar='<compute-api-version>',
|
2015-05-08 13:14:15 -06:00
|
|
|
default=utils.env('OS_COMPUTE_API_VERSION'),
|
2024-05-09 17:51:02 +01:00
|
|
|
help=_("Compute API version, default=%s (Env: OS_COMPUTE_API_VERSION)")
|
2023-05-08 10:48:54 +01:00
|
|
|
% DEFAULT_API_VERSION,
|
2016-06-03 10:23:58 +08:00
|
|
|
)
|
2013-11-20 18:02:09 -06:00
|
|
|
return parser
|