Upgrade testing of OpenStack projects built on top of DevStack.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upgrade-nova 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/usr/bin/env bash
  2. source ${TARGET_DEVSTACK_DIR}/lib/apache
  3. source ${TARGET_DEVSTACK_DIR}/lib/database
  4. source ${TARGET_DEVSTACK_DIR}/lib/keystone
  5. source ${TARGET_DEVSTACK_DIR}/lib/nova
  6. source ${TARGET_DEVSTACK_DIR}/lib/placement
  7. source ${TARGET_DEVSTACK_DIR}/inc/ini-config
  8. source ${TARGET_DEVSTACK_DIR}/inc/python
  9. function configure_nova_upgrade() {
  10. # TODO(mriedem): Until https://review.openstack.org/#/c/600162/ merges
  11. # in devstack, we want to continue using placement from nova. We can
  12. # remove this once the devstack change lands.
  13. if [ -z "${PLACEMENT_REPO}" ]; then
  14. echo "devstack not new enough for extracted placement."
  15. return 0
  16. fi
  17. # NOTE(mriedem): We don't need to do any of this placement DB stuff
  18. # if PLACEMENT_DB_ENABLED=True from the old side.
  19. # Devstack on the Rocky side won't install the placement repo because
  20. # it didn't exist until Stein, so unless the CI infra (devstack-gate)
  21. # already cloned the repo, we have to git clone the repo here
  22. # to get the DB script.
  23. if [[ ! -d ${TARGET_RELEASE_DIR}/placement ]]; then
  24. git_clone ${PLACEMENT_REPO} \
  25. ${TARGET_RELEASE_DIR}/placement ${TARGET_DEVSTACK_BRANCH}
  26. fi
  27. # Install placement so that placement-api script exists
  28. setup_develop ${TARGET_RELEASE_DIR}/placement
  29. # Get the location of the placement DB migration script and
  30. # verify it exists.
  31. local db_script=${TARGET_RELEASE_DIR}/placement/tools/${DATABASE_TYPE}-migrate-db.sh
  32. if [[ ! -x ${db_script} ]]; then
  33. die $LINENO "${db_script} does not exist or is not executable."
  34. fi
  35. # Get our database variables set.
  36. initialize_database_backends
  37. # Write out the contents of placement.conf.
  38. # This should be done before executing the database migration script.
  39. local placement_conf_dir=/etc/placement
  40. sudo install -d -o ${STACK_USER} ${placement_conf_dir}
  41. local placement_conf=${placement_conf_dir}/placement.conf
  42. # NOTE(mriedem): iniset will create the config file if it does not exist
  43. # NOTE(cdent): new placement uses _only_ the 'placement_database' group
  44. # for explicitness.
  45. iniset ${placement_conf} placement_database connection `database_connection_url placement`
  46. # Configure logging options.
  47. setup_logging ${placement_conf}
  48. # Configure [keystone_authtoken] option and auth cache.
  49. sudo install -d -o $STACK_USER /var/cache/placement
  50. configure_auth_token_middleware ${placement_conf} placement /var/cache/placement
  51. # Copy the remaining non-keystoneauth [placement] group options from
  52. # nova.conf if set.
  53. for option in randomize_allocation_candidates incomplete_consumer_project_id incomplete_consumer_user_id; do
  54. local value=$(iniget ${NOVA_CONF} placement ${option})
  55. if [ ${value} ]; then
  56. iniset ${placement_conf} placement ${option} ${value}
  57. fi
  58. done
  59. # Write out the migrate-db.rc file.
  60. local rc_file=/tmp/migrate-db.rc
  61. touch ${rc_file}
  62. # $db_script is an absolute path so we can execute it directly.
  63. ${db_script} --mkconfig ${rc_file}
  64. sed -i s/NOVA_API_USER.*/NOVA_API_USER=\"${DATABASE_USER}\"/g ${rc_file}
  65. sed -i s/NOVA_API_PASS.*/NOVA_API_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
  66. sed -i s/PLACEMENT_USER.*/PLACEMENT_USER=\"${DATABASE_USER}\"/g ${rc_file}
  67. sed -i s/PLACEMENT_PASS.*/PLACEMENT_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
  68. # Create the placement database.
  69. recreate_database placement
  70. # Copy the placement-related table data from the nova_api database into
  71. # the placement database and "stamp" the database version to bring it
  72. # under alembic control. Note that stamping relies on the
  73. # `placement.conf` having `[placement_database]/connection` set first.
  74. ${db_script} --migrate ${rc_file}
  75. # Copy any policy overrides from nova. We assume yaml here since that is
  76. # the default in code, but it could also be a json file.
  77. local old_policy_file=${NOVA_CONF_DIR}/placement-policy.yaml
  78. if [[ -f ${old_policy_file} ]]; then
  79. local new_policy_file=${placement_conf_dir}/policy.yaml
  80. cp ${old_policy_file} ${new_policy_file}
  81. # Update the config to point at the renamed file.
  82. iniset ${placement_conf} placement policy_file ${new_policy_file}
  83. fi
  84. # Make adjustments to uwsgi and apache configuration so that we are
  85. # pointing to the right service and configuration.
  86. # TODO(cdent): We set our own values for this instead of values from
  87. # lib/placement because we're in a dependency catch-22 with devstack
  88. # changes. When both sides have merged we can replace these with globals.
  89. # PLACEMENT_BIN_DIR is okay because it is the same whether it comes from
  90. # old or new devstack code, as long as we are not in a virtualenv.
  91. # PLACEMENT_UWSGI_CONF is used as a global so that when start_placement
  92. # is called later, it has the right value.
  93. local placement_uwsgi=${PLACEMENT_BIN_DIR}/placement-api
  94. PLACEMENT_UWSGI_CONF=${placement_conf_dir}/placement-uwsgi.ini
  95. disable_apache_site nova-placement-api
  96. # This will enable_apache_site placement-api. The entry in the service
  97. # catalog remains the same.
  98. write_uwsgi_config "${PLACEMENT_UWSGI_CONF}" "${placement_uwsgi}" "/placement"
  99. # Grenade itself will ensure that placement is restarted, and when it does
  100. # that, a new systemd unit file, pointing to the right wsgi app, is created.
  101. }