diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cbf14e0..0000000 --- a/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -*.py[cod] -*.sw[op] - -# C extensions -*.so - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox -.stestr/ - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -instack.answers -ChangeLog -Authors diff --git a/.stestr.conf b/.stestr.conf deleted file mode 100644 index 5cfd912..0000000 --- a/.stestr.conf +++ /dev/null @@ -1,4 +0,0 @@ -[DEFAULT] -test_path=./instack/tests -top_dir=./ - diff --git a/.zuul.yaml b/.zuul.yaml deleted file mode 100644 index 3167aa3..0000000 --- a/.zuul.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- project: - templates: - - openstack-cover-jobs - - openstack-python-jobs - - openstack-python35-jobs - - openstack-python36-jobs - - check-requirements diff --git a/HACKING.rst b/HACKING.rst deleted file mode 100644 index 32b6920..0000000 --- a/HACKING.rst +++ /dev/null @@ -1,4 +0,0 @@ -instack Style Commandments -=============================================== - -Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ diff --git a/HOWTO/Releasing.md b/HOWTO/Releasing.md deleted file mode 100644 index 7bdf002..0000000 --- a/HOWTO/Releasing.md +++ /dev/null @@ -1,26 +0,0 @@ -To do a new build of instack you need to: - -1. Go to your git checkout of instack -1. Commit any updates, then make an annotated tag, if the previous version was - 0.0.2, the new tag would be called 0.0.3. - - git tag -a 0.0.3 - -1. Push any changes and the tag. - - git push --tags - -1. Build an sdist tarball for the release. This command would create - instack-0.0.3.tar.gz under the dist directory. - - python setup.py sdist - -1. Go to github for instack, https://github.com/rdo-management/instack/releases/ - -1. Click Draft a new release - -1. Enter the tag you've created, github should tell you it's an existing tag - -1. Upload the tgz created earlier to the release. - -1. Update the specfile Version in dist-git and rebuild. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 67db858..0000000 --- a/LICENSE +++ /dev/null @@ -1,175 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 90f8a7a..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include AUTHORS -include ChangeLog -exclude .gitignore -exclude .gitreview - -global-exclude *.pyc \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 02f6bbb..0000000 --- a/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Team and repository tags -======================== - -[![Team and repository tags](https://governance.openstack.org/tc/badges/instack.svg)](https://governance.openstack.org/tc/reference/tags/index.html) - - - -instack -======= - -instack executes [diskimage-builder](https://github.com/openstack/diskimage-builder) -style elements on the current system. This enables a -current running system to have an element applied in the same way that -diskimage-builder applies the element to an image build. - -instack, in its current form, should be considered low level tooling. It is meant -to be used by higher level scripting that understands what elements and -hook scripts need execution. Using instack requires a rather in depth -knowledge of the elements within diskimage-builder and tripleo-image-elements. - -An example of higher level tooling that uses instack to install a TripleO style -undercloud is at: -https://github.com/rdo-management/instack-undercloud diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..0c145cd --- /dev/null +++ b/README.rst @@ -0,0 +1,6 @@ +This project is no longer maintained. + +The contents of this repository are still available in the Git source code management system. To see the contents of this repository before it reached its end of life, please check out the previous commit with "git checkout HEAD^1". + +For any further questions, please email openstack-dev@lists.openstack.org or join #openstack-dev on Freenode. + diff --git a/babel.cfg b/babel.cfg deleted file mode 100644 index efceab8..0000000 --- a/babel.cfg +++ /dev/null @@ -1 +0,0 @@ -[python: **.py] diff --git a/doc/source/conf.py b/doc/source/conf.py deleted file mode 100755 index a827239..0000000 --- a/doc/source/conf.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- 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. - -import os -import sys - -sys.path.insert(0, os.path.abspath('../..')) -# -- General configuration ---------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - #'sphinx.ext.intersphinx', - 'oslosphinx' -] - -# autodoc generation is a bit aggressive and a nuisance when doing heavy -# text edit cycles. -# execute "export SPHINX_DEBUG=1" in your terminal to disable - -# The suffix of source filenames. -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'instack' -copyright = u'2013, OpenStack Foundation' - -# If true, '()' will be appended to :func: etc. cross-reference text. -add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -add_module_names = True - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# -- Options for HTML output -------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -# html_theme_path = ["."] -# html_theme = '_theme' -# html_static_path = ['static'] - -# Output file base name for HTML help builder. -htmlhelp_basename = '%sdoc' % project - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass -# [howto/manual]). -latex_documents = [ - ('index', - '%s.tex' % project, - u'%s Documentation' % project, - u'OpenStack Foundation', 'manual'), -] - -# Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst deleted file mode 100644 index 8cb3146..0000000 --- a/doc/source/contributing.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../CONTRIBUTING.rst \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst deleted file mode 100644 index 1754d90..0000000 --- a/doc/source/index.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. instack documentation master file, created by - sphinx-quickstart on Tue Jul 9 22:26:36 2013. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to instack's documentation! -======================================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - readme - installation - usage - contributing - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`search` diff --git a/doc/source/installation.rst b/doc/source/installation.rst deleted file mode 100644 index d90e172..0000000 --- a/doc/source/installation.rst +++ /dev/null @@ -1,12 +0,0 @@ -============ -Installation -============ - -At the command line:: - - $ pip install instack - -Or, if you have virtualenvwrapper installed:: - - $ mkvirtualenv instack - $ pip install instack \ No newline at end of file diff --git a/doc/source/readme.rst b/doc/source/readme.rst deleted file mode 100644 index 8416370..0000000 --- a/doc/source/readme.rst +++ /dev/null @@ -1,85 +0,0 @@ -.. include:: ../../README.md - -Usage ------ - -Use the command line arguments for fine grained control over which elements to -apply, or drive instack via a declarative style json file (see -https://github.com/openstack/instack-undercloud/blob/master/json-files/centos-7-undercloud-packages.json -for an example). - -Be aware that most elements are not idempotent. Subsequent runs of instack with the same set of elements -will often fail due to things files and directories already existing. One way around this is to write a clean up -element for your environment that cleans up before a run early in pre-install.d, and then always -include that element when you run instack. - -

