本文整理汇总了Python中emulator.Emulator.chroot_and_run方法的典型用法代码示例。如果您正苦于以下问题:Python Emulator.chroot_and_run方法的具体用法?Python Emulator.chroot_and_run怎么用?Python Emulator.chroot_and_run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emulator.Emulator
的用法示例。
在下文中一共展示了Emulator.chroot_and_run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scan
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import chroot_and_run [as 别名]
def scan(images=True):
""" scanning method that will scan all images or containers """
# FIXME using default 'unix://var/run/docker.sock'
client = docker.Client(base_url='unix://var/run/docker.sock')
emu = Emulator()
objs = client.images(quiet=True)
driver = client.info()['Driver']
# If there are no images/containers on the machine, objs will be ['']
if objs == ['']:
return
# does actual work here!
for im in objs:
try:
emu.create_dirs()
cid = mount_obj(emu.tmp_image_dir, im, driver)
if emu.is_applicable():
print "scanning " + im[:12]
emu.intial_setup()
emu.chroot_and_run()
emu.unmount()
else:
print im[:12] + " is not RHEL based"
unmount_obj(emu.tmp_image_dir, cid, driver)
emu.remove_dirs()
except MountError as dme:
force_clean(cid, client, emu)
print "Red Hat Insights was unable to complete " \
"due to the below error. All mounts and devices " \
"have been removed."
raise ValueError(str(dme))
except EmulatorError as eme:
force_clean(cid, client, emu)
print "Red Hat Insights was unable to complete " \
"due to the below error. All mounts and devices " \
"have been removed."
raise ValueError(str(eme))
emu.gather_data()
示例2: scan
# 需要导入模块: from emulator import Emulator [as 别名]
# 或者: from emulator.Emulator import chroot_and_run [as 别名]
def scan(images=True):
""" scanning method that will scan all images or containers """
client = DockerClient()
emu = Emulator()
objs = client.images() if images is True else client.containers()
# If there are no images/containers on the machine, objs will be ['']
if objs == ['']:
return
# does actual work here!
for im in objs:
try:
emu.create_dirs()
mount_obj(emu.tmp_image_dir, im, client.info()['Storage Driver'])
if emu.is_applicable():
print "scanning " + im[:12]
emu.intial_setup()
emu.chroot_and_run()
emu.unmount()
else:
print im[:12] + " is not RHEL based"
unmount_obj(emu.tmp_image_dir, client.info()['Storage Driver'])
emu.remove_dirs()
except MountError as dme:
raise ValueError(str(dme))
emu.gather_data(images)