@Override public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) fs.destory(true); return null; } }
@Override public String invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) return fs.getName(); // TODO: for now, only support agents that are already on ZFS. throw new IOException("Not on ZFS"); } }
LibZFS zfs = new LibZFS(); ZFSFileSystem existing = zfs.getFileSystemByMountPoint(home); if(existing!=null) { return existing.getName(); String name = computeHudsonFileSystemName(zfs, zfs.roots().get(0)); out.println("Creating "+name); ZFSFileSystem hudson = zfs.create(name, ZFSFileSystem.class); hudson.setMountPoint(dir); hudson.mount(); if(LIBC.chown(dir.getPath(),uid,gid)!=0) throw new IOException("Failed to chown "+dir); hudson.unmount(); hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson" ACLBuilder acl = new ACLBuilder(); acl.user(userName).withEverything(); hudson.allow(acl); } catch (ZFSException e) { hudson.destory(); } catch (Exception ignored) { return hudson.getName();
LibZFS zfs = new LibZFS(); ZFSFileSystem existing = zfs.getFileSystemByMountPoint(home); if(existing!=null) { out.println(home+" is already on ZFS. Doing nothing"); ZFSFileSystem hudson = zfs.open(target, ZFSFileSystem.class); hudson.setMountPoint(tmpDir); hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson" hudson.mount(); hudson.unmount(MountFlags.MS_FORCE); hudson.setMountPoint(home); hudson.mount(); hudson.setProperty("sharesmb","on"); hudson.setProperty("sharenfs","on"); hudson.share(); } catch (ZFSException e) { listener.error("Failed to share the file systems: "+e.getCode());
@Override public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) return null; // already on ZFS // nope. create a file system String fullName = rootDataset + '/' + name; listener.getLogger().println("Creating a ZFS file system "+fullName+" at "+f); fs = libzfs.create(fullName, ZFSFileSystem.class); fs.setMountPoint(f); fs.mount(); return null; } }
private boolean shouldBeActive() { if(!System.getProperty("os.name").equals("SunOS") || disabled) // on systems that don't have ZFS, we don't need this monitor return false; try { LibZFS zfs = new LibZFS(); List<ZFSFileSystem> roots = zfs.roots(); if(roots.isEmpty()) return false; // no active ZFS pool // if we don't run on a ZFS file system, activate ZFSFileSystem hudsonZfs = zfs.getFileSystemByMountPoint(Jenkins.getInstance().getRootDir()); if(hudsonZfs!=null) return false; // already on ZFS // decide what file system we'll create ZFSFileSystem pool = roots.get(0); prospectiveZfsFileSystemName = computeHudsonFileSystemName(zfs,pool); return true; } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to detect whether Hudson is on ZFS",e); return false; } catch (LinkageError e) { LOGGER.info("No ZFS available. If you believe this is an error, increase the logging level to get the stack trace"); LOGGER.log(Level.FINE,"Stack trace of failed ZFS load",e); return false; } }
public void allow(String userName) { ACLBuilder acl = new ACLBuilder(); acl.user(userName).withEverything(); zfsFileSystem.allow(acl); }
/** * For everyone. */ public PermissionBuilder everyone() { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_EVERYONE)); }
if(ze.getCode()==ErrorCode.EZFS_PERM) {
public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) fs.destory(true); return null; } });
/** * For user */ public PermissionBuilder user(final String userName) { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_USER) { protected String who() { return userName; } }); }
public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) fs.destory(true); return null; } });
/** * For group */ public PermissionBuilder group(final String groupName) { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_GROUP) { protected String who() { return groupName; } }); }
/** * For group */ public PermissionBuilder group(final String groupName) { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_GROUP) { protected String who() { return groupName; } }); }
/** * For user */ public PermissionBuilder user(final String userName) { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_USER) { protected String who() { return userName; } }); }
/** * For everyone. */ public PermissionBuilder everyone() { return add(new PermissionBuilder(zfs_deleg_who_type_t.ZFS_DELEG_EVERYONE)); }