Пример #1
0
 def handle_delete(self, cxt, resource, name):
     try:
         cli = self._get_client(cxt)
         cli.delete_fake_res(name)
     except FakeException:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable(FAKE_TYPE, cli.endpoint)
Пример #2
0
 def handle_list(self, cxt, resource, filters):
     try:
         cli = self._get_client(cxt)
         return cli.list_fake_res(
             resource_handle._transform_filters(filters))
     except FakeException:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable(FAKE_TYPE, cli.endpoint)
Пример #3
0
 def handle_create(self, cxt, resource, *args, **kwargs):
     try:
         client = self._get_client(cxt)
         collection = '%ss' % resource
         return getattr(client, collection).create(*args,
                                                   **kwargs).to_dict()
     except r_exceptions.ConnectTimeout:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable('nova',
                                              client.client.management_url)
Пример #4
0
 def handle_list(self, cxt, resource, filters):
     try:
         client = self._get_client(cxt)
         collection = '%ss' % resource
         return [
             res.to_dict() for res in getattr(client, collection).list(
                 filters=_transform_filters(filters))
         ]
     except g_exceptions.InvalidEndpoint:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable('glance',
                                              client.http_client.endpoint)
Пример #5
0
 def handle_list(self, cxt, resource, filters):
     try:
         client = self._get_client(cxt)
         collection = '%ss' % resource
         search_opts = _transform_filters(filters)
         return [
             res for res in getattr(client, 'list_%s' %
                                    collection)(**search_opts)[collection]
         ]
     except q_exceptions.ConnectionFailed:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable(
             'neutron', client.httpclient.endpoint_url)
Пример #6
0
 def handle_delete(self, cxt, resource, resource_id):
     try:
         client = self._get_client(cxt)
         collection = '%ss' % resource
         return getattr(client, collection).delete(resource_id)
     except r_exceptions.ConnectTimeout:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable('nova',
                                              client.client.management_url)
     except n_exceptions.NotFound:
         LOG.debug("Delete %(resource)s %(resource_id)s which not found", {
             'resource': resource,
             'resource_id': resource_id
         })
Пример #7
0
 def handle_list(self, cxt, resource, filters):
     try:
         client = self._get_client(cxt)
         collection = '%ss' % resource
         # only server list supports filter
         if resource == 'server':
             search_opts = _transform_filters(filters)
             return [
                 res.to_dict() for res in getattr(client, collection).list(
                     search_opts=search_opts)
             ]
         else:
             return [
                 res.to_dict()
                 for res in getattr(client, collection).list()
             ]
     except r_exceptions.ConnectTimeout:
         self.endpoint_url = None
         raise exception.EndpointNotAvailable('nova',
                                              client.client.management_url)