Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 2 | |
| 3 | # Copyright 2013 IBM Corp. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 17 | import argparse |
Matthew Treinish | 4f30eb8 | 2014-01-07 21:04:49 +0000 | [diff] [blame] | 18 | import json |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 19 | import os |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 20 | import sys |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 21 | import urlparse |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 22 | |
Matthew Treinish | 4f30eb8 | 2014-01-07 21:04:49 +0000 | [diff] [blame] | 23 | import httplib2 |
Matthew Treinish | c795b9e | 2014-06-09 17:01:10 -0400 | [diff] [blame] | 24 | from six import moves |
Matthew Treinish | 4f30eb8 | 2014-01-07 21:04:49 +0000 | [diff] [blame] | 25 | |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 26 | from tempest import clients |
| 27 | from tempest import config |
| 28 | |
| 29 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 30 | CONF = config.CONF |
Matthew Treinish | 4f30eb8 | 2014-01-07 21:04:49 +0000 | [diff] [blame] | 31 | RAW_HTTP = httplib2.Http() |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 32 | CONF_PARSER = None |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 33 | |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 34 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 35 | def _get_config_file(): |
| 36 | default_config_dir = os.path.join(os.path.abspath( |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 37 | os.path.dirname(os.path.dirname(os.path.dirname(__file__)))), "etc") |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 38 | default_config_file = "tempest.conf" |
| 39 | |
| 40 | conf_dir = os.environ.get('TEMPEST_CONFIG_DIR', default_config_dir) |
| 41 | conf_file = os.environ.get('TEMPEST_CONFIG', default_config_file) |
| 42 | path = os.path.join(conf_dir, conf_file) |
| 43 | fd = open(path, 'rw') |
| 44 | return fd |
| 45 | |
| 46 | |
| 47 | def change_option(option, group, value): |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 48 | if not CONF_PARSER.has_section(group): |
| 49 | CONF_PARSER.add_section(group) |
| 50 | CONF_PARSER.set(group, option, str(value)) |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | def print_and_or_update(option, group, value, update): |
| 54 | print('Config option %s in group %s should be changed to: %s' |
| 55 | % (option, group, value)) |
| 56 | if update: |
| 57 | change_option(option, group, value) |
| 58 | |
| 59 | |
| 60 | def verify_glance_api_versions(os, update): |
Matthew Treinish | 99afd07 | 2013-10-22 18:03:06 +0000 | [diff] [blame] | 61 | # Check glance api versions |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 62 | versions = os.image_client.get_versions() |
Matthew Treinish | 99afd07 | 2013-10-22 18:03:06 +0000 | [diff] [blame] | 63 | if CONF.image_feature_enabled.api_v1 != ('v1.1' in versions or 'v1.0' in |
| 64 | versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 65 | print_and_or_update('api_v1', 'image_feature_enabled', |
| 66 | not CONF.image_feature_enabled.api_v1, update) |
Matthew Treinish | 99afd07 | 2013-10-22 18:03:06 +0000 | [diff] [blame] | 67 | if CONF.image_feature_enabled.api_v2 != ('v2.0' in versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 68 | print_and_or_update('api_v2', 'image_feature_enabled', |
| 69 | not CONF.image_feature_enabled.api_v2, update) |
Matthew Treinish | 99afd07 | 2013-10-22 18:03:06 +0000 | [diff] [blame] | 70 | |
| 71 | |
Matthew Treinish | 9b89624 | 2014-04-23 21:25:27 +0000 | [diff] [blame] | 72 | def _get_unversioned_endpoint(base_url): |
| 73 | endpoint_parts = urlparse.urlparse(base_url) |
| 74 | endpoint = endpoint_parts.scheme + '://' + endpoint_parts.netloc |
| 75 | return endpoint |
| 76 | |
| 77 | |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 78 | def _get_api_versions(os, service): |
| 79 | client_dict = { |
| 80 | 'nova': os.servers_client, |
| 81 | 'keystone': os.identity_client, |
Matthew Treinish | 2e43963 | 2014-03-05 21:53:33 +0000 | [diff] [blame] | 82 | 'cinder': os.volumes_client, |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 83 | } |
| 84 | client_dict[service].skip_path() |
Matthew Treinish | 9b89624 | 2014-04-23 21:25:27 +0000 | [diff] [blame] | 85 | endpoint = _get_unversioned_endpoint(client_dict[service].base_url) |
Matthew Treinish | a508081 | 2014-02-11 15:49:04 +0000 | [diff] [blame] | 86 | __, body = RAW_HTTP.request(endpoint, 'GET') |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 87 | client_dict[service].reset_path() |
Matthew Treinish | 4f30eb8 | 2014-01-07 21:04:49 +0000 | [diff] [blame] | 88 | body = json.loads(body) |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 89 | if service == 'keystone': |
| 90 | versions = map(lambda x: x['id'], body['versions']['values']) |
| 91 | else: |
| 92 | versions = map(lambda x: x['id'], body['versions']) |
| 93 | return versions |
| 94 | |
| 95 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 96 | def verify_keystone_api_versions(os, update): |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 97 | # Check keystone api versions |
| 98 | versions = _get_api_versions(os, 'keystone') |
| 99 | if CONF.identity_feature_enabled.api_v2 != ('v2.0' in versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 100 | print_and_or_update('api_v2', 'identity_feature_enabled', |
| 101 | not CONF.identity_feature_enabled.api_v2, update) |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 102 | if CONF.identity_feature_enabled.api_v3 != ('v3.0' in versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 103 | print_and_or_update('api_v3', 'identity_feature_enabled', |
| 104 | not CONF.identity_feature_enabled.api_v3, update) |
Matthew Treinish | 864fe07 | 2014-03-02 03:47:26 +0000 | [diff] [blame] | 105 | |
| 106 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 107 | def verify_cinder_api_versions(os, update): |
Matthew Treinish | 2e43963 | 2014-03-05 21:53:33 +0000 | [diff] [blame] | 108 | # Check cinder api versions |
| 109 | versions = _get_api_versions(os, 'cinder') |
| 110 | if CONF.volume_feature_enabled.api_v1 != ('v1.0' in versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 111 | print_and_or_update('api_v1', 'volume_feature_enabled', |
| 112 | not CONF.volume_feature_enabled.api_v1, update) |
Matthew Treinish | 2e43963 | 2014-03-05 21:53:33 +0000 | [diff] [blame] | 113 | if CONF.volume_feature_enabled.api_v2 != ('v2.0' in versions): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 114 | print_and_or_update('api_v2', 'volume_feature_enabled', |
| 115 | not CONF.volume_feature_enabled.api_v2, update) |
Matthew Treinish | 2e43963 | 2014-03-05 21:53:33 +0000 | [diff] [blame] | 116 | |
| 117 | |
Adam Gandelman | 03af556 | 2014-10-07 12:22:48 -0700 | [diff] [blame] | 118 | def verify_api_versions(os, service, update): |
| 119 | verify = { |
| 120 | 'cinder': verify_cinder_api_versions, |
| 121 | 'glance': verify_glance_api_versions, |
| 122 | 'keystone': verify_keystone_api_versions, |
Adam Gandelman | 03af556 | 2014-10-07 12:22:48 -0700 | [diff] [blame] | 123 | } |
| 124 | if service not in verify: |
| 125 | return |
| 126 | verify[service](os, update) |
| 127 | |
| 128 | |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 129 | def get_extension_client(os, service): |
| 130 | extensions_client = { |
| 131 | 'nova': os.extensions_client, |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 132 | 'cinder': os.volumes_extension_client, |
Matthew Treinish | 8c6706d | 2014-01-07 19:28:18 +0000 | [diff] [blame] | 133 | 'neutron': os.network_client, |
Matthew Treinish | c0120ba | 2014-01-31 20:10:19 +0000 | [diff] [blame] | 134 | 'swift': os.account_client, |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 135 | } |
| 136 | if service not in extensions_client: |
| 137 | print('No tempest extensions client for %s' % service) |
| 138 | exit(1) |
| 139 | return extensions_client[service] |
| 140 | |
| 141 | |
| 142 | def get_enabled_extensions(service): |
| 143 | extensions_options = { |
| 144 | 'nova': CONF.compute_feature_enabled.api_extensions, |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 145 | 'cinder': CONF.volume_feature_enabled.api_extensions, |
Matthew Treinish | 8c6706d | 2014-01-07 19:28:18 +0000 | [diff] [blame] | 146 | 'neutron': CONF.network_feature_enabled.api_extensions, |
Matthew Treinish | c0120ba | 2014-01-31 20:10:19 +0000 | [diff] [blame] | 147 | 'swift': CONF.object_storage_feature_enabled.discoverable_apis, |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 148 | } |
| 149 | if service not in extensions_options: |
| 150 | print('No supported extensions list option for %s' % service) |
| 151 | exit(1) |
| 152 | return extensions_options[service] |
| 153 | |
| 154 | |
| 155 | def verify_extensions(os, service, results): |
| 156 | extensions_client = get_extension_client(os, service) |
David Kranz | 5cf4ba4 | 2015-02-10 14:00:50 -0500 | [diff] [blame^] | 157 | if service != 'swift': |
David Kranz | 34e8812 | 2014-12-11 15:24:05 -0500 | [diff] [blame] | 158 | resp = extensions_client.list_extensions() |
| 159 | else: |
| 160 | __, resp = extensions_client.list_extensions() |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 161 | # For Nova, Cinder and Neutron we use the alias name rather than the |
| 162 | # 'name' field because the alias is considered to be the canonical |
| 163 | # name. |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 164 | if isinstance(resp, dict): |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 165 | if service == 'swift': |
Matthew Treinish | c0120ba | 2014-01-31 20:10:19 +0000 | [diff] [blame] | 166 | # Remove Swift general information from extensions list |
| 167 | resp.pop('swift') |
| 168 | extensions = resp.keys() |
Matthew Treinish | 8c6706d | 2014-01-07 19:28:18 +0000 | [diff] [blame] | 169 | else: |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 170 | extensions = map(lambda x: x['alias'], resp['extensions']) |
Matthew Treinish | 8c6706d | 2014-01-07 19:28:18 +0000 | [diff] [blame] | 171 | |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 172 | else: |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 173 | extensions = map(lambda x: x['alias'], resp) |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 174 | if not results.get(service): |
| 175 | results[service] = {} |
| 176 | extensions_opt = get_enabled_extensions(service) |
| 177 | if extensions_opt[0] == 'all': |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 178 | results[service]['extensions'] = extensions |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 179 | return results |
| 180 | # Verify that all configured extensions are actually enabled |
| 181 | for extension in extensions_opt: |
| 182 | results[service][extension] = extension in extensions |
| 183 | # Verify that there aren't additional extensions enabled that aren't |
| 184 | # specified in the config list |
| 185 | for extension in extensions: |
| 186 | if extension not in extensions_opt: |
| 187 | results[service][extension] = False |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 188 | return results |
| 189 | |
| 190 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 191 | def display_results(results, update, replace): |
| 192 | update_dict = { |
| 193 | 'swift': 'object-storage-feature-enabled', |
| 194 | 'nova': 'compute-feature-enabled', |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 195 | 'cinder': 'volume-feature-enabled', |
| 196 | 'neutron': 'network-feature-enabled', |
| 197 | } |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 198 | for service in results: |
| 199 | # If all extensions are specified as being enabled there is no way to |
| 200 | # verify this so we just assume this to be true |
| 201 | if results[service].get('extensions'): |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 202 | if replace: |
| 203 | output_list = results[service].get('extensions') |
| 204 | else: |
| 205 | output_list = ['all'] |
| 206 | else: |
| 207 | extension_list = get_enabled_extensions(service) |
| 208 | output_list = [] |
| 209 | for extension in results[service]: |
| 210 | if not results[service][extension]: |
| 211 | if extension in extension_list: |
| 212 | print("%s extension: %s should not be included in the " |
| 213 | "list of enabled extensions" % (service, |
| 214 | extension)) |
| 215 | else: |
| 216 | print("%s extension: %s should be included in the list" |
| 217 | " of enabled extensions" % (service, extension)) |
| 218 | output_list.append(extension) |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 219 | else: |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 220 | output_list.append(extension) |
| 221 | if update: |
| 222 | # Sort List |
| 223 | output_list.sort() |
| 224 | # Convert list to a string |
| 225 | output_string = ', '.join(output_list) |
| 226 | if service == 'swift': |
| 227 | change_option('discoverable_apis', update_dict[service], |
| 228 | output_string) |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 229 | else: |
| 230 | change_option('api_extensions', update_dict[service], |
| 231 | output_string) |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 232 | |
| 233 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 234 | def check_service_availability(os, update): |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 235 | services = [] |
| 236 | avail_services = [] |
| 237 | codename_match = { |
| 238 | 'volume': 'cinder', |
| 239 | 'network': 'neutron', |
| 240 | 'image': 'glance', |
| 241 | 'object_storage': 'swift', |
| 242 | 'compute': 'nova', |
| 243 | 'orchestration': 'heat', |
| 244 | 'metering': 'ceilometer', |
| 245 | 'telemetry': 'ceilometer', |
Matthew Treinish | 42d50f6 | 2014-04-11 19:47:13 +0000 | [diff] [blame] | 246 | 'data_processing': 'sahara', |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 247 | 'baremetal': 'ironic', |
Matthew Treinish | 42d50f6 | 2014-04-11 19:47:13 +0000 | [diff] [blame] | 248 | 'identity': 'keystone', |
Victoria MartÃnez de la Cruz | 1173b6e | 2014-09-22 18:32:13 -0300 | [diff] [blame] | 249 | 'messaging': 'zaqar', |
Matthew Treinish | 42d50f6 | 2014-04-11 19:47:13 +0000 | [diff] [blame] | 250 | 'database': 'trove' |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 251 | } |
| 252 | # Get catalog list for endpoints to use for validation |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 253 | endpoints = os.endpoints_client.list_endpoints() |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 254 | for endpoint in endpoints: |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 255 | service = os.service_client.get_service(endpoint['service_id']) |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 256 | services.append(service['type']) |
| 257 | # Pull all catalog types from config file and compare against endpoint list |
| 258 | for cfgname in dir(CONF._config): |
| 259 | cfg = getattr(CONF, cfgname) |
| 260 | catalog_type = getattr(cfg, 'catalog_type', None) |
| 261 | if not catalog_type: |
| 262 | continue |
| 263 | else: |
| 264 | if cfgname == 'identity': |
| 265 | # Keystone is a required service for tempest |
| 266 | continue |
| 267 | if catalog_type not in services: |
| 268 | if getattr(CONF.service_available, codename_match[cfgname]): |
| 269 | print('Endpoint type %s not found either disable service ' |
| 270 | '%s or fix the catalog_type in the config file' % ( |
Matthew Treinish | 96e9e88 | 2014-06-09 18:37:19 -0400 | [diff] [blame] | 271 | catalog_type, codename_match[cfgname])) |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 272 | if update: |
| 273 | change_option(codename_match[cfgname], |
| 274 | 'service_available', False) |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 275 | else: |
| 276 | if not getattr(CONF.service_available, |
| 277 | codename_match[cfgname]): |
| 278 | print('Endpoint type %s is available, service %s should be' |
| 279 | ' set as available in the config file.' % ( |
Matthew Treinish | 96e9e88 | 2014-06-09 18:37:19 -0400 | [diff] [blame] | 280 | catalog_type, codename_match[cfgname])) |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 281 | if update: |
| 282 | change_option(codename_match[cfgname], |
| 283 | 'service_available', True) |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 284 | # If we are going to enable this we should allow |
| 285 | # extension checks. |
| 286 | avail_services.append(codename_match[cfgname]) |
Matthew Treinish | 221bd7f | 2014-02-07 21:16:09 +0000 | [diff] [blame] | 287 | else: |
| 288 | avail_services.append(codename_match[cfgname]) |
| 289 | return avail_services |
Matthew Treinish | d44fe03 | 2014-01-31 20:07:24 +0000 | [diff] [blame] | 290 | |
| 291 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 292 | def parse_args(): |
| 293 | parser = argparse.ArgumentParser() |
| 294 | parser.add_argument('-u', '--update', action='store_true', |
| 295 | help='Update the config file with results from api ' |
| 296 | 'queries. This assumes whatever is set in the ' |
| 297 | 'config file is incorrect. In the case of ' |
| 298 | 'endpoint checks where it could either be the ' |
| 299 | 'incorrect catalog type or the service available ' |
| 300 | 'option the service available option is assumed ' |
| 301 | 'to be incorrect and is thus changed') |
| 302 | parser.add_argument('-o', '--output', |
| 303 | help="Output file to write an updated config file to. " |
| 304 | "This has to be a separate file from the " |
| 305 | "original config file. If one isn't specified " |
| 306 | "with -u the new config file will be printed to " |
| 307 | "STDOUT") |
| 308 | parser.add_argument('-r', '--replace-ext', action='store_true', |
| 309 | help="If specified the all option will be replaced " |
| 310 | "with a full list of extensions") |
| 311 | args = parser.parse_args() |
| 312 | return args |
| 313 | |
| 314 | |
Matthew Treinish | f8b816a | 2014-04-23 20:35:49 +0000 | [diff] [blame] | 315 | def main(): |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 316 | print('Running config verification...') |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 317 | opts = parse_args() |
| 318 | update = opts.update |
| 319 | replace = opts.replace_ext |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 320 | global CONF_PARSER |
| 321 | |
| 322 | outfile = sys.stdout |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 323 | if update: |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 324 | conf_file = _get_config_file() |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 325 | if opts.output: |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 326 | outfile = open(opts.output, 'w+') |
| 327 | CONF_PARSER = moves.configparser.SafeConfigParser() |
| 328 | CONF_PARSER.optionxform = str |
| 329 | CONF_PARSER.readfp(conf_file) |
Andrea Frittoli | daadcdb | 2014-12-24 00:41:36 +0000 | [diff] [blame] | 330 | os = clients.AdminManager(interface='json') |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 331 | services = check_service_availability(os, update) |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 332 | results = {} |
Ken'ichi Ohmichi | b7ee5a0 | 2014-12-12 04:07:11 +0000 | [diff] [blame] | 333 | for service in ['nova', 'cinder', 'neutron', 'swift']: |
| 334 | if service not in services: |
Matthew Treinish | d44fe03 | 2014-01-31 20:07:24 +0000 | [diff] [blame] | 335 | continue |
Matthew Treinish | 8b006d2 | 2014-01-07 15:37:20 +0000 | [diff] [blame] | 336 | results = verify_extensions(os, service, results) |
Adam Gandelman | 03af556 | 2014-10-07 12:22:48 -0700 | [diff] [blame] | 337 | |
Marc Solanas Tarre | ca600f5 | 2015-01-29 11:31:28 -0800 | [diff] [blame] | 338 | # Verify API versions of all services in the keystone catalog and keystone |
Adam Gandelman | 03af556 | 2014-10-07 12:22:48 -0700 | [diff] [blame] | 339 | # itself. |
| 340 | services.append('keystone') |
| 341 | for service in services: |
| 342 | verify_api_versions(os, service, update) |
| 343 | |
Matthew Treinish | f097171 | 2014-04-11 20:08:53 +0000 | [diff] [blame] | 344 | display_results(results, update, replace) |
David Kranz | f20ac32 | 2014-05-02 16:46:15 -0400 | [diff] [blame] | 345 | if update: |
| 346 | conf_file.close() |
| 347 | CONF_PARSER.write(outfile) |
| 348 | outfile.close() |
Matthew Treinish | 1f7b33d | 2013-10-21 18:07:02 +0000 | [diff] [blame] | 349 | |
| 350 | |
| 351 | if __name__ == "__main__": |
Matthew Treinish | f8b816a | 2014-04-23 20:35:49 +0000 | [diff] [blame] | 352 | main() |