- added class variables: event_type, object_type, object_ids (used by event logger)
authorTony Mack <tmack@cs.princeton.edu>
Fri, 20 Oct 2006 18:42:55 +0000 (18:42 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Fri, 20 Oct 2006 18:42:55 +0000 (18:42 +0000)
24 files changed:
PLC/Methods/AddAddressType.py
PLC/Methods/AddAddressTypeToAddress.py
PLC/Methods/AddBootState.py
PLC/Methods/AddKeyType.py
PLC/Methods/AddNetworkMethod.py
PLC/Methods/AddNetworkType.py
PLC/Methods/AddNode.py
PLC/Methods/AddNodeGroup.py
PLC/Methods/AddNodeNetwork.py
PLC/Methods/AddNodeToNodeGroup.py
PLC/Methods/AddNodeToPCU.py
PLC/Methods/AddPCU.py
PLC/Methods/AddPerson.py
PLC/Methods/AddPersonKey.py
PLC/Methods/AddPersonToSite.py
PLC/Methods/AddPersonToSlice.py
PLC/Methods/AddRole.py
PLC/Methods/AddRoleToPerson.py
PLC/Methods/AddSite.py
PLC/Methods/AddSiteAddress.py
PLC/Methods/AddSlice.py
PLC/Methods/AddSliceAttribute.py
PLC/Methods/AddSliceAttributeType.py
PLC/Methods/AddSliceToNodes.py

index d55aa4d..075fca2 100644 (file)
@@ -25,11 +25,16 @@ class AddAddressType(Method):
         ]
 
     returns = Parameter(int, 'New address_type_id (> 0) if successful')
+        
+    event_type = 'Add'    
+    object_type = 'AddressType'
+    object_ids = []
 
     def call(self, auth, name, address_type_fields = {}):
         address_type_fields = dict(filter(can_update, address_type_fields.items()))
         address_type = AddressType(self.api, address_type_fields)
         address_type['name'] = name
         address_type.sync()
