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;
}
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());
}
Aggregations