def _proxy_start_check_not_in_network(self): from stakkr.proxy import Proxy # First start Proxy to verify it'll be added in the network Proxy().stop() Proxy().start() # Proxy is not connected to network self.assertIs(False, ct_in_network('proxy_stakkr', 'test_stakkr'))
def start(self, container: str, pull: bool, recreate: bool, proxy: bool): """If not started, start the containers defined in config.""" self.init_project() verb = self.context['VERBOSE'] debug = self.context['DEBUG'] self._is_up(container) if pull is True: command.launch_cmd_displays_output( self._get_compose_base_cmd() + ['pull'], verb, debug, True) recreate_param = '--force-recreate' if recreate is True else '--no-recreate' cmd = self._get_compose_base_cmd() + [ 'up', '-d', recreate_param, '--remove-orphans' ] cmd += _get_single_container_option(container) command.verbose(self.context['VERBOSE'], 'Command: ' + ' '.join(cmd)) command.launch_cmd_displays_output(cmd, verb, debug, True) running_cts, cts = docker.get_running_containers(self.project_name) if not running_cts: raise SystemError( "Couldn't start the containers, run the start with '-v' and '-d'" ) self._run_iptables_rules(cts) if proxy is True: conf = self.config['proxy'] Proxy(conf.get('http_port'), conf.get('https_port')).start( docker.get_network_name(self.project_name))
def stop(self, container: str, proxy: bool): """If started, stop the containers defined in config. Else throw an error.""" self.init_project() verb = self.context['VERBOSE'] debug = self.context['DEBUG'] docker.check_cts_are_running(self.project_name) cmd = self._get_compose_base_cmd() + [ 'stop' ] + _get_single_container_option(container) command.launch_cmd_displays_output(cmd, verb, debug, True) running_cts, _ = docker.get_running_containers(self.project_name) if running_cts and container is None: raise SystemError("Couldn't stop services ...") if proxy is True: Proxy().stop()
def stop(self, container: str, proxy: bool): """If started, stop the containers defined in config. Else throw an error.""" verb = self.context['VERBOSE'] debug = self.context['DEBUG'] docker.check_cts_are_running(self.project_name) cmd = self.compose_base_cmd + [ 'stop' ] + self._get_single_container_option(container) command.launch_cmd_displays_output(cmd, verb, debug, True) self.running_cts, self.cts = docker.get_running_containers( self.project_name) if self.running_cts is not 0 and container is None: raise SystemError("Couldn't stop services ...") if proxy is True: network_name = docker.get_network_name(self.project_name) Proxy(self.config['proxy'].get('port')).stop()