-
-        return address_type['address_type_id']
+       self.object_ids = [address_type['address_type_id']]
+        
+       return address_type['address_type_id']
index 64f532a..1a20e0e 100644 (file)
@@ -25,8 +25,12 @@ class AddAddressTypeToAddress(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'AddTo'
+    object_type = 'Address'
+    object_ids = []
+
     def call(self, auth, address_type_id_or_name, address_id):
-        address_types = AddressTypes(self.api, [address_type_id_or_name]).values()
+       address_types = AddressTypes(self.api, [address_type_id_or_name]).values()
         if not address_types:
             raise PLCInvalidArgument, "No such address type"
         address_type = address_types[0]
@@ -41,5 +45,6 @@ class AddAddressTypeToAddress(Method):
                 raise PLCPermissionDenied, "Address must be associated with one of your sites"
 
         address.add_address_type(address_type)
+       self.object_ids = [address['address_id']]
 
         return 1
index 2ecd90b..ba39b66 100644 (file)
@@ -20,6 +20,10 @@ class AddBootState(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'Add'
+    object_type = 'BootState'
+    object_ids = []
+    
     def call(self, auth, name):
         boot_state = BootState(self.api)
         boot_state['boot_state'] = name
index 86c2bc9..914323c 100644 (file)
@@ -20,6 +20,9 @@ class AddKeyType(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'Add'
+    object_type = 'KeyType'
+
     def call(self, auth, name):
         key_type = KeyType(self.api)
         key_type['key_type'] = name
index c207e1d..d243ae3 100644 (file)
@@ -20,6 +20,9 @@ class AddNetworkMethod(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'Add'
+    object_type = 'NetworkMethod'
+
     def call(self, auth, name):
         network_method = NetworkMethod(self.api)
         network_method['method'] = name
index eb2e780..cd28d05 100644 (file)
@@ -20,6 +20,9 @@ class AddNetworkType(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'Add'
+    object_type = 'NetworkType'
+
     def call(self, auth, name):
         network_type = NetworkType(self.api)
         network_type['type'] = name
index 086f5e0..a61fad6 100644 (file)
@@ -34,6 +34,10 @@ class AddNode(Method):
 
     returns = Parameter(int, 'New node_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Node'
+    object_ids = []
+
     def call(self, auth, site_id_or_login_base, hostname, node_fields = {}):
         node_fields = dict(filter(can_update, node_fields.items()))
         
@@ -60,5 +64,6 @@ class AddNode(Method):
         node['hostname'] = hostname
         node['site_id'] = site['site_id']
         node.sync()
+       self.object_ids = [node['node_id']]     
 
         return node['node_id']
index fe16b81..75d4d91 100644 (file)
@@ -27,10 +27,15 @@ class AddNodeGroup(Method):
 
     returns = Parameter(int, 'New nodegroup_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'NodeGroup'
+    object_ids = []
+
     def call(self, auth, name, nodegroup_fields = {}):
         nodegroup_fields = dict(filter(can_update, nodegroup_fields.items()))
         nodegroup = NodeGroup(self.api, nodegroup_fields)
         nodegroup['name'] = name
         nodegroup.sync()
+       self.object_ids = [nodegroup['nodegroup_id']]
 
         return nodegroup['nodegroup_id']
index b8ddba6..16e3782 100644 (file)
@@ -39,6 +39,10 @@ class AddNodeNetwork(Method):
 
     returns = Parameter(int, 'New nodenetwork_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'NodeNetwork'
+    object_ids = []
+
     def call(self, auth, node_id, method, type, nodenetwork_fields = {}):
         nodenetwork_fields = dict(filter(can_update, nodenetwork_fields.items()))
 
@@ -63,5 +67,6 @@ class AddNodeNetwork(Method):
        nodenetwork['method'] = method
         nodenetwork['type'] = type
         nodenetwork.sync()
+       self.object_ids = [nodenetwork['nodenetwork_id']]       
 
         return nodenetwork['nodenetwork_id']
index 04e92be..c1e70d6 100644 (file)
@@ -25,6 +25,10 @@ class AddNodeToNodeGroup(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'AddTo'
+    object_type = 'NodeGroup'
+    object_ids = []
+
     def call(self, auth, nodegroup_id_or_name, node_id_or_hostname):
         # Get node info
        nodes = Nodes(self.api, [node_id_or_hostname])
@@ -42,5 +46,6 @@ class AddNodeToNodeGroup(Method):
        # add node to nodegroup
         if node['node_id'] not in nodegroup['node_ids']:
             nodegroup.add_node(node)
+       self.object_ids = [nodegroup['nodegroup_id']]
 
         return 1
index 6a4cd75..5378987 100644 (file)
@@ -26,6 +26,9 @@ class AddNodeToPCU(Method):
         ]
 
     returns = Parameter(int, '1 if successful')
+    event_type = 'AddTo'
+    object_type = 'PCU'
+    object_ids = []
 
     def call(self, auth, node_id_or_hostname, pcu_id, port):
         # Get node
@@ -60,5 +63,6 @@ class AddNodeToPCU(Method):
             raise PLCInvalidArgument, "PCU port already in use"
 
         pcu.add_node(node, port)
+       self.object_ids = [pcu['pcu_id']]
 
         return 1
index 3dec3ef..d311e37 100644 (file)
@@ -34,6 +34,10 @@ class AddPCU(Method):
         ]
 
     returns = Parameter(int, 'New pcu_id (> 0) if successful')
+    
+    event_type = 'Add'
+    object_type = 'PCU'
+    object_ids = []
 
     def call(self, auth, site_id_or_login_base, ip, pcu_fields = {}):
         pcu_fields = dict(filter(can_update, pcu_fields.items()))
@@ -52,5 +56,6 @@ class AddPCU(Method):
         pcu['site_id'] = site['site_id']
         pcu['ip'] = ip
         pcu.sync()
+       self.object_ids = [pcu['pcu_id']]       
 
         return pcu['pcu_id']
index d80826b..6393982 100644 (file)
@@ -31,6 +31,10 @@ class AddPerson(Method):
 
     returns = Parameter(int, 'New person_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Person'
+    object_ids = []
+
     def call(self, auth, first_name, last_name, person_fields = {}):
         person_fields = dict(filter(can_update, person_fields.items()))
         person = Person(self.api, person_fields)
@@ -38,5 +42,6 @@ class AddPerson(Method):
         person['last_name'] = last_name
         person['enabled'] = False
         person.sync()
+       self.object_ids = [person['person']]
 
         return person['person_id']
index b4ba0d3..edad2cb 100644 (file)
@@ -26,6 +26,10 @@ class AddPersonKey(Method):
 
     returns = Parameter(int, 'New key_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Key'
+    object_ids = []
+
     def call(self, auth, person_id_or_email, key_type, key_value):
         # Get account details
         persons = Persons(self.api, [person_id_or_email]).values()
@@ -43,7 +47,7 @@ class AddPersonKey(Method):
         key['key_type'] = key_type
         key['key'] = key_value
         key.sync(commit = False)
-
         person.add_key(key, commit = True)
-        
+        self.object_ids = [key['key_id']]
+
         return key['key_id']
index 71d1d67..e4719ab 100644 (file)
@@ -25,6 +25,9 @@ class AddPersonToSite(Method):
         ]
 
     returns = Parameter(int, '1 if successful')
+    event_type = 'AddTo'
+    object_type = 'Site'
+    object_ids = []
 
     def call(self, auth, person_id_or_email, site_id_or_login_base):
         # Get account information
@@ -43,5 +46,6 @@ class AddPersonToSite(Method):
 
         if site['site_id'] not in person['site_ids']:
             site.add_person(person)
-
+       self.object_ids = [site['site_id']]
+       
         return 1
index 9948af2..c60b5fd 100644 (file)
@@ -24,6 +24,9 @@ class AddPersonToSlice(Method):
         ]
 
     returns = Parameter(int, '1 if successful')
+    event_type = 'AddTo'
+    object_type = 'Slice'
+    object_ids = []
 
     def call(self, auth, person_id_or_email, slice_id_or_name):
         # Get account information
@@ -48,5 +51,6 @@ class AddPersonToSlice(Method):
 
        if slice['slice_id'] not in person['slice_ids']:
             slice.add_person(person)
+       self.object_ids = [slice['slice_id']]
 
         return 1
index 109374c..3da92aa 100644 (file)
@@ -21,10 +21,15 @@ class AddRole(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'Add'
+    object_type = 'Role'
+    object_ids = []
+
     def call(self, auth, role_id, name):
         role = Role(self.api)
         role['role_id'] = role_id
         role['name'] = name
         role.sync(insert = True)
+       self.object_ids = [role['role_id']]
 
         return 1
index bfe6817..0d82dea 100644 (file)
@@ -27,6 +27,10 @@ class AddRoleToPerson(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'AddTo'
+    object_type = 'Person'
+    object_ids = []
+
     def call(self, auth, role_id_or_name, person_id_or_email):
         # Get all roles
         roles = {}
@@ -64,4 +68,6 @@ class AddRoleToPerson(Method):
         if role_id not in person['role_ids']:
             person.add_role(role_id)
 
+       self.object_ids = [person['person_id']]
+
         return 1
index 320121a..8f77d86 100644 (file)
@@ -30,6 +30,10 @@ class AddSite(Method):
 
     returns = Parameter(int, 'New site_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Site'
+    object_ids = []
+
     def call(self, auth, name, abbreviated_name, login_base, site_fields = {}):
         site_fields = dict(filter(can_update, site_fields.items()))
         site = Site(self.api, site_fields)
@@ -37,5 +41,6 @@ class AddSite(Method):
         site['abbreviated_name'] = abbreviated_name
         site['login_base'] = login_base
         site.sync()
-
-        return site['site_id']
+       self.object_ids = [site['site_id']]
+        
+       return site['site_id']
index cb6e706..662250c 100644 (file)
@@ -32,6 +32,10 @@ class AddSiteAddress(Method):
 
     returns = Parameter(int, 'New address_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Address'
+    object_ids = []
+
     def call(self, auth, site_id_or_login_base, address_fields = {}):
         address_fields = dict(filter(can_update, address_fields.items()))
 
@@ -48,5 +52,6 @@ class AddSiteAddress(Method):
         address = Address(self.api, address_fields)
         address['site_id'] = site['site_id']
         address.sync()
+       self.object_ids = [address['address_id']]
 
         return address['address_id']
index 3c0e204..58bce63 100644 (file)
@@ -39,6 +39,10 @@ class AddSlice(Method):
 
     returns = Parameter(int, 'New slice_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'Slice'
+    object_ids = []
+
     def call(self, auth, name, slice_fields = {}):
         slice_fields = dict(filter(can_update, slice_fields.items()))
 
@@ -70,5 +74,6 @@ class AddSlice(Method):
         slice['name'] = name
         slice['site_id'] = site['site_id']
         slice.sync()
+       self.object_ids = [slice['slice_id']]
 
         return slice['slice_id']
index e221be8..58fdac7 100644 (file)
@@ -37,6 +37,10 @@ class AddSliceAttribute(Method):
 
     returns = Parameter(int, 'New slice_attribute_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'SliceAttribute'
+    object_ids = []
+
     def call(self, auth, slice_id_or_name, attribute_type_id_or_name, value, node_id_or_hostname = None):
         slices = Slices(self.api, [slice_id_or_name]).values()
         if not slices:
@@ -78,5 +82,6 @@ class AddSliceAttribute(Method):
             slice_attribute['node_id'] = node['node_id']
 
         slice_attribute.sync()
+       self.object_ids = [slice_attribute['slice_attribute_id']]
 
         return slice_attribute['slice_attribute_id']
index 413471e..c1d3fce 100644 (file)
@@ -28,10 +28,15 @@ class AddSliceAttributeType(Method):
 
     returns = Parameter(int, 'New attribute_id (> 0) if successful')
 
+    event_type = 'Add'
+    object_type = 'SliceAttributeType'
+    object_ids = []
+
     def call(self, auth, name, attribute_type_fields = {}):
         attribute_type_fields = dict(filter(can_update, attribute_type_fields.items()))
         attribute_type = SliceAttributeType(self.api, attribute_type_fields)
         attribute_type['name'] = name
         attribute_type.sync()
+       self.object_ids = [attribute_type['attribute_type_id']]
 
         return attribute_type['attribute_type_id']
index 7e0a5d9..290dbc7 100644 (file)
@@ -25,6 +25,10 @@ class AddSliceToNodes(Method):
 
     returns = Parameter(int, '1 if successful')
 
+    event_type = 'AddTo'
+    object_type = 'Node'
+    object_ids = []
+
     def call(self, auth, slice_id_or_name, node_id_or_hostname_list):
         # Get slice information
         slices = Slices(self.api, [slice_id_or_name])
@@ -48,5 +52,7 @@ class AddSliceToNodes(Method):
        for node in nodes:
             if slice['slice_id'] not in node['slice_ids']:
                 slice.add_node(node)
+                
+       self.object_ids = [node['node_id'] for node in nodes]
 
         return 1