[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons sourceware org	2006-07-27 16:34:11

Modified files:
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	Methods for resource creation and editing

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/07/27 15:53:00	1.16
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/07/27 16:34:11	1.17
@@ -1291,3 +1291,207 @@
       req['specialpagetype'] = "1"
       return map
   return map
+
+def getResourcesInfo(modelb, request):
+  resList = list()
+  baseurl = request['URL']
+  cluname = request['clustername']
+  for item in modelb.getResources():
+    itemmap = {}
+    itemmap['name'] = item.getName()
+    itemmap['type'] = item.resource_type
+    itemmap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE_CONFIG
+    itemmap['url'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + item.getName() + "&pagetype=" + RESOURCE
+    resList.append(itemmap)
+  return resList
+                                                                                
+def getResourceInfo(modelb, request):
+  resMap = {}
+  name = request['resourcename']
+  baseurl = request['URL']
+  cluname = request['clustername']
+  for res in modelb.getResources():
+    if res.getName() == name:
+          resMap['name'] = res.getName()
+          resMap['type'] = res.resource_type
+          resMap['tag_name'] = res.TAG_NAME
+          resMap['cfgurl'] = baseurl + "?" + "clustername=" + cluname + "&resourcename=" + res.getName() + "&pagetype=" + RESOURCE_CONFIG
+          return resMap
+                                                                                
+  return {}
+                                                                                
+def addResource(self, request):
+  if not request.form:
+    return "Nothing submitted, no changes made."
+                                                                                
+  if not request.form["resourceName"]:
+    return "Please enter a name for the resource."
+  types = {'ip': addIp,
+           'fs': addFs,
+           'gfs': addGfs,
+           'nfsm': addNfsm,
+           'nfsx': addNfsx,
+           'nfsc': addNfsx,
+           'scr': addScr,
+           'smb': addSmb}
+                                                                                
+  type = request.form["type"]
+  return types[type](request)
+
+def getResourceForEdit(modelb, name):
+  resPtr = modelb.getResourcesPtr()
+  resources = resPrt.getChildren()
+                                                                                
+  for res in resources:
+    if res.getName() == name:
+      resources.removeChild(res)
+      break
+                                                                                
+  return res
+def addIp(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Ip)
+  form = request.form
+  addr = form["ip1"]+"."+form["ip2"]+"."+form["ip3"]+"."+form["ip4"]
+  res.attr_hash["address"] = addr
+  if form.has_key('monitorLink'):
+    res.attr_hash["monitor_link"] = '1'
+  else:
+    res.attr_hash["monitor_link"] = '0'
+  modelb.getResourcesPtr().addChild(res);
+  return res
+
+def addFs(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Fs)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["mountpoint"] = form["mountpoint"]
+  res.attr_hash["device"] = form["device"]
+  res.attr_hash["options"] = form["options"]
+  res.attr_hash["fstype"] = form["fstype"]
+  res.attr_hash["fsid"] = form["fsid"]
+  if form.has_key('forceunmount'):
+    res.attr_hash["force_unmount"] = '1'
+  else:
+    res.attr_hash["force_unmount"] = '0'
+                                                                                
+  if form.has_key('selffence'):
+    res.attr_hash["self_fence"] = '1'
+  else:
+    res.attr_hash["self_fence"] = '0'
+                                                                                
+  if form.has_key('checkfs'):
+    res.attr_hash["force_fsck"] = '1'
+  else:
+    res.attr_hash["force_fsck"] = '0'
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+                                                                                
+def addGfs(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Clusterfs)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["mountpoint"] = form["mountpoint"]
+  res.attr_hash["device"] = form["device"]
+  res.attr_hash["options"] = form["options"]
+  res.attr_hash["fsid"] = form["fsid"]
+                                                                                
+  if form.has_key('forceunmount'):
+    res.attr_hash["force_unmount"] = '1'
+  else:
+    res.attr_hash["force_unmount"] = '0'
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+
+def addNfsm(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Netfs)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["mountpoint"] = form["mountpoint"]
+  res.attr_hash["host"] = form["host"]
+  res.attr_hash["options"] = form["options"]
+  res.attr_hash["exportpath"] = form["export"]
+  res.attr_hash["nfstype"] = form["fstype"]
+                                                                                
+  if form.has_key('forceunmount'):
+    res.attr_hash["force_unmount"] = '1'
+  else:
+    res.attr_hash["force_unmount"] = '0'
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+                                                                                
+def addNfsc(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(NFSClient)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["target"] = form["target"]
+  res.attr_hash["options"] = form["options"]
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+                                                                                
+def addNfsx(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(NFSExport)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+
+def addScr(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Script)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["file"] = form["file"]
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+                                                                                
+def addSmb(request):
+  modelb = request.SESSION["model"]
+  if request.form.has_key('edit'):
+    res = getResourceForEdit(modelb, request.form['oldname'])
+  else:
+    res = apply(Samba)
+  form = request.form
+  res.attr_hash["name"] = form["resourceName"]
+  res.attr_hash["workgroup"] = form["workgroup"]
+                                                                                
+  modelb.getResourcesPtr().addChild(res);
+  return res
+                                                                                
+def appendModel(request, model):
+  try:
+    request.SESSION.set('model', model)
+  except: pass
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]