Skip to content
Permalink
Browse files

Do not use absolute path for zfs/zpool

  • Loading branch information...
william-gr committed Mar 21, 2019
1 parent 3f9d242 commit afacb599eb25d20443cf0dcc7bbb280f5a8df3ee
@@ -653,15 +653,15 @@ def zfs_snapshot_list(self, path=None, sort=None, system=False):
with client as c:
basename = c.call('systemdataset.config')['basename']

zfsproc = self._pipeopen("/sbin/zfs list -t volume -o name %s -H" % sort)
zfsproc = self._pipeopen("zfs list -t volume -o name %s -H" % sort)
zvols = set([y for y in zfsproc.communicate()[0].split('\n') if y != ''])
volnames = set([o.vol_name for o in Volume.objects.all()])

fieldsflag = '-o name,used,available,referenced,mountpoint,freenas:vmsynced'
if path:
zfsproc = self._pipeopen("/sbin/zfs list -p -r -t snapshot %s -H -S creation '%s'" % (fieldsflag, path))
zfsproc = self._pipeopen("zfs list -p -r -t snapshot %s -H -S creation '%s'" % (fieldsflag, path))
else:
zfsproc = self._pipeopen("/sbin/zfs list -p -t snapshot -H -S creation %s" % (fieldsflag))
zfsproc = self._pipeopen("zfs list -p -t snapshot -H -S creation %s" % (fieldsflag))
lines = zfsproc.communicate()[0].split('\n')
for line in lines:
if line != '':
@@ -709,7 +709,7 @@ def zfs_get_options(self, name=None, recursive=False, props=None, zfstype=None):
if zfstype is None:
zfstype = 'filesystem,volume'

