Replaces uuid.uuid4 with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids. We should use that function when generating uuids for consistency. Change-Id: I331fb62e6f7278cdac3852b84fb161732aaad2a3 Closes-Bug: #1082248
This commit is contained in:
@@ -21,13 +21,13 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import uuid
|
|
||||||
|
|
||||||
import croniter
|
import croniter
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import pecan
|
import pecan
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
import pytz
|
import pytz
|
||||||
@@ -541,7 +541,7 @@ class AlarmController(rest.RestController):
|
|||||||
project_id = pecan.request.headers.get('X-Project-Id')
|
project_id = pecan.request.headers.get('X-Project-Id')
|
||||||
on_behalf_of = on_behalf_of or project_id
|
on_behalf_of = on_behalf_of or project_id
|
||||||
severity = scrubbed_data.get('severity')
|
severity = scrubbed_data.get('severity')
|
||||||
payload = dict(event_id=str(uuid.uuid4()),
|
payload = dict(event_id=uuidutils.generate_uuid(),
|
||||||
alarm_id=self._id,
|
alarm_id=self._id,
|
||||||
type=type,
|
type=type,
|
||||||
detail=detail,
|
detail=detail,
|
||||||
@@ -567,7 +567,7 @@ class AlarmController(rest.RestController):
|
|||||||
detail = {'state': alarm.state}
|
detail = {'state': alarm.state}
|
||||||
user_id = pecan.request.headers.get('X-User-Id')
|
user_id = pecan.request.headers.get('X-User-Id')
|
||||||
project_id = pecan.request.headers.get('X-Project-Id')
|
project_id = pecan.request.headers.get('X-Project-Id')
|
||||||
payload = dict(event_id=str(uuid.uuid4()),
|
payload = dict(event_id=uuidutils.generate_uuid(),
|
||||||
alarm_id=self._id,
|
alarm_id=self._id,
|
||||||
type=type,
|
type=type,
|
||||||
detail=detail,
|
detail=detail,
|
||||||
@@ -720,7 +720,7 @@ class AlarmsController(rest.RestController):
|
|||||||
user_id = pecan.request.headers.get('X-User-Id')
|
user_id = pecan.request.headers.get('X-User-Id')
|
||||||
project_id = pecan.request.headers.get('X-Project-Id')
|
project_id = pecan.request.headers.get('X-Project-Id')
|
||||||
severity = scrubbed_data.get('severity')
|
severity = scrubbed_data.get('severity')
|
||||||
payload = dict(event_id=str(uuid.uuid4()),
|
payload = dict(event_id=uuidutils.generate_uuid(),
|
||||||
alarm_id=alarm_id,
|
alarm_id=alarm_id,
|
||||||
type=type,
|
type=type,
|
||||||
detail=detail,
|
detail=detail,
|
||||||
@@ -751,7 +751,7 @@ class AlarmsController(rest.RestController):
|
|||||||
conn = pecan.request.storage
|
conn = pecan.request.storage
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
|
|
||||||
data.alarm_id = str(uuid.uuid4())
|
data.alarm_id = uuidutils.generate_uuid()
|
||||||
user_limit, project_limit = rbac.get_limited_to(pecan.request.headers,
|
user_limit, project_limit = rbac.get_limited_to(pecan.request.headers,
|
||||||
pecan.request.enforcer)
|
pecan.request.enforcer)
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import uuid
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from aodh.i18n import _LI, _LW
|
from aodh.i18n import _LI, _LW
|
||||||
from aodh import service
|
from aodh import service
|
||||||
@@ -118,7 +118,7 @@ def conversion():
|
|||||||
{'alarm': e.sub_alarm_id, 'type': e.sub_alarm_type})
|
{'alarm': e.sub_alarm_id, 'type': e.sub_alarm_type})
|
||||||
continue
|
continue
|
||||||
new_alarm = models.Alarm(**alarm.as_dict())
|
new_alarm = models.Alarm(**alarm.as_dict())
|
||||||
new_alarm.alarm_id = str(uuid.uuid4())
|
new_alarm.alarm_id = uuidutils.generate_uuid()
|
||||||
new_alarm.name = new_name
|
new_alarm.name = new_name
|
||||||
new_alarm.type = 'composite'
|
new_alarm.type = 'composite'
|
||||||
new_alarm.description = ('composite alarm converted from combination '
|
new_alarm.description = ('composite alarm converted from combination '
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
import bisect
|
import bisect
|
||||||
import hashlib
|
import hashlib
|
||||||
import struct
|
import struct
|
||||||
import uuid
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
import tenacity
|
import tenacity
|
||||||
import tooz.coordination
|
import tooz.coordination
|
||||||
@@ -116,7 +116,7 @@ class PartitionCoordinator(object):
|
|||||||
self.backend_url = self.conf.coordination.backend_url
|
self.backend_url = self.conf.coordination.backend_url
|
||||||
self._coordinator = None
|
self._coordinator = None
|
||||||
self._groups = set()
|
self._groups = set()
|
||||||
self._my_id = my_id or str(uuid.uuid4())
|
self._my_id = my_id or uuidutils.generate_uuid()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self.backend_url:
|
if self.backend_url:
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ from futurist import periodics
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import pytz
|
import pytz
|
||||||
import six
|
import six
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
import uuid
|
|
||||||
|
|
||||||
import aodh
|
import aodh
|
||||||
from aodh import coordination
|
from aodh import coordination
|
||||||
@@ -87,7 +87,7 @@ class Evaluator(object):
|
|||||||
user_id, project_id = self.ks_client.user_id, self.ks_client.project_id
|
user_id, project_id = self.ks_client.user_id, self.ks_client.project_id
|
||||||
on_behalf_of = alarm.project_id
|
on_behalf_of = alarm.project_id
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
payload = dict(event_id=str(uuid.uuid4()),
|
payload = dict(event_id=uuidutils.generate_uuid(),
|
||||||
alarm_id=alarm.alarm_id,
|
alarm_id=alarm.alarm_id,
|
||||||
type=type,
|
type=type,
|
||||||
detail=detail,
|
detail=detail,
|
||||||
|
|||||||
@@ -14,11 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
"""Rest alarm notifier."""
|
"""Rest alarm notifier."""
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import requests
|
import requests
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
|
|
||||||
@@ -63,8 +62,8 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
|
|||||||
current, reason, reason_data, headers=None):
|
current, reason, reason_data, headers=None):
|
||||||
headers = headers or {}
|
headers = headers or {}
|
||||||
if 'x-openstack-request-id' not in headers:
|
if 'x-openstack-request-id' not in headers:
|
||||||
headers['x-openstack-request-id'] = b'req-' + str(
|
headers['x-openstack-request-id'] = b'req-' + \
|
||||||
uuid.uuid4()).encode('ascii')
|
uuidutils.generate_uuid().encode('ascii')
|
||||||
|
|
||||||
LOG.info(_LI(
|
LOG.info(_LI(
|
||||||
"Notifying alarm %(alarm_name)s %(alarm_id)s with severity"
|
"Notifying alarm %(alarm_name)s %(alarm_id)s with severity"
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient import exceptions
|
from gnocchiclient import exceptions
|
||||||
import mock
|
import mock
|
||||||
import oslo_messaging.conffixture
|
import oslo_messaging.conffixture
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
|
|
||||||
@@ -152,8 +152,8 @@ class TestAlarmsBase(v2.FunctionalTest):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestAlarmsBase, self).setUp()
|
super(TestAlarmsBase, self).setUp()
|
||||||
self.auth_headers = {'X-User-Id': str(uuid.uuid4()),
|
self.auth_headers = {'X-User-Id': uuidutils.generate_uuid(),
|
||||||
'X-Project-Id': str(uuid.uuid4())}
|
'X-Project-Id': uuidutils.generate_uuid()}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_default_threshold_rule(alarm):
|
def _add_default_threshold_rule(alarm):
|
||||||
@@ -1971,8 +1971,8 @@ class TestAlarmsHistory(TestAlarmsBase):
|
|||||||
def test_get_recorded_alarm_history_state_transition_on_behalf_of(self):
|
def test_get_recorded_alarm_history_state_transition_on_behalf_of(self):
|
||||||
# credentials for new non-admin user, on who's behalf the alarm
|
# credentials for new non-admin user, on who's behalf the alarm
|
||||||
# is created
|
# is created
|
||||||
member_user = str(uuid.uuid4())
|
member_user = uuidutils.generate_uuid()
|
||||||
member_project = str(uuid.uuid4())
|
member_project = uuidutils.generate_uuid()
|
||||||
member_auth = {'X-Roles': 'member',
|
member_auth = {'X-Roles': 'member',
|
||||||
'X-User-Id': member_user,
|
'X-User-Id': member_user,
|
||||||
'X-Project-Id': member_project}
|
'X-Project-Id': member_project}
|
||||||
@@ -1997,8 +1997,8 @@ class TestAlarmsHistory(TestAlarmsBase):
|
|||||||
alarm = self.get_json('/alarms', headers=member_auth)[0]
|
alarm = self.get_json('/alarms', headers=member_auth)[0]
|
||||||
|
|
||||||
# effect a state transition as a new administrative user
|
# effect a state transition as a new administrative user
|
||||||
admin_user = str(uuid.uuid4())
|
admin_user = uuidutils.generate_uuid()
|
||||||
admin_project = str(uuid.uuid4())
|
admin_project = uuidutils.generate_uuid()
|
||||||
admin_auth = {'X-Roles': 'admin',
|
admin_auth = {'X-Roles': 'admin',
|
||||||
'X-User-Id': admin_user,
|
'X-User-Id': admin_user,
|
||||||
'X-Project-Id': admin_project}
|
'X-Project-Id': admin_project}
|
||||||
@@ -2045,8 +2045,8 @@ class TestAlarmsHistory(TestAlarmsBase):
|
|||||||
'rule change',
|
'rule change',
|
||||||
detail)
|
detail)
|
||||||
auth = {'X-Roles': 'member',
|
auth = {'X-Roles': 'member',
|
||||||
'X-User-Id': str(uuid.uuid4()),
|
'X-User-Id': uuidutils.generate_uuid(),
|
||||||
'X-Project-Id': str(uuid.uuid4())}
|
'X-Project-Id': uuidutils.generate_uuid()}
|
||||||
self._get_alarm_history('a', auth_headers=auth,
|
self._get_alarm_history('a', auth_headers=auth,
|
||||||
expect_errors=True, status=404)
|
expect_errors=True, status=404)
|
||||||
|
|
||||||
@@ -2246,7 +2246,7 @@ class TestAlarmsQuotas(TestAlarmsBase):
|
|||||||
self.assertEqual(201, resp.status_code)
|
self.assertEqual(201, resp.status_code)
|
||||||
_test('project_id', self.auth_headers['X-Project-Id'])
|
_test('project_id', self.auth_headers['X-Project-Id'])
|
||||||
|
|
||||||
self.auth_headers['X-Project-Id'] = str(uuid.uuid4())
|
self.auth_headers['X-Project-Id'] = uuidutils.generate_uuid()
|
||||||
alarm['name'] = 'another_user_alarm'
|
alarm['name'] = 'another_user_alarm'
|
||||||
alarm['project_id'] = self.auth_headers['X-Project-Id']
|
alarm['project_id'] = self.auth_headers['X-Project-Id']
|
||||||
resp = self.post_json('/alarms', params=alarm,
|
resp = self.post_json('/alarms', params=alarm,
|
||||||
@@ -2586,8 +2586,8 @@ class TestAlarmsRuleCombination(TestAlarmsBase):
|
|||||||
'operator': 'and',
|
'operator': 'and',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
an_other_user_auth = {'X-User-Id': str(uuid.uuid4()),
|
an_other_user_auth = {'X-User-Id': uuidutils.generate_uuid(),
|
||||||
'X-Project-Id': str(uuid.uuid4())}
|
'X-Project-Id': uuidutils.generate_uuid()}
|
||||||
resp = self.post_json('/alarms', params=json, status=404,
|
resp = self.post_json('/alarms', params=json, status=404,
|
||||||
headers=an_other_user_auth)
|
headers=an_other_user_auth)
|
||||||
self.assertEqual("Alarm a not found in project "
|
self.assertEqual("Alarm a not found in project "
|
||||||
@@ -2679,8 +2679,8 @@ class TestAlarmsRuleCombination(TestAlarmsBase):
|
|||||||
'operator': 'and',
|
'operator': 'and',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
an_other_admin_auth = {'X-User-Id': str(uuid.uuid4()),
|
an_other_admin_auth = {'X-User-Id': uuidutils.generate_uuid(),
|
||||||
'X-Project-Id': str(uuid.uuid4()),
|
'X-Project-Id': uuidutils.generate_uuid(),
|
||||||
'X-Roles': 'admin'}
|
'X-Roles': 'admin'}
|
||||||
if owner_is_set:
|
if owner_is_set:
|
||||||
json['project_id'] = an_other_admin_auth['X-Project-Id']
|
json['project_id'] = an_other_admin_auth['X-Project-Id']
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
"""Base classes for API tests."""
|
"""Base classes for API tests."""
|
||||||
import os
|
import os
|
||||||
import uuid
|
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo_config import fixture as fixture_config
|
from oslo_config import fixture as fixture_config
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
@@ -33,7 +33,7 @@ from aodh.tests import base as test_base
|
|||||||
class SQLManager(fixtures.Fixture):
|
class SQLManager(fixtures.Fixture):
|
||||||
def __init__(self, conf):
|
def __init__(self, conf):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
db_name = 'aodh_%s' % uuid.uuid4().hex
|
db_name = 'aodh_%s' % uuidutils.generate_uuid(dashed=False)
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
self._engine = sqlalchemy.create_engine(conf.database.connection)
|
self._engine = sqlalchemy.create_engine(conf.database.connection)
|
||||||
self._conn = self._engine.connect()
|
self._conn = self._engine.connect()
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
"""Fixtures used during Gabbi-based test runs."""
|
"""Fixtures used during Gabbi-based test runs."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gabbi import fixture
|
from gabbi import fixture
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_config import fixture as fixture_config
|
from oslo_config import fixture as fixture_config
|
||||||
from oslo_policy import opts
|
from oslo_policy import opts
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
import sqlalchemy_utils
|
import sqlalchemy_utils
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ class ConfigFixture(fixture.GabbiFixture):
|
|||||||
parsed_url = urlparse.urlparse(db_url)
|
parsed_url = urlparse.urlparse(db_url)
|
||||||
if parsed_url.scheme != 'sqlite':
|
if parsed_url.scheme != 'sqlite':
|
||||||
parsed_url = list(parsed_url)
|
parsed_url = list(parsed_url)
|
||||||
parsed_url[2] += '-%s' % str(uuid.uuid4()).replace('-', '')
|
parsed_url[2] += '-%s' % uuidutils.generate_uuid(dashed=False)
|
||||||
db_url = urlparse.urlunparse(parsed_url)
|
db_url = urlparse.urlunparse(parsed_url)
|
||||||
|
|
||||||
conf.set_override('connection', db_url, group='database',
|
conf.set_override('connection', db_url, group='database',
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import uuid
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from tempest.common.utils import data_utils
|
from tempest.common.utils import data_utils
|
||||||
from tempest.lib import exceptions as lib_exc
|
from tempest.lib import exceptions as lib_exc
|
||||||
from tempest import test
|
from tempest import test
|
||||||
@@ -34,7 +33,7 @@ class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
|
|||||||
@test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7e')
|
@test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7e')
|
||||||
def test_get_non_existent_alarm(self):
|
def test_get_non_existent_alarm(self):
|
||||||
# get the non-existent alarm
|
# get the non-existent alarm
|
||||||
non_existent_id = str(uuid.uuid4())
|
non_existent_id = uuidutils.generate_uuid()
|
||||||
self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
|
self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
|
||||||
non_existent_id)
|
non_existent_id)
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import uuid
|
|
||||||
|
|
||||||
from ceilometerclient import exc
|
from ceilometerclient import exc
|
||||||
from ceilometerclient.v2 import alarms
|
from ceilometerclient.v2 import alarms
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from aodh.evaluator import combination
|
from aodh.evaluator import combination
|
||||||
@@ -42,7 +42,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='foobar',
|
user_id='foobar',
|
||||||
project_id='snafu',
|
project_id='snafu',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
@@ -64,7 +64,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='foobar',
|
user_id='foobar',
|
||||||
project_id='snafu',
|
project_id='snafu',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
|
|||||||
@@ -13,11 +13,10 @@
|
|||||||
"""Tests for aodh/evaluator/composite.py
|
"""Tests for aodh/evaluator/composite.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from ceilometerclient.v2 import statistics
|
from ceilometerclient.v2 import statistics
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
@@ -123,7 +122,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='fake_user',
|
user_id='fake_user',
|
||||||
project_id='fake_project',
|
project_id='fake_project',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
@@ -151,7 +150,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
ok_actions=[],
|
ok_actions=[],
|
||||||
alarm_actions=[],
|
alarm_actions=[],
|
||||||
repeat_actions=False,
|
repeat_actions=False,
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
time_constraints=[],
|
time_constraints=[],
|
||||||
rule={
|
rule={
|
||||||
"or": [self.sub_rule1, self.sub_rule2,
|
"or": [self.sub_rule1, self.sub_rule2,
|
||||||
@@ -172,7 +171,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
ok_actions=[],
|
ok_actions=[],
|
||||||
alarm_actions=[],
|
alarm_actions=[],
|
||||||
repeat_actions=False,
|
repeat_actions=False,
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
time_constraints=[],
|
time_constraints=[],
|
||||||
rule={
|
rule={
|
||||||
"and": [self.sub_rule1, self.sub_rule2,
|
"and": [self.sub_rule1, self.sub_rule2,
|
||||||
@@ -186,7 +185,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='fake_user',
|
user_id='fake_user',
|
||||||
project_id='fake_project',
|
project_id='fake_project',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import six
|
import six
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from aodh import evaluator
|
from aodh import evaluator
|
||||||
from aodh.evaluator import event as event_evaluator
|
from aodh.evaluator import event as event_evaluator
|
||||||
@@ -34,7 +34,7 @@ class TestEventAlarmEvaluate(base.TestEvaluatorBase):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _alarm(**kwargs):
|
def _alarm(**kwargs):
|
||||||
alarm_id = kwargs.get('id') or str(uuid.uuid4())
|
alarm_id = kwargs.get('id') or uuidutils.generate_uuid()
|
||||||
return models.Alarm(name=kwargs.get('name', alarm_id),
|
return models.Alarm(name=kwargs.get('name', alarm_id),
|
||||||
type='event',
|
type='event',
|
||||||
enabled=True,
|
enabled=True,
|
||||||
@@ -56,7 +56,7 @@ class TestEventAlarmEvaluate(base.TestEvaluatorBase):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _event(**kwargs):
|
def _event(**kwargs):
|
||||||
return {'message_id': kwargs.get('id') or str(uuid.uuid4()),
|
return {'message_id': kwargs.get('id') or uuidutils.generate_uuid(),
|
||||||
'event_type': kwargs.get('event_type', 'type0'),
|
'event_type': kwargs.get('event_type', 'type0'),
|
||||||
'traits': kwargs.get('traits', [])}
|
'traits': kwargs.get('traits', [])}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ class TestEventAlarmEvaluate(base.TestEvaluatorBase):
|
|||||||
|
|
||||||
def test_skip_event_missing_event_type(self):
|
def test_skip_event_missing_event_type(self):
|
||||||
alarm = self._alarm()
|
alarm = self._alarm()
|
||||||
event = {'message_id': str(uuid.uuid4()), 'traits': []}
|
event = {'message_id': uuidutils.generate_uuid(), 'traits': []}
|
||||||
self._do_test_event_alarm(
|
self._do_test_event_alarm(
|
||||||
[alarm], [event],
|
[alarm], [event],
|
||||||
expect_alarm_states={alarm.alarm_id: evaluator.UNKNOWN},
|
expect_alarm_states={alarm.alarm_id: evaluator.UNKNOWN},
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import unittest
|
import unittest
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient import exceptions
|
from gnocchiclient import exceptions
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
import pytz
|
import pytz
|
||||||
import six
|
import six
|
||||||
@@ -43,7 +43,7 @@ class TestGnocchiEvaluatorBase(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='foobar',
|
user_id='foobar',
|
||||||
project_id='snafu',
|
project_id='snafu',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
@@ -75,7 +75,7 @@ class TestGnocchiEvaluatorBase(base.TestEvaluatorBase):
|
|||||||
ok_actions=[],
|
ok_actions=[],
|
||||||
alarm_actions=[],
|
alarm_actions=[],
|
||||||
repeat_actions=False,
|
repeat_actions=False,
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
time_constraints=[],
|
time_constraints=[],
|
||||||
rule=dict(
|
rule=dict(
|
||||||
comparison_operator='le',
|
comparison_operator='le',
|
||||||
@@ -92,7 +92,7 @@ class TestGnocchiEvaluatorBase(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='foobar',
|
user_id='foobar',
|
||||||
project_id='snafu',
|
project_id='snafu',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import uuid
|
|
||||||
|
|
||||||
from ceilometerclient import exc
|
from ceilometerclient import exc
|
||||||
from ceilometerclient.v2 import statistics
|
from ceilometerclient.v2 import statistics
|
||||||
import mock
|
import mock
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import pytz
|
import pytz
|
||||||
from six import moves
|
from six import moves
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
enabled=True,
|
enabled=True,
|
||||||
user_id='foobar',
|
user_id='foobar',
|
||||||
project_id='snafu',
|
project_id='snafu',
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
state='insufficient data',
|
state='insufficient data',
|
||||||
state_timestamp=constants.MIN_DATETIME,
|
state_timestamp=constants.MIN_DATETIME,
|
||||||
timestamp=constants.MIN_DATETIME,
|
timestamp=constants.MIN_DATETIME,
|
||||||
@@ -81,7 +81,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
ok_actions=[],
|
ok_actions=[],
|
||||||
alarm_actions=[],
|
alarm_actions=[],
|
||||||
repeat_actions=False,
|
repeat_actions=False,
|
||||||
alarm_id=str(uuid.uuid4()),
|
alarm_id=uuidutils.generate_uuid(),
|
||||||
time_constraints=[],
|
time_constraints=[],
|
||||||
rule=dict(
|
rule=dict(
|
||||||
comparison_operator='le',
|
comparison_operator='le',
|
||||||
@@ -290,7 +290,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||||||
payloads.append(payload)
|
payloads.append(payload)
|
||||||
return payloads
|
return payloads
|
||||||
|
|
||||||
@mock.patch.object(uuid, 'uuid4')
|
@mock.patch.object(uuidutils, 'generate_uuid')
|
||||||
@mock.patch.object(timeutils, 'utcnow')
|
@mock.patch.object(timeutils, 'utcnow')
|
||||||
@mock.patch.object(messaging, 'get_notifier')
|
@mock.patch.object(messaging, 'get_notifier')
|
||||||
def test_alarm_change_record(self, get_notifier, utcnow, mock_uuid):
|
def test_alarm_change_record(self, get_notifier, utcnow, mock_uuid):
|
||||||
|
|||||||
Reference in New Issue
Block a user