def enforce_port_deletion_rules(resource, event, trigger, **kwargs):
 context = kwargs['context']
 port_id = kwargs['port_id']
 subport_obj = trunk_objects.SubPort.get_object(context, port_id=port_id)
 if subport_obj:
  raise trunk_exc.PortInUseAsSubPort(port_id=port_id, trunk_id=subport_obj.trunk_id)
 trunk_obj = trunk_objects.Trunk.get_object(context, port_id=port_id)
 if trunk_obj:
  raise trunk_exc.PortInUseAsTrunkParent(port_id=port_id, trunk_id=trunk_obj.id)

def enforce_port_deletion_rules ( resource , event , trigger , ** kwargs ) : context = kwargs [ 'context' ] port_id = kwargs [ 'port_id' ] subport_obj = trunk_objects . SubPort . get_object ( context , port_id = port_id ) if subport_obj : raise trunk_exc . PortInUseAsSubPort ( port_id = port_id , trunk_id = subport_obj . trunk_id ) trunk_obj = trunk_objects . Trunk . get_object ( context , port_id = port_id ) if trunk_obj : raise trunk_exc . PortInUseAsTrunkParent ( port_id = port_id , trunk_id = trunk_obj . id )
prohibit the deletion of a port thats used in a trunk .