示例#1
0
 def test_0004(self, mock_system_full):
     """
         Can't obtain system list
     """
     mock_system_full.return_value = (False, "PUF!")
     ret = get_all_systems_with_ping_info()
     self.assertFalse(ret[0])
示例#2
0
 def test_0004(self, mock_system_full):
     """
         Can't obtain system list
     """
     mock_system_full.return_value = (False, "PUF!")
     ret = get_all_systems_with_ping_info()
     self.assertFalse(ret[0])
示例#3
0
 def test_0001(self, mock_ping, mock_system_full):
     """
         Reachable OK
     """
     uuid1 = str(uuid.uuid1())
     mock_system_full.return_value = (True,
         [(uuid1, {'admin_ip': '192.168.1.1',
         'profile': 'Server,Sensor',
         'hostname': 'ascodevida',
         'vpn_ip': ''}),
         ])
     mock_ping.return_value = True, "PING"
     ret = get_all_systems_with_ping_info()
     self.assertTrue(ret[0])
     self.assertTrue(ret[1][uuid1]['reachable'])
示例#4
0
 def test_0003(self, mock_ping, mock_system_full):
     """
         Reachable true with VPN
     """
     uuid1 = str(uuid.uuid1())
     mock_system_full.return_value = (True, [(uuid1, {
         'admin_ip': '192.168.1.1',
         'profile': 'Server,Sensor',
         'hostname': 'ascodevida',
         'vpn_ip': '192.168.1.2'
     })])
     mock_ping.return_value = True, "PING"
     ret = get_all_systems_with_ping_info()
     self.assertTrue(ret[0])
     self.assertTrue(ret[1][uuid1]['reachable'])
     self.assertTrue(call('192.168.1.2') == mock_ping.call_args_list[0])
示例#5
0
 def test_0002(self, mock_ping, mock_system_full):
     """
         Reachable False
     """
     uuid1 = str(uuid.uuid1())
     mock_system_full.return_value = (True, [
         (uuid1, {
             'admin_ip': '192.168.1.1',
             'profile': 'Server,Sensor',
             'hostname': 'ascodevida',
             'vpn_ip': ''
         }),
     ])
     mock_ping.return_value = False, "not reachable"
     ret = get_all_systems_with_ping_info()
     self.assertTrue(ret[0])
     self.assertFalse(ret[1][uuid1]['reachable'])
示例#6
0
def get_sensors():
    ret, sensor_data = get_all_systems_with_ping_info(system_type='Sensor')
    if not ret:
        return make_error("Error retrieving the list of reachable sensors",
                          500)
    return make_ok(sensors=dict(sensor_data))