use of org.apache.cloudstack.api.response.AlertResponse in project cloudstack by apache.
the class ListAlertsCmd method execute.
@Override
public void execute() {
Pair<List<? extends Alert>, Integer> result = _mgr.searchForAlerts(this);
ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
for (Alert alert : result.first()) {
AlertResponse alertResponse = new AlertResponse();
alertResponse.setId(alert.getUuid());
alertResponse.setAlertType(alert.getType());
alertResponse.setDescription(alert.getSubject());
alertResponse.setLastSent(alert.getLastSent());
alertResponse.setName(alert.getName());
alertResponse.setObjectName("alert");
alertResponseList.add(alertResponse);
}
response.setResponses(alertResponseList, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.AlertResponse in project cloudstack by apache.
the class KeystoreTest method testUuid.
/*
public void testKeystoreSave() throws Exception {
KeystoreVO ksVo;
ComponentLocator locator = ComponentLocator.getCurrentLocator();
KeystoreDao ksDao = locator.getDao(KeystoreDao.class);
ksDao.save("CPVMCertificate", "CPVMCertificate", "KeyForCertificate", "realhostip.com");
ksVo = ksDao.findByName("CPVMCertificate");
assertTrue(ksVo != null);
assertTrue(ksVo.getCertificate().equals("CPVMCertificate"));
assertTrue(ksVo.getKey().equals("KeyForCertificate"));
assertTrue(ksVo.getDomainSuffix().equals("realhostip.com"));
ksDao.save("CPVMCertificate", "CPVMCertificate Again", "KeyForCertificate Again", "again.realhostip.com");
ksVo = ksDao.findByName("CPVMCertificate");
assertTrue(ksVo != null);
assertTrue(ksVo.getCertificate().equals("CPVMCertificate Again"));
assertTrue(ksVo.getKey().equals("KeyForCertificate Again"));
assertTrue(ksVo.getDomainSuffix().equals("again.realhostip.com"));
ksDao.expunge(ksVo.getId());
}
public void testStripeKey() throws Exception {
Pattern regex = Pattern.compile("(^[\\-]+[^\\-]+[\\-]+[\\n]?)([^\\-]+)([\\-]+[^\\-]+[\\-]+$)");
Matcher m = regex.matcher("-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAm4bLUORp9oM65GV9XrPrbs+K563DjUR1M8mP1HaE+Y4lX5pk\nvQjC/xoEqSs5pxDDWXAkoexvxij8A4AWcsKU1Q+ep2E+GcytBoz8XINGvgb8cQNn\n/4PlVWKp7j5SDDNCfleYvmiRn8k6P4mxVJOHKzwb/IwQcKghyqAF1w==\n-----END RSA PRIVATE KEY-----");
if(m.find()) {
String content = m.group(2);
assertTrue(content.startsWith("MIIEpAIBAAKCAQE"));
assertTrue(content.endsWith("KghyqAF1w==\n"));
} else {
assertTrue(false);
}
}
public void testKeystoreManager() throws Exception {
ComponentLocator locator = ComponentLocator.getCurrentLocator();
KeystoreManagerImpl ksMgr = ComponentLocator.inject(KeystoreManagerImpl.class);
assertTrue(ksMgr.configure("TaskManager", new HashMap<String, Object>()));
assertTrue(ksMgr.start());
ksMgr.saveCertificate("CPVMCertificate", certContent, keyContent, "realhostip.com");
byte[] ksBits = ksMgr.getKeystoreBits("CPVMCertificate", "realhostip", "vmops.com");
assertTrue(ksBits != null);
try {
KeyStore ks = CertificateHelper.loadKeystore(ksBits, "vmops.com");
assertTrue(ks != null);
} catch(Exception e) {
assertTrue(false);
}
KeystoreDao ksDao = locator.getDao(KeystoreDao.class);
KeystoreVO ksVo = ksDao.findByName("CPVMCertificate");
ksDao.expunge(ksVo.getId());
}
*/
public void testUuid() {
UserVmResponse vm = new UserVmResponse();
vm.setId(Long.toString(3L));
/*
vm.setAccountName("admin");
vm.setName("i-2-3-KY");
vm.setDisplayName("i-2-3-KY");
vm.setDomainId(1L);
vm.setDomainName("ROOT");
vm.setCreated(new Date());
vm.setState("Running");
vm.setZoneId(1L);
vm.setZoneName("KY");
vm.setHostId(1L);
vm.setObjectName("virtualmachine");
*/
String result = ApiSerializerHelper.toSerializedString(vm);
System.out.println(result);
// Object obj = ApiSerializerHelper.fromSerializedString(result);
AlertResponse alert = new AlertResponse();
alert.setId("100");
alert.setDescription("Hello");
result = ApiSerializerHelper.toSerializedString(alert);
System.out.println(result);
ApiSerializerHelper.fromSerializedString(result);
}
Aggregations