[luci] Don't allow resource names to be duplicated within service groups when assembling the forms before a
by Ryan McCabe
commit 741840fdccb018eda673066f1740152d91558b93
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Feb 23 18:42:17 2012 -0500
Don't allow resource names to be duplicated within service groups
when assembling the forms before adding them to the config
luci/validation/validate_resource.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index bdb4168..3f5c3b5 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -687,6 +687,7 @@ def validate_clusvc_form(model, **kw):
is_vm = False
form_hash = {}
form_hash[root_elem] = { 'form': None, 'kids': [] }
+ existing_res_names = []
for i in forms:
form_id = i.getAttribute('id')
form_parent = i.getAttribute('parent')
@@ -737,6 +738,10 @@ def validate_clusvc_form(model, **kw):
else:
dummy_form['resourcename'] = dummy_form['address_nominal']
dummy_form['address'] = dummy_form['resourcename']
+ if dummy_form['resourcename'] in existing_res_names:
+ return (False, { 'errors': [ _('A resource named "%s" already exists') % dummy_form['resourcename'] ]})
+ else:
+ existing_res_names.append(dummy_form['resourcename'])
except:
log.exception('no ipaddr')
return (False, { 'errors': [ _('No IP address was given') ]})
12 years, 2 months
[luci] Error out if inline resource names inside service groups collide with global resource names and vice
by Ryan McCabe
commit 1cfd2f1b48889a384756cb983dd0fa0529cf1a2c
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Feb 23 18:10:49 2012 -0500
Error out if inline resource names inside service groups collide
with global resource names and vice versa.
luci/lib/ClusterConf/ModelBuilder.py | 4 ++--
luci/lib/ClusterConf/TagObject.py | 17 +++++++++++++----
luci/validation/validate_resource.py | 14 ++++++--------
3 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/luci/lib/ClusterConf/ModelBuilder.py b/luci/lib/ClusterConf/ModelBuilder.py
index 92d1197..a4e7d9f 100644
--- a/luci/lib/ClusterConf/ModelBuilder.py
+++ b/luci/lib/ClusterConf/ModelBuilder.py
@@ -1197,8 +1197,8 @@ class ModelBuilder:
if found_one is True:
break
- def searchObjectTree(self, tagtype):
+ def searchObjectTree(self, tagtype, subclass=False):
objlist = list()
- self.object_tree.searchTree(objlist, tagtype)
+ self.object_tree.searchTree(objlist, tagtype, subclass)
return objlist
diff --git a/luci/lib/ClusterConf/TagObject.py b/luci/lib/ClusterConf/TagObject.py
index 0f32b59..2d61caa 100644
--- a/luci/lib/ClusterConf/TagObject.py
+++ b/luci/lib/ClusterConf/TagObject.py
@@ -157,14 +157,23 @@ class TagObject(object):
def isRefObject(self):
return False
- def searchTree(self, objlist, tagtype):
- if self.TAG_NAME == tagtype:
- objlist.append(self)
+ def searchTree(self, objlist, tagtype, subclass=False):
+ if subclass is not True:
+ if type(tagtype) in (str, unicode):
+ if self.TAG_NAME == tagtype:
+ objlist.append(self)
+ else:
+ if type(self) == tagtype:
+ objlist.append(self)
+ else:
+ if issubclass(type(self), tagtype):
+ objlist.append(self)
+
if len(self.children) > 0:
for child in self.children:
if child is None:
continue
- child.searchTree(objlist, tagtype)
+ child.searchTree(objlist, tagtype, subclass)
def replaceChild(self, oldchild, newchild):
"""Looks up oldchild and replace it with newchild."""
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index 7f546b6..bdb4168 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -522,13 +522,11 @@ def create_resource(res_type, model, **kw):
rname = kw['resourcename'].strip()
res.addAttribute('name', rname)
+ existing_res_names = map(lambda x: x.getName(), model.searchObjectTree(BaseResource, subclass=True))
+
if not resource_edit:
- try:
- dummy = getResourceForEdit(model, rname)
- if dummy:
- raise Exception, _('A resource named "%s" already exists.') % rname
- except:
- pass
+ if rname in existing_res_names:
+ raise Exception, _('A resource named "%s" already exists.') % rname
errors = resource_table[res_type][0](res, rname, model, **kw)
if resource_edit and oldname != res.getName():
@@ -758,7 +756,7 @@ def validate_clusvc_form(model, **kw):
cur_res_name = 'resource "%s"' % cur_name
except Exception, e:
resObj = None
- errors.append(_('Error adding resource type %s: %s') % (res_type, str(e)))
+ errors.append(_('Error adding resource type "%s": %s') % (res_type, str(e)))
log.exception('Error validating %s resource "%r"' % (res_type, dummy_form))
if not resObj:
@@ -865,6 +863,6 @@ def validate_resource_form(model, **kw):
res = create_resource(res_type, model, **kw)
model.getResourcesPtr().addChild(res)
except Exception, e:
- errors.append(_('Error adding resource type %s: %s') % (res_type, str(e)))
+ errors.append(_('Error adding resource type "%s": %s') % (res_type, str(e)))
return (False, {'errors': errors})
return (True, {})
12 years, 2 months
[luci] Fix a typo in the previous patch
by Ryan McCabe
commit c0795ce2b20905e9d5c1599539dc603a55aabc7f
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Feb 23 18:03:22 2012 -0500
Fix a typo in the previous patch
luci/lib/ClusterConf/ModelBuilder.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/luci/lib/ClusterConf/ModelBuilder.py b/luci/lib/ClusterConf/ModelBuilder.py
index a4ecaee..92d1197 100644
--- a/luci/lib/ClusterConf/ModelBuilder.py
+++ b/luci/lib/ClusterConf/ModelBuilder.py
@@ -341,9 +341,9 @@ class ModelBuilder:
##entities after the object tree is built.
def resolve_references(self):
reset_list_sentinel = True
- while(reset_list_sentinel is True):
+ while reset_list_sentinel is True:
reset_list_sentinel = False
- resource_children = self.getResources()
+ resource_children = self.resourcemanager_ptr.getChildren()
for r_child in resource_children:
if r_child.getTagName() == Service.TAG_NAME:
reset_list_sentinel = self.find_references(r_child)
12 years, 2 months
[luci] Fix 3 more places where an invalid cluster.conf could cause luci to fail ungracefully
by Ryan McCabe
commit c0be8008c4162e18ac1111fb6cb7a669f065bff9
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Thu Feb 23 15:16:41 2012 -0500
Fix 3 more places where an invalid cluster.conf could
cause luci to fail ungracefully
luci/lib/ClusterConf/BaseResource.py | 13 ++++++++++---
luci/lib/ClusterConf/FailoverDomain.py | 6 +++---
luci/lib/ClusterConf/ModelBuilder.py | 30 +++++++++++++++++++++---------
luci/lib/ClusterConf/QuorumD.py | 12 ++++++++++--
luci/lib/ClusterConf/Service.py | 10 +++++++++-
luci/templates/configure.html | 2 +-
luci/templates/resource_list.html | 4 ++--
luci/templates/service.html | 2 +-
8 files changed, 57 insertions(+), 22 deletions(-)
---
diff --git a/luci/lib/ClusterConf/BaseResource.py b/luci/lib/ClusterConf/BaseResource.py
index da20500..75aca05 100644
--- a/luci/lib/ClusterConf/BaseResource.py
+++ b/luci/lib/ClusterConf/BaseResource.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011 Red Hat, Inc.
+# Copyright (C) 2006-2012 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
@@ -17,11 +17,11 @@ class BaseResource(TagObject):
self.deny_all_children = False
self.refcount = 1
self.reflist = []
-
+
def ref(self):
self.refcount += 1
return self.refcount
-
+
def unref(self):
self.refcount -= 1
return self.refcount
@@ -115,6 +115,13 @@ class BaseResource(TagObject):
def delResRestartExpireTime(self):
return self.removeAttribute('__restart_expire_time')
+ def getChildResources(self):
+ ret = []
+ for i in self.getChildren():
+ if issubclass(type(i), BaseResource):
+ ret.append(i)
+ return ret
+
def delSubtreeProperties(self):
self.delIndependentSubtree()
self.delEnforceTimeouts()
diff --git a/luci/lib/ClusterConf/FailoverDomain.py b/luci/lib/ClusterConf/FailoverDomain.py
index 63de7f1..e62439c 100644
--- a/luci/lib/ClusterConf/FailoverDomain.py
+++ b/luci/lib/ClusterConf/FailoverDomain.py
@@ -75,9 +75,9 @@ class FailoverDomain(TagObject):
self.children = list()
def removeDefaults(self):
- if self.getRestricted() == self.DEFAULTS.get('restricted'):
+ if self.getRestricted() == int(self.DEFAULTS.get('restricted')):
self.delRestricted()
- if self.getOrdered() == self.DEFAULTS.get('ordered'):
+ if self.getOrdered() == int(self.DEFAULTS.get('ordered')):
self.delOrdered()
- if self.getNoFailback() == self.DEFAULTS.get('nofailback'):
+ if self.getNoFailback() == int(self.DEFAULTS.get('nofailback')):
self.delNoFailback()
diff --git a/luci/lib/ClusterConf/ModelBuilder.py b/luci/lib/ClusterConf/ModelBuilder.py
index 41e605a..a4ecaee 100644
--- a/luci/lib/ClusterConf/ModelBuilder.py
+++ b/luci/lib/ClusterConf/ModelBuilder.py
@@ -8,6 +8,7 @@
from xml.dom import minidom, Node
from TagObject import TagObject
from RefObject import RefObject
+from BaseResource import BaseResource
import Cluster
@@ -342,7 +343,7 @@ class ModelBuilder:
reset_list_sentinel = True
while(reset_list_sentinel is True):
reset_list_sentinel = False
- resource_children = self.resourcemanager_ptr.getChildren()
+ resource_children = self.getResources()
for r_child in resource_children:
if r_child.getTagName() == Service.TAG_NAME:
reset_list_sentinel = self.find_references(r_child)
@@ -364,7 +365,7 @@ class ModelBuilder:
result = False
#This entity has a "ref" attr...need to walk through resources list
#and look for a match
- recs = self.resources_ptr.getChildren()
+ recs = self.getResources()
for rec in recs:
if rec.getTagName() == entity.getTagName():
if entity.getTagName() == "ip":
@@ -822,8 +823,7 @@ class ModelBuilder:
def getServices(self):
rg_list = list()
if self.resourcemanager_ptr is not None:
- kids = self.resourcemanager_ptr.getChildren()
- for kid in kids:
+ for kid in self.resourcemanager_ptr.getChildren():
if kid.getTagName() in (Service.TAG_NAME, Vm.TAG_NAME):
rg_list.append(kid)
@@ -862,10 +862,22 @@ class ModelBuilder:
break
def getResources(self):
+ ret = []
if self.resources_ptr is not None:
- return self.resources_ptr.getChildren()
- else:
- return list()
+ for i in self.resources_ptr.getChildren():
+ if issubclass(type(i), BaseResource):
+ ret.append(i)
+ else:
+ self.errors = True
+ try:
+ if not i.errors:
+ i.errors = True
+ cur_msg = 'Expecting a resource element, got %s' % i.getTagName()
+ self.errmsg.append(cur_msg)
+ log.error("Error parsing cluster.conf XML: %s" % cur_msg)
+ except:
+ pass
+ return ret
def getResourcesPtr(self):
return self.resources_ptr
@@ -929,7 +941,7 @@ class ModelBuilder:
return gobj
def getResourceByName(self, name):
- resources = self.resources_ptr.getChildren()
+ resources = self.getResources()
res = filter(lambda x: x.getName() == name, resources)
if not res or len(res) < 1:
raise KeyError, name
@@ -938,7 +950,7 @@ class ModelBuilder:
return res[0]
def deleteResource(self, name):
- for i in self.resources_ptr.getChildren():
+ for i in self.getResources():
if i.getName() == name:
self.resources_ptr.removeChild(i)
return i
diff --git a/luci/lib/ClusterConf/QuorumD.py b/luci/lib/ClusterConf/QuorumD.py
index 0fa744d..bb5eabc 100644
--- a/luci/lib/ClusterConf/QuorumD.py
+++ b/luci/lib/ClusterConf/QuorumD.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011 Red Hat, Inc.
+# Copyright (C) 2006-2012 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
@@ -6,6 +6,7 @@
# Free Software Foundation.
from TagObject import TagObject
+from Heuristic import Heuristic
TAG_NAME = "quorumd"
@@ -214,8 +215,15 @@ class QuorumD(TagObject):
def delUseUptime(self):
return self.removeAttribute('use_uptime')
+ def getHeuristics(self):
+ ret = []
+ for i in self.getChildren():
+ if type(i) == Heuristic:
+ ret.append(i)
+ return ret
+
def getHeuristicsLen(self):
- return len(self.children)
+ return len(self.getHeuristics())
def removeDefaults(self):
if self.getReboot() == int(self.DEFAULTS.get('reboot')):
diff --git a/luci/lib/ClusterConf/Service.py b/luci/lib/ClusterConf/Service.py
index 698368b..a10f0e1 100644
--- a/luci/lib/ClusterConf/Service.py
+++ b/luci/lib/ClusterConf/Service.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Red Hat, Inc.
+# Copyright (C) 2006-2012 Red Hat, Inc.
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of version 2 of the
@@ -6,6 +6,7 @@
# Free Software Foundation.
from TagObject import TagObject
+from BaseResource import BaseResource
TAG_NAME = "service"
@@ -127,6 +128,13 @@ class Service(TagObject):
def delDepend(self):
return self.removeAttribute('depend')
+ def getChildResources(self):
+ ret = []
+ for i in self.getChildren():
+ if issubclass(type(i), BaseResource):
+ ret.append(i)
+ return ret
+
def removeDefaults(self):
if self.getAutostart() == int(self.DEFAULTS.get('autostart')):
self.delAutostart()
diff --git a/luci/templates/configure.html b/luci/templates/configure.html
index 85412b8..d6a83d3 100644
--- a/luci/templates/configure.html
+++ b/luci/templates/configure.html
@@ -317,7 +317,7 @@
</tr>
</py:when>
<py:otherwise>
- <tr py:for="(hnum, hobj) in enumerate(quorumd_ptr.getChildren())"
+ <tr py:for="(hnum, hobj) in enumerate(quorumd_ptr.getHeuristics())"
class="qdisk_heuristic" id="qdisk_heuristic${hnum}">
<td>
<input type="text" class="text" name="heuristic${hnum}:hprog"
diff --git a/luci/templates/resource_list.html b/luci/templates/resource_list.html
index 64137e1..b8aa938 100644
--- a/luci/templates/resource_list.html
+++ b/luci/templates/resource_list.html
@@ -1981,8 +1981,8 @@ ${condor_schedd_resource(None,None,None,0)}
onclick="${'insert_resource_dialog(this.form, \'children_%s\', \'%s\')' % (cur_id_str, cur_id_str)}"/>
</div>
<div class="reschild" id="${'children_%s' % cur_id_str}">
- <py:if test="cur_res.getChildren()">
- ${print_svc_children(model, cur_res.getChildren(), cur_id_str)}
+ <py:if test="cur_res.getChildResources()">
+ ${print_svc_children(model, cur_res.getChildResources(), cur_id_str)}
</py:if>
</div>
</div>
diff --git a/luci/templates/service.html b/luci/templates/service.html
index a864505..bf623bb 100644
--- a/luci/templates/service.html
+++ b/luci/templates/service.html
@@ -220,7 +220,7 @@
${print_svc_children(cluster_data, [ svc ], 'esvc_root')}
</py:when>
<py:otherwise>
- ${print_svc_children(cluster_data, svc.getChildren(), 'esvc_root')}
+ ${print_svc_children(cluster_data, svc.getChildResources(), 'esvc_root')}
</py:otherwise>
</py:choose>
</div>
12 years, 2 months
[luci] Fix to account for different return values for getEffectiveLevel() from different versions of the py
by Ryan McCabe
commit 60e6324d6ca888fba71ba3d390b55c05f0231afa
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Fri Feb 17 13:11:13 2012 -0500
Fix to account for different return values for getEffectiveLevel()
from different versions of the python logging module
luci/templates/admin.html | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/luci/templates/admin.html b/luci/templates/admin.html
index 10a0d39..f82ee34 100644
--- a/luci/templates/admin.html
+++ b/luci/templates/admin.html
@@ -190,11 +190,11 @@
<select name="log_level_tg.i18n"
py:with="cur_level=logging.getLogger('tg.i18n').getEffectiveLevel()">
<option value="0" py:attrs="not cur_level and {'selected':'selected'} or None">unset</option>
- <option value="DEBUG" py:attrs="cur_level==10 and {'selected':'selected'} or None">debug</option>
- <option value="INFO" py:attrs="cur_level==20 and {'selected':'selected'} or None">info</option>
- <option value="WARNING" py:attrs="cur_level==30 and {'selected':'selected'} or None">warning</option>
- <option value="ERROR" py:attrs="cur_level==40 and {'selected':'selected'} or None">error</option>
- <option value="CRITICAL" py:attrs="cur_level==50 and {'selected':'selected'} or None">critical</option>
+ <option value="DEBUG" py:attrs="cur_level in (10, 'DEBUG') and {'selected':'selected'} or None">debug</option>
+ <option value="INFO" py:attrs="cur_level in (20, 'INFO') and {'selected':'selected'} or None">info</option>
+ <option value="WARNING" py:attrs="cur_level in (30, 'WARNING', 'WARN') and {'selected':'selected'} or None">warning</option>
+ <option value="ERROR" py:attrs="cur_level in (40, 'ERROR') and {'selected':'selected'} or None">error</option>
+ <option value="CRITICAL" py:attrs="cur_level in (50, 'CRITICAL') and {'selected':'selected'} or None">critical</option>
</select>
</td>
</tr>
@@ -204,11 +204,11 @@
<select name="log_level_sqlalchemy"
py:with="cur_level=logging.getLogger('sqlalchemy').getEffectiveLevel()">
<option value="0" py:attrs="not cur_level and {'selected':'selected'} or None">unset</option>
- <option value="DEBUG" py:attrs="cur_level==10 and {'selected':'selected'} or None">debug</option>
- <option value="INFO" py:attrs="cur_level==20 and {'selected':'selected'} or None">info</option>
- <option value="WARNING" py:attrs="cur_level==30 and {'selected':'selected'} or None">warning</option>
- <option value="ERROR" py:attrs="cur_level==40 and {'selected':'selected'} or None">error</option>
- <option value="CRITICAL" py:attrs="cur_level==50 and {'selected':'selected'} or None">critical</option>
+ <option value="DEBUG" py:attrs="cur_level in (10, 'DEBUG') and {'selected':'selected'} or None">debug</option>
+ <option value="INFO" py:attrs="cur_level in (20, 'INFO') and {'selected':'selected'} or None">info</option>
+ <option value="WARNING" py:attrs="cur_level in (30, 'WARNING', 'WARN') and {'selected':'selected'} or None">warning</option>
+ <option value="ERROR" py:attrs="cur_level in (40, 'ERROR') and {'selected':'selected'} or None">error</option>
+ <option value="CRITICAL" py:attrs="cur_level in (50, 'CRITICAL') and {'selected':'selected'} or None">critical</option>
</select>
</td>
</tr>
@@ -218,11 +218,11 @@
<select name="log_level_luci"
py:with="cur_level=logging.getLogger('luci').getEffectiveLevel()">
<option value="0" py:attrs="not cur_level and {'selected':'selected'} or None">unset</option>
- <option value="DEBUG" py:attrs="cur_level==10 and {'selected':'selected'} or None">debug</option>
- <option value="INFO" py:attrs="cur_level==20 and {'selected':'selected'} or None">info</option>
- <option value="WARNING" py:attrs="cur_level==30 and {'selected':'selected'} or None">warning</option>
- <option value="ERROR" py:attrs="cur_level==40 and {'selected':'selected'} or None">error</option>
- <option value="CRITICAL" py:attrs="cur_level==50 and {'selected':'selected'} or None">critical</option>
+ <option value="DEBUG" py:attrs="cur_level in (10, 'DEBUG') and {'selected':'selected'} or None">debug</option>
+ <option value="INFO" py:attrs="cur_level in (20, 'INFO') and {'selected':'selected'} or None">info</option>
+ <option value="WARNING" py:attrs="cur_level in (30, 'WARNING', 'WARN') and {'selected':'selected'} or None">warning</option>
+ <option value="ERROR" py:attrs="cur_level in (40, 'ERROR') and {'selected':'selected'} or None">error</option>
+ <option value="CRITICAL" py:attrs="cur_level in (50, 'CRITICAL') and {'selected':'selected'} or None">critical</option>
</select>
</td>
</tr>
@@ -232,11 +232,11 @@
<select name="log_level_root"
py:with="cur_level=logging.getLogger('').getEffectiveLevel()">
<option value="0" py:attrs="not cur_level and {'selected':'selected'} or None">unset</option>
- <option value="DEBUG" py:attrs="cur_level==10 and {'selected':'selected'} or None">debug</option>
- <option value="INFO" py:attrs="cur_level==20 and {'selected':'selected'} or None">info</option>
- <option value="WARNING" py:attrs="cur_level==30 and {'selected':'selected'} or None">warning</option>
- <option value="ERROR" py:attrs="cur_level==40 and {'selected':'selected'} or None">error</option>
- <option value="CRITICAL" py:attrs="cur_level==50 and {'selected':'selected'} or None">critical</option>
+ <option value="DEBUG" py:attrs="cur_level in (10, 'DEBUG') and {'selected':'selected'} or None">debug</option>
+ <option value="INFO" py:attrs="cur_level in (20, 'INFO') and {'selected':'selected'} or None">info</option>
+ <option value="WARNING" py:attrs="cur_level in (30, 'WARNING', 'WARN') and {'selected':'selected'} or None">warning</option>
+ <option value="ERROR" py:attrs="cur_level in (40, 'ERROR') and {'selected':'selected'} or None">error</option>
+ <option value="CRITICAL" py:attrs="cur_level in (50, 'CRITICAL') and {'selected':'selected'} or None">critical</option>
</select>
</td>
</tr>
12 years, 2 months
[luci] Add support for the condor_schedd resource agent
by Ryan McCabe
commit b8fbd8a9940eadf1e96ccbf40f4461d9721c5cc4
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Wed Feb 8 14:38:13 2012 -0500
Add support for the condor_schedd resource agent
luci/lib/ClusterConf/CondorSchedd.py | 18 ++++++++++++++++++
luci/lib/ClusterConf/ModelBuilder.py | 3 ++-
luci/templates/resource_list.html | 27 +++++++++++++++++++++++++++
luci/validation/validate_resource.py | 7 +++++++
4 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/luci/lib/ClusterConf/CondorSchedd.py b/luci/lib/ClusterConf/CondorSchedd.py
new file mode 100644
index 0000000..718c8d4
--- /dev/null
+++ b/luci/lib/ClusterConf/CondorSchedd.py
@@ -0,0 +1,18 @@
+# Copyright (C) 2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of version 2 of the
+# GNU General Public License as published by the
+# Free Software Foundation.
+
+from BaseResource import BaseResource
+from gettext import gettext as _
+
+TAG_NAME = 'condor_schedd'
+RESOURCE_TYPE = _('condor_schedd Instance')
+
+class CondorSchedd(BaseResource):
+ def __init__(self):
+ BaseResource.__init__(self)
+ self.TAG_NAME = TAG_NAME
+ self.resource_type = RESOURCE_TYPE
diff --git a/luci/lib/ClusterConf/ModelBuilder.py b/luci/lib/ClusterConf/ModelBuilder.py
index 9f8a939..41e605a 100644
--- a/luci/lib/ClusterConf/ModelBuilder.py
+++ b/luci/lib/ClusterConf/ModelBuilder.py
@@ -62,7 +62,7 @@ import Event
# Children of <resources> and <service>
import Ip, Script, NFSClient, NFSExport, NFSServer, Fs, Samba, Smb, Apache, Named, \
- DRBD, LVM, MySQL, OpenLDAP, Postgres8, Tomcat5, Tomcat6, \
+ CondorSchedd, DRBD, LVM, MySQL, OpenLDAP, Postgres8, Tomcat5, Tomcat6, \
SAPDatabase, SAPInstance, SybaseASE, Netfs, Clusterfs, \
OracleDB, OracleListener, OracleInstance
@@ -112,6 +112,7 @@ TAGNAMES = {
Smb.TAG_NAME: Smb.Smb,
Apache.TAG_NAME: Apache.Apache,
Named.TAG_NAME: Named.Named,
+ CondorSchedd.TAG_NAME: CondorSchedd.CondorSchedd,
DRBD.TAG_NAME: DRBD.DRBD,
LVM.TAG_NAME: LVM.LVM,
MySQL.TAG_NAME: MySQL.MySQL,
diff --git a/luci/templates/resource_list.html b/luci/templates/resource_list.html
index 9cb0828..64137e1 100644
--- a/luci/templates/resource_list.html
+++ b/luci/templates/resource_list.html
@@ -1604,6 +1604,29 @@
</table>
</div>
+<div py:def="condor_schedd_resource(res, form_id, parent_id, isref)" name="CONDOR_SCHEDD" id="condor_schedd_resource" class="row rescfg"
+ py:with="global_resource = res and isref != 0"
+ py:attrs="res and {'id': 'global_res_%s' % res.getName(), 'name': res.getName()}">
+ <input name="global" type="hidden" value="1" py:if="global_resource"/>
+ <input name="parent_id" type="hidden" value="${parent_id}"/>
+ <input name="form_id" type="hidden" value="${form_id}"/>
+ <input name="oldname" type="hidden"
+ py:attrs="res and {'value':res.getAttribute('name')} or {}" />
+ <input name="type" type="hidden" value="condor_schedd" />
+
+ <h3>condor_schedd Instance</h3>
+ <table class="formtable">
+ <tr>
+ <td>Name of the condor_schedd Instance to Control</td>
+ <td>
+ <input type="text" class="text" name="resourcename"
+ py:attrs="res and {'value':res.getAttribute('name'), 'disabled':global_resource and 'disabled' or None} or {}" />
+ </td>
+ </tr>
+ ${res_footer(res)}
+ </table>
+</div>
+
<div py:def="vm_resource(res, form_id, parent_id, isref)" name="VM" id="vm_resource" class="row rescfg"
py:with="global_resource = res and isref != 0"
py:attrs="res and {'id': 'global_res_%s' % res.getName(), 'name': res.getName()}">
@@ -1707,6 +1730,7 @@ ${oralistener_resource(None,None,None,0)}
${named_resource(None,None,None,0)}
${drbd_resource(None,None,None,0)}
${vm_resource(None,None,None,0)}
+${condor_schedd_resource(None,None,None,0)}
<py:if test="model">
<py:for each="res in model.getResources()">
@@ -1725,6 +1749,7 @@ ${vm_resource(None,None,None,0)}
svc_onchange_fn = 'insert_resource(this.options[this.selectedIndex].value, \'%s\', this.form, \'%s\')' % (dest, parentid);
res_onchange_fn = 'swap_resource_form(this.options[this.selectedIndex].value)';
cluster_version = tmpl_context.cluster.get_version();
+ os_version = tmpl_context.cluster.get_OSVersion();
cluster_os = tmpl_context.cluster.get_OS()"
py:attrs="{'onchange': model and svc_onchange_fn or res_onchange_fn, 'id': parentid and '%s_resource_selector' % parentid or 'resource_selector'}">
<py:if test="model" py:with="global_res = model.getResources()">
@@ -1741,6 +1766,8 @@ ${vm_resource(None,None,None,0)}
<option selected="selected" disabled="disabled">-- Select a Resource Type --</option>
<option name="apache_resource" value="apache_resource">Apache</option>
<py:if test="cluster_version >= 3">
+ <option py:if="cluster_os != 'RHEL' or os_version > 6.2"
+ name="condor_schedd" value="condor_schedd_resource">condor_schedd Instance</option>
<option name="drbd_resource" value="drbd_resource">DRBD Resource</option>
</py:if>
<option name="fs_resource" value="fs_resource">Filesystem</option>
diff --git a/luci/validation/validate_resource.py b/luci/validation/validate_resource.py
index ca092b5..7f546b6 100644
--- a/luci/validation/validate_resource.py
+++ b/luci/validation/validate_resource.py
@@ -23,6 +23,7 @@ from luci.lib.ClusterConf.Apache import Apache
from luci.lib.ClusterConf.OpenLDAP import OpenLDAP
from luci.lib.ClusterConf.LVM import LVM
from luci.lib.ClusterConf.MySQL import MySQL
+from luci.lib.ClusterConf.CondorSchedd import CondorSchedd
from luci.lib.ClusterConf.DRBD import DRBD
from luci.lib.ClusterConf.Vm import Vm
from luci.lib.ClusterConf.Named import Named
@@ -444,6 +445,11 @@ def addDRBD(res, rname, model, **kw):
errors = config_resource(params, res, rname, **kw)
return errors
+def addCondorSchedd(res, rname, model, **kw):
+ params = ()
+ errors = config_resource(params, res, rname, **kw)
+ return errors
+
resource_table = {
'ip': ( addIp, Ip ),
'fs': ( addFs, Fs ),
@@ -470,6 +476,7 @@ resource_table = {
'ASEHAagent': ( addSybaseASE, SybaseASE ),
'named': ( addNamed, Named ),
'drbd': ( addDRBD, DRBD ),
+ 'condor_schedd': ( addCondorSchedd, CondorSchedd ),
'vm': ( addVM, Vm ),
}
12 years, 2 months