Use os-service-types for service type validation

We wrote a library to encompass this data, and it knows a bit more about
how to handle things like placement and whatnot. Use it.

Canonical name for senlin is clustering, use that one to fix build.

Change-Id: I215fb11c1e7e6aac5e020f3f3da3a0a0632cc2eb
This commit is contained in:
Monty Taylor 2017-08-17 18:11:34 -05:00 committed by Andreas Jaeger
parent cf94afc0e1
commit 27ebdb01df
6 changed files with 19 additions and 24 deletions

View File

@ -17,6 +17,7 @@ requestsexceptions>=1.2.0 # Apache-2.0
lxml>=2.3,!=3.7.0 # BSD
PyYAML>=3.10.0 # MIT
jsonschema>=2.6.0
os-service-types
# For translations
# Babel 2.4.0 is broken, fixed in 2.4.1

View File

@ -26,6 +26,7 @@ import sys
from bs4 import BeautifulSoup
import jinja2
import jsonschema
import os_service_types
import requests
import yaml
@ -178,19 +179,6 @@ _URLS = [
'https://developer.openstack.org/api-guide/{service_type}/index.html'),
]
_SERVICE_TYPES_URL = 'http://git.openstack.org/cgit/openstack/service-types-authority/plain/service-types.yaml' # noqa
def _get_service_types():
"Return a map between repo base name and service type"
raw = requests.get(_SERVICE_TYPES_URL) # noqa
data = yaml.safe_load(raw.text)
service_types = {
d['project'].rsplit('/')[-1]: d['service_type']
for d in data['services']
}
return service_types
def load_project_data(source_directory,
check_all_links=False,
@ -201,7 +189,8 @@ def load_project_data(source_directory,
series_to_load = series_to_load or []
project_data = {}
fail = False
service_types = _get_service_types()
service_types = os_service_types.ServiceTypes(
session=requests.Session(), only_remote=True)
# Set up a schema validator so we can quickly check that the input
# data conforms.
project_schema_filename = os.path.join(
@ -235,17 +224,22 @@ def load_project_data(source_directory,
# the value in the service-type-authority data.base.
st = project.get('service_type')
if st is not None:
if project['name'] not in service_types:
st_data = service_types.get_service_data_for_project(
project['name'])
if not st_data:
# It's possible this is a project listed by its
# service-type
st_data = service_types.get_service_data(st)
if not st_data:
logger.error(
'did not find %s in %s',
project['name'], _SERVICE_TYPES_URL,
'did not find %s in Service Types Authority',
project['name'],
)
fail = True
elif project['service_type'] != service_types[project['name']]:
elif st != st_data['service_type']:
logger.error(
'expected service_type %r for %s but got %r',
service_types[project['name']], project['name'],
project['service_type'],
st_data['service_type'], project['name'], st,
)
fail = True

View File

@ -393,7 +393,7 @@
- name: senlin
service: Clustering service
service_type: resource-cluster
service_type: clustering
type: service
has_install_guide: true
has_api_ref: true

View File

@ -102,7 +102,7 @@
- name: senlin
service: Clustering service
service_type: resource-cluster
service_type: clustering
type: service
has_api_ref: true

View File

@ -102,7 +102,7 @@
- name: senlin
service: Clustering service
service_type: resource-cluster
service_type: clustering
type: service
has_api_ref: true

View File

@ -385,7 +385,7 @@
- name: senlin
service: Clustering service
service_type: resource-cluster
service_type: clustering
type: service
has_install_guide: true
has_api_ref: true