use of net.juniper.contrail.api.ApiObjectBase in project cloudstack by apache.
the class ServerDBSyncImpl method deleteChildren.
public <T extends ApiPropertyBase> void deleteChildren(List<ObjectReference<T>> childs, Class<?> childCls, StringBuffer syncLogMesg) throws Exception {
final ApiConnector api = _manager.getApiConnector();
if (childs == null) {
syncLogMesg.append("no children of type: " + childCls.getName() + "\n");
return;
}
syncLogMesg.append("delete children of type : " + DBSyncGeneric.getClassName(childCls) + "\n");
String deleteChildMethod = "delete" + DBSyncGeneric.getClassName(childCls);
Method method = null;
Method[] methods = this.getClass().getMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equalsIgnoreCase(deleteChildMethod)) {
method = methods[i];
break;
}
}
int count = 0;
for (ObjectReference<T> childRef : childs) {
@SuppressWarnings("unchecked") ApiObjectBase child = api.findById((Class<? extends ApiObjectBase>) childCls, childRef.getUuid());
if (method != null) {
method.invoke(this, child, syncLogMesg);
} else {
deleteDefault(child, childCls, syncLogMesg);
}
count++;
}
syncLogMesg.append("deleted children count : " + count + "\n");
}
use of net.juniper.contrail.api.ApiObjectBase in project cloudstack by apache.
the class PublicNetworkTest method testPublicNetwork.
@Test
public void testPublicNetwork() throws IOException {
DataCenter zone = _server.getZone();
List<NetworkVO> networks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Public);
assertNotNull(networks);
assertFalse(networks.isEmpty());
UserVm vm1 = _server.createVM("test", networks.get(0));
ArgumentCaptor<ApiObjectBase> createArg = ArgumentCaptor.forClass(ApiObjectBase.class);
verify(_spy, times(4)).create(createArg.capture());
List<ApiObjectBase> argumentList = createArg.getAllValues();
ApiObjectBase vmObj = argumentList.get(0);
assertEquals(VirtualNetwork.class, vmObj.getClass());
assertEquals("__default_Public__", vmObj.getName());
String vmiName = null;
for (ApiObjectBase obj : argumentList) {
if (obj.getClass() == VirtualMachineInterface.class) {
vmiName = obj.getName();
}
}
assertEquals("test-0", vmiName);
}
Aggregations