def _make_plugin_call(self, plugin, method, instance=None, vm_ref=None,
                          **addl_args):
        """Abstracts out the process of calling a method of a xenapi plugin.
        Any errors raised by the plugin will in turn raise a RuntimeError here.
        """
        args = {}
        if instance or vm_ref:
            args['dom_id'] = self._get_dom_id(instance, vm_ref)
        args.update(addl_args)
        try:
            return self._session.call_plugin(plugin, method, args)
        except self._session.XenAPI.Failure as e:
            err_msg = e.details[-1].splitlines()[-1]
            if 'TIMEOUT:' in err_msg:
                LOG.error(_LE('TIMEOUT: The call to %(method)s timed out. '
                              'args=%(args)r'),
                          {'method': method, 'args': args}, instance=instance)
                return {'returncode': 'timeout', 'message': err_msg}
            elif 'NOT IMPLEMENTED:' in err_msg:
                LOG.error(_LE('NOT IMPLEMENTED: The call to %(method)s is not'
                              ' supported by the agent. args=%(args)r'),
                          {'method': method, 'args': args}, instance=instance)
                return {'returncode': 'notimplemented', 'message': err_msg}
            else:
                LOG.error(_LE('The call to %(method)s returned an error: '
                              '%(e)s. args=%(args)r'),
                          {'method': method, 'args': args, 'e': e},
                          instance=instance)
                return {'returncode': 'error', 'message': err_msg}
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._make_plugin_call/original