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
This commit is contained in:
Lingxian Kong 2020-11-26 11:02:24 +13:00
parent 3a3b82452d
commit da2da6969a
5 changed files with 18 additions and 16 deletions

View File

@ -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"

View File

@ -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

View File

@ -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 <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
~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -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

View File

@ -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. '