librelist archives

« back to archive

Asset module problem

Asset module problem

From:
Damian Kaliszan
Date:
2014-11-03 @ 11:12
Hi guys,

After   upgrading   to   ralph==2.1.0   and   ralph-assets==2.3.0  I'm
encountering several problems which preventme from moving forward.

I  removed  all  problematic  assets   (in Admin module) which  couldn't  
be match with
discovered devices and tried to create them from scratch.

When selecting 'Ralph device id' in /assets/dc/edit/device/-device_id-
and clicking on Save button I get

[03.11.2014 11:53:25,462] ERROR   [MainProcess 3844] base - Internal 
Server Error: /assets/dc/edit/device/26/
Traceback (most recent call last):
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py",
line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/views/generic/base.py",
line 48, in view
    return self.dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/base.py",
line 71, in dispatch
    return super(AssetsBase, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph/account/models.py", 
line 272, in inner_decorator
    return func(self, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/base.py",
line 55, in dispatch
    return super(ACLGateway, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph/ui/views/common.py", 
line 249, in dispatch
    return super(MenuMixin, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/views/generic/base.py",
line 69, in dispatch
    return handler(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/device.py",
line 254, in post
    self.additional_info.is_valid(),
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/forms/forms.py", 
line 124, in is_valid
    return self.is_bound and not bool(self.errors)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/forms/forms.py", 
line 115, in _get_errors
    self.full_clean()
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/forms/forms.py", 
line 271, in full_clean
    self._clean_form()
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/forms/forms.py", 
line 299, in _clean_form
    self.cleaned_data = self.clean()
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/forms.py", 
line 597, in clean
    mark_safe(msg.format(escape(device_info.asset.id)))
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/fields/related.py",
line 255, in __get__
    rel_obj = self.get_query_set(instance=instance).get(**params)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/query.py",
line 366, in get
    % self.model._meta.object_name)
DoesNotExist: Asset matching query does not exist.




However,  when  I  triy  to  delete  this Asset from /assets/dc/search
context I get


[03.11.2014 11:56:07,536] ERROR   [MainProcess 3844] base - Internal 
Server Error: /assets/dc/delete/asset/
Traceback (most recent call last):
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py",
line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/views/generic/base.py",
line 48, in view
    return self.dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/base.py",
line 71, in dispatch
    return super(AssetsBase, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph/account/models.py", 
line 272, in inner_decorator
    return func(self, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/base.py",
line 55, in dispatch
    return super(ACLGateway, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph/ui/views/common.py", 
line 249, in dispatch
    return super(MenuMixin, self).dispatch(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/views/generic/base.py",
line 69, in dispatch
    return handler(request, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/views/asset.py",
line 68, in post
    self.asset.delete_with_info()
  File 
"/home/ralph/local/lib/python2.7/site-packages/ralph_assets/models_assets.py",
line 795, in delete_with_info
    self.device_info.delete()
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/base.py", 
line 576, in delete
    collector.delete()
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/deletion.py",
line 61, in decorated
    func(self, *args, **kwargs)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/deletion.py",
line 263, in delete
    query.delete_batch(pk_list, self.using)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/sql/subqueries.py",
line 44, in delete_batch
    self.do_query(self.model._meta.db_table, where, using=using)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/sql/subqueries.py",
line 29, in do_query
    self.get_compiler(using).execute_sql(None)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
line 818, in execute_sql
    cursor.execute(sql, params)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/backends/util.py",
line 40, in execute
    return self.cursor.execute(sql, params)
  File 
"/home/ralph/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
line 114, in execute
    return self.cursor.execute(query, args)
  File "/home/ralph/local/lib/python2.7/site-packages/MySQLdb/cursors.py",
line 174, in execute
    self.errorhandler(self, exc, value)
  File 
"/home/ralph/local/lib/python2.7/site-packages/MySQLdb/connections.py", 
line 36, in defaulterrorhandler
    raise errorclass, errorvalue
IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign 
key constraint fails (`ralph`.`ralph_assets_assethistorychange`, 
CONSTRAINT `device_info_id_refs_id_cc96a30f` FOREIGN KEY 
(`device_info_id`) REFERENCES `ralph_assets_deviceinfo` (`id`))')



Damian