Rewrite dictionary creation as a dictionary literal
Do that if it makes sense Change-Id: I4c53ca90c082faa62d8584f75d5bb0a31bb5131f
This commit is contained in:
parent
1f3bea3081
commit
fa8eaf7a4a
@ -39,15 +39,14 @@ class ComputeMetricsNotificationBase(notifications.ComputeNotificationBase):
|
|||||||
try:
|
try:
|
||||||
for metric in message['payload']['metrics']:
|
for metric in message['payload']['metrics']:
|
||||||
if name == metric['name']:
|
if name == metric['name']:
|
||||||
info = {}
|
info = {'payload': metric,
|
||||||
info['payload'] = metric
|
'event_type': message['event_type'],
|
||||||
info['event_type'] = message['event_type']
|
'publisher_id': message['publisher_id'],
|
||||||
info['publisher_id'] = message['publisher_id']
|
'resource_id': '%s_%s' % (
|
||||||
info['resource_id'] = '%s_%s' % (
|
message['payload']['host'],
|
||||||
message['payload']['host'],
|
message['payload']['nodename']),
|
||||||
message['payload']['nodename'])
|
'timestamp': str(timeutils.parse_strtime(
|
||||||
info['timestamp'] = str(timeutils.parse_strtime(
|
metric['timestamp']))}
|
||||||
metric['timestamp']))
|
|
||||||
return info
|
return info
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
LOG.warning(_('An error occurred while building %(m)s '
|
LOG.warning(_('An error occurred while building %(m)s '
|
||||||
|
@ -96,14 +96,13 @@ class SensorNotification(plugin.NotificationBase):
|
|||||||
data)
|
data)
|
||||||
|
|
||||||
def _package_payload(self, message, payload):
|
def _package_payload(self, message, payload):
|
||||||
info = {}
|
|
||||||
info['publisher_id'] = message['publisher_id']
|
|
||||||
info['timestamp'] = message['payload']['timestamp']
|
|
||||||
info['event_type'] = message['payload']['event_type']
|
|
||||||
info['user_id'] = message['payload'].get('user_id')
|
|
||||||
info['project_id'] = message['payload'].get('project_id')
|
|
||||||
# NOTE(chdent): How much of the payload should we keep?
|
# NOTE(chdent): How much of the payload should we keep?
|
||||||
info['payload'] = payload
|
info = {'publisher_id': message['publisher_id'],
|
||||||
|
'timestamp': message['payload']['timestamp'],
|
||||||
|
'event_type': message['payload']['event_type'],
|
||||||
|
'user_id': message['payload'].get('user_id'),
|
||||||
|
'project_id': message['payload'].get('project_id'),
|
||||||
|
'payload': payload}
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def process_notification(self, message):
|
def process_notification(self, message):
|
||||||
|
@ -53,8 +53,7 @@ class TestDispatcherDB(test.BaseTestCase):
|
|||||||
msg = {'counter_name': 'test',
|
msg = {'counter_name': 'test',
|
||||||
'resource_id': self.id(),
|
'resource_id': self.id(),
|
||||||
'counter_volume': 1,
|
'counter_volume': 1,
|
||||||
}
|
'message_signature': 'invalid-signature'}
|
||||||
msg['message_signature'] = 'invalid-signature'
|
|
||||||
|
|
||||||
class ErrorConnection:
|
class ErrorConnection:
|
||||||
|
|
||||||
|
@ -39,10 +39,9 @@ class TestClientHTTPBasicAuth(test.BaseTestCase):
|
|||||||
self.parsed_url.netloc,
|
self.parsed_url.netloc,
|
||||||
self.parsed_url.path,
|
self.parsed_url.path,
|
||||||
None, None, None))
|
None, None, None))
|
||||||
odl_params = {}
|
odl_params = {'auth': self.params.get('auth')[0],
|
||||||
odl_params['auth'] = self.params.get('auth')[0]
|
'user': self.params.get('user')[0],
|
||||||
odl_params['user'] = self.params.get('user')[0]
|
'password': self.params.get('password')[0]}
|
||||||
odl_params['password'] = self.params.get('password')[0]
|
|
||||||
self.client = client.Client(self.endpoint, odl_params)
|
self.client = client.Client(self.endpoint, odl_params)
|
||||||
|
|
||||||
self.resp = mock.MagicMock()
|
self.resp = mock.MagicMock()
|
||||||
|
@ -88,7 +88,6 @@ class TestFloatingIPPollster(test.BaseTestCase):
|
|||||||
self.assertEqual(set(['ip.floating']), set([s.name for s in samples]))
|
self.assertEqual(set(['ip.floating']), set([s.name for s in samples]))
|
||||||
|
|
||||||
def test_get_samples_cached(self):
|
def test_get_samples_cached(self):
|
||||||
cache = {}
|
cache = {'floating_ips': self.fake_get_ips()[:2]}
|
||||||
cache['floating_ips'] = self.fake_get_ips()[:2]
|
|
||||||
samples = list(self.pollster.get_samples(self.manager, cache))
|
samples = list(self.pollster.get_samples(self.manager, cache))
|
||||||
self.assertEqual(2, len(samples))
|
self.assertEqual(2, len(samples))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user