#g)ddlZddlZddlZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl Z da dadadadadadadadZdZddZifdZdZd Zgdifd Zgdifd Zd Zd ZdZdZ dZ!dZ"dZ#ddZ$dS)NFcjtjdddtgddjdkS)NpodmanimageexistsFT)check no_podmanr)testenvcmdrun image_name returncodeT/home/osmocom-build/jenkins/workspace/ttcn3-hlr-test-asan/_testenv/testenv/podman.py image_existsrs/ ;??HgxDE]a? b b mqr rrrctjddtddgddd}t j|jddd d d}tj |d }tj d |tj d rtj ddStjtjd}tj|j}tj|}tj dt+|d d||kS)Nrhistoryz--formatjsonT)capture_outputrtextrcreated.z%Y-%m-%dT%H:%M:%SzImage creation date: !TESTENV_NO_IMAGE_UP_TO_DATE_CHECKz'Assuming the podman image is up-to-datezpodman/DockerfilezDockerfile last modified: )r r r r rloadsstdoutsplitdatetimestrptimeloggingdebugosenvirongetpathjoindata_dirstatst_mtimeutcfromtimestampstr)rr dockerfilemtimes rimage_up_to_dater.sCkoo 9j*f=  G j((+I6<> .00  MEEE F F F|!  FGGGG L7:77888 KOO    f     GLL)8 4 4      rcg}tj|dD]\}}|d|d|gz }|S)NTz-e=)r r generate_envitems)envretkeyvals rgenerate_env_podmanrAQsX CK,,S$77==??&&S nnsnn%% Jrcttjdtjatdat ddddadS)Nr6z-osmo-ttcn3-testenv:-_)getattrr r3distro_defaultr6r replacerrrinit_image_name_distrorIZsQW\8W-C D DF///J##C--55c3??JJJrc2tjtjjddatjtjjddatjt dtjtdtjtjj dttstj dtsotjddkr$t!jd t%d n(t!jd t!jd t)jt,tjjrdadSdS) Nrz var-cache-aptz var-lib-aptTexist_okzDMissing podman image, run 'testenv.py init podman' first to build itTESTENV_REBUILD_OUTDATED_IMAGE1zQThe podman image is outdated, rebuilding it... (TESTENV_REBUILD_OUTDATED_IMAGE=1)Fz[The podman image might be outdated, consider running 'testenv.py init podman' to rebuild itz@Set TESTENV_REBUILD_OUTDATED_IMAGE=1 to rebuild it automatically)r"r%r&r r3cacheapt_dir_var_cacheapt_dir_var_libmakedirsccacherIrNoTraceExceptionr.r#r$r warningr8r!atexitregisterstopshellrun_shell_on_stoprrrinitr[csW  W\%7?SSgll7<#5xOOOK!D1111K$////K #d3333 >>o&'mnnn    ^ :>>: ; ;s B B Oo p p p      Om    M\ ] ] ] OD|! !!rc"tstd|t|}|t|z }|dgz }|r|d|gz }t |t rdd|g}t jjddg|ztgz|zg|Rdd i|S) NzTAttempting to execute a command in podman, but the container isn't running anymore: r2-wsh-crexecrT) container_name RuntimeErrorlistrA isinstancer+r r r )r podman_optscwdr=r3kwargss rexec_cmdrhs ywruwwxxx{##K&s+++KD6K #c{" #s T3 ;? 6[(N+;;cA          rct|t|z}|r|d|gz }t|trdd|g}ddg|ztgz|z}t jd|tj|S)Nr]r^r_rr`+ ) rcrArdr+rar r! subprocessPopen)r rerfr=s rexec_cmd_backgroundrms{##&9#&>&>>K #c{" #s T3 V { *n-= = CC M*s**  C  rc tjdtjddtddg}|jrt jddSP#t$rYdSwxYw)NTrr`touchz /tmp/watchdogzpodman container crashed!) timesleeprkr rar r errorKeyboardInterrupt)ps rfeed_watchdog_looprvs|    JqMMM&.'?[\\A|  9:::        sAAA A! A!ctdD]'}tjdtrdS(t d)Ndg?zPodman failed to start)rangerqrr is_runningrb)is rwait_until_startedr|sK 3ZZ 3 <<  FF  / 0 00rctjtjjd}tj|dtjd|tj |tj ttjt }|dS)NrTrKrj)r=)target)r"r%r&r testdirtestdir_topdirrRr r!rkrlr r;r|multiprocessingProcessrvstart)r log_dirfeed_watchdog_processs rstart_in_backgroundrsgll7?98DDGK$'''' M*s**Sgk66889999+3;MNNN!!!!!rctjj}tj}tjjdt atj tj d}ddddtddd d |d td d |ddddtddtdddddg}tjjs |d|d|gz }tjjrtjds&tj dr|ddgz }tj tjr%tjtj}|ddgz }|d|d|dtjjdtjjdtjjdtjjdtjdtjt4tj tj dg z }t7|t9ddgtj td}tj |st9gd dSdS)!NrDzpodman/seccomp.jsonrr z--rmz--namez --log-driverz json-filez --log-optzpath=z/podman/z.logz--security-opt=seccomp=z--cap-add=NET_ADMINz--cap-add=NET_RAWz--device=/dev/net/tunz--volumez:/var/cache/aptz :/var/lib/aptz--sysctlz"net.ipv4.conf.all.send_redirects=0z&net.ipv4.conf.default.send_redirects=0rCTESTENV_NO_KVMz/dev/kvmz/dev/kvm:/dev/kvmz{dest}:{dest}:rozscripts/testenv-podman-main.shrmz /etc/apt/apt.conf.d/docker-cleanz pkgcache.binzapt-get-qupdate)r rrosmo_devget_osmo_dev_dirprefix restart_countrar"r%r&r'rPrQr3 binary_repokernelr#r$rislinkcustom_kernel_pathreadlinkrOrSsrc_dirr rrh)r osmo_dev_dirseccompr destpkgcaches rrrs_3N#4466L.@@@@Ngll7+-BCCG  <<<<<<+'++ --- ))),0+ C0 < #   , ,l , ,   |4z~~.// 5BGNN:4N4N 5 J 34 4C 7>>'4 5 5 4;w9::D J 23 3C ,,N,, < 44 244 < 66!466 ?..W_..  W%'GHH  C d6 7888w||-~>>H 7>>( # #.,,,-----..rc8|dkrdStd|d)Nzdebian:bookworm Debian_12zCan't translate distro z to repo_dir!)rb)r6s rdistro_to_repo_dirrs- """{ FFFF G GGrc d}|dz }|tjjddz }|dz }|t t z }|dz }d}t dd d tj|d |gt gd dS) Nzdeb [signed-by=/obs.key]z( https://downloads.osmocom.org/packages/rCz://z/ ./z$/etc/apt/sources.list.d/osmocom.listr^r_zecho z > r) r r3rrHrr6rhshlexquote)configr%s renable_binary_repors 'F 88F gl&..sD999F cMF  (((F fF 1D dD@%+f"5"5@@$@@ ABBB ( ( ()))))rcrtdSdddddtg}tj|ddjsdSdS) NFrpsrz--filterzname=T)rr)rarkr r)r s rrzrz+sLu T4-E^-E-E FC >#d > > > Eu 4rctsdStj|sBtr;t jdtdgdgtjjddda|rdnd}t jd|tr4t t da tj d d tgd d |r*tj d d tgd d da|rtdz at!dSdS)Nz=Running interactive shell before stopping container (--shell)bashz-iF)rfstdinrz (restart)zStopping podman containerrkillT)rrwaitr)rzr coredump get_backtracerZr r5rhrr terminaterr r rarr)restart restart_msgs rrXrX6sK << ""$$$ "(" TUUU &D6w'>dRWXXXX!")1,,rK L:[::;;;%'')))""$$$ $ KOOXv~6$eOTTTY 6>:dRWXXXN  r)T)F)%rVrrr rr"rrk testenv.cmdr testenv.testdirtestenv.coredumprqr r6rarPrQrrZrrr.r8rArIr[rhrmrvr|rrrrrzrXrrrrs      sss60@@@ ! ! !F!d.*,2 ! ! ! !    111 " " "C.C.C.LHHH * * *&&&&&&r