def execute_resource(self, resource_id='', command=None):
        """Execute command on the resource represented by agent.
        """
        res_type = self._get_resource_type(resource_id)
        if self._has_agent(res_type):
            rac = ResourceAgentClient(resource_id=resource_id)
            return rac.execute_resource(resource_id=resource_id,
                                        command=command)

        cmd_res = None
        res_interface = self._get_type_interface(res_type)

        target = get_safe(res_interface,
                          "commands.%s.execute" % command.command, None)
        if target:
            res = self._call_execute(target, resource_id, res_type,
                                     command.args, command.kwargs)
            cmd_res = AgentCommandResult(command_id=command.command_id,
                                         command=command.command,
                                         ts_execute=get_ion_ts(),
                                         status=0)
        else:
            log.warn("execute_resource(): command %s not defined",
                     command.command)

        return cmd_res
    def execute_resource(self, resource_id='', command=None):
        """Execute command on the resource represented by agent.
        """
        res_type = self._get_resource_type(resource_id)
        if self._has_agent(res_type):
            rac = ResourceAgentClient(resource_id=resource_id)
            return rac.execute_resource(resource_id=resource_id, command=command)

        cmd_res = None
        res_interface = self._get_type_interface(res_type)

        target = get_safe(res_interface, "commands.%s.execute" % command.command, None)
        if target:
            res = self._call_execute(target, resource_id, res_type, command.args, command.kwargs)
            cmd_res = AgentCommandResult(command_id=command.command_id,
                command=command.command,
                ts_execute=get_ion_ts(),
                status=0)
        else:
            log.warn("execute_resource(): command %s not defined", command.command)

        return cmd_res