[Uludag-commits] r15077 - trunk/comar/ahenk/ajan/ajan
uludag-commits at pardus.org.tr
uludag-commits at pardus.org.tr
22 Ağu 2007 Çar 09:37:39 EEST
Author: selda.kuruoglu
Date: Wed Aug 22 09:37:38 2007
New Revision: 15077
Modified:
trunk/comar/ahenk/ajan/ajan/ldaputil.py
trunk/comar/ahenk/ajan/ajan/mod_service.py
Log:
servis betiği düzeltmeleri
Modified: trunk/comar/ahenk/ajan/ajan/ldaputil.py
=================================================================
--- trunk/comar/ahenk/ajan/ajan/ldaputil.py (original)
+++ trunk/comar/ahenk/ajan/ajan/ldaputil.py Wed Aug 22 09:37:38 2007
@@ -34,6 +34,8 @@
val = int(value[0])
elif valuetype == str:
val = unicode(value[0])
+ elif valuetype == set:
+ val = set(value)
else:
val = value
else:
@@ -54,6 +56,8 @@
val = [str(val)]
elif item[2] == str:
val = [val]
+ elif item[2] == set:
+ val = list(val)
attr[item[1]] = val
return attr
Modified: trunk/comar/ahenk/ajan/ajan/mod_service.py
=================================================================
--- trunk/comar/ahenk/ajan/ajan/mod_service.py (original)
+++ trunk/comar/ahenk/ajan/ajan/mod_service.py Wed Aug 22 09:37:38 2007
@@ -1,37 +1,46 @@
-#G.Selda Kuruoglu
+ #G.Selda Kuruoglu
-import comar
-import logging
-
-
-import ajan.ldaputil
+import comar # for 'comar's connection functions
+import logging # for log messages
+import ajan.ldaputil
class ServicePolicy(ajan.ldaputil.LdapClass):
-
- """ Service policy class has attributes : service names to start, service names to stop """
-
+ """ Service policy class has 2 attributes : service names to start, service names to stop """
entries = (
- ("service_to_start", "comarServiceStart", list, None),
- ("service_to_stop", "comarServiceStop", list, None),
- )
+ ("service_to_start", "comarServiceStart", set, set()),
+ ("service_to_stop", "comarServiceStop", set, set()),
+ )
class Policy:
-
- def __init__( self ):
+ def __init__(self):
self.policy = ServicePolicy()
self.log = logging.getLogger("Mod.Service")
-
- def override(self, attr, is_ou=False):
+ def override(self, attr, is_ou = False):
+ """ Overrides service policy"""
temp = ServicePolicy(attr)
- self.policy.service_to_start = temp.service_to_start
- self.policy.service_to_stop = temp.service_to_stop
-
+
+ # Retrieve current service policy
+ start_set = temp.service_to_start
+ stop_set = temp.service_to_stop
+
+ if is_ou:
+ start_set.union (self.policy.service_to_start)
+ stop_set.union (self.policy.service_to_stop)
+
+ else:
+ start_set = start_set.union (self.policy.service_to_start)
+ start_set = start_set.difference (stop_set)
+
+ stop_set = stop_set.union (self.policy.service_to_stop)
+ stop_set = stop_set.difference (start_set)
+
+ self.policy.service_to_start = start_set
+ self.policy.service_to_stop = stop_set
+
def update(self, computer, units ):
-
- """ Updates """
-
+ """ Updates service policy"""
self.log.debug("Updating Service Policy")
self.policy = ServicePolicy()
for unit in units:
@@ -40,24 +49,19 @@
self.log.debug("Service policy is now:\n%s" % str(self.policy))
- def start_service ( self ):
-
- """ starts sevices in 'service_to_start' list by connecting comar """
-
- link = comar.Link()
- for service in self.policy.service_to_start:
- link.System.Service[ service ].start()
-
- def stop_service ( self ):
-
- """ stops sevices in 'service_to_start' list by connecting comar """
-
- link = comar.Link()
+ def start_service (self):
+ """ starts sevices in 'service_to_start' list by connecting comar """
+ link = comar.Link()
+ for service in self.policy.service_to_start:
+ link.System.Service[service].start()
+
+ def stop_service (self):
+ """ stops sevices in 'service_to_start' list by connecting comar """
+ link = comar.Link()
for service in self.policy.service_to_stop:
- link.System.Service[service].stop()
-
+ link.System.Service[service].stop()
+
def apply(self):
self.log.debug("Applying Service Policy" )
self.start_service()
self.stop_service()
-
Uludag-commits mesaj listesiyle ilgili
daha fazla bilgi