AddNode/UpdateNode/GetNodes should no be 100% tag-friendly
[plcapi.git] / PLC / Methods / DeleteSite.py
index d16946d..381bdf3 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
@@ -5,7 +6,7 @@ from PLC.Sites import Site, Sites
 from PLC.Persons import Person, Persons
 from PLC.Nodes import Node, Nodes
 from PLC.PCUs import PCU, PCUs
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
 
 class DeleteSite(Method):
     """
@@ -20,7 +21,7 @@ class DeleteSite(Method):
     roles = ['admin']
 
     accepts = [
-        PasswordAuth(),
+        Auth(),
         Mixed(Site.fields['site_id'],
               Site.fields['login_base'])
         ]
@@ -32,8 +33,15 @@ class DeleteSite(Method):
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
+        site = sites[0]
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
-        site = sites.values()[0]
         site.delete()
+       
+       # Logging variables
+       self.event_objects = {'Site': [site['site_id']]}
+       self.message = 'Site %d deleted' % site['site_id']      
 
         return 1