id FddlZddlmZddlmZddlmZGddeZy)N)ContainerRuntime)sos_get_command_output)quotec2eZdZdZdZdZdZd dZdZdZ y) CrioContainerRuntimez-Runtime class to use for systems running criocriocrictlcy)NF)selfs t j |d}|d D]}|j|d |d d f |S) zGet a list of containers present on the system. :param get_all: If set, include stopped containers as well :type get_all: ``bool`` z ps z-az -o jsonchrootstatusroutput containersidmetadataname)binaryactiverpolicysysrootjsonloadsappend)r get_allr_cmdoutout_json containers r get_containersz#CrioContainerRuntime.get_containerss  %)[['$r2IJ ;;(dkk6I6IJC8}!::c(m4!),!7JI%%"4)J*?*GHJJrcg}|jrtd|jz|jj}|ddk(rt j |d}|dD]{}t|ddkDr!|dD]}|j||df5t|d dk(rd }n|d djd d}|j|d z|df}|S) zGet a list of images present on the system :returns: A list of 2-tuples containing (image_name, image_id) :rtype: ``list`` z%s images -o jsonrrrrimagesrepoTagsr repoDigestsz@z:) rrrrrrrlenr split)r r(r#r$imagerepo_tag image_names r get_imageszCrioContainerRuntime.get_images,s  ;;()rBs$ 20IM+IMr