Search in sources :

Example 1 with ListTemplateCommand

use of com.cloud.legacymodel.communication.command.ListTemplateCommand in project cosmic by MissionCriticalCloud.

the class TemplateServiceImpl method listTemplate.

private Map<String, TemplateProp> listTemplate(final DataStore ssStore) {
    final ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getTO());
    final EndPoint ep = _epSelector.select(ssStore);
    Answer answer = null;
    if (ep == null) {
        final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
        s_logger.error(errMsg);
        answer = new Answer(cmd, false, errMsg);
    } else {
        answer = ep.sendMessage(cmd);
    }
    if (answer != null && answer.getResult()) {
        final ListTemplateAnswer tanswer = (ListTemplateAnswer) answer;
        return tanswer.getTemplateInfo();
    } else {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("can not list template for secondary storage host " + ssStore.getId());
        }
    }
    return null;
}
Also used : ListTemplateAnswer(com.cloud.legacymodel.communication.answer.ListTemplateAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) ListTemplateAnswer(com.cloud.legacymodel.communication.answer.ListTemplateAnswer) ListTemplateCommand(com.cloud.legacymodel.communication.command.ListTemplateCommand) EndPoint(com.cloud.engine.subsystem.api.storage.EndPoint)

Example 2 with ListTemplateCommand

use of com.cloud.legacymodel.communication.command.ListTemplateCommand in project cosmic by MissionCriticalCloud.

the class RequestTest method testSerDeserTO.

@Test
public void testSerDeserTO() {
    s_logger.info("Testing serializing and deserializing interface TO works as expected");
    final NfsTO nfs = new NfsTO("nfs://192.168.56.10/opt/storage/secondary", DataStoreRole.Image);
    // SecStorageSetupCommand cmd = new SecStorageSetupCommand(nfs, "nfs://192.168.56.10/opt/storage/secondary", null);
    final ListTemplateCommand cmd = new ListTemplateCommand(nfs);
    final Request sreq = new Request(2, 3, cmd, true);
    sreq.setSequence(892403718);
    final byte[] bytes = sreq.getBytes();
    assert Request.getSequence(bytes) == 892403718;
    assert Request.getManagementServerId(bytes) == 3;
    assert Request.getAgentId(bytes) == 2;
    assert Request.getViaAgentId(bytes) == 2;
    Request creq = null;
    try {
        creq = Request.parse(bytes);
    } catch (final ClassNotFoundException e) {
        s_logger.error("Unable to parse bytes: ", e);
    } catch (final UnsupportedVersionException e) {
        s_logger.error("Unable to parse bytes: ", e);
    }
    assert creq != null : "Couldn't get the request back";
    compareRequest(creq, sreq);
    assertEquals("nfs://192.168.56.10/opt/storage/secondary", ((NfsTO) ((ListTemplateCommand) creq.getCommand()).getDataStore()).getUrl());
}
Also used : ListTemplateCommand(com.cloud.legacymodel.communication.command.ListTemplateCommand) NfsTO(com.cloud.legacymodel.to.NfsTO) UnsupportedVersionException(com.cloud.legacymodel.exceptions.UnsupportedVersionException) Test(org.junit.Test)

Aggregations

ListTemplateCommand (com.cloud.legacymodel.communication.command.ListTemplateCommand)2 EndPoint (com.cloud.engine.subsystem.api.storage.EndPoint)1 Answer (com.cloud.legacymodel.communication.answer.Answer)1 ListTemplateAnswer (com.cloud.legacymodel.communication.answer.ListTemplateAnswer)1 UnsupportedVersionException (com.cloud.legacymodel.exceptions.UnsupportedVersionException)1 NfsTO (com.cloud.legacymodel.to.NfsTO)1 Test (org.junit.Test)1