All of lore.kernel.org
 help / color / mirror / Atom feed
From: jparsons@sourceware.org <jparsons@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...
Date: 8 Nov 2006 15:52:41 -0000	[thread overview]
Message-ID: <20061108155241.24371.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons at sourceware.org	2006-11-08 15:52:41

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

Log message:
	Finish task of separating fence info methods so that conditional arg need not be passed. Also some fixes

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/07 21:33:52	1.153
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/08 15:52:41	1.154
@@ -2867,7 +2867,7 @@
 
 def getFence(self, model, request):
   map = {}
-  fencename = request['fencedevicename']
+  fencename = request['fencename']
   fencedevs = model.getFenceDevices()
   for fencedev in fencedevs:
     if fencedev.getName().strip() == fencename:
@@ -2877,9 +2877,37 @@
       except:
         map['pretty_name'] = fencedev.getAgentType()
 
+      nodes_used = list()
+      nodes = model.getNodes()
+      for node in nodes:
+        flevels = node.getFenceLevels()
+        for flevel in flevels: #These are the method blocks...
+          kids = flevel.getChildren()
+          for kid in kids: #These are actual devices in each level
+            if kid.getName().strip() == fencedev.getName().strip():
+              #See if this fd already has an entry for this node
+              found_duplicate = False
+              for item in nodes_used:
+                if item['nodename'] == node.getName().strip():
+                  found_duplicate = True
+              if found_duplicate == True:
+                continue
+              node_hash = {}
+              node_hash['nodename'] = node.getName().strip()
+              node_hash['nodeurl'] = baseurl + "?clustername=" + clustername + "&nodename=" + node.getName() + "&pagetype=" + NODE 
+              nodes_used.append(node_hash)
+
+      map['nodesused'] = nodes_used
       return map
 
   return map
+
+def getFDForInstance(fds, name):
+  for fd in fds:
+    if fd.getName().strip() == name:
+      return fd
+
+  raise
   
 def getFenceInfo(self, model, request):
   clustername = request['clustername']
@@ -2894,7 +2922,8 @@
   map['shared1'] = shared1
   map['shared2'] = shared2
 
-  pass
+  major_num = 1
+  minor_num = 100
 
   try:
     nodename = request['nodename']
@@ -2911,70 +2940,200 @@
   except GeneralError, e:
     raise GeneralError('FATAL', "Couldn't find node name in current node list")
 
+  fds = model.getFenceDevices()
+
   levels = node.getFenceLevels()
   len_levels = len(levels)
 
   if len_levels == 0:
     return map
 
