Examples of AgentRegistrationResults


Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        out.println(MSG.getMsg(AgentI18NResourceKeys.REGISTER_SENT_REQUEST, regenerate));
        out.println(MSG.getMsg(AgentI18NResourceKeys.REGISTER_WAITING, wait));

        agent.registerWithServer(wait * 1000L, regenerate);
        AgentRegistrationResults registration = agent.getAgentRegistration();

        if (registration == null) {
            out.println(MSG.getMsg(AgentI18NResourceKeys.REGISTER_FAILED));
        } else {
            out.println(MSG.getMsg(AgentI18NResourceKeys.REGISTER_REGISTRATION, registration));
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        // get existing or generate new server list for the registering agent
        FailoverListComposite failoverList = getPartitionEventManager().agentPartitionEvent(
            getSubjectManager().getOverlord(), agentByName.getName(), PartitionEventType.AGENT_REGISTRATION,
            agentByName.getName() + " - " + registeringServer.getName());

        AgentRegistrationResults results = new AgentRegistrationResults();
        results.setAgentToken(agentByName.getAgentToken());
        results.setFailoverList(failoverList);

        // Link this agent with its installation details.
        // If the agent was told about its install ID, then we'll use that to update the existing row.
        // (this happens if a remote install was performed and its SSH details were already persisted).
        // Otherwise, this will create or update an existing AgentInstall entity without any additional data
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

                                m_commServices.addCustomData(
                                    SecurityTokenCommandAuthenticator.CMDCONFIG_PROP_SECURITY_TOKEN, null);

                                FailoverListComposite failover_list = null;
                                try {
                                    AgentRegistrationResults results = remote_pojo.registerAgent(request);
                                    failover_list = results.getFailoverList();
                                    token = results.getAgentToken(); // make sure our finally block gets this - BZ 963982

                                    // Try to do a simple connect to each server in the failover list
                                    // If only some of the servers are unreachable, just keep going;
                                    //    the agent will eventually switchover to one of the live servers.
                                    // But if all servers in the list are unreachable, we need to keep retrying hoping
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        // changed their mind and want to re-run that agent and re-register it again.
        // In this case, the agent (if not using --cleanallconfig) would still have the old token.
        // The agent should still be allowed to register again.
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request = createRequest(prefixName("old"), "hostOld", 12345, "oldtoken");
        AgentRegistrationResults results = service.registerAgent(request);
        assert results != null : "cannot re-register an old agent";
        Agent agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(request.getName());
        assert agent.getAddress().equals(request.getAddress());
        assert agent.getPort() == request.getPort();
        LookupUtil.getAgentManager().deleteAgent(agent);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

    @Test
    public void testChangeAddressPort() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;
        AgentRegistrationResults results;

        String tuid = "" + new Random().nextInt();
        //let's make this unique per run to support repeated individual runs.
        String zName = prefixName("Z" + "-" + tuid);

        // create a new agent Z with host/port of hostZ/55550
        request = createRequest(zName, "hostZ", 55550, null);
        results = service.registerAgent(request);
        assert results != null : "got null results";

        // now change Z's host to hostZprime
        request = createRequest(zName, "hostZprime", 55550, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        Agent agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZprime");
        assert agent.getPort() == 55550;

        // now change Z's port to 55551
        request = createRequest(zName, "hostZprime", 55551, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZprime");
        assert agent.getPort() == 55551;

        // now change Z's host/port to hostZdoubleprime/55552
        request = createRequest(zName, "hostZdoubleprime" + tuid, 55552, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZdoubleprime" + tuid);
        assert agent.getPort() == 55552;

        // now don't change Z's host/port but re-register everything the same with its token
        request = createRequest(zName, "hostZdoubleprime" + tuid, 55552, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZdoubleprime" + tuid);
        assert agent.getPort() == 55552;

        // remember this agent so our later tests can use it
        AgentRegistrationRequest zReq = request;
        AgentRegistrationResults zResults = results;

        writeObjects("b.obj", zReq, zResults);

        // Try to re-register changes to host and/or port but do not send any token.
        // Because there is no token, these should fail.
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

    @Test(dependsOnMethods = "testChangeAddressPort")
    public void testNormalAgentRegistration() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest aReq = createRequest(prefixName("A"), A_HOST, A_PORT, null);
        AgentRegistrationResults aResults = service.registerAgent(aReq);
        assert aResults != null : "got null results";

        writeObjects("a.obj", aReq, aResults);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);

        objs = readObjects("b.obj", 2);
        @SuppressWarnings("unused")
        AgentRegistrationRequest zReq = (AgentRegistrationRequest) objs.get(0);
        AgentRegistrationResults zResults = (AgentRegistrationResults) objs.get(1);

        request = createRequest(aReq.getName(), aReq.getAddress(), aReq.getPort(), zResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack agent A using Z's token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, aReq.getPort(), zResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack agent A using Z's token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), aReq.getAddress(), B_PORT, zResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack agent A using Z's token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, B_PORT, zResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack agent A using Z's token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

    public void testAgentHijackingAnotherAgentAddressPort() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;
        List<Object> objs = readObjects("a.obj", 2);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);
        AgentRegistrationResults aResults = (AgentRegistrationResults) objs.get(1);

        objs = readObjects("b.obj", 1);
        AgentRegistrationRequest zReq = (AgentRegistrationRequest) objs.get(0);

        request = createRequest(aReq.getName(), zReq.getAddress(), zReq.getPort(), aResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "An agent should not have been able to hijack another agent's host/port";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;

        List<Object> objs = readObjects("b.obj", 2);
        AgentRegistrationRequest zReq = (AgentRegistrationRequest) objs.get(0);
        AgentRegistrationResults zResults = (AgentRegistrationResults) objs.get(1);

        request = createRequest(prefixName("newName"), zReq.getAddress(), zReq.getPort(), zResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "An agent should not be able to change its name";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationResults

        assert agentInstall.getInstallLocation() == null : "there should be no install location yet";

        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest aReq = createRequest(prefixName(".AgentInstall"), A_HOST, A_PORT, null,
            String.valueOf(agentInstall.getId()), "/tmp/CoreServerServiceImplTest/rhq-agent");
        AgentRegistrationResults aResults = service.registerAgent(aReq);
        assert aResults != null : "got null results";

        persistedAgentInstall = agentManager.getAgentInstallByAgentName(sm.getOverlord(), aReq.getName());
        assert persistedAgentInstall != null : "the new agent info is missing";
        assert persistedAgentInstall.getAgentName().equals(aReq.getName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.