[Libvirt-cim] [PATCH 2 of 3] Adding nfs_netfs_setup() to configure nfs server setup
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Tue Jun 16 22:59:35 UTC 2009
> +def nfs_config(server, nfs_server_bin):
> + cmd = "ps aux | grep -v -e nfsiod -e grep | grep nfsd"
> + rc, out = utils.run_remote(server, cmd)
> + # if NFS services is not found on the machine, start it..
> + if rc != PASS :
> + nfs_server_cmd = "%s start" % nfs_server_bin
> + rc, out = utils.run_remote(server, nfs_server_cmd)
> + if rc != PASS:
> + logger.error("Could not start the nfsserver on '%s'", server)
> + if not os.path.exists(nfs_server_bin):
> + logger.error("NFS server '%s' does not seem to be installed "\
> + "on '%s'", nfs_server_bin, server)
> + return SKIP
I would check to see if the nfs binary exists before attempting to run it.
> +def netfs_config(server, nfs_server_bin):
> + src_dir_for_mnt = mkdtemp()
> + dest_dir_to_mnt = mkdtemp()
> + fd = open("/etc/exports", "a")
I would create a backup of /etc/exports just incase. Something like
/etc/exports.cimtest.bk - that way the user can restore it if we
accidentally mess the file up.
Also, what is /etc/exports doesn't exist on the system?
> + fd.seek(0)
> + line = "\n %s %s(rw)" %(src_dir_for_mnt, server)
> + fd.write(line)
> + fd.close()
> +
> + try:
> + # Need to give suitable perm, otherwise netfs pool-create fails
> + cmd = "chmod go+rx %s %s" % (src_dir_for_mnt, dest_dir_to_mnt)
> + rc, out = utils.run_remote(server, cmd)
> + if rc != 0:
> + raise Exception("Failed to chmod on %s %s" \
> + % (src_dir_for_mnt, dest_dir_to_mnt))
> +
> + # Restart the nfs server....
> + nfs_server_cmd = "%s restart" % nfs_server_bin
> + rc, out = utils.run_remote(server, nfs_server_cmd)
> + if rc != PASS:
> + raise Exception("Could not restart NFS server on '%s'" % server)
> +
> + # NFS mount src_dir_for_mnt
> + cmd = "mount -t nfs %s:%s %s" %(server, src_dir_for_mnt, dest_dir_to_mnt)
No need to do this.. libvirt should handle mounting for you.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list