Commit ea4e7a0a authored by David Hancock's avatar David Hancock

Add debug breaks before raising exceptions

parent 5cb25235
......@@ -191,6 +191,7 @@ class HP4_Command(object):
def __str__(self):
""" assumes command is \'table_add\' """
if self.command != 'table_add':
debug()
raise Exception("Incorrect table command %s, table %s" % (self.command, self.table))
ret = self.table + ' ' + self.action + ' :'
ret += ' '.join(self.match_params)
......@@ -1128,6 +1129,7 @@ def get_parse_select_table_code(first_byte):
ret = '[PARSE_SELECT_'
ret += '%02d_%02d]' % (lowerbound, upperbound - 1)
return ret
debug()
raise Exception("Did not find parse_select table; first_byte: %d" % first_byte)
def get_pc_action(pcs):
......@@ -1705,6 +1707,7 @@ def process_extract_statements(pcs):
if pcs.hp4_bits_extracted < pcs.p4_bits_extracted:
pcs.hp4_bits_extracted = pcs.p4_bits_extracted
else:
debug()
raise Exception('Unsupported parse call: %s' % call[PS_CALL_TYPE])
def process_parse_tree_clr(pcs, h):
......@@ -1743,6 +1746,7 @@ def process_parse_tree_clr(pcs, h):
values = []
for value in branch[BRANCH_VALUES]:
if value[VAL_TYPE] != 'value' and value[VAL_TYPE] != 'default':
debug()
raise Exception('Unsupported branch value type: %s' % value[VAL_TYPE])
if value[VAL_TYPE] == 'default':
values.append('default')
......@@ -1762,6 +1766,7 @@ def process_parse_tree_clr(pcs, h):
next_pcs = add_next(next_parse_state)
process_parse_tree_clr(next_pcs, h)
else:
debug()
raise Exception('Unsupported return type: %s' % \
pcs.parse_state.return_statement[PS_RET_TYPE])
......
......@@ -303,6 +303,7 @@ class Controller(object):
break
except socket.error as (code, msg):
if code != errno.EINTR:
debug()
raise
if killer.kill_now:
self.dbugprint("\rConViDa terminated")
......
......@@ -134,16 +134,19 @@ class Lease(object):
# validate request
# - validate vdev_name
if vdev_name in self.vdevs:
debug()
raise LoadError(vdev_name + ' already present')
# - validate lease has sufficient entries
entries_available = self.entry_limit - self.entry_usage
if (len(vdev.hp4_code_and_rules) > entries_available):
debug()
raise LoadError('request('+ str(len(vdev.hp4_code_and_rules)) + ') \
exceeds entries available(' + str(entries_available) + ')')
# - validate virtual device not already somewhere else
if vdev.dev_name != 'none':
debug()
raise LoadError('first remove ' + vdev_name + ' from ' + vdev.dev_name)
#if vdev_name == 's1_vib_enc':
......@@ -167,6 +170,7 @@ class Lease(object):
aparams[2] = '1'
elif egress_mode != 'etrue':
debug()
raise LoadError('Invalid egress handling mode: ' + egress_mode)
if action == 'mod_intmeta_mcast_grp_const':
......@@ -186,6 +190,7 @@ class Lease(object):
rule_identifier = table + ' ' + str(handle)
self.device.do_table_delete(rule_identifier)
del vdev.hp4_code_and_rules[(table, handle)]
debug()
raise LoadError('Lease::insert: ' + str(e))
for rule in vdev.hp4code:
......@@ -355,6 +360,7 @@ class Chain(Lease):
else:
if len(vdev.t_egr_virtnet_handles) > 0:
debug()
raise VirtnetError('vdev2p: t_egr_virtnet has entries when t_virtnet doesn\'t')
for vegress in self.mcast_egress_specs:
......@@ -412,6 +418,7 @@ class Chain(Lease):
else:
# table_add
if len(src_vdev.t_egr_virtnet_handles) > 0:
debug()
raise VirtnetError('vdev2vdev: t_egr_virtnet has entries when t_virtnet doesn\'t')
command_type = 'table_add'
......
......@@ -344,8 +344,10 @@ class VirtualDeviceFactory():
self.compiled_programs[program_path] = \
self.hp4c.compile_to_hp4(program_path, out_path, mt_out_path, 9)
except CompileError as e:
debug()
return "Compile Error: " + str(e)
else:
debug()
raise CompileError('filetype not supported')
object_code_path = self.compiled_programs[program_path].object_code_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment