pa?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-bsc-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)NT-e=)r r generate_envitems)envretkeyvals rgenerate_env_podmanrBQsX CK,,S$77==??&&S nnsnn%% Jrcttjdtjatdat ddddadS)Nr6z-osmo-ttcn3-testenv:-_)getattrr r3distro_defaultr6r replacerrrinit_image_name_distrorJZsQW\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_libmakedirsccacherJrNoTraceExceptionr.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 RuntimeErrorlistrB isinstancer+r r r )r podman_optscwdr>r3kwargss rexec_cmdris 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`rra+ ) rdrBrer+rbr r! subprocessPopen)r rfrgr>s rexec_cmd_backgroundrns{##&9#&>&>>K #c{" #s T3 V { *n-= = CC M*s**  C  rc tjdtjddtddgtj}|jrtjddS\#t$rYdSwxYw) NTrratouchz /tmp/watchdog)stderrz0feed_watchdog_loop: podman container has stopped) timesleeprlr rbDEVNULLr r r!KeyboardInterrupt)ps rfeed_watchdog_looprxs    JqMMM&.'?[dndvwwwA|  PQQQ        sAAA A-,A-ctdD]'}tjdtrdS(t d)Ndg?zPodman failed to start)rangersrt is_runningrc)is rwait_until_startedr~sK 3ZZ 3 <<  FF  / 0 00rctjtjjd}tj|dtjd|tj |tj ttjt }|dS)NrTrLrk)r>)target)r"r%r&r testdirtestdir_topdirrSr r!rlrmr r<r~multiprocessingProcessrxstart)r log_dirfeed_watchdog_processs rstart_in_backgroundrsgll7?98DDGK$'''' M*s**Sgk66889999+3;MNNN!!!!!rc4tjj}tj}tjjdt atj tj d}ddddtddd d |d td d |ddddtddtdddddddg}tjjr|ddgz }n |d|d|gz }tjjrtjds&tj dr|ddgz }tj tjr+tjtj}|d|d|dgz }|d|d|dtjjdtjjdtjjdtjjdtjdtjt4tj tj dg z }t7|t9d d!gtj td"}tj |st9gd#dSdS)$NrEzpodman/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=0r:zPODMAN=1zTESTENV_BINARY_REPO=1rDTESTENV_NO_KVMz/dev/kvmz/dev/kvm:/dev/kvmz:rozscripts/testenv-podman-main.shrmz /etc/apt/apt.conf.d/docker-cleanz pkgcache.binzapt-get-qupdate)r rrosmo_devget_osmo_dev_dirprefix restart_countrbr"r%r&r'rQrRr3 binary_repokernelr#r$rislinkcustom_kernel_pathreadlinkrPrTsrc_dirr rri)r osmo_dev_dirseccompr destpkgcaches rrrs_3N#4466L.@@@@Ngll7+-BCCG  <<<<<<+'++ --- ))),0 / C4|    #    , ,l , ,   |5z~~.// 5BGNN:4N4N 5 J 34 4C 7>>'4 5 5 5;w9::D J4 3 3$ 3 3 34 4C ,,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!)rc)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/rDz://z/ ./z$/etc/apt/sources.list.d/osmocom.listr_r`zecho z > r) r r3rrIrr6rishlexquote)configr%s renable_binary_repor$s 'F 88F gl&..sD999F cMF  (((F fF 1D dD@%+f"5"5@@$@@ ABBB ( ( ()))))rcrtdSdddddtg}tj|ddjsdSdS) NFrpsrz--filterzname=T)rr)rbrlr r)r s rr|r|2sLu T4-E^-E-E FC >#d > > > Eu 4rc*tsdStj|sBtr;t jdtdgdgtjjddda|rdnd}t jd|tr4t t da tj d d tgd d da|rtd z at!dSdS)Nz=Running interactive shell before stopping container (--shell)bashz-iF)rgstdinrz (restart)zStopping podman containerrkillT)rrr)r|r coredump get_backtracer[r r5rirr terminatewaitr r rbrr)restart restart_msgs rrYrY=s  << ""$$$ "(" TUUU &D6w'>dRWXXXX!")1,,rK L:[::;;;%'')))""$$$ $ KOOXv~6$eOTTTN  r)T)F)%rWrrr rr"rrl testenv.cmdr testenv.testdirtestenv.coredumprsr r6rbrQrRrr[rrr.r8rBrJr\rirnrxr~rrrrr|rYrrrrs      sss60@@@ ! ! !F!d.*,2 ! ! ! !    111 " " "J.J.J.ZHHH * * *######r