use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method syncServiceInstance.
/**
* The service-instance model list is build as a result of synchronizing virtual-machines.
* @return
*/
public boolean syncServiceInstance() {
final ApiConnector api = _manager.getApiConnector();
boolean inSync;
try {
@SuppressWarnings("unchecked") List<ServiceInstance> siList = (List<ServiceInstance>) api.list(ServiceInstance.class, null);
java.util.Collections.sort(siList, new ServiceInstanceComparator());
DBSyncGeneric.SyncStats stats = new DBSyncGeneric.SyncStats();
_dbSync.syncCollections(ServiceInstance.class, _manager.getDatabase().getServiceInstances(), siList, _rwMode, stats);
inSync = stats.create == 0 && stats.delete == 0;
} catch (Exception ex) {
s_logger.warn("synchronize service-instances", ex);
return false;
}
return inSync;
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method deleteDefault.
public void deleteDefault(ApiObjectBase vnc, Class<?> cls, StringBuffer syncLogMesg) throws IOException {
final ApiConnector api = _manager.getApiConnector();
api.delete(vnc);
syncLogMesg.append(cls.getCanonicalName() + "# VNC: " + vnc.getName() + " deleted\n");
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method syncNetworkPolicy.
/*
* Network Policy Synchronization methods
*/
@SuppressWarnings({ "unchecked" })
public boolean syncNetworkPolicy() throws Exception {
final ApiConnector api = _manager.getApiConnector();
try {
List<NetworkACLVO> dbAcls = _manager.findManagedACLs();
if (dbAcls == null) {
dbAcls = new ArrayList<NetworkACLVO>();
}
List<NetworkPolicy> pList = (List<NetworkPolicy>) api.list(NetworkPolicy.class, null);
List<NetworkPolicy> vncList = new ArrayList<NetworkPolicy>();
for (NetworkPolicy policy : pList) {
if (!_manager.isSystemDefaultNetworkPolicy(policy)) {
vncList.add(policy);
}
}
s_logger.debug("sync Network Policy - DB size: " + dbAcls.size() + " VNC Size: " + vncList.size());
return _dbSync.syncGeneric(NetworkPolicy.class, dbAcls, vncList);
} catch (Exception ex) {
s_logger.warn("sync network-policys", ex);
throw ex;
}
}
use of net.juniper.contrail.api.ApiConnector in project cloudstack by apache.
the class ServerDBSyncImpl method createProject.
@Override
public void createProject(ProjectVO db, StringBuffer syncLogMesg) throws IOException {
final ApiConnector api = _manager.getApiConnector();
net.juniper.contrail.api.types.Project vnc = new net.juniper.contrail.api.types.Project();
vnc.setName(db.getName());
vnc.setUuid(db.getUuid());
if (!api.create(vnc)) {
s_logger.error("Unable to create project: " + vnc.getName());
syncLogMesg.append("Error: Virtual project# VNC : Unable to create project: " + vnc.getName() + "\n");
return;
}
syncLogMesg.append("Project# VNC: " + vnc.getName() + " created \n");
}
Aggregations