def is_local_share(self, share_path): # In case of Scale-Out File Servers, we'll get the Distributed Node # Name of the share. We have to check whether this resolves to a # local ip, which would happen in a hyper converged scenario. # # In this case, mounting the share is not supported and we have to # use the local share path. if share_path in self._loopback_share_map: return self._loopback_share_map[share_path] addr = share_path.lstrip('\\').split('\\', 1)[0] local_ips = _utils.get_ips(socket.gethostname()) dest_ips = _utils.get_ips(addr) is_local = bool(set(local_ips).intersection(set(dest_ips))) self._loopback_share_map[share_path] = is_local return is_local
def test_get_ips(self, mock_getaddrinfo): ips = ['1.2.3.4', '5.6.7.8'] mock_getaddrinfo.return_value = [(None, None, None, None, (ip, 0)) for ip in ips] resulted_ips = _utils.get_ips(mock.sentinel.addr) self.assertEqual(ips, resulted_ips) mock_getaddrinfo.assert_called_once_with(mock.sentinel.addr, None, 0, 0, 0)
def test_get_ips(self, mock_getaddrinfo): ips = ['1.2.3.4', '5.6.7.8'] mock_getaddrinfo.return_value = [ (None, None, None, None, (ip, 0)) for ip in ips] resulted_ips = _utils.get_ips(mock.sentinel.addr) self.assertEqual(ips, resulted_ips) mock_getaddrinfo.assert_called_once_with( mock.sentinel.addr, None, 0, 0, 0)
def get_local_ips(self): """Returns the list of locally assigned IPs.""" hostname = socket.gethostname() return _utils.get_ips(hostname)
def get_local_ips(self): hostname = socket.gethostname() return _utils.get_ips(hostname)