1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
"""
SoftLayer.tests.CLI.modules.report_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: MIT, see LICENSE for more details.
"""
from SoftLayer import testing
import json
from unittest import mock as mock
from pprint import pprint as pp
class ReportTests(testing.TestCase):
def test_dc_closure_report(self):
search_mock = self.set_mock('SoftLayer_Search', 'advancedSearch')
search_mock.side_effect = [_advanced_search(), [], [], []]
result = self.run_command(['report', 'datacenter-closures'])
self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Network_Pod', 'getAllObjects', filter=mock.ANY, mask=mock.ANY)
self.assert_called_with('SoftLayer_Search', 'advancedSearch')
json_output = json.loads(result.output)
pp(json_output)
self.assertEqual(5, len(json_output))
self.assertEqual('bcr01a.ams01', json_output[0]['POD'])
def _advanced_search():
results = [{'matchedTerms': ['primaryRouter.hostname:|fcr01a.mex01|'],
'relevanceScore': '5.4415264',
'resource': {'fullyQualifiedName': 'mex01.fcr01.858',
'hardware': [{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'testpooling2.ibmtest.com',
'id': 1676221},
{'billingItem': {'cancellationDate': '2022-03-03T23:59:59-06:00'},
'fullyQualifiedDomainName': 'testpooling.ibmtest.com',
'id': 1534033}],
'id': 1133383,
'name': 'Mex-BM-Public',
'networkSpace': 'PUBLIC',
'privateNetworkGateways': [],
'publicNetworkGateways': [],
'virtualGuests': [],
'vlanNumber': 858},
'resourceType': 'SoftLayer_Network_Vlan'},
{'matchedTerms': ['primaryRouter.hostname:|fcr01a.mex01|'],
'relevanceScore': '5.4415264',
'resource': {'fullyQualifiedName': 'mex01.fcr01.1257',
'hardware': [],
'id': 2912280,
'networkSpace': 'PUBLIC',
'privateNetworkGateways': [],
'publicNetworkGateways': [],
'virtualGuests': [{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'imageTest.ibmtest.com',
'id': 127270182},
{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'test.deleteme.com',
'id': 106291032},
{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'testslack.test.com',
'id': 127889958}],
'vlanNumber': 1257},
'resourceType': 'SoftLayer_Network_Vlan'},
{'matchedTerms': ['primaryRouter.hostname:|bcr01a.mex01|'],
'relevanceScore': '5.003179',
'resource': {'fullyQualifiedName': 'mex01.bcr01.1472',
'hardware': [],
'id': 2912282,
'networkSpace': 'PRIVATE',
'privateNetworkGateways': [],
'publicNetworkGateways': [],
'virtualGuests': [{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'imageTest.ibmtest.com',
'id': 127270182},
{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'test.deleteme.com',
'id': 106291032},
{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'testslack.test.com',
'id': 127889958}],
'vlanNumber': 1472},
'resourceType': 'SoftLayer_Network_Vlan'},
{'matchedTerms': ['primaryRouter.hostname:|bcr01a.mex01|'],
'relevanceScore': '4.9517627',
'resource': {'fullyQualifiedName': 'mex01.bcr01.1664',
'hardware': [{'billingItem': {'cancellationDate': '2022-03-03T23:59:59-06:00'},
'fullyQualifiedDomainName': 'testpooling.ibmtest.com',
'id': 1534033},
{'billingItem': {'cancellationDate': None},
'fullyQualifiedDomainName': 'testpooling2.ibmtest.com',
'id': 1676221}],
'id': 3111644,
'name': 'testmex',
'networkSpace': 'PRIVATE',
'privateNetworkGateways': [],
'publicNetworkGateways': [],
'virtualGuests': [],
'vlanNumber': 1664},
'resourceType': 'SoftLayer_Network_Vlan'},
{'matchedTerms': ['primaryRouter.hostname:|bcr01a.mex01|'],
'relevanceScore': '4.9517627',
'resource': {'fullyQualifiedName': 'mex01.bcr01.1414',
'hardware': [],
'id': 2933662,
'name': 'test-for-trunks',
'networkSpace': 'PRIVATE',
'privateNetworkGateways': [],
'publicNetworkGateways': [],
'virtualGuests': [],
'vlanNumber': 1414},
'resourceType': 'SoftLayer_Network_Vlan'}]
return results
|