join_tables = ['pcu_protocol_type']
fields = {
'pcu_type_id': Parameter(int, "PCU Type Identifier"),
join_tables = ['pcu_protocol_type']
fields = {
'pcu_type_id': Parameter(int, "PCU Type Identifier"),
- 'model': Parameter(str, "PCU model", max = 254),
- 'name': Parameter(str, "PCU full name", max = 254),
+ 'model': Parameter(str, "PCU model", max = 254),
+ 'name': Parameter(str, "PCU full name", max = 254),
-
- # Make sure boot state does not alredy exist
- conflicts = PCUTypes(self.api, [model])
+
+ # Make sure boot state does not alredy exist
+ conflicts = PCUTypes(self.api, [model])
- if 'pcu_type_id' not in self or self['pcu_type_id'] != pcu_type['pcu_type_id']:
- raise PLCInvalidArgument, "Model already in use"
+ if 'pcu_type_id' not in self or self['pcu_type_id'] != pcu_type['pcu_type_id']:
+ raise PLCInvalidArgument, "Model already in use"
def __init__(self, api, pcu_type_filter = None, columns = None):
def __init__(self, api, pcu_type_filter = None, columns = None):
- # Remove pcu_protocol_types from query since its not really a field
- # in the db. We will add it later
- if columns == None:
- columns = PCUType.fields.keys()
- if 'pcu_protocol_types' in columns:
- removed_fields = ['pcu_protocol_types']
- columns.remove('pcu_protocol_types')
- else:
- removed_fields = []
+ # Remove pcu_protocol_types from query since its not really a field
+ # in the db. We will add it later
+ if columns == None:
+ columns = PCUType.fields.keys()
+ if 'pcu_protocol_types' in columns:
+ removed_fields = ['pcu_protocol_types']
+ columns.remove('pcu_protocol_types')
+ else:
+ removed_fields = []
Table.__init__(self, api, PCUType, columns)
sql = "SELECT %s FROM view_pcu_types WHERE True" % \
", ".join(self.columns)
Table.__init__(self, api, PCUType, columns)
sql = "SELECT %s FROM view_pcu_types WHERE True" % \
", ".join(self.columns)
if isinstance(pcu_type_filter, (list, tuple, set)):
# Separate the list into integers and strings
ints = filter(lambda x: isinstance(x, (int, long)), pcu_type_filter)
if isinstance(pcu_type_filter, (list, tuple, set)):
# Separate the list into integers and strings
ints = filter(lambda x: isinstance(x, (int, long)), pcu_type_filter)
pcu_type_filter = Filter(PCUType.fields, pcu_type_filter)
sql += " AND (%s) %s" % pcu_type_filter.sql(api, "AND")
elif isinstance (pcu_type_filter, StringTypes):
pcu_type_filter = Filter(PCUType.fields, pcu_type_filter)
sql += " AND (%s) %s" % pcu_type_filter.sql(api, "AND")
elif isinstance (pcu_type_filter, StringTypes):
sql += " AND (%s) %s" % pcu_type_filter.sql(api, "AND")
elif isinstance (pcu_type_filter, int):
sql += " AND (%s) %s" % pcu_type_filter.sql(api, "AND")
elif isinstance (pcu_type_filter, int):
protocol_type_ids = set()
for pcu_type in self:
protocol_type_ids.update(pcu_type['pcu_protocol_type_ids'])
protocol_return_fields = ['pcu_protocol_type_id', 'port', 'protocol', 'supported']
all_protocol_types = PCUProtocolTypes(self.api, list(protocol_type_ids), \
protocol_type_ids = set()
for pcu_type in self:
protocol_type_ids.update(pcu_type['pcu_protocol_type_ids'])
protocol_return_fields = ['pcu_protocol_type_id', 'port', 'protocol', 'supported']
all_protocol_types = PCUProtocolTypes(self.api, list(protocol_type_ids), \