use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method syncVirtualNetwork.
/*
* Virtual Network Synchronization methods
*/
@SuppressWarnings({ "unchecked" })
public boolean syncVirtualNetwork() throws Exception {
final ApiConnector api = _manager.getApiConnector();
try {
List<TrafficType> types = new ArrayList<TrafficType>();
types.add(TrafficType.Public);
types.add(TrafficType.Guest);
List<NetworkVO> dbNets = _manager.findManagedNetworks(types);
List<VirtualNetwork> vList = (List<VirtualNetwork>) api.list(VirtualNetwork.class, null);
List<VirtualNetwork> vncList = new ArrayList<VirtualNetwork>();
for (VirtualNetwork vn : vList) {
if (!_manager.isSystemDefaultNetwork(vn)) {
vncList.add(vn);
}
}
s_logger.debug("sync VN - DB size: " + dbNets.size() + " VNC Size: " + vncList.size());
return _dbSync.syncGeneric(VirtualNetwork.class, dbNets, vncList);
} catch (Exception ex) {
s_logger.warn("sync virtual-networks", ex);
throw ex;
}
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method syncProject.
/*
* Project Synchronization methods
*/
@SuppressWarnings("unchecked")
public boolean syncProject() throws Exception {
final ApiConnector api = _manager.getApiConnector();
try {
List<?> dbList = _projectDao.listAll();
List<?> vncList = api.list(net.juniper.contrail.api.types.Project.class, null);
return _dbSync.syncGeneric(net.juniper.contrail.api.types.Project.class, dbList, vncList);
} catch (Exception ex) {
s_logger.warn("syncProject", ex);
throw ex;
}
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method deleteVirtualMachineInterfaces.
private void deleteVirtualMachineInterfaces(List<ObjectReference<ApiPropertyBase>> list, StringBuffer syncLogMesg) throws IOException {
if (list == null) {
return;
}
final ApiConnector api = _manager.getApiConnector();
for (ObjectReference<ApiPropertyBase> vmiRef : list) {
VirtualMachineInterface vmi = (VirtualMachineInterface) api.findById(VirtualMachineInterface.class, vmiRef.getUuid());
deleteInstanceIps(vmi.getInstanceIpBackRefs(), syncLogMesg);
deleteFloatingIps(vmi.getFloatingIpBackRefs(), syncLogMesg);
api.delete(VirtualMachineInterface.class, vmiRef.getUuid());
syncLogMesg.append("VNC vmi: " + vmi.getUuid() + " deleted\n");
}
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method deleteProject.
public void deleteProject(net.juniper.contrail.api.types.Project vnc, StringBuffer syncLogMesg) throws IOException {
final ApiConnector api = _manager.getApiConnector();
api.read(vnc);
syncLogMesg.append("Project# DB: none; VNC: " + vnc.getName() + "(" + vnc.getUuid() + "); action: delete\n");
try {
deleteChildren(vnc.getVirtualNetworks(), VirtualNetwork.class, syncLogMesg);
deleteChildren(vnc.getSecurityGroups(), net.juniper.contrail.api.types.SecurityGroup.class, syncLogMesg);
deleteChildren(vnc.getNetworkIpams(), net.juniper.contrail.api.types.NetworkIpam.class, syncLogMesg);
deleteChildren(vnc.getNetworkPolicys(), net.juniper.contrail.api.types.NetworkPolicy.class, syncLogMesg);
} catch (Exception ex) {
s_logger.warn("deleteProject", ex);
}
api.delete(vnc);
syncLogMesg.append("Project# VNC: " + vnc.getName() + " deleted\n");
}
use of net.juniper.contrail.api.ApiConnector 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");
}
Aggregations