Merge pull request #232 from rackerlabs/stable_bandwidth_none
Merge bandwidth = None fix to Stable
This commit is contained in:
commit
4a591c2917
@ -223,7 +223,8 @@ class NovaNotification(Notification):
|
||||
self.audit_period_ending = self.payload.get(
|
||||
'audit_period_ending', None)
|
||||
self.message = self.payload.get('message', None)
|
||||
bandwidth = self.payload.get('bandwidth', {})
|
||||
# (TMaddox) bandwidth could be None in the payload.
|
||||
bandwidth = self.payload.get('bandwidth', {}) or {}
|
||||
bandwidth_public = bandwidth.get('public', {})
|
||||
self.bandwidth_public_out = bandwidth_public.get('bw_out', 0)
|
||||
|
||||
|
@ -231,6 +231,42 @@ class NovaNotificationTestCase(StacktachBaseTestCase):
|
||||
self.assertEquals(notification.bandwidth_public_out, 0)
|
||||
|
||||
|
||||
def test_bandwidth_public_out_is_set_to_blank_object_if_none_in_json(self):
|
||||
body = {
|
||||
"event_type": "compute.instance.exists",
|
||||
'_context_request_id': REQUEST_ID_1,
|
||||
'_context_project_id': TENANT_ID_1,
|
||||
"timestamp": TIMESTAMP_1,
|
||||
"publisher_id": "compute.global.preprod-ord.ohthree.com",
|
||||
"payload": {
|
||||
'instance_id': INSTANCE_ID_1,
|
||||
"status": "saving",
|
||||
"container_format": "ovf",
|
||||
"properties": {
|
||||
"image_type": "snapshot",
|
||||
},
|
||||
"bandwidth": None,
|
||||
"tenant": "5877054",
|
||||
"old_state": 'old_state',
|
||||
"old_task_state": 'old_task',
|
||||
"image_meta": {
|
||||
"org.openstack__1__architecture": 'os_arch',
|
||||
"org.openstack__1__os_distro": 'os_distro',
|
||||
"org.openstack__1__os_version": 'os_version',
|
||||
"com.rackspace__1__options": 'rax_opt',
|
||||
},
|
||||
"state": 'state',
|
||||
"new_task_state": 'task'
|
||||
}
|
||||
}
|
||||
deployment = "1"
|
||||
routing_key = "monitor.info"
|
||||
json_body = json.dumps([routing_key, body])
|
||||
notification = NovaNotification(body, deployment, routing_key,
|
||||
json_body)
|
||||
self.assertEquals(notification.bandwidth_public_out, 0)
|
||||
|
||||
|
||||
class GlanceNotificationTestCase(StacktachBaseTestCase):
|
||||
def setUp(self):
|
||||
self.mox = mox.Mox()
|
||||
|
Loading…
x
Reference in New Issue
Block a user