From da2da6969aaf43e57af2356e15742368e527f662 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Thu, 26 Nov 2020 11:02:24 +1300 Subject: [PATCH] Support --image-tags for trove-manager datastore_version_update command image-tags was introduced in commit 1d24b65 but the implementation was backward incompatible for the CLI `trove-manager datastore_version_update`. This patch changes that by supporting an optional parameter `--image-tags`. Change-Id: I583c296f15a453bdfadf10de5c678ac483cbd4dd --- devstack/plugin.sh | 2 +- doc/source/admin/upgrade.rst | 2 +- doc/source/cli/trove-manage.rst | 17 +++++++++-------- integration/scripts/trovestack | 3 ++- trove/cmd/manage.py | 10 +++++----- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index afda34a69e..56cedd411e 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -485,7 +485,7 @@ function create_guest_image { echo "Register the image in datastore" $TROVE_MANAGE datastore_update $TROVE_DATASTORE_TYPE "" - $TROVE_MANAGE datastore_version_update $TROVE_DATASTORE_TYPE $TROVE_DATASTORE_VERSION $TROVE_DATASTORE_TYPE "" "trove" "" 1 + $TROVE_MANAGE datastore_version_update $TROVE_DATASTORE_TYPE $TROVE_DATASTORE_VERSION $TROVE_DATASTORE_TYPE "" "" 1 --image-tags trove $TROVE_MANAGE datastore_update $TROVE_DATASTORE_TYPE $TROVE_DATASTORE_VERSION echo "Add parameter validation rules if available" diff --git a/doc/source/admin/upgrade.rst b/doc/source/admin/upgrade.rst index 1e4946cadd..757c06fd0f 100644 --- a/doc/source/admin/upgrade.rst +++ b/doc/source/admin/upgrade.rst @@ -157,7 +157,7 @@ Upgrade Trove services --property hw_rng_model='virtio' \ --tag trove \ -c id -f value) - $ trove-manage datastore_version_update mysql 5.7.29 mysql $imageid "" "" 1 + $ trove-manage datastore_version_update mysql 5.7.29 mysql $imageid "" 1 $ trove-manage db_load_datastore_config_parameters mysql 5.7.29 $stackdir/trove/trove/templates/mysql/validation-rules.json Upgrade Trove guest agent diff --git a/doc/source/cli/trove-manage.rst b/doc/source/cli/trove-manage.rst index ef2bb8a71f..2e890739dc 100644 --- a/doc/source/cli/trove-manage.rst +++ b/doc/source/cli/trove-manage.rst @@ -200,7 +200,8 @@ trove-manage datastore_version_update usage: trove-manage datastore_version_update [-h] datastore version_name manager - image_id image_tags packages active + image_id packages active + --image-tags Add or update a datastore version. If the datastore version already exists, all values except the datastore name and version will be updated. @@ -219,13 +220,6 @@ all values except the datastore name and version will be updated. ``image_id`` ID of the image used to create an instance of the datastore version. -``image_tags`` - List of image tags separated by comma. If the image ID is not provided - explicitly, the image can be retrieved by the image tags. Multiple image tags - are separated by comma, e.g. trove,mysql. Using image tags is more flexible - than ID especially when new guest image is uploaded to Glance, Trove can pick - up the latest image automatically for creating instances. - ``packages`` Packages required by the datastore version that are installed on the guest image. @@ -239,6 +233,13 @@ all values except the datastore name and version will be updated. ``-h, --help`` show this help message and exit +``--image-tags`` + List of image tags separated by comma. If the image ID is not provided + explicitly, the image can be retrieved by the image tags. Multiple image tags + are separated by comma, e.g. trove,mysql. Using image tags is more flexible + than ID especially when new guest image is uploaded to Glance, Trove can pick + up the latest image automatically for creating instances. + trove-manage db_downgrade ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/integration/scripts/trovestack b/integration/scripts/trovestack index 5672ca132a..0045fff574 100755 --- a/integration/scripts/trovestack +++ b/integration/scripts/trovestack @@ -522,7 +522,8 @@ function set_bin_path() { function cmd_set_datastore() { rd_manage datastore_update "$datastore" "" - rd_manage datastore_version_update "${DATASTORE_TYPE}" "${DATASTORE_VERSION}" "${DATASTORE_TYPE}" "" "trove" "" 1 + # Use image tags for datastore version. + rd_manage datastore_version_update "${DATASTORE_TYPE}" "${DATASTORE_VERSION}" "${DATASTORE_TYPE}" "" "" 1 --image-tags trove rd_manage datastore_update "${DATASTORE_TYPE}" "${DATASTORE_VERSION}" if [[ -f "$PATH_TROVE"/trove/templates/${DATASTORE_TYPE}/validation-rules.json ]]; then diff --git a/trove/cmd/manage.py b/trove/cmd/manage.py index e456451e2b..c6e3c6757d 100644 --- a/trove/cmd/manage.py +++ b/trove/cmd/manage.py @@ -62,7 +62,7 @@ class Commands(object): print(e) def datastore_version_update(self, datastore, version_name, manager, - image_id, image_tags, packages, active, + image_id, packages, active, image_tags=None, version=None): try: datastore_models.update_datastore_version(datastore, @@ -251,10 +251,6 @@ def main(): 'image_id', help='ID of the image used to create an instance of ' 'the datastore version.') - parser.add_argument( - 'image_tags', - help='List of image tags separated by comma used for getting ' - 'guest image.') parser.add_argument( 'packages', help='Packages required by the datastore version that ' 'are installed on the guest image.') @@ -262,6 +258,10 @@ def main(): 'active', type=int, help='Whether the datastore version is active or not. ' 'Accepted values are 0 and 1.') + parser.add_argument( + '--image-tags', + help='List of image tags separated by comma used for getting ' + 'guest image.') parser.add_argument( '--version', help='The version number of the datastore version, e.g. 5.7.30. '