def from_container(cls, container): """ Converts a container to ContainerViewModel. :param container: Container/MultiContainer: container being converted :return ContainerViewModel """ soln_stk = container.soln_stk cids = _get_cids(container) container.is_running() ip = compat.container_ip() services = [ ServiceInfo(cid=cid, ip=ip, is_running=commands.is_running(cid), hostports=commands.get_exposed_hostports(cid)) for cid in cids ] return cls(soln_stk, ip, services)
def is_running(self): return any(commands.is_running(cid) for cid in self.list_services())
def test_is_running_command_error(self, get_container_lowlvl_info): get_container_lowlvl_info.side_effect = CommandError self.assertFalse(commands.is_running(MOCK_CONTAINER_NAME))
def is_running(self): return commands.is_running(self.get_name())
def test_is_running_happy_case(self, get_container_lowlvl_info): get_container_lowlvl_info.return_value = MOCK_CONTAINER_INFO self.assertEqual(MOCK_IS_RUNNING, commands.is_running(MOCK_CONTAINER_NAME))