Initial import
This commit is contained in:
		
							
								
								
									
										35
									
								
								otc_metadata/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								otc_metadata/__init__.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#      http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
__all__ = ['__version__', 'Docs']
 | 
			
		||||
 | 
			
		||||
import pbr.version
 | 
			
		||||
 | 
			
		||||
from otc_metadata.services import Services  # flake8: noqa
 | 
			
		||||
 | 
			
		||||
__version__ = pbr.version.VersionInfo('otc-metadata').version_string()
 | 
			
		||||
_service_manager = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_service_data(*args, **kwargs):
 | 
			
		||||
    """Return singleton instance of the Services object.
 | 
			
		||||
    Parameters are all passed through to the
 | 
			
		||||
    :class:`~otc_metadata.services.Services` constructor.
 | 
			
		||||
    .. note::
 | 
			
		||||
      Only one singleton is kept, so if instances with different parameter
 | 
			
		||||
      values are desired, directly calling the constructor is necessary.
 | 
			
		||||
    :returns: Singleton instance of
 | 
			
		||||
        :class:`~otc_metadata.services.Services`
 | 
			
		||||
    """
 | 
			
		||||
    global _service_manager
 | 
			
		||||
    if not _service_manager:
 | 
			
		||||
        _service_manager = Services(*args, **kwargs)
 | 
			
		||||
    return _service_manager
 | 
			
		||||
							
								
								
									
										29
									
								
								otc_metadata/data/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								otc_metadata/data/__init__.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import yaml
 | 
			
		||||
 | 
			
		||||
__all__ = ['read_data']
 | 
			
		||||
 | 
			
		||||
DATA_DIR = os.path.dirname(__file__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def read_data(filename):
 | 
			
		||||
    """Return data that is shipped inside the Python package.
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    filepath = os.path.join(DATA_DIR, filename)
 | 
			
		||||
    with open(filepath, 'r') as fd:
 | 
			
		||||
        return yaml.safe_load(fd)
 | 
			
		||||
							
								
								
									
										876
									
								
								otc_metadata/data/services.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										876
									
								
								otc_metadata/data/services.yaml
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										38
									
								
								otc_metadata/docs.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								otc_metadata/docs.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
 | 
			
		||||
import copy
 | 
			
		||||
 | 
			
		||||
import otc_metadata.data
 | 
			
		||||
 | 
			
		||||
__all__ = ['Docs']
 | 
			
		||||
 | 
			
		||||
BUILTIN_DATA = otc_metadata.data.read_data('docs.yaml')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _normalize_type(service_type):
 | 
			
		||||
    if service_type:
 | 
			
		||||
        return service_type.replace('_', '-')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Service(object):
 | 
			
		||||
    """Encapsulation of the OTC Docs data
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        self._service_data = BUILTIN_DATA
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def all_services(self):
 | 
			
		||||
        "Service Categories data listing."
 | 
			
		||||
        return copy.deepcopy(self._service_data['services'])
 | 
			
		||||
							
								
								
									
										47
									
								
								otc_metadata/services.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								otc_metadata/services.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
 | 
			
		||||
import copy
 | 
			
		||||
 | 
			
		||||
import otc_metadata.data
 | 
			
		||||
 | 
			
		||||
__all__ = ['Services']
 | 
			
		||||
 | 
			
		||||
BUILTIN_DATA = otc_metadata.data.read_data('services.yaml')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _normalize_type(service_type):
 | 
			
		||||
    if service_type:
 | 
			
		||||
        return service_type.replace('_', '-')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Services(object):
 | 
			
		||||
    """Encapsulation of the OTC Services data
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        self._service_data = BUILTIN_DATA
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def all_services(self):
 | 
			
		||||
        "Service Categories data listing."
 | 
			
		||||
        return copy.deepcopy(self._service_data['services'])
 | 
			
		||||
 | 
			
		||||
    def services_by_category(self, category):
 | 
			
		||||
        """List services matching category
 | 
			
		||||
        """
 | 
			
		||||
        res = []
 | 
			
		||||
        for srv in self.all_services:
 | 
			
		||||
            if srv['service_category'] == category:
 | 
			
		||||
                res.append(copy.deepcopy(srv))
 | 
			
		||||
        return res
 | 
			
		||||
							
								
								
									
										0
									
								
								otc_metadata/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								otc_metadata/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										23
									
								
								otc_metadata/tests/base.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								otc_metadata/tests/base.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
 | 
			
		||||
# Copyright 2010-2011 OpenStack Foundation
 | 
			
		||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
 | 
			
		||||
#
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#      http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
 | 
			
		||||
from unittest import TestCase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestCase(TestCase):
 | 
			
		||||
 | 
			
		||||
    """Test case base class for all unit tests."""
 | 
			
		||||
							
								
								
									
										28
									
								
								otc_metadata/tests/test_otc-metadata.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								otc_metadata/tests/test_otc-metadata.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
 | 
			
		||||
# 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
 | 
			
		||||
#
 | 
			
		||||
#      http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# 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.
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
test_otc-metadata
 | 
			
		||||
----------------------------------
 | 
			
		||||
 | 
			
		||||
Tests for `otc-metadata` module.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from otc-metadata.tests import base
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestOtc-metadata(base.TestCase):
 | 
			
		||||
 | 
			
		||||
    def test_something(self):
 | 
			
		||||
        pass
 | 
			
		||||
		Reference in New Issue
	
	Block a user