Exemplo n.º 1
0
    def test_nslist(self, mock_listdir, mock_path):
        mock_path.exists.return_value = True
        mock_listdir.return_value = []
        mock_listdir.return_value.append(('qdhcp-1111111-2222222-3333333'))
        mock_listdir.return_value.append(('qdhcp-4444444-5555555-6666666'))
        nsdirs = nslist()
        self.assertEqual('qdhcp-1111111-2222222-3333333', nsdirs[0])
        self.assertEqual('qdhcp-4444444-5555555-6666666', nsdirs[1])

        mock_path.exists.return_value = False
        nsdirs = nslist()
        self.assertEqual([], nsdirs)
Exemplo n.º 2
0
    def test_nslist(self, mock_listdir, mock_path):
        mock_path.exists.return_value = True
        mock_listdir.return_value = []
        mock_listdir.return_value.append(('qdhcp-1111111-2222222-3333333'))
        mock_listdir.return_value.append(('qdhcp-4444444-5555555-6666666'))
        nsdirs = nslist()
        self.assertEqual('qdhcp-1111111-2222222-3333333', nsdirs[0])
        self.assertEqual('qdhcp-4444444-5555555-6666666', nsdirs[1])

        mock_path.exists.return_value = False
        nsdirs = nslist()
        self.assertEqual([], nsdirs)
Exemplo n.º 3
0
    def _namespace_monitor(self):

        while True:
            if self.kill_now:
                break
            eventlet.sleep(MONITOR_INTERVAL)

            # Get list of network namespaces on system
            try:
                curr_ns = set(netns.nslist())
            except Exception:
                LOG.error('Failed to get current namespace set')
                continue

            # For each unknown namespace, start a relay thread
            for ns in curr_ns:
                if not ns.startswith(NS_PREFIX) or ns in self.ns_states:
                    continue
                self.ns_states[ns] = NS_RELAY_PENDING
                eventlet.spawn_n(self._client_network_relay, ns)

            # Set state to DELETING for any unknown namespaces
            for ns in self.ns_states:
                if ns in curr_ns:
                    continue
                self.ns_states[ns] = NS_RELAY_DELETING
        LOG.debug('Namespace Monitor exiting')
Exemplo n.º 4
0
    def _namespace_monitor(self):

        while True:
            eventlet.sleep(MONITOR_INTERVAL)

            # Get list of network namespaces on system
            try:
                curr_ns = set(netns.nslist())
            except Exception:
                LOG.error(_LE('Failed to get current namespace set'))
                continue

            # For each unknown namespace, start a relay thread
            for ns in curr_ns:
                if not ns.startswith("qdhcp") or ns in self.ns_states:
                    continue
                self.ns_states[ns] = NS_RELAY_PENDING
                eventlet.spawn_n(self._client_network_relay, ns)

            # Set state to DELETING for any unknown namespaces
            for ns in self.ns_states:
                if ns in curr_ns:
                    continue
                self.ns_states[ns] = NS_RELAY_DELETING