"Fossies" - the Fresh Open Source Software Archive

Member "cinder-14.0.2/cinder/api/microversions.py" (4 Oct 2019, 4644 Bytes) of package /linux/misc/openstack/cinder-14.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "microversions.py" see the Fossies "Dox" file reference documentation.

    1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 #    not use this file except in compliance with the License. You may obtain
    3 #    a copy of the License at
    4 #
    5 #         http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 #    Unless required by applicable law or agreed to in writing, software
    8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 #    License for the specific language governing permissions and limitations
   11 #    under the License.
   12 
   13 """API Microversion definitions.
   14 
   15 All new microversions should have a constant added here to be used throughout
   16 the code instead of the specific version number. Until patches land, it's
   17 common to end up with merge conflicts with other microversion changes. Merge
   18 conflicts will be easier to handle via the microversion constants defined here
   19 as the version number will only need to be changed in a single location.
   20 
   21 Actual version numbers should be used:
   22 
   23   * In this file
   24   * In cinder/api/openstack/rest_api_version_history.rst
   25   * In cinder/api/openstack/api_version_request.py
   26   * In release notes describing the new functionality
   27   * In updates to api-ref
   28 
   29 Nearly all microversion changes should include changes to all of those
   30 locations. Make sure to add relevant documentation, and make sure that
   31 documentation includes the final version number used.
   32 """
   33 
   34 from cinder.api.openstack import api_version_request as api_version
   35 from cinder import exception
   36 
   37 
   38 # Add new constants here for each new microversion.
   39 
   40 V2_BASE_VERSION = '2.0'
   41 
   42 BASE_VERSION = '3.0'
   43 
   44 UPLOAD_IMAGE_PARAMS = '3.1'
   45 
   46 VOLUME_LIST_BOOTABLE = '3.2'
   47 
   48 MESSAGES = '3.3'
   49 
   50 VOLUME_LIST_GLANCE_METADATA = '3.4'
   51 
   52 MESSAGES_PAGINATION = '3.5'
   53 
   54 CG_UPDATE_BLANK_PROPERTIES = '3.6'
   55 
   56 CLUSTER_SUPPORT = '3.7'
   57 
   58 MANAGE_EXISTING_LIST = '3.8'
   59 
   60 BACKUP_UPDATE = '3.9'
   61 
   62 VOLUME_LIST_GROUP = '3.10'
   63 
   64 GROUP_TYPE = '3.11'
   65 
   66 VOLUME_SUMMARY = '3.12'
   67 
   68 GROUP_VOLUME = '3.13'
   69 
   70 GROUP_SNAPSHOTS = '3.14'
   71 
   72 ETAGS = '3.15'
   73 
   74 VOLUME_MIGRATE_CLUSTER = '3.16'
   75 
   76 MANAGE_EXISTING_CLUSTER = '3.17'
   77 
   78 BACKUP_PROJECT = '3.18'
   79 
   80 GROUP_SNAPSHOT_RESET_STATUS = '3.19'
   81 
   82 GROUP_VOLUME_RESET_STATUS = '3.20'
   83 
   84 VOLUME_DETAIL_PROVIDER_ID = '3.21'
   85 
   86 SNAPSHOT_LIST_METADATA_FILTER = '3.22'
   87 
   88 VOLUME_DELETE_FORCE = '3.23'
   89 
   90 WORKERS_CLEANUP = '3.24'
   91 
   92 GROUP_VOLUME_LIST = '3.25'
   93 
   94 REPLICATION_CLUSTER = '3.26'
   95 
   96 NEW_ATTACH = '3.27'
   97 
   98 POOL_FILTER = '3.28'
   99 
  100 GROUP_SNAPSHOT_PAGINATION = '3.29'
  101 
  102 SNAPSHOT_SORT = '3.30'
  103 
  104 RESOURCE_FILTER = '3.31'
  105 
  106 LOG_LEVEL = '3.32'
  107 
  108 RESOURCE_FILTER_CONFIG = '3.33'
  109 
  110 LIKE_FILTER = '3.34'
  111 
  112 POOL_TYPE_FILTER = '3.35'
  113 
  114 VOLUME_SUMMARY_METADATA = '3.36'
  115 
  116 BACKUP_SORT_NAME = '3.37'
  117 
  118 GROUP_REPLICATION = '3.38'
  119 
  120 LIMITS_ADMIN_FILTER = '3.39'
  121 
  122 VOLUME_REVERT = '3.40'
  123 
  124 SNAPSHOT_LIST_USER_ID = '3.41'
  125 
  126 VOLUME_EXTEND_INUSE = '3.42'
  127 
  128 BACKUP_METADATA = '3.43'
  129 
  130 NEW_ATTACH_COMPLETION = '3.44'
  131 
  132 SUPPORT_COUNT_INFO = '3.45'
  133 
  134 SUPPORT_NOVA_IMAGE = '3.46'
  135 
  136 VOLUME_CREATE_FROM_BACKUP = '3.47'
  137 
  138 VOLUME_SHARED_TARGETS_AND_SERVICE_FIELDS = '3.48'
  139 
  140 BACKEND_STATE_REPORT = '3.49'
  141 
  142 MULTIATTACH_VOLUMES = '3.50'
  143 
  144 BACKUP_AZ = '3.51'
  145 
  146 SUPPORT_VOLUME_TYPE_FILTER = '3.52'
  147 
  148 SUPPORT_VOLUME_SCHEMA_CHANGES = '3.53'
  149 
  150 ATTACHMENT_CREATE_MODE_ARG = '3.54'
  151 
  152 TRANSFER_WITH_SNAPSHOTS = '3.55'
  153 
  154 BACKUP_PROJECT_USER_ID = '3.56'
  155 
  156 TRANSFER_WITH_HISTORY = '3.57'
  157 
  158 GROUP_GROUPSNAPSHOT_PROJECT_ID = '3.58'
  159 
  160 SUPPORT_TRANSFER_PAGINATION = '3.59'
  161 
  162 
  163 def get_mv_header(version):
  164     """Gets a formatted HTTP microversion header.
  165 
  166     :param version: The microversion needed.
  167     :return: A tuple containing the microversion header with the
  168              requested version value.
  169     """
  170     return {'OpenStack-API-Version':
  171             'volume %s' % version}
  172 
  173 
  174 def get_api_version(version):
  175     """Gets a ``APIVersionRequest`` instance.
  176 
  177     :param version: The microversion needed.
  178     :return: The ``APIVersionRequest`` instance.
  179     """
  180     return api_version.APIVersionRequest(version)
  181 
  182 
  183 def get_prior_version(version):
  184     """Gets the microversion before the given version.
  185 
  186     Mostly useful for testing boundaries. This gets the microversion defined
  187     just prior to the given version.
  188 
  189     :param version: The version of interest.
  190     :return: The version just prior to the given version.
  191     """
  192     parts = version.split('.')
  193 
  194     if len(parts) != 2 or parts[0] != '3':
  195         raise exception.InvalidInput(reason='Version %s is not a valid '
  196                                      'microversion format.' % version)
  197 
  198     minor = int(parts[1]) - 1
  199 
  200     if minor < 0:
  201         # What's your problem? Are you trying to be difficult?
  202         minor = 0
  203 
  204     return '%s.%s' % (parts[0], minor)