Exemplo n.º 1
0
static gboolean
mh_qpid_callback(qmf::AgentSession session, qmf::AgentEvent event,
                 gpointer user_data)
{
    MatahariAgent *agent = (MatahariAgent*) user_data;
    mh_trace("Qpid message recieved");
    if (event.hasDataAddr()) {
        mh_trace("Message is for %s (type: %s)",
                 event.getDataAddr().getName().c_str(),
                 event.getDataAddr().getAgentName().c_str());
    }
    return agent->invoke(session, event, user_data);
}
Exemplo n.º 2
0
gboolean
SrvAgent::invoke(qmf::AgentSession session, qmf::AgentEvent event,
                 gpointer user_data)
{
    if (event.getType() == qmf::AGENT_METHOD && event.hasDataAddr()) {
        if (event.getDataAddr().getName() == "Services") {
            return invoke_services(session, event, user_data);

        } else if (event.getDataAddr().getName() == "Resources") {
	    return invoke_resources(session, event, user_data);

        } else {
	    mh_err("Unknown agent: %s", event.getDataAddr().getName().c_str());
	}
    }

    mh_err("Unhandled message");
    return TRUE;
}
Exemplo n.º 3
0
bool ObjectManager::invoke(qmf::AgentSession& session,
                           qmf::AgentEvent& event) const
{
    if (event.hasDataAddr()) {
        MatahariObject *obj = _impl->find(event.getDataAddr());

        if (obj) {
            return obj->invoke(session, event);
        }

        mh_err("Target of method call not found");
    }

    return false;
}
Exemplo n.º 4
0
bool
VolumeWrap::handleMethod(qmf::AgentSession& session, qmf::AgentEvent& event)
{
    int ret;

    if (*this != event.getDataAddr()) {
        return false;
    }

    const std::string& methodName(event.getMethodName());
    qpid::types::Variant::Map args(event.getArguments());

    if (methodName == "getXMLDesc") {
        const char *desc = virStorageVolGetXMLDesc(_volume_ptr, 0);
        if (!desc) {
            std::string err = FORMAT_ERR(_conn, "Error getting xml description for volume (virStorageVolGetXMLDesc).", &ret);
            raiseException(session, event, err, STATUS_USER + ret);
        } else {
            event.addReturnArgument("description", desc);
            session.methodSuccess(event);
        }
        return true;
    }

    if (methodName == "delete") {
        ret = virStorageVolDelete(_volume_ptr, 0);
        if (ret < 0) {
            std::string err = FORMAT_ERR(_conn, "Error deleting storage volume (virStorageVolDelete).", &ret);
            raiseException(session, event, err, STATUS_USER + ret);
        } else {
            update();
            session.methodSuccess(event);
        }
        return true;
    }

    raiseException(session, event,
                   ERROR_UNKNOWN_METHOD, STATUS_UNKNOWN_METHOD);
    return true;
}