====
[plcapi.git] / PLC / Methods / GetSlivers.py
index 1f4bc12..9e3b73d 100644 (file)
@@ -23,11 +23,6 @@ from PLC.PersonTags import PersonTag,PersonTags
 
 from PLC.Accessors.Accessors_standard import *
 
-# Caching
-import os
-os.environ['DJANGO_SETTINGS_MODULE']='plc_django_settings'
-from cache_utils.decorators import cached
-
 # XXX used to check if slice expiration time is sane
 MAXINT =  2L**31-1
 
@@ -96,11 +91,12 @@ def get_slivers(api, caller, auth, slice_filter, node = None):
                 # Do not set any nodegroup slice attributes for
                 # which there is at least one sliver attribute
                 # already set.
-                if slice_tag not in slice_tags:
+                if slice_tag['tagname'] not in sliver_attributes:
+                    sliver_attributes.append(slice_tag['tagname'])
                     attributes.append({'tagname': slice_tag['tagname'],
-                                   'value': slice_tag['value']})
+                                       'value': slice_tag['value']})
 
-        for slice_tag in [ a for a in slice_tags if a['node_id'] is None ]:
+        for slice_tag in [ a for a in slice_tags if a['node_id'] is None and a['nodegroup_id'] is None ]:
             # Do not set any global slice attributes for
             # which there is at least one sliver attribute
             # already set.
@@ -211,20 +207,9 @@ class GetSlivers(Method):
     }
 
     def call(self, auth, node_id_or_hostname = None):
-        try:
-            cache_opt = self.api.config.PLC_GETSLIVERS_CACHE
-        with AttributeError:
-            cache_opt = False
-
-        if (cache_opt):
-            return self.cacheable_call(auth, node_id_or_hostname)
-        else:
-            return self.raw_call(auth, node_id_or_hostname)
-
-    @cached(7200)
-    def cacheable_call(self, auth, node_id_or_hostname):
         return self.raw_call(auth, node_id_or_hostname)
 
+
     def raw_call(self, auth, node_id_or_hostname):
         timestamp = int(time.time())
 
@@ -356,13 +341,10 @@ class GetSlivers(Method):
         # XMPP config for omf federation
         try:
             if not self.api.config.PLC_OMF_ENABLED:
-                raise Exception,"OMF disabled"
-            xmpp={'server':self.api.config.PLC_OMF_XMPP_SERVER,
-                  'user':self.api.config.PLC_OMF_XMPP_USER,
-                  'password':self.api.config.PLC_OMF_XMPP_PASSWORD,
-                  }
+                raise Exception,"OMF not enabled"
+            xmpp={'server':self.api.config.PLC_OMF_XMPP_SERVER}
         except:
-            xmpp={'server':None,'user':None,'password':None}
+            xmpp={'server':None}
 
         node.update_last_contact()