Ejemplo n.º 1
0
 def create(self, option=None):
     """
     Create the dataset with options.
     """
     if option is None:
         cmd = [rcEnv.syspaths.zfs, 'create', self.name]
     else:
         cmd = [rcEnv.syspaths.zfs, 'create'] + option + [self.name]
     ret, _, _ = vcall(cmd, log=self.log)
     if ret == 0:
         return True
     else:
         return False
Ejemplo n.º 2
0
 def rename(self, name=None, option=None):
     """
     Rename the dataset.
     """
     if option is None:
         cmd = [rcEnv.syspaths.zfs, 'rename', self.name, name]
     else:
         cmd = [rcEnv.syspaths.zfs, 'rename'] + option + [self.name, name]
     ret, _, _ = vcall(cmd, log=self.log)
     if ret == 0:
         return True
     else:
         return False
Ejemplo n.º 3
0
 def setprop(self, propname, propval, err_to_warn=False, err_to_info=False):
     """
     Set Dataset property value.
     Return True is success else return False.
     """
     cmd = [rcEnv.syspaths.zfs, 'set', propname + '=' + propval, self.name]
     ret, out, err = vcall(cmd,
                           log=self.log,
                           err_to_warn=err_to_warn,
                           err_to_info=err_to_info)
     if ret == 0:
         return True
     else:
         return False
Ejemplo n.º 4
0
 def clone(self, name, option=None):
     """
     Clone the dataset with options
     Return the clone dataset object.
     Return False on failure.
     """
     if option is None:
         cmd = [rcEnv.syspaths.zfs, 'clone', self.name, name]
     else:
         cmd = [rcEnv.syspaths.zfs, 'clone'] + option + [self.name, name]
     ret, _, _ = vcall(cmd, log=self.log)
     if ret == 0:
         return Dataset(name)
     else:
         return False
Ejemplo n.º 5
0
 def snapshot(self, snapname=None, recursive=False):
     """
     Snapshot the dataset.
     Return the snapshot dataset object.
     Return False on error.
     """
     if snapname is None:
         raise ex.excError("snapname should be defined")
     snapdataset = self.name + "@" + snapname
     cmd = [rcEnv.syspaths.zfs, 'snapshot']
     if recursive:
         cmd.append("-r")
     cmd.append(snapdataset)
     ret, _, _ = vcall(cmd, log=self.log)
     if ret == 0:
         return Dataset(snapdataset)
     else:
         return False
Ejemplo n.º 6
0
def zfs_setprop(dataset='undef_ds',
                propname='undef_prop',
                propval='undef_val',
                log=None):
    """
    Set the dataset property <propname> to value <propval>.
    """
    current = zfs_getprop(dataset, propname)
    if current == "":
        # dataset does not exist
        return False
    if current == propval:
        return True
    cmd = [rcEnv.syspaths.zfs, 'set', propname + '=' + propval, dataset]
    ret, _, _ = vcall(cmd, log=log)
    if ret == 0:
        return True
    else:
        return False
Ejemplo n.º 7
0
    def vcall(self, cmd):
        if self.node is not None:
            cmd = [' '.join(cmd)]
            cmd = rcEnv.rsh.split() + [self.node] + cmd

        return vcall(cmd, log=self.log)
Ejemplo n.º 8
0
 def vcall(self, *args, **kwargs):
     """
     Wrap vcall, setting the resource logger
     """
     kwargs["log"] = self.log
     return vcall(*args, **kwargs)