diff --git a/openstack_releases/__init__.py b/openstack_releases/__init__.py index e69de29bb2..41f0f4ec3e 100644 --- a/openstack_releases/__init__.py +++ b/openstack_releases/__init__.py @@ -0,0 +1,16 @@ +import os +import os.path + +# Try to guess where the deliverables directory is relative to where +# the code is imported from. +_venv = os.environ.get('VIRTUAL_ENV', '') +if _venv: + deliverable_dir = os.path.dirname(_venv) + if deliverable_dir.endswith('.tox'): + deliverable_dir = os.path.dirname(deliverable_dir) + deliverable_dir = os.path.join(deliverable_dir, 'deliverables') +else: + deliverable_dir = os.path.join( + os.path.dirname(__file__), + '../deliverables', + ) diff --git a/openstack_releases/cmds/list_deliverables.py b/openstack_releases/cmds/list_deliverables.py new file mode 100644 index 0000000000..7d2ea019ef --- /dev/null +++ b/openstack_releases/cmds/list_deliverables.py @@ -0,0 +1,79 @@ +# 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 __future__ import print_function + +import argparse + +import openstack_releases +from openstack_releases import defaults +from openstack_releases import deliverable + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--team', + help='the name of the project team, such as "Nova" or "Oslo"', + ) + parser.add_argument( + '--deliverable', + help='the name of the deliverable, such as "nova" or "oslo.config"', + ) + parser.add_argument( + '--series', + default=defaults.RELEASE, + help='the release series, such as "newton" or "ocata"', + ) + model = parser.add_mutually_exclusive_group() + model.add_argument( + '--model', + help='the release model, such as "cycle-with-milestones" or "independent"', + ) + model.add_argument( + '--cycle-based', + action='store_true', + default=False, + help='include all cycle-based code repositories', + ) + parser.add_argument( + '--type', + help='deliverable type, such as "library" or "service"', + ) + parser.add_argument( + '--deliverables-dir', + default=openstack_releases.deliverable_dir, + help='location of deliverable files', + ) + args = parser.parse_args() + + # Deal with the inconsistency of the name for the independent + # directory. + series = args.series + if series == 'independent': + series = '_independent' + + all_deliv = deliverable.Deliverables( + root_dir=args.deliverables_dir, + collapse_history=False, + ) + for entry in all_deliv.get_deliverables(args.team, series): + deliv = deliverable.Deliverable(*entry) + + if args.model and deliv.model != args.model: + continue + if args.cycle_based and not deliv.is_cycle_based: + continue + if args.type and deliv.type != args.type: + continue + + print(deliv.name) diff --git a/openstack_releases/deliverable.py b/openstack_releases/deliverable.py index 27a4436102..1892d9f207 100644 --- a/openstack_releases/deliverable.py +++ b/openstack_releases/deliverable.py @@ -177,3 +177,26 @@ class Deliverables(object): self._deliverable_from_filename(filename), self._by_filename.get(filename, {}), ) + + +class Deliverable(object): + + def __init__(self, team, series, name, data): + self.team = team + self.series = series + self.name = name + self._data = data + + @property + def model(self): + if self.series == '_independent': + return 'independent' + return self._data.get('release-model', '').lstrip('_') + + @property + def is_cycle_based(self): + return self.model.startswith('cycle-') + + @property + def type(self): + return self._data.get('type', 'other') diff --git a/setup.cfg b/setup.cfg index 5b40acf3d3..cd5ee037f0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,7 @@ console_scripts = interactive-release = openstack_releases.cmds.interactive_release:main missing-releases = openstack_releases.cmds.missing:main check-diff-start = openstack_releases.cmds.check_diff_start:main + list-deliverables = openstack_releases.cmds.list_deliverables:main [extras] sphinxext =