zfsproc = self._pipeopen("/sbin/zfs get %s -H -o name,property,value,source -t %s %s %s" % (
zfsproc = self._pipeopen("zfs get %s -H -o name,property,value,source -t %s %s %s" % (
'-r' if recursive else '',
zfstype,
props,
@@ -755,9 +755,9 @@ def zfs_set_option(self, name, item, value, recursive=False):
# Escape single quotes because of shell call
value = value.replace("'", "'\"'\"'")
if recursive:
zfsproc = self._pipeopen("/sbin/zfs set -r '%s'='%s' '%s'" % (item, value, name))
zfsproc = self._pipeopen("zfs set -r '%s'='%s' '%s'" % (item, value, name))
else:
zfsproc = self._pipeopen("/sbin/zfs set '%s'='%s' '%s'" % (item, value, name))
zfsproc = self._pipeopen("zfs set '%s'='%s' '%s'" % (item, value, name))
err = zfsproc.communicate()[1]
if zfsproc.returncode == 0:
return True, None
@@ -915,7 +915,7 @@ def zfs_list(path="", recursive=False, hierarchical=False, include_root=False,
mountpoints
"""
args = [
"/sbin/zfs",
"zfs",
"get",
"-p",
"-H",
@@ -24,7 +24,7 @@ def rename_bes(apps, schema_editor):
if 'N' in columns[1]:
continue

subprocess.run(['/sbin/zfs', 'rename', f'freenas-boot/ROOT/{columns[0]}', f'freenas-boot/ROOT/{columns[0].replace(":", "-")}'])
subprocess.run(['zfs', 'rename', f'freenas-boot/ROOT/{columns[0]}', f'freenas-boot/ROOT/{columns[0].replace(":", "-")}'])


class Migration(migrations.Migration):
@@ -103,7 +103,7 @@ def sendzfs(fromsnap, tosnap, dataset, localfs, remotefs, followdelete, throttle
global templog

progressfile = '/tmp/.repl_progress_%d' % replication.id
cmd = ['/sbin/zfs', 'send', '-V']
cmd = ['zfs', 'send', '-V']

# -p switch will send properties for whole dataset, including snapshots
# which will result in stale snapshots being delete as well
@@ -122,15 +122,15 @@ def sendzfs(fromsnap, tosnap, dataset, localfs, remotefs, followdelete, throttle
os.close(readfd)
os.dup2(writefd, 1)
os.close(writefd)
os.execv('/sbin/zfs', cmd)
os.execvp('zfs', cmd)
# NOTREACHED
else:
with open(progressfile, 'w') as f2:
f2.write(str(zproc_pid))
os.close(writefd)

compress, decompress = compress_pipecmds(compression)
replcmd = '%s%s/usr/local/bin/pipewatcher $$ | %s "%s/sbin/zfs receive -F -d \'%s\' && echo Succeeded"' % (compress, throttle, sshcmd, decompress, remotefs)
replcmd = '%s%s/usr/local/bin/pipewatcher $$ | %s "%szfs receive -F -d \'%s\' && echo Succeeded"' % (compress, throttle, sshcmd, decompress, remotefs)
log.debug('Sending zfs snapshot: %s | %s', ' '.join(cmd), replcmd)
with open(templog, 'w+') as f:
readobj = os.fdopen(readfd, 'rb', 0)
@@ -342,9 +342,9 @@ def write_results():

# Grab map from local system.
if recursive:
zfsproc = pipeopen('/sbin/zfs list -H -t snapshot -p -o name,creation -r "%s"' % (localfs), debug)
zfsproc = pipeopen('zfs list -H -t snapshot -p -o name,creation -r "%s"' % (localfs), debug)
else:
zfsproc = pipeopen('/sbin/zfs list -H -t snapshot -p -o name,creation -r -d 1 "%s"' % (localfs), debug)
zfsproc = pipeopen('zfs list -H -t snapshot -p -o name,creation -r -d 1 "%s"' % (localfs), debug)

output, error = zfsproc.communicate()
if zfsproc.returncode:
@@ -256,7 +256,7 @@ def doesVMSnapshotByNameExists(vm, snapshotName):

vol_name = task.task_filesystem.split('/')[0]
if isMatchingTime(task, snaptime):
proc = pipeopen(f'/sbin/zpool list {vol_name}')
proc = pipeopen(f'zpool list {vol_name}')
proc.communicate()
if proc.returncode != 0:
log.warn(f'Volume {vol_name} not imported, skipping snapshot task #{task.id}')
@@ -286,7 +286,7 @@ def doesVMSnapshotByNameExists(vm, snapshotName):
snapshots_pending_delete = []
previous_prefix = '/'
# Use -s name because its faster. See #18428
zfsproc = pipeopen("/sbin/zfs list -t snapshot -H -o name -s name", debug, logger=log)
zfsproc = pipeopen("zfs list -t snapshot -H -o name -s name", debug, logger=log)
lines = zfsproc.communicate()[0].split('\n')
# Sort it in python to behave the same way as without "-s name"
lines = sorted(lines, key=lambda x: x.split('@'))
@@ -529,7 +529,7 @@ def doesVMSnapshotByNameExists(vm, snapshotName):

# Take the ZFS snapshot
MNTLOCK.lock()
snapcmd = '/sbin/zfs snapshot%s %s"%s"' % (rflag, vmflag, snapname)
snapcmd = 'zfs snapshot%s %s"%s"' % (rflag, vmflag, snapname)
proc = pipeopen(snapcmd, logger=log)
err = proc.communicate()[1]
MNTLOCK.unlock()
@@ -608,7 +608,7 @@ def doesVMSnapshotByNameExists(vm, snapshotName):
if not autorepl_running():
for snapshot in snapshots_pending_delete:
# snapshots with clones will have destruction deferred
snapcmd = '/sbin/zfs destroy -r -d "%s"' % (snapshot)
snapcmd = 'zfs destroy -r -d "%s"' % (snapshot)
proc = pipeopen(snapcmd, logger=log)
err = proc.communicate()[1]
if proc.returncode != 0:
@@ -95,7 +95,7 @@ def main(argv):
args = parser.parse_args(argv)

pipe = subprocess.Popen([
"/sbin/zfs",
"zfs",
"list",
"-Hr",
],
@@ -19,7 +19,7 @@ def check_sync(self):
] + ["freenas-boot"]
for pool in pools:
proc = subprocess.Popen([
"/sbin/zpool",
"zpool",
"list",
"-H",
"-o", "cap",

0 comments on commit afacb59

Please sign in to comment.
You can’t perform that action at this time.