-  for i in xrange(2):
-    if not i in levels:
-      continue
-    fence_struct = {}
-    if levels[i] != None:
-      level = levels[i]
-    else:
-      #No more levels...
-      continue
-    kids = level.getChildren()
-    if len(kids) == 0:
-      continue
-    else:
-      #for each kid, 
-      ### resolve name, find fence device
-      ### Add fd to list, if it is not there yet 
-      ### determine if it is a shared fence type
-      ### if it is a shared device, add instance entry
-      fds = model.getFenceDevices()
-      fence_struct = None
-      for kid in kids:
-        name = kid.getName()
-        found_fd = False
-        if not i in map:
-          continue
-        for entry in map[i]:
-          if entry['name'] == name:
-            fence_struct = entry
-            found_fd = True
-            break
-        if found_fd == False:
-          for fd in fds:
-            if fd.getName() == name:  #Found the fence device
-              fence_struct = {}
-              fence_struct['isShareable'] = fd.isShared()
-              fd_attrs = fd.getAttributes()
-              kees = fd_attrs.keys()
-              for kee in kees:
-                fence_struct[kee] = fd_attrs[kee]
-        fi_attrs = kid.getAttributes()
-        kees = fi_attrs.keys()
-        if fence_struct['isShareable'] == True:
-          instance_struct = {}
+  if len_levels >= 1:
+    first_level = levels[0]
+    kids = first_level.getChildren()
+    last_kid_fd = None  #This is a marker for allowing multi instances
+                        #beneath a fencedev
+    for kid in kids:
+      instance_name = kid.getName().strip()
+      try:
+        fd = getFDForInstance(fds, instance_name)
+      except:
+        fd = None #Set to None in case last time thru loop
+        continue
+      if fd != None:
+        if fd.isShared() == False:  #Not a shared dev...build struct and add
+          fencedev = {}
+          fencedev['prettyname'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+          fencedev['isShared'] = False
+          fencedev['id'] = str(major_num)
+          major_num = major_num + 1
+          devattrs = fd.getAttributes()
+          kees = devattrs.keys()
           for kee in kees:
-            instance_struct[kee] = fi_attrs[kee]
-            try:
-                check = fence_struct['instances']
-                check.append(instance_struct)
-            except KeyError, e:
-                fence_struct['instances'] = list()
-                fence_struct['instances'].append(instance_struct) 
-        else:  #Not a shareable fence device type
+            fencedev[kee] = devattrs[kee]
+          kidattrs = kid.getAttributes()
+          kees = kidattrs.keys()
           for kee in kees:
-            fence_struct[kee] = fi_attrs[kee]
-      if i == 0:
-        level1.append(fence_struct)      
-      else:
-        level2.append(fence_struct)      
+            if kee == "name":
+              continue #Don't duplicate name attr
+            fencedev[kee] = kidattrs[kee]
+          #This fencedev struct is complete, and needs to be placed on the 
+          #level1 Q. Because it is non-shared, we should set last_kid_fd
+          #to none.
+          last_kid_fd = None
+          level1.append(fencedev)
+        else:  #This dev is shared
+          if (last_kid_fd != None) and (fd.getName().strip() == last_kid_fd.getName().strip()):  #just append a new instance struct to last_kid_fd
+            instance_struct = {}
+            instance_struct['id'] = str(minor_num)
+            minor_num = minor_num + 1
+            kidattrs = kid.getAttributes()
+            kees = kidattrs.keys()
+            for kee in kees:
+              if kee == "name":
+                continue
+              instance_struct[kee] = kidattrs[kee]
+            #Now just add this struct to last_kid_fd and reset last_kid_fd
+            ilist = last_kid_fd['instance_list']
+            ilist.append(instance_struct)
+            last_kid_fd = fd
+            continue
+          else: #Shared, but not used above...so we need a new fencedev struct
+            fencedev = {}
+            fencedev['prettyname'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+            fencedev['isShared'] = True
+            fencedev['cfgurl'] = baseurl + "?clustername=" + clustername + "&fencename=" + fd.getName().strip() + "&pagetype=" + FENCEDEV 
+            fencedev['id'] = str(major_num)
+            major_num = major_num + 1
+            inlist = list()
+            fencedev['instance_list'] = inlist
+            devattrs = fd.getAttributes()
+            kees = devattrs.keys()
+            for kee in kees:
+              fencedev[kee] = devattrs[kee]
+            instance_struct = {}
+            kidattrs = kid.getAttributes()
+            kees = kidattrs.keys()
+            for kee in kees:
+              if kee == "name":
+                continue
+              instance_struct[kee] = kidattrs[kee]
+            inlist.append(instance_struct) 
+            level1.append(fencedev)
+            last_kid_fd = fd
+            continue
+
+    #level1 list is complete now, but it is still necessary to build shared1
+    sharednames = list()
+    for fd in fds:
+      isUnique = True
+      if fd.isShared() == False:
+        continue
+      for fdev in level1
+        if fd.getName.strip() == fdev['name']:
+          isUnique = False
+          break
+      if isUnique == True:
+        shared_struct = {}
+        shared_struct['name'] = fd.getName().strip()
+        agentname = fd.getAgentType()
+        shared_struct['agent'] = agentname
+        shared_struct['prettyname'] = FenceHandler.FENCE_OPTS[agentname]
+        shared1.append(shared_struct)
+
+  #YUK: This next section violates the DRY rule, :-(
+  if len_levels >= 2:
+    second_level = levels[1]
+    kids = second_level.getChildren()
+    last_kid_fd = None  #This is a marker for allowing multi instances
+                        #beneath a fencedev
+    for kid in kids:
+      instance_name = kid.getName().strip()
+      try:
+        fd = getFDForInstance(fds, instance_name)
+      except:
+        fd = None #Set to None in case last time thru loop
+        continue
+      if fd != None:
+        if fd.isShared() == False:  #Not a shared dev...build struct and add
+          fencedev = {}
+          fencedev['prettyname'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+          fencedev['isShared'] = False
+          fencedev['id'] = str(major_num)
+          major_num = major_num + 1
+          devattrs = fd.getAttributes()
+          kees = devattrs.keys()
+          for kee in kees:
+            fencedev[kee] = devattrs[kee]
+          kidattrs = kid.getAttributes()
+          kees = kidattrs.keys()
+          for kee in kees:
+            if kee == "name":
+              continue #Don't duplicate name attr
+            fencedev[kee] = kidattrs[kee]
+          #This fencedev struct is complete, and needs to be placed on the 
+          #level2 Q. Because it is non-shared, we should set last_kid_fd
+          #to none.
+          last_kid_fd = None
+          level2.append(fencedev)
+        else:  #This dev is shared
+          if (last_kid_fd != None) and (fd.getName().strip() == last_kid_fd.getName().strip()):  #just append a new instance struct to last_kid_fd
+            instance_struct = {}
+            instance_struct['id'] = str(minor_num)
+            minor_num = minor_num + 1
+            kidattrs = kid.getAttributes()
+            kees = kidattrs.keys()
+            for kee in kees:
+              if kee == "name":
+                continue
+              instance_struct[kee] = kidattrs[kee]
+            #Now just add this struct to last_kid_fd and reset last_kid_fd
+            ilist = last_kid_fd['instance_list']
+            ilist.append(instance_struct)
+            last_kid_fd = fd
+            continue
+          else: #Shared, but not used above...so we need a new fencedev struct
+            fencedev = {}
+            fencedev['prettyname'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+            fencedev['isShared'] = True
+            fencedev['cfgurl'] = baseurl + "?clustername=" + clustername + "&fencename=" + fd.getName().strip() + "&pagetype=" + FENCEDEV 
+            fencedev['id'] = str(major_num)
+            major_num = major_num + 1
+            inlist = list()
+            fencedev['instance_list'] = inlist
+            devattrs = fd.getAttributes()
+            kees = devattrs.keys()
+            for kee in kees:
+              fencedev[kee] = devattrs[kee]
+            instance_struct = {}
+            kidattrs = kid.getAttributes()
+            kees = kidattrs.keys()
+            for kee in kees:
+              if kee == "name":
+                continue
+              instance_struct[kee] = kidattrs[kee]
+            inlist.append(instance_struct) 
+            level2.append(fencedev)
+            last_kid_fd = fd
+            continue
+
+    #level2 list is complete but like above, we need to build shared2
+    sharednames = list()
+    for fd in fds:
+      isUnique = True
+      if fd.isShared() == False:
+        continue
+      for fdev in level2
+        if fd.getName.strip() == fdev['name']:
+          isUnique = False
+          break
+      if isUnique == True:
+        shared_struct = {}
+        shared_struct['name'] = fd.getName().strip()
+        agentname = fd.getAgentType()
+        shared_struct['agent'] = agentname
+        shared_struct['prettyname'] = FenceHandler.FENCE_OPTS[agentname]
+        shared2.append(shared_struct)
 
   return map    
       
@@ -2999,6 +3158,8 @@
         fencedev['pretty_name'] = FENCE_OPTS[fd.getAgentType()]
       except:
         fencedev['pretty_name'] = fd.getAgentType()
+      #Add config url for this fencedev
+      fencedev['cfgurl'] = baseurl + "?clustername=" + clustername + "&fencename=" + fd.getName().strip() + "&pagetype=" + FENCEDEV
 
       nodes = model.getNodes()
       for node in nodes:
@@ -3016,7 +3177,7 @@
                 continue
               node_hash = {}
               node_hash['nodename'] = node.getName().strip()
-              node_hash['nodeurl'] = baseurl + "#fence" + "?clustername=" + clustername + "&nodename=" + node.getName() + "&pagetype=" + NODE 
+              node_hash['nodeurl'] = baseurl + "?clustername=" + clustername + "&nodename=" + node.getName() + "&pagetype=" + NODE 
               nodes_used.append(node_hash)
 
       fencedev['nodesused'] = nodes_used



             reply	other threads:[~2006-11-08 15:52 UTC|newest]

Thread overview: 185+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-08 15:52 jparsons [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-07-17 16:36 [Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte rmccabe
2008-04-18 20:37 rmccabe
2007-12-12 15:45 rmccabe
2007-08-23 19:00 rmccabe
2007-08-22 20:57 rmccabe
2007-05-03 19:51 rmccabe
2007-04-02 16:35 rmccabe
2007-04-02 15:56 rmccabe
2007-03-27  2:03 rmccabe
2007-03-16  3:19 rmccabe
2007-03-16  3:19 rmccabe
2007-03-16  3:19 rmccabe
2007-03-13  3:07 rmccabe
2007-03-13  3:06 rmccabe
2007-03-12  5:47 rmccabe
2007-03-12  5:46 rmccabe
2007-03-12  5:46 rmccabe
2007-03-06 22:48 rmccabe
2007-03-01 20:22 rmccabe
2007-03-01 20:22 rmccabe
2007-03-01 20:22 rmccabe
2007-02-13 19:50 rmccabe
2007-02-13 19:50 rmccabe
2007-02-12 20:25 rmccabe
2007-02-12 20:24 rmccabe
2007-02-07 22:00 rmccabe
2007-02-07 21:30 rmccabe
2007-02-05 19:56 rmccabe
2007-01-31 23:45 rmccabe
2007-01-31 19:28 rmccabe
2007-01-31 18:50 rmccabe
2007-01-30 21:41 jparsons
2007-01-30 21:21 jparsons
2007-01-30 21:05 jparsons
2007-01-29 23:30 rmccabe
2007-01-26 19:35 rmccabe
2007-01-18  2:48 rmccabe
2007-01-17 22:26 rmccabe
2007-01-17 22:14 rmccabe
2007-01-10 23:33 jparsons
2007-01-10 22:45 rmccabe
2007-01-10 20:06 rmccabe
2006-12-20 20:40 jparsons
2006-12-14 21:37 rmccabe
2006-12-14 17:03 rmccabe
2006-12-08 23:02 rmccabe
2006-11-30 20:12 jparsons
2006-11-27 21:06 rmccabe
2006-11-27 21:05 rmccabe
2006-11-27 18:15 rmccabe
2006-11-20 23:32 rmccabe
2006-11-20 15:05 jparsons
2006-11-17  5:50 rmccabe
2006-11-17  5:48 rmccabe
2006-11-10 18:18 rmccabe
2006-11-10 17:59 rmccabe
2006-11-09 22:30 rmccabe
2006-11-09 14:17 rmccabe
2006-11-08 21:42 rmccabe
2006-11-07 20:14 jparsons
2006-11-07 20:13 jparsons
2006-11-07  2:36 jparsons
2006-11-07  1:32 jparsons
2006-11-06 23:55 rmccabe
2006-11-05  0:59 rmccabe
2006-11-03 21:13 jparsons
2006-11-03  1:24 rmccabe
2006-11-03  1:08 rmccabe
2006-11-02 20:58 rmccabe
2006-11-02 20:45 rmccabe
2006-11-02 20:41 rmccabe
2006-11-02  3:17 rmccabe
2006-10-31 17:18 rmccabe
2006-10-31  0:16 rmccabe
2006-10-30 22:52 rmccabe
2006-10-30 20:43 jparsons
2006-10-27  1:11 rmccabe
2006-10-25  0:43 rmccabe
2006-10-24 14:08 rmccabe
2006-10-23 20:47 jparsons
2006-10-20 22:09 rmccabe
2006-10-20 21:59 rmccabe
2006-10-19 14:57 rmccabe
2006-10-18 23:12 rmccabe
2006-10-18 19:16 rmccabe
2006-10-16 21:01 rmccabe
2006-10-16 20:51 jparsons
2006-10-16 19:17 jparsons
2006-10-16  5:28 rmccabe
2006-10-16  4:54 rmccabe
2006-10-16  4:51 rmccabe
2006-10-13 22:56 rmccabe
2006-10-12 22:11 jparsons
2006-10-12 21:00 kupcevic
2006-10-12 20:54 jparsons
2006-10-12 20:48 jparsons
2006-10-12 19:40 rmccabe
2006-10-12 17:27 jparsons
2006-10-12 17:08 jparsons
2006-10-12 15:50 jparsons
2006-10-12 15:45 jparsons
2006-10-12  0:04 jparsons
2006-10-11 23:56 jparsons
2006-10-11 23:11 jparsons
2006-10-11 23:08 rmccabe
2006-10-11 22:37 jparsons
2006-10-11 20:58 jparsons
2006-10-11 17:43 jparsons
2006-10-11 17:29 rmccabe
2006-10-11 16:35 jparsons
2006-10-11 16:25 jparsons
2006-10-11 16:18 rmccabe
2006-10-10 21:33 kupcevic
2006-10-09 20:21 rmccabe
2006-10-04 16:20 rmccabe
2006-10-04 16:05 jparsons
2006-10-04 15:11 jparsons
2006-10-02 22:30 rmccabe
2006-10-02 21:42 rmccabe
2006-10-02 21:09 rmccabe
2006-10-02 20:53 rmccabe
2006-09-28 22:04 rmccabe
2006-09-28 20:10 rmccabe
2006-09-27 18:46 rmccabe
2006-09-27 16:18 jparsons
2006-09-27 15:51 jparsons
2006-09-27 15:35 jparsons
2006-09-25 22:59 rmccabe
2006-09-22 18:24 rmccabe
2006-08-30 22:59 rmccabe
2006-08-22 17:46 jparsons
2006-08-22 17:41 jparsons
2006-08-16 23:40 jparsons
2006-08-16 21:56 jparsons
2006-08-16 21:54 jparsons
2006-08-16 21:51 jparsons
2006-08-16 19:14 rmccabe
2006-08-16 16:10 jparsons
2006-08-14 15:12 jparsons
2006-08-13 19:38 jparsons
2006-08-13 19:37 jparsons
2006-08-13 18:36 jparsons
2006-08-13 16:32 jparsons
2006-08-13 16:15 jparsons
2006-08-13 15:02 jparsons
2006-08-13 14:57 jparsons
2006-08-13 13:48 jparsons
2006-08-12 21:13 jparsons
2006-08-12 20:31 jparsons
2006-08-12 18:22 jparsons
2006-08-12 17:53 jparsons
2006-08-11  0:29 jparsons
2006-08-10 23:06 shuennek
2006-08-10 16:50 jparsons
2006-08-10 14:16 jparsons
2006-08-09 22:05 jparsons
2006-08-09 21:48 jparsons
2006-08-03 13:37 jparsons
2006-08-02 18:59 rmccabe
2006-08-02 17:25 rmccabe
2006-08-01 15:29 jparsons
2006-08-01 15:25 jparsons
2006-08-01 15:20 jparsons
2006-08-01 15:13 jparsons
2006-08-01 15:04 jparsons
2006-07-31 18:21 rmccabe
2006-07-28 19:03 jparsons
2006-07-28 18:57 jparsons
2006-07-28 18:40 jparsons
2006-07-28 14:16 jparsons
2006-07-28 14:02 jparsons
2006-07-28 11:46 jparsons
2006-07-27 16:34 jparsons
2006-07-27 15:53 rmccabe
2006-07-25 20:16 jparsons
2006-07-25 20:01 jparsons
2006-07-25  0:56 jparsons
2006-07-24 21:51 jparsons
2006-07-24 21:13 jparsons
2006-07-24 19:50 jparsons
2006-07-19 22:28 rmccabe
2006-07-19 21:38 rmccabe
2006-07-19 20:57 rmccabe
2006-07-19 20:19 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061108155241.24371.qmail@sourceware.org \
    --to=jparsons@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.