Exemplo n.º 1
0
 def handle_get(self, url):
     #TODO(salvatore-orlando): handle field selection
     parsedurl = urlparse.urlparse(url)
     (res_type, uuids) = self._get_resource_type(parsedurl.path)
     relations = urlparse.parse_qs(parsedurl.query).get('relations')
     response_file = self.FAKE_GET_RESPONSES.get(res_type)
     if not response_file:
         raise api_exc.NsxApiException()
     if 'lport' in res_type or 'nat' in res_type:
         if len(uuids) > 1:
             return self._show(res_type,
                               response_file,
                               uuids[0],
                               uuids[1],
                               relations=relations)
         else:
             return self._list(res_type,
                               response_file,
                               uuids[0],
                               query=parsedurl.query,
                               relations=relations)
     elif ('lswitch' in res_type or 'lrouter' in res_type
           or self.SECPROF_RESOURCE in res_type
           or self.LQUEUE_RESOURCE in res_type
           or 'gatewayservice' in res_type):
         LOG.debug("UUIDS:%s", uuids)
         if uuids:
             return self._show(res_type,
                               response_file,
                               uuids[0],
                               relations=relations)
         else:
             return self._list(res_type,
                               response_file,
                               query=parsedurl.query,
                               relations=relations)
     else:
         raise Exception("unknown resource:%s" % res_type)
Exemplo n.º 2
0
 def raise_nsx_exc(*args, **kwargs):
     raise api_exc.NsxApiException()
Exemplo n.º 3
0
 def side_effect(*args):
     if args[-1].get('subnet_id') == s['subnet']['id']:
         # Do the real thing.
         return real_func(plugin_instance, *args)
     # Otherwise raise.
     raise api_exc.NsxApiException()