Exemplo n.º 1
0
 def emit_share_changed(self, message, share):
     """ emits ShareChanged or ShareDeleted signal for the share
     notification.
     """
     logger.debug('emit_share_changed: message %r, share %r.',
                 message, share)
     if message == 'deleted':
         self.emit_signal('on_share_deleted', get_share_dict(share))
     elif message == 'changed':
         self.emit_signal('on_share_changed', get_share_dict(share))
Exemplo n.º 2
0
 def handle_SYS_QUOTA_EXCEEDED(self, volume_id, free_bytes):
     """Handle the SYS_QUOTA_EXCEEDED event."""
     volume = self.vm.get_volume(str(volume_id))
     volume_dict = {}
     if isinstance(volume, UDF):
         volume_dict = get_udf_dict(volume)
         to_call = self.status_frontend.udf_quota_exceeded
     elif isinstance(volume, Root):
         volume_dict = get_share_dict(volume)
         to_call = self.status_frontend.root_quota_exceeded
     else:
         volume_dict = get_share_dict(volume)
         to_call = self.status_frontend.share_quota_exceeded
     volume_dict['free_bytes'] = str(free_bytes)
     to_call(volume_dict)
    def test_refresh_volumes(self):
        """Test for refresh_volumes method."""
        udf = self._create_udf()
        yield self.main.vm.add_udf(udf)

        share = self._create_share()
        yield self.main.vm.add_share(share)

        volumes = list(self.main.vm.get_volumes(all_volumes=True))

        def volumes_changed():
            """Fake volumes_changed."""
            self.main.event_q.push('VM_VOLUMES_CHANGED', volumes=volumes)

        self.patch(self.main.vm, 'refresh_volumes', volumes_changed)
        result = yield self.tool.refresh_volumes()

        str_volumes = []
        for volume in volumes:
            if isinstance(volume, volume_manager.UDF):
                str_vol = interaction_interfaces.get_udf_dict(volume)
            else:
                str_vol = interaction_interfaces.get_share_dict(volume)
            str_volumes.append(str_vol)
        self.assertEqual(result, str_volumes)
Exemplo n.º 4
0
 def emit_free_space(self, share_id, free_bytes):
     """ emits ShareChanged when free space changes """
     if share_id in self.syncdaemon_shares.shares:
         share = self.syncdaemon_shares.shares[share_id]
         share_dict = get_share_dict(share)
         share_dict['free_bytes'] = unicode(free_bytes)
         self.emit_signal('on_share_changed',
             share_dict)
Exemplo n.º 5
0
 def emit_share_unsubscribed(self, share):
     """Emit the ShareUnSubscribed signal"""
     self.emit_signal('on_share_unsubscribed', get_share_dict(share))
Exemplo n.º 6
0
 def emit_new_share(self, share_id):
     """Emits NewShare signal."""
     share = self.syncdaemon_shares.get_volume(share_id)
     logger.debug('emit_new_share: share_id %r.', share_id)
     self.emit_signal('on_new_share', get_share_dict(share))
Exemplo n.º 7
0
 def emit_share_delete_error(self, share, error):
     """Emits ShareDeleteError signal."""
     logger.info('emit_share_delete_error: share %r, error %r.',
                 share, error)
     self.emit_signal('on_share_delete_error',
         get_share_dict(share), error)