From 1646647564d5410d7f0379bf9b6d6985df42ffda Mon Sep 17 00:00:00 2001 From: Deklan Dieterly Date: Wed, 14 Oct 2015 16:44:57 -0600 Subject: [PATCH] Fix double decode bug in notifications Notifications was trying to double decode utf-8 data. Also, make monasca-ci dir variable. Change-Id: I95d2008bd313cb813f5341933c4b95390de7cfab --- devstack/plugin.sh | 15 ++++++++------- monasca_api/v2/reference/notifications.py | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index c0212000b..33f6854e1 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -1227,18 +1227,19 @@ function install_monasca_smoke_test { sudo tar -xzf /opt/monasca/monasca-ci.tar.gz -C /opt/monasca - sudo sed -i s/192\.168\.10\.4/127\.0\.0\.1/g /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/utils.py - sudo sed -i s/192\.168\.10\.5/127\.0\.0\.1/g /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/utils.py - sudo sed -i "s/'hostname', '-f'/'hostname'/g" /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/smoke_configs.py + HPCLOUD_MON_MONASCA_CI_DIR=$(ls -td /opt/monasca/hpcloud-mon-monasca-ci-* | head -1) + + sudo sed -i s/192\.168\.10\.4/127\.0\.0\.1/g ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/utils.py + sudo sed -i s/192\.168\.10\.5/127\.0\.0\.1/g ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/utils.py + sudo sed -i "s/'hostname', '-f'/'hostname'/g" ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/smoke_configs.py (cd /opt/monasca ; sudo -H ./bin/pip install influxdb) - sudo cp -f /opt/stack/monasca/devstack/files/monasca-smoke-test/smoke2_configs.py /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/smoke2_configs.py + sudo cp -f /opt/stack/monasca/devstack/files/monasca-smoke-test/smoke2_configs.py ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/smoke2_configs.py - sudo /opt/monasca/bin/python /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/smoke2.py || true - - (cd /opt/monasca ; LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 OS_USERNAME=test OS_PASSWORD=password OS_PROJECT_NAME=test OS_AUTH_URL=http://127.0.0.1:35357/v3 bash -c 'sudo /opt/monasca/bin/python /opt/monasca/hpcloud-mon-monasca-ci-7a45d29/tests/smoke/smoke.py' || true) + sudo /opt/monasca/bin/python ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/smoke2.py || true + (cd /opt/monasca ; LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 OS_USERNAME=test OS_PASSWORD=password OS_PROJECT_NAME=test OS_AUTH_URL=http://127.0.0.1:35357/v3 bash -c "sudo /opt/monasca/bin/python ${HPCLOUD_MON_MONASCA_CI_DIR}/tests/smoke/smoke.py") } function clean_monasca_smoke_test { diff --git a/monasca_api/v2/reference/notifications.py b/monasca_api/v2/reference/notifications.py index 6ca68f2e8..0a5f0d47c 100644 --- a/monasca_api/v2/reference/notifications.py +++ b/monasca_api/v2/reference/notifications.py @@ -53,9 +53,9 @@ class Notifications(notifications_api_v2.NotificationsV2API): @resource.resource_try_catch_block def _create_notification(self, tenant_id, notification, uri): - name = notification['name'].decode('utf8') - notification_type = notification['type'].upper().decode('utf8') - address = notification['address'].decode('utf8') + name = notification['name'] + notification_type = notification['type'].upper() + address = notification['address'] notification_id = self._notifications_repo.create_notification( tenant_id, name, @@ -71,9 +71,9 @@ class Notifications(notifications_api_v2.NotificationsV2API): @resource.resource_try_catch_block def _update_notification(self, id, tenant_id, notification, uri): - name = notification['name'].decode('utf8') - notification_type = notification['type'].upper().decode('utf8') - address = notification['address'].decode('utf8') + name = notification['name'] + notification_type = notification['type'].upper() + address = notification['address'] self._notifications_repo.update_notification(id, tenant_id, name, notification_type, address)