-usage: instack [-h] [-e [ELEMENT [ELEMENT ...]]]
-               [-p ELEMENT_PATH [ELEMENT_PATH ...]] [-k [HOOK [HOOK ...]]]
-               [-b [BLACKLIST [BLACKLIST ...]]]
-               [-x [EXCLUDE_ELEMENT [EXCLUDE_ELEMENT ...]]] [-j JSON_FILE]
-               [-d] [-i] [--dry-run] [--no-cleanup]
-
-Execute diskimage-builder elements on the current system.
-
-optional arguments:
-  -h, --help            show this help message and exit
-  -e [ELEMENT [ELEMENT ...]], --element [ELEMENT [ELEMENT ...]]
-                        element(s) to execute
-  -p ELEMENT_PATH [ELEMENT_PATH ...], --element-path ELEMENT_PATH [ELEMENT_PATH ...]
-                        element path(s) to search for elements (ELEMENTS_PATH
-                        environment variable will take precedence if defined)
-  -k [HOOK [HOOK ...]], --hook [HOOK [HOOK ...]]
-                        hook(s) to execute for each element
-  -b [BLACKLIST [BLACKLIST ...]], --blacklist [BLACKLIST [BLACKLIST ...]]
-                        script names, that if found, will be blacklisted and
-                        not run
-  -x [EXCLUDE_ELEMENT [EXCLUDE_ELEMENT ...]], --exclude-element [EXCLUDE_ELEMENT [EXCLUDE_ELEMENT ...]]
-                        element names that will be excluded from running even
-                        if they are listed as dependencies
-  -j JSON_FILE, --json-file JSON_FILE
-                        read runtime configuration from json file
-  -d, --debug           Debugging output
-  -i, --interactive     If set, prompt to continue running after a failed
-                        script.
-  --dry-run             Dry run only, don't actually modify system, prints out
-                        what would have been run.
-  --no-cleanup          Do not cleanup tmp directories
-
- -Setup ------ - -1. Make sure you have pip and git installed. If using your distro's pip, make you have at least pip version 1.5. There's a bug in older versions that causes some files to not be installed +x, which is a requirement for element hook scripts. To use upstream pip, see: http://www.pip-installer.org/en/latest/installing.html - -1. git clone this repository - - git clone https://github.com/rdo-management/instack - -1. pip install the cloned instack - - pushd instack && sudo pip install -e . && popd - -1. pip install diskimage-builder and tripleo-image-elements - - sudo pip install diskimage-builder tripleo-image-elements -If you so choose, you can use these from their git repositories instead: - - git clone https://git.openstack.org/openstack/diskimage-builder - git clone https://git.openstack.org/openstack/tripleo-image-elements - pushd diskimage-builder && sudo pip install . && popd - pushd tripleo-image-elements && sudo pip install . && popd - -Example Uses ------------- - -On Fedora, apply the keystone and mariadb element: - -

