Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion SoftLayer/CLI/report/bandwidth.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def _get_virtual_bandwidth(env, start, end):
label='Calculating for virtual',
file=sys.stderr) as vms:
for instance in vms:
metric_tracking_id = utils.lookup(instance,
'metricTrackingObjectId')

if metric_tracking_id is None:
continue

pool_name = None
if utils.lookup(instance,
'virtualRack',
Expand All @@ -161,7 +167,7 @@ def _get_virtual_bandwidth(env, start, end):
end.strftime('%Y-%m-%d %H:%M:%S %Z'),
types,
3600,
id=instance['metricTrackingObjectId'],
id=metric_tracking_id,
),
}

Expand Down
33 changes: 22 additions & 11 deletions tests/CLI/modules/report_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def test_bandwidth_report(self):
}, {
'id': 2,
'name': 'pool2',
'metricTrackingObjectId': 2,
}, {
'id': 3,
'name': 'pool3',
'metricTrackingObjectId': 3,
}]
hardware = self.set_mock('SoftLayer_Account', 'getHardware')
hardware.return_value = [{
Expand All @@ -50,8 +53,12 @@ def test_bandwidth_report(self):
'hostname': 'host1',
}, {
'id': 102,
'metricTrackingObject': {'id': 102},
'hostname': 'host1',
'hostname': 'host2',
'virtualRack': {'id': 1, 'bandwidthAllotmentTypeId': 2},
}, {
'id': 103,
'metricTrackingObject': {'id': 103},
'hostname': 'host3',
'virtualRack': {'id': 1, 'bandwidthAllotmentTypeId': 2},
}]
guests = self.set_mock('SoftLayer_Account', 'getVirtualGuests')
Expand All @@ -61,8 +68,12 @@ def test_bandwidth_report(self):
'hostname': 'host1',
}, {
'id': 202,
'metricTrackingObjectId': 202,
'hostname': 'host1',
'hostname': 'host2',
'virtualRack': {'id': 2, 'bandwidthAllotmentTypeId': 2},
}, {
'id': 203,
'metricTrackingObjectId': 203,
'hostname': 'host3',
'virtualRack': {'id': 2, 'bandwidthAllotmentTypeId': 2},
}]
summary_data = self.set_mock('SoftLayer_Metric_Tracking_Object',
Expand Down Expand Up @@ -93,7 +104,7 @@ def test_bandwidth_report(self):
'public_out': 20,
'type': 'pool',
}, {
'name': 'pool2',
'name': 'pool3',
'pool': None,
'private_in': 30,
'private_out': 40,
Expand All @@ -109,7 +120,7 @@ def test_bandwidth_report(self):
'public_out': 20,
'type': 'virtual',
}, {
'name': 'host1',
'name': 'host3',
'pool': 2,
'private_in': 30,
'private_out': 40,
Expand All @@ -125,7 +136,7 @@ def test_bandwidth_report(self):
'public_out': 20,
'type': 'hardware',
}, {
'name': 'host1',
'name': 'host3',
'pool': None,
'private_in': 30,
'private_out': 40,
Expand All @@ -145,19 +156,19 @@ def test_bandwidth_report(self):
identifier=1)
self.assert_called_with('SoftLayer_Metric_Tracking_Object',
'getSummaryData',
identifier=2)
identifier=3)
self.assert_called_with('SoftLayer_Metric_Tracking_Object',
'getSummaryData',
identifier=101)
self.assert_called_with('SoftLayer_Metric_Tracking_Object',
'getSummaryData',
identifier=102)
identifier=103)
self.assert_called_with('SoftLayer_Metric_Tracking_Object',
'getSummaryData',
identifier=201)
self.assert_called_with('SoftLayer_Metric_Tracking_Object',
'getSummaryData',
identifier=202)
identifier=203)
call = self.calls('SoftLayer_Metric_Tracking_Object', 'getSummaryData',
identifier=1)[0]
expected_args = (
Expand Down