Merge "Permit use of tuple API_VERSIONS"
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -21,13 +20,11 @@ from openstackclient.i18n import _
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# global variables used when building the shell
|
||||||
DEFAULT_API_VERSION = '2.1'
|
DEFAULT_API_VERSION = '2.1'
|
||||||
API_VERSION_OPTION = 'os_compute_api_version'
|
API_VERSION_OPTION = 'os_compute_api_version'
|
||||||
API_NAME = 'compute'
|
API_NAME = 'compute'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = ('2', '2.1')
|
||||||
'2': 'openstack.connection.Connection',
|
|
||||||
'2.1': 'openstack.connection.Connection',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -20,9 +19,9 @@ from osc_lib import utils
|
|||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# global variables used when building the shell
|
||||||
DEFAULT_API_VERSION = '3'
|
DEFAULT_API_VERSION = '3'
|
||||||
API_VERSION_OPTION = 'os_identity_api_version'
|
API_VERSION_OPTION = 'os_identity_api_version'
|
||||||
API_NAME = 'identity'
|
API_NAME = 'identity'
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -21,13 +20,11 @@ from openstackclient.i18n import _
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# global variables used when building the shell
|
||||||
DEFAULT_API_VERSION = '2'
|
DEFAULT_API_VERSION = '2'
|
||||||
API_VERSION_OPTION = 'os_image_api_version'
|
API_VERSION_OPTION = 'os_image_api_version'
|
||||||
API_NAME = 'image'
|
API_NAME = 'image'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = ('1', '2')
|
||||||
'1': 'openstack.connection.Connection',
|
|
||||||
'2': 'openstack.connection.Connection',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -17,16 +16,13 @@ from osc_lib import utils
|
|||||||
|
|
||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# global variables used when building the shell
|
||||||
DEFAULT_API_VERSION = '2.0'
|
DEFAULT_API_VERSION = '2.0'
|
||||||
API_VERSION_OPTION = 'os_network_api_version'
|
API_VERSION_OPTION = 'os_network_api_version'
|
||||||
API_NAME = "network"
|
API_NAME = 'network'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = ('2.0', '2')
|
||||||
"2.0": "openstack.connection.Connection",
|
|
||||||
"2": "openstack.connection.Connection",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
|
@@ -19,12 +19,11 @@ from osc_lib import utils
|
|||||||
|
|
||||||
from openstackclient.api import object_store_v1
|
from openstackclient.api import object_store_v1
|
||||||
|
|
||||||
|
# global variables used when building the shell
|
||||||
DEFAULT_API_VERSION = '1'
|
DEFAULT_API_VERSION = '1'
|
||||||
API_VERSION_OPTION = 'os_object_api_version'
|
API_VERSION_OPTION = 'os_object_api_version'
|
||||||
API_NAME = 'object_store'
|
API_NAME = 'object_store'
|
||||||
API_VERSIONS = {
|
API_VERSIONS = ('1',)
|
||||||
'1': 'openstackclient.object.client.ObjectClientv1',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def make_client(instance):
|
def make_client(instance):
|
||||||
|
@@ -88,17 +88,34 @@ class OpenStackShell(shell.OpenStackShell):
|
|||||||
# this throws an exception if invalid
|
# this throws an exception if invalid
|
||||||
skip_old_check = mod_check_api_version(version_opt)
|
skip_old_check = mod_check_api_version(version_opt)
|
||||||
|
|
||||||
|
# NOTE(stephenfin): API_VERSIONS has traditionally been a
|
||||||
|
# dictionary but the values are only used internally and are
|
||||||
|
# ignored for the modules using SDK. So we now support tuples
|
||||||
|
# instead.
|
||||||
mod_versions = getattr(mod, 'API_VERSIONS', None)
|
mod_versions = getattr(mod, 'API_VERSIONS', None)
|
||||||
if not skip_old_check and mod_versions:
|
if mod_versions is not None and not isinstance(
|
||||||
|
mod_versions, (dict, tuple)
|
||||||
|
):
|
||||||
|
raise TypeError(
|
||||||
|
f'Plugin {mod} has incompatible API_VERSIONS. '
|
||||||
|
f'Expected: tuple, dict. Got: {type(mod_versions)}. '
|
||||||
|
f'Please report this to your package maintainer.'
|
||||||
|
)
|
||||||
|
|
||||||
|
if mod_versions and not skip_old_check:
|
||||||
if version_opt not in mod_versions:
|
if version_opt not in mod_versions:
|
||||||
sorted_versions = sorted(
|
sorted_versions = sorted(
|
||||||
mod.API_VERSIONS.keys(),
|
list(mod.API_VERSIONS),
|
||||||
key=lambda s: list(map(int, s.split('.'))),
|
key=lambda s: list(map(int, s.split('.'))),
|
||||||
)
|
)
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"{} version {} is not in supported versions: {}".format(
|
"%(name)s API version %(version)s is not in "
|
||||||
api, version_opt, ', '.join(sorted_versions)
|
"supported versions: %(supported)s",
|
||||||
)
|
{
|
||||||
|
'name': api,
|
||||||
|
'version': version_opt,
|
||||||
|
'supported': ', '.join(sorted_versions),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
# Command groups deal only with major versions
|
# Command groups deal only with major versions
|
||||||
|
Reference in New Issue
Block a user