+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(a)linux.vnet.ibm.com