From 5fc979e641d182493f0e49f4a65e88066e85a62d Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Fri, 14 Sep 2018 14:37:15 -0600 Subject: [PATCH] Initial tuning from cookiecutter start This adds in the initial stab of os_resource_classes. --- .coveragerc | 1 + .mailmap | 3 -- CONTRIBUTING.rst | 2 +- README.rst | 6 +-- babel.cfg | 2 - os_resource_classes/__init__.py | 68 +++++++++++++++++++++++++-------- setup.cfg | 14 ------- 7 files changed, 58 insertions(+), 38 deletions(-) delete mode 100644 .mailmap delete mode 100644 babel.cfg diff --git a/.coveragerc b/.coveragerc index 6795d3f..84bae46 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,7 @@ [run] branch = True source = os_resource_classes +omit = os_resource_classes/tests/* [report] ignore_errors = True diff --git a/.mailmap b/.mailmap deleted file mode 100644 index 516ae6f..0000000 --- a/.mailmap +++ /dev/null @@ -1,3 +0,0 @@ -# Format is: -# -# diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index f0ce6f5..f97e417 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -12,4 +12,4 @@ submitted for review via the Gerrit tool: Pull requests submitted through GitHub will be ignored. -Bugs should be filed on Launchpadhttps://bugs.launchpad.net/nova \ No newline at end of file +Bugs should be filed on Launchpad: https://bugs.launchpad.net/nova diff --git a/README.rst b/README.rst index 1c26df1..853c45b 100644 --- a/README.rst +++ b/README.rst @@ -2,11 +2,11 @@ os-resource-classes =============================== +**WIP** + Resource Classes for OpenStack -Please fill here a long description which must be at least 3 lines wrapped on -80 cols, so that distribution package maintainers can use it in their packages. -Note that this is a hard requirement. +A list of standardized resource classes for OpenStack. * Free software: Apache license * Documentation: https://docs.openstack.org/os-resource-classes/latest diff --git a/babel.cfg b/babel.cfg deleted file mode 100644 index 15cd6cb..0000000 --- a/babel.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[python: **.py] - diff --git a/os_resource_classes/__init__.py b/os_resource_classes/__init__.py index b7c1eb8..5eb4c24 100644 --- a/os_resource_classes/__init__.py +++ b/os_resource_classes/__init__.py @@ -1,19 +1,57 @@ -# -*- coding: utf-8 -*- +"""Static symbols for resources classes used by OpenStack. -# 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. +A resource class is a type of countable thing that exists in +a cloud environment, for example VCPU, DISK_GB. They are +upper case with underscores. They often include a unit in their +name. -import pbr.version +This package provides a collection of standard resource classes +which are expected to be available in any OpenStack deployment. + +There also exists a concept of custom resource classes. These +are countable types that are custom to a particular environment. +The OpenStack placement API provides a way to create these. A +custom resource class always begins with a "CUSTOM_" prefix. +""" + +import sys + +# NOTE(cdent): We don't expect there to be thousands of resource +# classes and we don't desire to track their history in any +# particular way so we maintain them as a list of strings ordered by +# by the time they were added to the list. From that we automatically +# create symbols in the same package. Ordering is important because +# it reflects database ids that have been used for resource classes +# prior to this package existing. -__version__ = pbr.version.VersionInfo( - 'os-resource-classes').version_string() +# Extend this list, if required, by adding **to the end of it**. +ORDERED_CLASSES = [ + # Virtual CPUs + 'VCPU', + # Memory Megabytes + 'MEMORY_MB', + # Disk Gigabytes + 'DISK_GB', + 'PCI_DEVICE', + 'SRIOV_NET_VF', + 'NUMA_SOCKET', + 'NUMA_CORE', + 'NUMA_THREAD', + 'NUMA_MEMORY_MB', + 'IPV4_ADDRESS', + 'VGPU', + 'VGPU_DISPLAY_HEAD', +] + +# Namespace used for custom resource classes +CUSTOM_NAMESPACE = 'CUSTOM_' + +def is_custom(resource_class): + return resource_class.startswith(CUSTOM_NAMESPACE) + + +# Set symbols that match resource class name strings. +package = sys.modules[__name__] +for resource_class in ORDERED_CLASSES: + setattr(package, resource_class, resource_class) diff --git a/setup.cfg b/setup.cfg index a473805..9494589 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,17 +21,3 @@ classifier = [files] packages = os_resource_classes - -[compile_catalog] -directory = os_resource_classes/locale -domain = os_resource_classes - -[update_catalog] -domain = os_resource_classes -output_dir = os_resource_classes/locale -input_file = os_resource_classes/locale/os_resource_classes.pot - -[extract_messages] -keywords = _ gettext ngettext l_ lazy_gettext -mapping_file = babel.cfg -output_file = os_resource_classes/locale/os_resource_classes.pot