svn keywords
[plcapi.git] / PLC / Methods / AddInterface.py
index cd3911a..8c6d4cb 100644 (file)
@@ -1,4 +1,5 @@
 # $Id$
+# $URL$
 from PLC.Faults import *
 from PLC.Auth import Auth
 from PLC.Method import Method
@@ -12,30 +13,29 @@ from PLC.InterfaceTags import InterfaceTags
 from PLC.Methods.AddInterfaceTag import AddInterfaceTag
 from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
 
-can_update = ['interface_id', 'node_id']
+cannot_update = ['interface_id', 'node_id']
 
 class AddInterface(Method):
     """
 
     Adds a new network for a node. Any values specified in
     interface_fields are used, otherwise defaults are
-    used. Acceptable values for method may be retrieved via
-    GetNetworkMethods. Acceptable values for type may be retrieved via
-    GetNetworkTypes.
+    used. 
 
-    If type is static, ip, gateway, network, broadcast, netmask, and
-    dns1 must all be specified in interface_fields. If type is dhcp,
-    these parameters, even if specified, are ignored.
+    If type is static, then ip, gateway, network, broadcast, netmask,
+    and dns1 must all be specified in interface_fields. If type is
+    dhcp, these parameters, even if specified, are ignored.
 
-    PIs and techs may only add networks to their own nodes. Admins may
-    add networks to any node.
+    PIs and techs may only add interfaces to their own nodes. Admins may
+    add interfaces to any node.
 
     Returns the new interface_id (> 0) if successful, faults otherwise.
     """
 
     roles = ['admin', 'pi', 'tech']
 
-    accepted_fields = Row.accepted_fields(can_update, [Interface.fields,Interface.tags])
+    accepted_fields = Row.accepted_fields(cannot_update, Interface.fields, exclude=True)
+    accepted_fields.update(Interface.tags)
 
     accepts = [
         Auth(),
@@ -50,6 +50,9 @@ class AddInterface(Method):
     def call(self, auth, node_id_or_hostname, interface_fields):
 
         [native,tags,rejected]=Row.split_fields(interface_fields,[Interface.fields,Interface.tags])
+
+        # type checking
+        native = Row.check_fields (native, self.accepted_fields)
         if rejected:
             raise PLCInvalidArgument, "Cannot add Interface with column(s) %r"%rejected