Example #1
0
 def resources_release(self):
     if self.resource_lock:
         time.sleep(5)
         self.resource_lock.release()
         utils.interface_release(self.server.adapter_type, self.interface)
         self.interface = None
         self.resource_lock = None
Example #2
0
 def resources_release(self):
     if self.resource_lock:
         self.resource_lock.release()
         utils.interface_release(
             'tap' if self.server.network_mode == BRIDGE else 'tun',
             self.interface)
         self.interface = None
Example #3
0
 def resources_release(self):
     if self.resource_lock:
         self.resource_lock.release()
         utils.interface_release(
             'tap' if self.server.network_mode == BRIDGE else 'tun',
             self.interface)
         self.interface = None
Example #4
0
 def resources_release(self):
     if self.resource_lock:
         time.sleep(5)
         self.resource_lock.release()
         utils.interface_release(self.server.adapter_type, self.interface)
         self.interface = None
         self.resource_lock = None
Example #5
0
    def resources_release(self):
        interface = self.interface
        if interface:
            utils.interface_release(self.server.adapter_type, interface)
            self.interface = None

        _instances_lock.acquire()
        try:
            if _instances.get(self.server.id) == self:
                _instances.pop(self.server.id)
        finally:
            _instances_lock.release()
Example #6
0
    def resources_release(self):
        interface = self.interface
        if interface:
            utils.interface_release(self.server.adapter_type, interface)
            self.interface = None

        _instances_lock.acquire()
        try:
            if _instances.get(self.server.id) == self:
                _instances.pop(self.server.id)
        finally:
            _instances_lock.release()
Example #7
0
    def openvpn_watch(self):
        try:
            while True:
                while True:
                    line = self.process.stdout.readline()
                    if not line:
                        if self.process.poll() is not None:
                            break
                        else:
                            time.sleep(0.05)
                            continue

                    yield

                    try:
                        self.server.output_link.push_output(
                            line,
                            label=self.output_label,
                            link_server_id=self.linked_server.id,
                        )
                    except:
                        logger.exception(
                            'Failed to push link vpn ' + 'output',
                            'server',
                            server_id=self.server.id,
                        )

                    yield

                if self.stop_event.is_set():
                    break
                else:
                    logger.error(
                        'Server instance link stopped ' +
                        'unexpectedly, restarting link',
                        'server',
                        server_id=self.server.id,
                        link_server_id=self.linked_server.id,
                    )
                    self.openvpn_start()
                    yield interrupter_sleep(1)

            yield

        finally:
            if self.interface:
                utils.interface_release(
                    'tap' if self.linked_server.network_mode == BRIDGE \
                        else 'tun',
                    self.interface)
                self.interface = None
            utils.rmtree(self._temp_path)
Example #8
0
    def openvpn_watch(self):
        try:
            while True:
                while True:
                    line = self.process.stdout.readline()
                    if not line:
                        if self.process.poll() is not None:
                            break
                        else:
                            time.sleep(0.05)
                            continue

                    yield

                    try:
                        self.server.output_link.push_output(
                            line,
                            label=self.output_label,
                            link_server_id=self.linked_server.id,
                        )
                    except:
                        logger.exception('Failed to push link vpn ' +
                            'output', 'server',
                            server_id=self.server.id,
                        )

                    yield

                if self.stop_event.is_set():
                    break
                else:
                    logger.error('Server instance link stopped ' +
                        'unexpectedly, restarting link', 'server',
                        server_id=self.server.id,
                        link_server_id=self.linked_server.id,
                    )
                    self.openvpn_start()
                    yield interrupter_sleep(1)

            yield

        finally:
            if self.interface:
                utils.interface_release(
                    'tap' if self.linked_server.network_mode == BRIDGE \
                        else 'tun',
                    self.interface)
                self.interface = None
            utils.rmtree(self._temp_path)
Example #9
0
 def stop_watch(self):
     try:
         while True:
             if self.stop_event.wait(1):
                 return
             yield
     finally:
         try:
             if not utils.stop_process(self.process):
                 logger.error('Failed to stop openvpn link process',
                     'server',
                     server_id=self.server.id,
                 )
         finally:
             if self.interface:
                 utils.interface_release(self.linked_server.adapter_type,
                     self.interface)
                 self.interface = None
Example #10
0
 def stop_watch(self):
     try:
         while True:
             if self.stop_event.wait(1):
                 return
             yield
     finally:
         try:
             if not utils.stop_process(self.process):
                 logger.error('Failed to stop openvpn link process',
                     'server',
                     server_id=self.server.id,
                 )
         finally:
             if self.interface:
                 utils.interface_release(self.linked_server.adapter_type,
                     self.interface)
                 self.interface = None
Example #11
0
 def stop_watch(self):
     try:
         while True:
             if self.stop_event.wait(1):
                 return
             yield
     finally:
         try:
             if not utils.stop_process(self.process):
                 logger.error(
                     'Failed to stop openvpn link process',
                     'server',
                     server_id=self.server.id,
                 )
         finally:
             if self.interface:
                 utils.interface_release(
                     'tap' if self.linked_server.network_mode == BRIDGE else
                     'tun', self.interface)
                 self.interface = None
Example #12
0
 def stop_watch(self):
     try:
         while True:
             if self.stop_event.wait(1):
                 return
             yield
     finally:
         try:
             if not utils.stop_process(self.process):
                 logger.error('Failed to stop openvpn link process',
                     'server',
                     server_id=self.server.id,
                 )
         finally:
             if self.interface:
                 utils.interface_release(
                     'tap' if self.linked_server.network_mode == BRIDGE \
                         else 'tun',
                     self.interface)
                 self.interface = None