from PLC.Faults import *
from PLC.Parameter import Parameter
-from PLC.Filter import Filter
from PLC.Debug import profile
-from PLC.Table import Row, Table
from PLC.Storage.AlchemyObject import AlchemyObj
from PLC.Interfaces import valid_ip, Interface, Interfaces
from PLC.Nodes import Node, Nodes
'password': Parameter(str, "PCU username", max = 254, nullok = True),
'notes': Parameter(str, "Miscellaneous notes", max = 254, nullok = True),
'model': Parameter(str, "PCU model string", max = 32, nullok = True),
- 'node_ids': Parameter([int], "List of nodes that this PCU controls"),
- 'ports': Parameter([int], "List of the port numbers that each node is connected to", ro=True),
+ 'node_ids': Parameter([int], "List of nodes that this PCU controls", joined=True),
+ 'ports': Parameter([int], "List of the port numbers that each node is connected to", joined=True),
'last_updated': Parameter(int, "Date and time when node entry was created"),
}
raise PLCInvalidArgument, "Invalid IP address " + ip
return ip
- validate_last_updated = Row.validate_timestamp
+ validate_last_updated = AlchemyObj.validate_timestamp
def update_timestamp(self, col_name, commit = True):
"""
Update col_name field with current time
"""
-
- assert 'pcu_id' in self
- assert self.table_name
-
- self.api.db.do("UPDATE %s SET %s = CURRENT_TIMESTAMP " % (self.table_name, col_name) + \
- " where pcu_id = %d" % (self['pcu_id']) )
- self.sync(commit)
+ pass
def update_last_updated(self, commit = True):
self.update_timestamp('last_updated', commit)
self['node_ids'].remove(node_id)
self['ports'].remove(port)
- def sync(self, insert=False, validate=True):
- AlchemyObj.sync(self, insert, validate):
- if insert == True or 'id' not in self:
+ def sync(self, commit, validate=True):
+ AlchemyObj.sync(self, commit=commit, valiate=validate):
+ if 'pcu_id' not in self:
AlchemyObj.insert(self, dict(self))
else:
- AlchemyObj.delete(self, dict(self))
+ AlchemyObj.delete(self, {'pcu_id': self['pcu_id']}, dict(self))
+
+ def delete(self, commit=True):
+ AlchemyObj.delete(self, dict(self))
class PCUs(list):
"""
pcus= PCU().select(filter=pcu_filter)
else:
raise PLCInvalidArgument, "Wrong pcu filter %r"%pcu_filter
- sql += " AND (%s) %s" % pcu_filter.sql(api)
for pcu in pcus:
self.append(pcu)