fix the gnocchi resource type upgrade
This fixes the upgrade code to return -1 on exception, and the volume updates dict. Change-Id: I3eb2f718428082d4c637cf0f13d503737cfcf1cb
This commit is contained in:
parent
48325c0ad0
commit
49aac3d607
@ -93,15 +93,16 @@ resources_initial = {
|
|||||||
|
|
||||||
# NOTE(sileht): Order matter this have to be considered like alembic migration
|
# NOTE(sileht): Order matter this have to be considered like alembic migration
|
||||||
# code, because it updates the resources schema of Gnocchi
|
# code, because it updates the resources schema of Gnocchi
|
||||||
resources_update_operation = [
|
resources_update_operations = [
|
||||||
{"desc": "add volume_type to volume",
|
{"desc": "add volume_type to volume",
|
||||||
"type": "update_attribute_type",
|
"type": "update_attribute_type",
|
||||||
"resource_type": "volume",
|
"resource_type": "volume",
|
||||||
"data": {
|
"data": [{
|
||||||
"op": "add",
|
"op": "add",
|
||||||
"path": "/attributes/volume_type",
|
"path": "/attributes/volume_type",
|
||||||
"value": {"type": "string", "min_length": 0, "max_length": 255,
|
"value": {"type": "string", "min_length": 0, "max_length": 255,
|
||||||
"required": False}}},
|
"required": False}
|
||||||
|
}]},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -112,23 +113,15 @@ def upgrade_resource_types(conf):
|
|||||||
gnocchi.resource_type.get(name=name)
|
gnocchi.resource_type.get(name=name)
|
||||||
except gnocchi_exc.ResourceTypeNotFound:
|
except gnocchi_exc.ResourceTypeNotFound:
|
||||||
rt = {'name': name, 'attributes': attributes}
|
rt = {'name': name, 'attributes': attributes}
|
||||||
try:
|
gnocchi.resource_type.create(resource_type=rt)
|
||||||
gnocchi.resource_type.create(resource_type=rt)
|
|
||||||
except Exception:
|
|
||||||
LOG.error("Gnocchi resource creation fail", exc_info=True)
|
|
||||||
return
|
|
||||||
|
|
||||||
for op in resources_update_operation:
|
for ops in resources_update_operations:
|
||||||
if op['type'] == 'update_attribute_type':
|
if ops['type'] == 'update_attribute_type':
|
||||||
rt = gnocchi.resource_type.get(name=op['resource_type'])
|
rt = gnocchi.resource_type.get(name=ops['resource_type'])
|
||||||
attrib = op['data']['path'].replace('/attributes', '')
|
first_op = ops['data'][0]
|
||||||
if op['data']['op'] == 'add' and attrib in rt['attributes']:
|
attrib = first_op['path'].replace('/attributes', '')
|
||||||
|
if first_op['op'] == 'add' and attrib in rt['attributes']:
|
||||||
continue
|
continue
|
||||||
if op['data']['op'] == 'remove' and attrib not in rt['attributes']:
|
if first_op['op'] == 'remove' and attrib not in rt['attributes']:
|
||||||
continue
|
continue
|
||||||
try:
|
gnocchi.resource_type.update(ops['resource_type'], ops['data'])
|
||||||
gnocchi.resource_type.update(op['resource_type'], op['data'])
|
|
||||||
except Exception:
|
|
||||||
LOG.error("Gnocchi resource update fail: %s", op['desc'],
|
|
||||||
exc_info=True)
|
|
||||||
return
|
|
||||||
|
@ -350,16 +350,12 @@ function init_ceilometer {
|
|||||||
if is_service_enabled mysql postgresql ; then
|
if is_service_enabled mysql postgresql ; then
|
||||||
if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then
|
if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then
|
||||||
recreate_database ceilometer
|
recreate_database ceilometer
|
||||||
set -e
|
|
||||||
$CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-gnocchi-resource-types
|
$CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-gnocchi-resource-types
|
||||||
set +e
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if is_service_enabled gnocchi ; then
|
if is_service_enabled gnocchi ; then
|
||||||
if [ "$CEILOMETER_BACKEND" = 'gnocchi' ]; then
|
if [ "$CEILOMETER_BACKEND" = 'gnocchi' ]; then
|
||||||
set -e
|
|
||||||
$CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-metering-database
|
$CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-metering-database
|
||||||
set +e
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user