mirror of https://github.com/apache/cloudstack.git
Make sure that Cloudstack DB should be atleast once synced with contrail api server
Signed-off-by: Sheng Yang <sheng.yang@citrix.com>
This commit is contained in:
parent
69365836af
commit
65f639219c
|
|
@ -54,7 +54,7 @@ public interface ContrailManager {
|
|||
public NetworkOffering getRouterOffering();
|
||||
public NetworkOffering getPublicRouterOffering();
|
||||
|
||||
public void syncNetworkDB(short syncMode) throws IOException;
|
||||
public void syncNetworkDB(short syncMode) throws Exception;
|
||||
|
||||
public boolean isManagedPhysicalNetwork(Network network);
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
|
||||
}
|
||||
|
||||
public void syncNetworkDB(short syncMode) throws IOException {
|
||||
public void syncNetworkDB(short syncMode) throws Exception {
|
||||
if (_dbSync.syncAll(syncMode) == ServerDBSync.SYNC_STATE_OUT_OF_SYNC) {
|
||||
if (syncMode == DBSyncGeneric.SYNC_MODE_CHECK) {
|
||||
s_logger.info("# Cloudstack DB & VNC are out of sync #");
|
||||
|
|
@ -440,6 +440,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
|||
} catch (Exception ex) {
|
||||
s_logger.debug(ex);
|
||||
s_logger.info("Unable to sync network db");
|
||||
//resync will be done after _dbSyncInterval seconds since _syncMode is still set to SYNC_MODE_UPDATE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public interface ServerDBSync {
|
|||
* API for syncing all classes of vnc objects with cloudstack
|
||||
* Sync cloudstack and vnc objects.
|
||||
*/
|
||||
public short syncAll(short syncMode);
|
||||
public short syncAll(short syncMode) throws Exception;
|
||||
public void syncClass(Class<?> cls);
|
||||
public void createProject(ProjectVO project, StringBuffer syncLogMesg) throws IOException;
|
||||
public void createDomain(DomainVO domain, StringBuffer logMesg)throws IOException;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class ServerDBSyncImpl implements ServerDBSync {
|
|||
* Order has to be maintained
|
||||
*/
|
||||
@Override
|
||||
public short syncAll(short syncMode) {
|
||||
public short syncAll(short syncMode) throws Exception {
|
||||
short syncState = SYNC_STATE_IN_SYNC;
|
||||
|
||||
/* vnc classes need to be synchronized with cloudstack */
|
||||
|
|
@ -158,6 +158,7 @@ public class ServerDBSyncImpl implements ServerDBSync {
|
|||
if (_lockSyncMode.isLocked()) {
|
||||
_lockSyncMode.unlock();
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return syncState;
|
||||
|
|
|
|||
|
|
@ -462,15 +462,19 @@ public class NetworkProviderTest extends TestCase {
|
|||
} catch (IOException ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
//now db sync
|
||||
if (_dbSync.syncAll(DBSyncGeneric.SYNC_MODE_UPDATE) == ServerDBSync.SYNC_STATE_OUT_OF_SYNC) {
|
||||
s_logger.info("# Cloudstack DB & VNC are out of sync - resync done");
|
||||
}
|
||||
|
||||
if (_dbSync.syncAll(DBSyncGeneric.SYNC_MODE_CHECK) == ServerDBSync.SYNC_STATE_OUT_OF_SYNC) {
|
||||
s_logger.info("# Cloudstack DB & VNC are still out of sync");
|
||||
fail("DB Sync failed");
|
||||
try {
|
||||
if (_dbSync.syncAll(DBSyncGeneric.SYNC_MODE_UPDATE) == ServerDBSync.SYNC_STATE_OUT_OF_SYNC) {
|
||||
s_logger.info("# Cloudstack DB & VNC are out of sync - resync done");
|
||||
}
|
||||
|
||||
if (_dbSync.syncAll(DBSyncGeneric.SYNC_MODE_CHECK) == ServerDBSync.SYNC_STATE_OUT_OF_SYNC) {
|
||||
s_logger.info("# Cloudstack DB & VNC are still out of sync");
|
||||
fail("DB Sync failed");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
fail(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue