Beispiel #1
0
    def test_share_set_metadata(self):
        fake_metadata = {
            "aim": "testing",
            "project": "my_abc",
            "deadline": "01/01/2020"
        }

        api.share_set_metadata(self.request, self.id, fake_metadata)

        self.manilaclient.shares.set_metadata.assert_called_once_with(
            self.id, fake_metadata)
Beispiel #2
0
 def handle(self, request, data):
     share_id = self.initial['share_id']
     try:
         share = manila.share_get(self.request, share_id)
         set_dict, unset_list = utils.parse_str_meta(data['metadata'])
         if set_dict:
             manila.share_set_metadata(request, share, set_dict)
         if unset_list:
             manila.share_delete_metadata(request, share, unset_list)
         message = _('Updating share metadata "%s"') % share.name
         messages.success(request, message)
         return True
     except ValidationError as e:
         self.api_error(e.messages[0])
         return False
     except Exception:
         redirect = reverse("horizon:project:shares:index")
         exceptions.handle(request,
                           _('Unable to update share metadata.'),
                           redirect=redirect)
Beispiel #3
0
 def handle(self, request, data):
     share_id = self.initial['share_id']
     try:
         share = manila.share_get(self.request, share_id)
         set_dict, unset_list = utils.parse_str_meta(data['metadata'])
         if set_dict:
             manila.share_set_metadata(request, share, set_dict)
         if unset_list:
             manila.share_delete_metadata(request, share, unset_list)
         message = _('Updating share metadata "%s"') % share.name
         messages.success(request, message)
         return True
     except ValidationError as e:
         self.api_error(e.messages[0])
         return False
     except Exception:
         redirect = reverse("horizon:project:shares:index")
         exceptions.handle(request,
                           _('Unable to update share metadata.'),
                           redirect=redirect)