-sudo -E instack \
-    -p /usr/share/tripleo-image-elements /usr/share/diskimage-builder/elements \
-    -e fedora base keystone mariadb \
-    -k extra-data pre-install install post-install \
-    -b 15-remove-grub 10-cloud-init 05-fstab-rootfs-label
-
- diff --git a/doc/source/usage.rst b/doc/source/usage.rst deleted file mode 100644 index d6a4880..0000000 --- a/doc/source/usage.rst +++ /dev/null @@ -1,7 +0,0 @@ -======== -Usage -======== - -To use instack in a project:: - - import instack \ No newline at end of file diff --git a/instack/__init__.py b/instack/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/instack/element.py b/instack/element.py deleted file mode 100644 index 842e73a..0000000 --- a/instack/element.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2013, Red Hat Inc. -# All Rights Reserved. -# -# 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 string - - -class Element(object): - """A diskimage-builder element.""" - - def __init__(self, directory): - """Element initialization. - - :param directory: The directory that defines the element. - :type directory str. - """ - if not os.access(directory, os.R_OK): - raise Exception - - self.directory = directory - self.hooks = {} - self.load_hooks() - - def load_hooks(self): - for f in os.listdir(self.directory): - if not os.path.isdir(os.path.join(self.directory, f)): - continue - if not f.endswith('.d'): - continue - - hook = f[:-2] - hook_path = os.path.abspath(os.path.join(self.directory, f)) - - for script in os.listdir(hook_path): - if script[0:1] not in string.digits: - continue - self.hooks.setdefault( - hook, []).append(os.path.join(hook_path, script)) - - def get_hook(self, hook): - return self.hooks.get(hook, []) diff --git a/instack/main.py b/instack/main.py deleted file mode 100644 index 15d9f9b..0000000 --- a/instack/main.py +++ /dev/null @@ -1,190 +0,0 @@ -# Copyright 2013, Red Hat Inc. -# All Rights Reserved. -# -# 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 errno -import json -import logging -import os -import platform -import shutil -import subprocess -import sys -import tempfile -import traceback - -from instack import runner - - -LOG = logging.getLogger() - - -def load_args(argv): - parser = argparse.ArgumentParser( - description="Execute diskimage-builder elements on the current " - "system.") - parser.add_argument( - '-e', '--element', nargs='*', - help="element(s) to execute") - parser.add_argument( - '-p', '--element-path', nargs='+', - help=("element path(s) to search for elements (ELEMENTS_PATH " - "environment variable will take precedence if defined)")) - parser.add_argument( - '-k', '--hook', nargs='*', - help=("hook(s) to execute for each element")) - parser.add_argument( - '-b', '--blacklist', nargs='*', - help=("script names, that if found, will be blacklisted and not run")) - parser.add_argument( - '-x', '--exclude-element', nargs='*', - help=("element names that will be excluded from running even if " - "they are listed as dependencies")) - parser.add_argument( - '-j', '--json-file', - help=("read runtime configuration from json file")) - parser.add_argument( - '-d', '--debug', action='store_true', - help=("Debugging output")) - parser.add_argument( - '-i', '--interactive', action='store_true', - help=("If set, prompt to continue running after a failed script.")) - parser.add_argument( - '--dry-run', action='store_true', - help=("Dry run only, don't actually modify system, prints out " - "what would have been run.")) - parser.add_argument( - '--no-cleanup', action='store_true', - help=("Do not cleanup tmp directories")) - parser.add_argument( - '-l', '--logfile', action='store', - default=os.path.join(os.path.expanduser('~'), '.instack/instack.log'), - help=("Logfile to log all actions")) - - args = parser.parse_args(argv) - - if args.json_file and (args.element or args.hook or args.exclude_element): - print("--json-file not compatible with --element, --hook,") - print("--exclude-element, or --blacklist") - sys.exit(1) - - return args - - -def set_environment(tmp_dir): - """Set environment variables that diskimage-builder elements expect.""" - - os.environ['TMP_MOUNT_PATH'] = os.path.join(tmp_dir, 'mnt') - os.symlink('/', os.environ['TMP_MOUNT_PATH']) - os.environ['DIB_OFFLINE'] = '' - os.environ['DIB_INIT_SYSTEM'] = 'systemd' - os.environ['DIB_IMAGE_CACHE'] = ( - '/root/.cache/image-create' if os.environ['USER'] == 'root' - else '%s/.cache/image-create' % os.environ['HOME'] - ) - os.environ['IMAGE_NAME'] = 'instack' - os.environ['PATH'] = "%s:/usr/local/bin" % os.environ['PATH'] - os.environ.setdefault('DIB_DEFAULT_INSTALLTYPE', 'package') - - # first try to get it with paths tooling from dib - try: - import diskimage_builder.paths - os.environ['_LIB'] = diskimage_builder.paths.get_path("lib") - except ImportError: - if os.path.exists('/usr/share/diskimage-builder/lib'): - os.environ['_LIB'] = '/usr/share/diskimage-builder/lib' - elif os.path.exists('diskimage-builder/lib'): - os.environ['_LIB'] = 'diskimage-builder/lib' - else: - raise Exception("Can't detect diskimage-builder lib directory.") - - os.environ['TARGET_ROOT'] = '/' - if platform.processor() == 'x86_64': - os.environ['ARCH'] = 'amd64' - else: - os.environ['ARCH'] = 'i386' - - os.environ['DIB_ENV'] = ( - subprocess.check_output(['export', '|', 'grep', '\' DIB_.*=\''], - shell=True)) - - os.environ['DIB_ARGS'] = str(sys.argv) - - -def cleanup(tmp_dir): - shutil.rmtree(tmp_dir) - - -def main(argv=sys.argv): - args = load_args(argv[1:]) - - tmp_dir = tempfile.mkdtemp(prefix='instack.') - try: - os.makedirs(os.path.dirname(args.logfile)) - except OSError as e: - if e.errno != errno.EEXIST: - raise - - formatter = logging.Formatter("%(levelname)s: %(asctime)s -- %(message)s") - stream_handler = logging.StreamHandler() - stream_handler.setFormatter(formatter) - stream_handler.setLevel(logging.INFO) - LOG.setLevel(logging.DEBUG) - LOG.addHandler(stream_handler) - file_handler = logging.FileHandler(args.logfile) - file_handler.setFormatter(formatter) - file_handler.setLevel(logging.INFO) - LOG.addHandler(file_handler) - - LOG.info("Starting run of instack") - - set_environment(tmp_dir) - - try: - if args.json_file: - LOG.info("Using json file: %s" % args.json_file) - json_list = json.loads(open(args.json_file).read()) - if not isinstance(json_list, list): - raise Exception("json file should be a list structure") - - for run in json_list: - if "name" in run: - LOG.info("Running %s" % run["name"]) - em = runner.ElementRunner( - run['element'], run['hook'], args.element_path, - run.get('blacklist', []), run.get('exclude-element', []), - args.dry_run, args.interactive, args.no_cleanup) - em.run() - else: - em = runner.ElementRunner( - args.element, args.hook, args.element_path, - args.blacklist, args.exclude_element, - args.dry_run, args.interactive, - args.no_cleanup) - em.run() - - except Exception as e: - LOG.error(str(e)) - LOG.error(traceback.print_tb(sys.exc_info()[2])) - sys.exit(1) - finally: - cleanup(tmp_dir) - - LOG.info("Ending run of instack.") - - -if __name__ == '__main__': - main() diff --git a/instack/runner.py b/instack/runner.py deleted file mode 100644 index 1cc698f..0000000 --- a/instack/runner.py +++ /dev/null @@ -1,223 +0,0 @@ -# Copyright 2013, Red Hat Inc. -# All Rights Reserved. -# -# 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 distutils import dir_util -import logging -import os -import shutil -import subprocess -import sys -import tempfile - -from diskimage_builder import element_dependencies - -from instack import element - -# dib-run-parts has moved in dibv2 to an internal call. We don't -# really want to introduce a dependency on dib-utils here. For v1 -# just call it from path. -# Note this is fragile as dib considers this internal -_DIB_RUN_PARTS = 'dib-run-parts' -try: - import diskimage_builder.paths - _DIB_RUN_PARTS = os.path.join(diskimage_builder.paths.get_path('lib'), - 'dib-run-parts') -except ImportError: - pass - - -LOG = logging.getLogger() - - -class ElementRunner(object): - - def __init__(self, elements, hooks, element_paths=None, blacklist=None, - exclude_elements=None, dry_run=False, interactive=False, - no_cleanup=False): - """Element Runner initialization. - - :param elements: Element names to apply. - :type elements: list. - :param hooks: Hooks to run for each element. - :type hooks: list. - :param element_paths: File system paths to search for elements. - :type element_paths: list of strings. - :param dry_run: If True, do not actually run the hooks. - :type dry_run: bool - """ - self.elements = elements - self.dry_run = dry_run - self.hooks = hooks - self.blacklist = blacklist or [] - self.exclude_elements = exclude_elements or [] - self.interactive = interactive - self.no_cleanup = no_cleanup - self.loaded_elements = {} - self.tmp_hook_dir = tempfile.mkdtemp() - self.environment_file = os.path.join(self.tmp_hook_dir, - 'environment.d', - '00-dib-v2-env') - - # the environment variable should override anything passed in - if 'ELEMENTS_PATH' in os.environ: - self.element_paths = os.environ['ELEMENTS_PATH'].split(':') - else: - self.element_paths = element_paths - - if self.element_paths is None: - raise Exception("No element paths specified") - - LOG.info('Initialized with elements path: %s' % - ' '.join(list(self.element_paths))) - - self.load_elements() - self.load_dependencies() - self.process_exclude_elements() - self.copy_elements() - self.generate_environment() - - def generate_environment(self): - """Generate a dib v2 environment.""" - # NOTE(bnemec): Older versions of dib don't need this. We can tell - # by looking for the --env parameter to element-info. - check_output = subprocess.check_output(['element-info', '-h']) - if '--env' not in check_output: - return - - command = ['element-info', '--env'] + list(self.elements) - env_output = subprocess.check_output(command) - with open(self.environment_file, 'w') as f: - f.write(env_output) - - def run(self): - """Apply the elements by running each specified hook.""" - for hook in self.hooks: - self.run_hook(hook) - - self.cleanup() - - def cleanup(self): - """Clean up after a run.""" - if not self.no_cleanup: - shutil.rmtree(self.tmp_hook_dir) - - def load_elements(self): - """Load all elements from self.element_paths. - - This populates self.loaded_elements. - """ - for path in self.element_paths: - self.process_path(path) - - def copy_elements(self): - """Copy elements to apply to a temporary directory.""" - # self.tmp_hook_dir may exist from a previous run, delete it if so. - if os.path.exists(self.tmp_hook_dir): - shutil.rmtree(self.tmp_hook_dir) - - os.makedirs(self.tmp_hook_dir) - - for elem in self.elements: - element_dir = self.loaded_elements[elem].directory - dir_util.copy_tree(element_dir, self.tmp_hook_dir) - - # elements expect this environment variable to be set - os.environ['TMP_HOOKS_PATH'] = self.tmp_hook_dir - tmp_path = '%s/bin' % self.tmp_hook_dir - if 'PATH' in os.environ: - tmp_path = os.environ["PATH"] + os.pathsep + tmp_path - os.environ["PATH"] = tmp_path - - def process_path(self, path): - """Load elements from a given filesystem path. - - :param path: Filesystem path from which to load elements. - :type path: str. - """ - if not os.access(path, os.R_OK): - raise Exception("Can't read from elements path at %s." % path) - - for elem in os.listdir(path): - if not os.path.isdir(os.path.join(path, elem)): - continue - self.loaded_elements[elem] = element.Element( - os.path.join(path, elem)) - - def load_dependencies(self): - """Load and add all element dependencies to self.elements.""" - all_elements = element_dependencies.expand_dependencies( - self.elements, ':'.join(self.element_paths)) - self.elements = all_elements - os.environ['IMAGE_ELEMENT'] = ' '.join( - [x for x in sorted(self.elements)]) - LOG.info("List of all elements and dependencies: %s" % - ' '.join(list(self.elements))) - - def process_exclude_elements(self): - """Remove any elements that have been specified as excluded.""" - for elem in self.exclude_elements: - if elem in self.elements: - LOG.info("Excluding element %s" % elem) - self.elements.remove(elem) - # Need to redefine OS.environ['IMAGE_ELEMENT'] after removing excludes - os.environ['IMAGE_ELEMENT'] = ' '.join( - [x for x in sorted(self.elements)]) - LOG.info("List of all elements and dependencies after excludes: %s" % - ' '.join(list(self.elements))) - - def run_hook(self, hook): - """Run a hook on the current system. - - :param hook: name of hook to run - :type hook: str - """ - LOG.info(" Running hook %s" % hook) - - hook_dir = os.path.join(self.tmp_hook_dir, '%s.d' % hook) - if not os.path.exists(hook_dir): - LOG.info(" Skipping hook %s, the hook directory doesn't " - "exist at %s" % (hook, hook_dir)) - return - - for blacklisted_script in self.blacklist: - if blacklisted_script in os.listdir(hook_dir): - LOG.debug(" Blacklisting %s" % blacklisted_script) - os.unlink(os.path.join(hook_dir, blacklisted_script)) - - command = [_DIB_RUN_PARTS, hook_dir] - if self.dry_run: - LOG.info(" Dry Run specified, not running hook") - else: - rc = call(command, env=os.environ) - if rc != 0: - LOG.error(" Hook FAILED.") - raise Exception("Failed running command %s" % command) - - -def call(command, **kwargs): - """Call out to run a command via subprocess.""" - - LOG.debug(' executing command: %s' % command) - - LOG.info('############### Begin stdout/stderr logging ###############') - rc = subprocess.call(command, - stdout=sys.stdout, - stderr=sys.stderr, - **kwargs) - LOG.info('############### End stdout/stderr logging ###############') - - LOG.debug(' exited with code: %s' % rc) - return rc diff --git a/instack/tests/__init__.py b/instack/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/instack/tests/elements/dep1/install.d/50-dep1 b/instack/tests/elements/dep1/install.d/50-dep1 deleted file mode 100755 index 6099731..0000000 --- a/instack/tests/elements/dep1/install.d/50-dep1 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo DEP1 ELEMENT diff --git a/instack/tests/elements/dep2/element-deps b/instack/tests/elements/dep2/element-deps deleted file mode 100644 index 9b85097..0000000 --- a/instack/tests/elements/dep2/element-deps +++ /dev/null @@ -1 +0,0 @@ -dep1 diff --git a/instack/tests/elements/dep2/install.d/50-dep2 b/instack/tests/elements/dep2/install.d/50-dep2 deleted file mode 100755 index ca5d705..0000000 --- a/instack/tests/elements/dep2/install.d/50-dep2 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo DEP2 ELEMENT diff --git a/instack/tests/elements/echo/install.d/50-echo b/instack/tests/elements/echo/install.d/50-echo deleted file mode 100755 index e09ea07..0000000 --- a/instack/tests/elements/echo/install.d/50-echo +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo ECHO ELEMENT diff --git a/instack/tests/elements/error/install.d/50-error b/instack/tests/elements/error/install.d/50-error deleted file mode 100755 index c3b0449..0000000 --- a/instack/tests/elements/error/install.d/50-error +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo ERROR ELEMENT >&2 -exit 1 diff --git a/instack/tests/elements/os/element-provides b/instack/tests/elements/os/element-provides deleted file mode 100644 index a72e049..0000000 --- a/instack/tests/elements/os/element-provides +++ /dev/null @@ -1 +0,0 @@ -operating-system diff --git a/instack/tests/elements/output/install.d/50-output b/instack/tests/elements/output/install.d/50-output deleted file mode 100755 index ae33619..0000000 --- a/instack/tests/elements/output/install.d/50-output +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Generate some lines of output so we can verify output is visible when -# elements are applied. -for i in `seq 10`; do - echo Line of output $i -done diff --git a/instack/tests/elements/repo/source-repository-repo b/instack/tests/elements/repo/source-repository-repo deleted file mode 100644 index 0bc4eb4..0000000 --- a/instack/tests/elements/repo/source-repository-repo +++ /dev/null @@ -1 +0,0 @@ -diskimage-builder git /tmp/diskimage-builder https://github.com/openstack/diskimage-builder.git diff --git a/instack/tests/test_runner.py b/instack/tests/test_runner.py deleted file mode 100644 index f388e58..0000000 --- a/instack/tests/test_runner.py +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright 2013 Red Hat, Inc. -# All Rights Reserved. -# -# 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 tempfile - -import mock -import testtools - -from instack import runner - - -class TestRunner(testtools.TestCase): - - def setUp(self): - super(TestRunner, self).setUp() - cwd = os.path.dirname(__file__) - # dib_elements = os.path.join(cwd, '..', '..', 'elements') - test_elements = os.path.join(cwd, 'elements') - self.element_paths = [test_elements] - - self.patcher = mock.patch.object(runner.ElementRunner, - 'generate_environment') - self.mock_env = self.patcher.start() - self.runner = runner.ElementRunner(['dep2', 'echo', 'os'], [], - self.element_paths) - tmp_dir = tempfile.mkdtemp() - self.runner.tmp_hook_dir = tmp_dir - - def tearDown(self): - super(TestRunner, self).tearDown() - self.patcher.stop() - - def test_cleanup(self): - self.runner.cleanup() - self.assertFalse(os.path.exists(self.runner.tmp_hook_dir)) - - @mock.patch.object(runner.ElementRunner, 'process_path') - def test_load_elements(self, mock_method): - self.runner.load_elements() - - self.assertEqual(len(self.element_paths), mock_method.call_count) - for idx in range(len(self.element_paths)): - self.assertEqual(mock.call(self.element_paths[idx]), - mock_method.call_args_list[idx]) - - def test_copy_elements(self): - self.runner.copy_elements() - - self.assertTrue( - os.path.exists( - os.path.join( - self.runner.tmp_hook_dir, 'install.d', '50-echo'))) - self.assertTrue( - os.path.exists( - os.path.join( - self.runner.tmp_hook_dir, 'install.d', '50-dep2'))) - - def test_load_dependencies(self): - self.runner.copy_elements() - self.runner.load_dependencies() - - self.assertEqual(4, len(self.runner.elements)) - self.assertIn('dep1', self.runner.elements) - - def test_process_exclude_elements(self): - self.runner.exclude_elements = ['dep1'] - - self.runner.copy_elements() - self.runner.load_dependencies() - self.assertEqual('dep1 dep2 echo os', - os.environ['IMAGE_ELEMENT']) - self.runner.process_exclude_elements() - - self.assertEqual(3, len(self.runner.elements)) - self.assertNotIn('dep1', self.runner.elements) - self.assertEqual('dep2 echo os', - os.environ['IMAGE_ELEMENT']) - - def test_process_path(self): - cwd = os.path.dirname(__file__) - test_elements = os.path.join(cwd, 'elements') - self.runner.loaded_elements = {} - self.runner.process_path(test_elements) - - self.assertEqual(7, len(self.runner.loaded_elements)) - self.assertIn('dep1', self.runner.loaded_elements) - self.assertIn('dep2', self.runner.loaded_elements) - self.assertIn('echo', self.runner.loaded_elements) - self.assertIn('error', self.runner.loaded_elements) - self.assertIn('output', self.runner.loaded_elements) - self.assertIn('repo', self.runner.loaded_elements) - - self.assertRaises(Exception, self.runner.process_path, - '/tmp/non/existant/path') # noqa - - @mock.patch('instack.runner.call', - return_value=0) - def test_run_hook(self, mock_call): - self.runner.copy_elements() - self.runner.load_dependencies() - self.runner.process_exclude_elements() - - self.runner.run_hook('install') - - self.assertEqual(1, mock_call.call_count) - self.assertEqual( - [runner._DIB_RUN_PARTS, - os.path.join(self.runner.tmp_hook_dir, 'install.d')], - mock_call.call_args_list[0][0][0]) - - @mock.patch('instack.runner.call', - return_value=0) - def test_blacklist(self, mock_call): - self.runner.copy_elements() - self.runner.load_dependencies() - self.runner.process_exclude_elements() - - self.runner.blacklist = ['50-echo'] - self.runner.run_hook('install') - - self.assertNotIn( - '50-echo', - os.listdir(os.path.join(self.runner.tmp_hook_dir, 'install.d'))) diff --git a/openstack-common.conf b/openstack-common.conf deleted file mode 100644 index f09d31d..0000000 --- a/openstack-common.conf +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] - -# The list of modules to copy from oslo-incubator.git -module=install_venv_common - -# The base module to hold the copy of openstack.common -base=instack \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 13fb484..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -pbr!=2.1.0,>=2.0.0 # Apache-2.0 -Babel!=2.4.0,>=2.3.4 # BSD -diskimage-builder!=1.6.0,!=1.7.0,!=1.7.1,>=1.1.2 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d3e7c0f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,48 +0,0 @@ -[metadata] -name = instack -summary = instack -description-file = - README.md -author = OpenStack -author-email = openstack-dev@lists.openstack.org -home-page = http://www.redhat.com/ -classifier = - Environment :: OpenStack - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 -[files] -packages = - instack - -[entry_points] -console_scripts = - instack = instack.main:main - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 - -[upload_sphinx] -upload-dir = doc/build/html - -[compile_catalog] -directory = instack/locale -domain = instack - -[update_catalog] -domain = instack -output_dir = instack/locale -input_file = instack/locale/instack.pot - -[extract_messages] -keywords = _ gettext ngettext l_ lazy_gettext -mapping_file = babel.cfg -output_file = instack/locale/instack.pot diff --git a/setup.py b/setup.py deleted file mode 100644 index 566d844..0000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. - -# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT -import setuptools - -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - -setuptools.setup( - setup_requires=['pbr>=2.0.0'], - pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index e16f45e..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -hacking<0.10,>=0.9.2 - -coverage!=4.4,>=4.0 # Apache-2.0 -fixtures>=3.0.0 # Apache-2.0/BSD -python-subunit>=1.0.0 # Apache-2.0/BSD -sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD -oslosphinx>=4.7.0 # Apache-2.0 -stestr>=2.0.0 # Apache-2.0 -testscenarios>=0.4 # Apache-2.0/BSD -testtools>=2.2.0 # MIT -mock>=2.0.0 # BSD diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 35999c6..0000000 --- a/tox.ini +++ /dev/null @@ -1,40 +0,0 @@ -[tox] -minversion = 1.6 -envlist = py35,py27,pep8 -skipsdist = True - -[testenv] -usedevelop = True -install_command = pip install -U {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -commands = stestr run --slowest {posargs} - -[testenv:pep8] -basepython = python3 -commands = flake8 - -[testenv:venv] -basepython = python3 -commands = {posargs} - -[testenv:cover] -basepython = python3 -setenv = - PYTHON=coverage run --source instack --parallel-mode -commands = - stestr run '{posargs}' - coverage combine - coverage html -d cover - coverage xml -o cover/coverage.xml - -[flake8] -# H803 skipped on purpose per list discussion. -# E123, E125 skipped as they are invalid PEP-8. - -show-source = True -ignore = E123,E125,H803 -builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build