CVSROOT:        /cvs/cluster
Module name:    conga
Changes by:     [EMAIL PROTECTED]       2007-09-24 18:05:57

Modified files:
        ricci/modules/storage: StorageModule.cpp 

Log message:
        Fix 242943: Changes to clustered volumes should be made on all cluster 
nodes, pass 1

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/StorageModule.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9

--- conga/ricci/modules/storage/StorageModule.cpp       2007/09/11 02:45:28     
1.8
+++ conga/ricci/modules/storage/StorageModule.cpp       2007/09/24 18:05:55     
1.9
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -26,6 +26,7 @@
 #include "BDFactory.h"
 #include "LVM.h"
 #include "FSController.h"
+#include "MountHandler.h"
 
 
 using namespace std;
@@ -49,6 +50,10 @@
 static VarMap modify_bd(const VarMap& args);
 static VarMap remove_bd(const VarMap& args);
 static VarMap get_fs_group_members(const VarMap& args);
+static VarMap mount_fs(const VarMap& args);
+static VarMap umount_fs(const VarMap& args);
+static VarMap fstab_add(const VarMap& args);
+static VarMap fstab_del(const VarMap& args);
 
 static VarMap enable_clustered_lvm(const VarMap& args);
 static VarMap disable_clustered_lvm(const VarMap& args);
@@ -86,11 +91,14 @@
   api_1_0["modify_bd"]                          = modify_bd;
   api_1_0["remove_bd"]                          = remove_bd;
 
-  api_1_0["get_fs_group_members"]                   = get_fs_group_members;
-
-  api_1_0["enable_clustered_lvm"]                 = enable_clustered_lvm;
-  api_1_0["disable_clustered_lvm"]                = disable_clustered_lvm;
+  api_1_0["get_fs_group_members"]               = get_fs_group_members;
 
+  api_1_0["enable_clustered_lvm"]               = enable_clustered_lvm;
+  api_1_0["disable_clustered_lvm"]              = disable_clustered_lvm;
+  api_1_0["mount_fs"]                           = mount_fs;
+  api_1_0["umount_fs"]                          = umount_fs;
+  api_1_0["fstab_add"]                          = fstab_add;
+  api_1_0["fstab_del"]                          = fstab_del;
 
   ApiFcnMap   api_fcn_map;
   api_fcn_map["1.0"] = api_1_0;
@@ -451,6 +459,137 @@
   return ret;
 }
 
+VarMap
+mount_fs(const VarMap& args)
+{
+       String device, mountpoint, fstype;
+
+       try {
+               VarMap::const_iterator iter = args.find("device");
+               if (iter == args.end())
+                       throw APIerror("missing device variable");
+               device = iter->second.get_string();
+
+               iter = args.find("mountpoint");
+               if (iter == args.end())
+                       throw APIerror("missing mountpoint variable");
+               mountpoint = iter->second.get_string();
+
+               iter = args.find("fstype");
+               if (iter == args.end())
+                       throw APIerror("missing fstyle variable");
+               fstype = iter->second.get_string();
+
+               MountHandler mh;
+               if (!mh.mount(device, mountpoint, fstype)) {
+                       throw APIerror("mounting " + device + " at "
+                                       + mountpoint + " failed");
+               }
+       } catch (String e) {
+               throw APIerror(e);
+       }
+
+       VarMap ret;
+       return ret;
+}
+
+VarMap 
+umount_fs(const VarMap& args)
+{
+       String device(""), mountpoint("");
+
+       try {
+               VarMap::const_iterator iter = args.find("device");
+               if (iter != args.end())
+                       device = iter->second.get_string();
+
+               iter = args.find("mountpoint");
+               if (iter != args.end())
+                       mountpoint = iter->second.get_string();
+
+               if (!device.size() && !mountpoint.size())
+                       throw APIerror("no device or mount point variable");
+
+               MountHandler mh;
+               if (mountpoint.size() > 0) {
+                       if (mh.umount((device.size() > 0 ? device : ""), 
mountpoint)) {
+                               VarMap ret;
+                               return ret;
+                       }
+               }
+
+               if (device.size() > 0) {
+                       if (mh.umount(device, device)) {
+                               VarMap ret;
+                               return ret;
+                       }
+               }
+       } catch (String e) {
+               throw APIerror(e);
+       }
+
+       throw APIerror("unable to unmount "
+                       + (mountpoint.size() ? mountpoint : device));
+}
+
+VarMap 
+fstab_add(const VarMap& args)
+{
+       String device, mountpoint, fstype;
+
+       try {
+               VarMap::const_iterator iter = args.find("device");
+               if (iter == args.end())
+                       throw APIerror("missing device variable");
+               device = iter->second.get_string();
+
+               iter = args.find("mountpoint");
+               if (iter == args.end())
+                       throw APIerror("missing mountpoint variable");
+               mountpoint = iter->second.get_string();
+
+               iter = args.find("fstype");
+               if (iter == args.end())
+                       throw APIerror("missing fstyle variable");
+               fstype = iter->second.get_string();
+
+               MountHandler mh;
+               if (!mh.fstab_add(device, mountpoint, fstype)) {
+                       throw APIerror("adding " + device + " at "
+                                       + mountpoint + " to fstab failed");
+               }
+       } catch (String e) {
+               throw APIerror(e);
+       }
+
+       VarMap ret;
+       return ret;
+}
+
+VarMap 
+fstab_del(const VarMap& args)
+{
+       String device, mountpoint;
+
+       try {
+               VarMap::const_iterator iter = args.find("device");
+               if (iter == args.end())
+                       throw APIerror("missing device variable");
+               device = iter->second.get_string();
+
+               iter = args.find("mountpoint");
+               if (iter == args.end())
+                       throw APIerror("missing mountpoint variable");
+               mountpoint = iter->second.get_string();
+               MountHandler mh;
+               mh.fstab_remove(device, mountpoint);
+       } catch (String e) {
+               throw APIerror(e);
+       }
+
+       VarMap ret;
+       return ret;
+}
 
 list<XMLObject>
 _mapper_ids(const String& mapper_type)

Reply via email to