本文整理汇总了Python中util.subp函数的典型用法代码示例。如果您正苦于以下问题:Python subp函数的具体用法?Python subp怎么用?Python subp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_rsync
def _run_rsync(self):
""" run rsync to pull out the rootfs /etc/ dir
(later it is re-mounted inside the container so RHI can edit
any needed files """
# rsync -aqPS ${IMAGE}/etc .
if os.path.exists(self.tmp_image_dir + "etc/"):
cmd = ['rsync', '-aqPS', self.tmp_image_dir + "etc/", "/home/temp_etc/"]
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Rysnc unable to copy files: %s ' % cmd)
# FIXME for some reason, some versions of RHEL containers don't have these dirs?
# odd right?
if not os.path.exists("/home/temp_etc/pki"):
cmd = ['mkdir', '/home/temp_etc/etc/pki']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to make temporary directory: %s ' % cmd)
if not os.path.exists("/home/temp_etc/pki/consumer"):
cmd = ['mkdir', '/home/temp_etc/pki/consumer']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to make temporary directory: %s ' % cmd)
示例2: _remove_var_tmp_dir
def _remove_var_tmp_dir(self):
""" remove the old location of where RHAI's output was stored """
cmd = ['rm', '-rf', self.vartmp_dir]
r = util.subp(cmd)
if r.return_code != 0:
print "vartmp dir did not remove"
示例3: remove_image
def remove_image(self, image_id):
""" force removes image image_id """
cmd = ['docker', 'rmi', '-f', image_id]
out = util.subp(cmd)
if out.return_code != 0:
print "image was not deleted"
示例4: _copy_launcher
def _copy_launcher(self):
""" copy the launching script into the rootfs/mnt dir """
cmd = ['cp', './launcher.sh', self.tmp_image_dir + '/mnt/']
r = util.subp(cmd)
if r.return_code != 0:
print "could not copy launcher!"
示例5: getDmsetupLs
def getDmsetupLs():
cmd = ['dmsetup', 'ls']
r = util.subp(cmd)
if r.return_code != 0:
print r.stderr
return -1
return r.stdout
示例6: _get_fs
def _get_fs(thin_pathname):
"""
Returns the file system type (xfs, ext4) of a given device
"""
cmd = ['lsblk', '-o', 'FSTYPE', '-n', thin_pathname]
fs_return = util.subp(cmd)
return fs_return.stdout.strip()
示例7: unmount_path
def unmount_path(path):
"""
Unmounts the directory specified by path.
"""
r = util.subp(['umount', path])
if r.return_code != 0:
raise ValueError(r.stderr)
示例8: chroot_and_run
def chroot_and_run(self):
""" give the chroot cmda and run the launcher script in the rootfs """
cmd = ['chroot', self.tmp_image_dir, '/mnt/launcher.sh']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to start Insights Script: %s ' % cmd)
示例9: _remove_thin_device
def _remove_thin_device(name):
"""
Destroys a thin device via subprocess call.
"""
r = util.subp(['dmsetup', 'remove', name])
if r.return_code != 0:
raise MountError('Could not remove thin device:\n' + r.stderr)
示例10: _copy_resolve_conf
def _copy_resolve_conf(self):
""" copy the host machines resolve.conf and put it into the rootfs' /etc/ dir """
cmd = ['cp', '/etc/resolv.conf', self.tmp_image_dir + '/etc/']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to copy file: %s ' % cmd)
示例11: _copy_launcher
def _copy_launcher(self):
""" copy the launching script into the rootfs/mnt dir """
cmd = ['cp', '/home/insights-docker/launcher.sh', self.tmp_image_dir + '/mnt/']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to copy file: %s ' % cmd)
示例12: inspect
def inspect(self, obj_id):
# returns dict representation of "docker inspect ID"
cmd = ['docker', 'inspect', obj_id]
r = util.subp(cmd)
if r.return_code != 0:
raise Exception('Unable to inspect object: %s' % obj_id)
return json.loads(r.stdout)
示例13: _mount_overlay
def _mount_overlay(self, identifier):
"""
OverlayFS mount backend.
"""
cid = self._identifier_as_cid(identifier)
cinfo = self.client.inspect_container(cid)
ld, ud, wd = '', '', ''
try:
ld = cinfo['GraphDriver']['Data']['lowerDir']
ud = cinfo['GraphDriver']['Data']['upperDir']
wd = cinfo['GraphDriver']['Data']['workDir']
except:
ld, ud, wd = DockerMount._no_gd_api_overlay(cid)
options = ['ro', 'lowerdir=' + ld, 'upperdir=' + ud, 'workdir=' + wd]
optstring = ','.join(options)
cmd = ['mount', '-t', 'overlay', '-o', optstring, 'overlay',
self.mountpoint]
status = util.subp(cmd)
if status.return_code != 0:
self._cleanup_container(cinfo)
raise MountError('Failed to mount OverlayFS device.\n%s' %
status.stderr.decode(sys.getdefaultencoding()))
return cid
示例14: chroot_and_run
def chroot_and_run(self):
""" give the chroot cmda and run the launcher script in the rootfs """
cmd = ['chroot', self.tmp_image_dir, '/mnt/launcher.sh']
r = util.subp(cmd)
if r.return_code != 0:
print "could not chroot and run!"
sys.exit()
示例15: commit
def commit(self, container):
""" commits the container into a new image with the given tag """
cmd = ['docker', 'commit', '-c', "ENV _RHAI_TEMP_CONTAINER=True", container]
out = util.subp(cmd)
if out.return_code != 0:
print "image was not commited"
return out.stdout.strip()