TWSD-1036 - Unable to assign VA instances and port details to the virtual switch in AVX
Review Request #1475 — Created March 31, 2026 and submitted
| Information | |
|---|---|
| shuinvy | |
| AVX2 | |
| rel_avx_2_7_6 | |
| TWSD-1036 | |
| Reviewers | |
| austin, stevenku | |
Fixing KeyError issue
The Jira ticket is:
https://arraynetworks.atlassian.net/browse/TWSD-1036The error message is:
ERROR - Internal Server Error: /apv.fcgi/api/avx/network/vswitch/VirtualSwitchVA/_add Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 113, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/ca/webui/htdocs/new/src/hive/router.py", line 253, in hive_ajax_router response = HttpResponse(ModelAjaxHandler(request, sess, app, model, action).render()) File "/ca/webui/htdocs/new/src/hive/model/ajax.py", line 47, in render return getattr(self, self.action)(**request_dict) File "/ca/webui/htdocs/new/src/hive/model/ajax.py", line 176, in add self.manager.insert(new_obj) File "/ca/webui/htdocs/new/src/hive/model/manager.py", line 218, in insert result = self._insert(model_instance) File "/ca/webui/htdocs/new/src/avx/models/network/vswitch/__init__.py", line 301, in _insert data = instance.get_field_dict() File "/ca/webui/htdocs/new/src/hive/model/base.py", line 587, in get_field_dict val = mgr.get_field_by_instance(self, f.attname) File "/ca/webui/htdocs/new/src/hive/model/manager.py", line 592, in get_field_by_instance the_instance = data.get(the_pk_dict) File "/ca/webui/htdocs/new/src/hive/model/query.py", line 72, in get return self.__getitem__(pk_str) File "/ca/webui/htdocs/new/src/hive/model/query.py", line 126, in __getitem__ return self._cache_dict[k] KeyError: '{"va": [{"_asso_idx": 0, "va_name": "M_custom_apv"}], "vport": "vport1", "vs_name": [{"_asso_idx": 0, "name": "test"}]}'The root cause is there is no key in the
_cache_dict,
so I used instance itself instead of transfer to dictionary,
then it won't try to get cache data and cause KeyError.
Besides,
because the fields are AssoFields, that is,
not primitive type(string or integer, boolean...),
if the key is a list such as[{"_asso_idx": 0, "va_name": "M_custom_apv"}],
it may not find the key in Python2.7.
Thus,
use instance is better than transfering it to dictionary.
