postscript_951.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- coding: utf-8 -*-
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software
  9. # distributed under the License is distributed on an "AS IS" BASIS,
  10. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  11. # implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """
  15. Plugin responsible for post-installation configuration
  16. """
  17. from packstack.installer import utils
  18. from packstack.installer import basedefs
  19. # ------------- Postscript Packstack Plugin Initialization --------------
  20. PLUGIN_NAME = "Postscript"
  21. PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue')
  22. def initConfig(controller):
  23. group = {"GROUP_NAME": "POSTSCRIPT",
  24. "DESCRIPTION": "POSTSCRIPT Config parameters",
  25. "PRE_CONDITION": lambda x: 'yes',
  26. "PRE_CONDITION_MATCH": "yes",
  27. "POST_CONDITION": False,
  28. "POST_CONDITION_MATCH": True}
  29. controller.addGroup(group, [])
  30. def initSequences(controller):
  31. config = controller.CONF
  32. postscript_steps = []
  33. if (config['CONFIG_PROVISION_TEMPEST'] == "y" and
  34. config['CONFIG_RUN_TEMPEST'] == "y"):
  35. postscript_steps.append(
  36. {'title': 'Running Tempest',
  37. 'functions': [run_tempest]}
  38. )
  39. controller.addSequence("Running post install scripts", [], [],
  40. postscript_steps)
  41. # -------------------------- step functions --------------------------
  42. def run_tempest(config, messages):
  43. logfile = basedefs.DIR_LOG + "/tempest.log"
  44. print("Running Tempest on %s" % config['CONFIG_TEMPEST_HOST'])
  45. server = utils.ScriptRunner(config['CONFIG_TEMPEST_HOST'])
  46. server.append('pushd /var/lib/tempest')
  47. server.append('tempest run --regex \'(%s)\' --concurrency 2 > %s'
  48. % (config['CONFIG_RUN_TEMPEST_TESTS'].replace(' ', '|'),
  49. logfile))
  50. server.append('popd')
  51. server.execute()