use of com.cloud.api.response.AlertResponse in project CloudStack-archive by CloudStack-extras.
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(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.toSerializedStringOld(vm);
// String result = "com.cloud.api.response.UserVmResponse/virtualmachine/{\"id\":{\"_tableName\":\"vm_instance\",\"_value\":3},\"name\":\"i-2-3-KY\",\"displayname\":\"i-2-3-KY\",\"account\":\"admin\",\"projectid\":{\"_tableName\":\"projects\"},\"domainid\":{\"_tableName\":\"domain\",\"_value\":1},\"domain\":\"ROOT\",\"created\":\"2011-11-02T21:54:07-0700\",\"state\":\"Running\",\"haenable\":false,\"groupid\":{\"_tableName\":\"instance_group\"},\"zoneid\":{\"_tableName\":\"data_center\",\"_value\":1},\"zonename\":\"KY\",\"hostid\":{\"_tableName\":\"host\",\"_value\":1},\"hostname\":\"xenserver-basic\",\"templateid\":{\"_tableName\":\"vm_template\",\"_value\":2},\"templatename\":\"CentOS 5.3(64-bit) no GUI (XenServer)\",\"templatedisplaytext\":\"CentOS 5.3(64-bit) no GUI (XenServer)\",\"passwordenabled\":false,\"isoid\":{\"_tableName\":\"vm_template\"},\"serviceofferingid\":{\"_tableName\":\"disk_offering\",\"_value\":7},\"serviceofferingname\":\"Small Instance\",\"cpunumber\":1,\"cpuspeed\":500,\"memory\":512,\"guestosid\":{\"_tableName\":\"guest_os\",\"_value\":12},\"rootdeviceid\":0,\"rootdevicetype\":\"NetworkFilesystem\",\"securitygroup\":[],\"jobid\":{\"_tableName\":\"async_job\"},\"nic\":[{\"id\":7,\"networkid\":200,\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\",\"ipaddress\":\"10.1.1.116\",\"isolationuri\":\"vlan://1699\",\"broadcasturi\":\"vlan://1699\",\"traffictype\":\"Guest\",\"type\":\"Virtual\",\"isdefault\":true,\"macaddress\":\"02:00:39:a7:00:01\"}],\"hypervisor\":\"XenServer\"}";
System.out.println(result);
//Object obj = ApiSerializerHelper.fromSerializedString(result);
AlertResponse alert = new AlertResponse();
alert.setId(100L);
alert.setDescription("Hello");
result = ApiSerializerHelper.toSerializedStringOld(alert);
System.out.println(result);
ApiSerializerHelper.fromSerializedString(result);
}
use of com.cloud.api.response.AlertResponse in project CloudStack-archive by CloudStack-extras.
the class ListAlertsCmd method execute.
@Override
public void execute() {
List<? extends Alert> result = _mgr.searchForAlerts(this);
ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
for (Alert alert : result) {
AlertResponse alertResponse = new AlertResponse();
alertResponse.setId(alert.getId());
alertResponse.setAlertType(alert.getType());
alertResponse.setDescription(alert.getSubject());
alertResponse.setLastSent(alert.getLastSent());
alertResponse.setObjectName("alert");
alertResponseList.add(alertResponse);
}
response.setResponses(alertResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations