Upgrade scripts to migrate aodh alarm data
authorPradeep Kilambi <pkilambi@redhat.com>
Mon, 8 Aug 2016 19:20:18 +0000 (15:20 -0400)
committerPradeep Kilambi <pkilambi@redhat.com>
Wed, 17 Aug 2016 12:40:06 +0000 (12:40 +0000)
In Newton, Aodh will be using its own mysql DB rather than
using ceilometer's mongo instance. This means we need to
migrate any existing alarm and alrm history data from
ceilometer DB to aodh mysqlDB. Upstream aodh provides us
with a aodh-data-migration utility. We need to invoke this
during the mitaka->newton upgrade procedure so data is
migrated as expected and aodh mysql backend takes over.

Closes-bug: #1611794

Change-Id: I17888b57ecf98cd83e92af2f9cdbead066b03aa3

environments/major-upgrade-aodh-migration.yaml [new file with mode: 0644]
extraconfig/tasks/aodh_data_migration.sh [new file with mode: 0644]
extraconfig/tasks/mitaka_to_newton_aodh_data_migration.yaml [new file with mode: 0644]

diff --git a/environments/major-upgrade-aodh-migration.yaml b/environments/major-upgrade-aodh-migration.yaml
new file mode 100644 (file)
index 0000000..c1dbde4
--- /dev/null
@@ -0,0 +1,10 @@
+resource_registry:
+  # aodh data migration
+  OS::TripleO::Tasks::UpdateWorkflow: ../extraconfig/tasks/mitaka_to_newton_aodh_data_migration.yaml
+
+  # no-op the rest
+  OS::TripleO::ControllerPostDeployment: OS::Heat::None
+  OS::TripleO::ComputePostDeployment: OS::Heat::None
+  OS::TripleO::ObjectStoragePostDeployment: OS::Heat::None
+  OS::TripleO::BlockStoragePostDeployment: OS::Heat::None
+  OS::TripleO::CephStoragePostDeployment: OS::Heat::None
diff --git a/extraconfig/tasks/aodh_data_migration.sh b/extraconfig/tasks/aodh_data_migration.sh
new file mode 100644 (file)
index 0000000..d4c2967
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# This delivers the aodh data migration script to be invoked as part of the tripleo
+# major upgrade workflow to migrate all the alarm data from mongodb to mysql.
+# This needs to run post controller node upgrades so new aodh mysql db configured and
+# running.
+#
+set -eu
+
+#Get existing mongodb connection
+MONGO_DB_CONNECTION="$(crudini --get /etc/ceilometer/ceilometer.conf database connection)"
+
+# Get the aodh database string from hiera data
+MYSQL_DB_CONNECTION="$(crudini --get /etc/aodh/aodh.conf database connection)"
+
+#Run migration
+/usr/bin/aodh-data-migration --nosql-conn $MONGO_DB_CONNECTION --sql-conn $MYSQL_DB_CONNECTION
+
+
diff --git a/extraconfig/tasks/mitaka_to_newton_aodh_data_migration.yaml b/extraconfig/tasks/mitaka_to_newton_aodh_data_migration.yaml
new file mode 100644 (file)
index 0000000..9414ac1
--- /dev/null
@@ -0,0 +1,33 @@
+heat_template_version: 2014-10-16
+
+description: >
+  Software-config for performing aodh data migration
+
+parameters:
+  controller_servers:
+    type: json
+  compute_servers:
+    type: json
+  blockstorage_servers:
+    type: json
+  objectstorage_servers:
+    type: json
+  cephstorage_servers:
+    type: json
+  input_values:
+    type: json
+    description: input values for the software deployments
+resources:
+
+  AodhMysqlMigrationScriptConfig:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: script
+      config: {get_file: aodh_data_migration.sh}
+
+  AodhMysqlMigrationScriptDeployment:
+    type: OS::Heat::SoftwareDeploymentGroup
+    properties:
+      servers:  {get_param: controller_servers}
+      config: {get_resource: AodhMysqlMigrationScriptConfig}
+      input_values: {get_param: input_values}