Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource_list not work correctly #89

Open
willliuwx opened this issue Jul 12, 2017 · 0 comments
Open

resource_list not work correctly #89

willliuwx opened this issue Jul 12, 2017 · 0 comments

Comments

@willliuwx
Copy link

file:neutron_plugin_contrail/plugins/opencontrail/vnc_client/vn_res_handler.py

def resource_list(self, context=None, filters=None, fields=None):

  | contrail_extensions_enabled = self._kwargs.get(
  | 'contrail_extensions_enabled', False)
  | contrail_exts_enabled = contrail_extensions_enabled
  | ret_dict = {}
  |  
  | def _collect_without_prune(net_ids):
  | for net_id in net_ids:
  | try:
  | net_obj = self._resource_get(id=net_id)
  | net_info = self.vn_to_neutron_dict(
  | net_obj,
  | contrail_extensions_enabled=contrail_exts_enabled,
  | fields=fields)
  | ret_dict[net_id] = net_info
  | except vnc_exc.NoIdError:
  | pass
  | # end _collect_without_prune
  |  
  | # collect phase
  | all_net_objs = [] # all n/ws in all projects
  | if context and not context['is_admin']:
  | if filters and 'id' in filters:
  | _collect_without_prune(filters['id'])
  | elif filters and 'name' in filters:
  | net_objs = self._network_list_project(context['tenant'])
  | all_net_objs.extend(net_objs)
  | all_net_objs.extend(self._network_list_shared())
  | all_net_objs.extend(self._network_list_router_external())
  | elif (filters and 'shared' in filters and filters['shared'][0] and
  | 'router:external' not in filters):
  | all_net_objs.extend(self._network_list_shared())
#wrong
  | elif (filters and 'router:external' in filters and
  | 'shared' not in filters):
  | all_net_objs.extend(self._network_list_router_external())
  | elif (filters and 'router:external' in filters and
  | 'shared' in filters):
#end of wrong code
  | all_net_objs.extend(self._network_list_shared_and_ext())
  | else:
  | project_uuid = self._project_id_neutron_to_vnc(
  | context['tenant'])
  | if not filters:
  | all_net_objs.extend(self._network_list_router_external())
  | all_net_objs.extend(self._network_list_shared())
  | all_net_objs.extend(self._network_list_project(project_uuid))
#########################
  | elif (filters and 'router:external' in filters and
  | 'shared' not in filters):
  | all_net_objs.extend(self._network_list_router_external())
  | elif (filters and 'router:external' in filters and
  | 'shared' in filters):
the filters is a dictionary like below:
{u'shared': [False], u'tenant_id': [u'f96d2b5b15c84e2e82e78a9a388679a4'], u'router:external': [False]}
the condition should be both the key in filter and the value is True when it's a bool.
The right code:
elif (filters and 'router:external' in filters and filters['router:external'][0] and
'shared' not in filters):
all_net_objs.extend(self._network_list_router_external())
elif (filters and 'router:external' in filters and filters['router:external'][0] and
'shared' in filters and filters['shared'][0]):
all_net_objs.extend(self._network_list_shared_and_ext())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant