* This function either completes the entire initialization successfully
* or rolls back partial initialization on any failure. In the latter case,
* we will attempt to re-initialize again at a later time on VC use.
*/
public static synchronized void initVcContext() {
AboutInfo info = null;
genCount++;
if (initialized) {
logger.info("VC already initialized");
return;
}
/*
* Don't attempt to relogin into VC on fatal errors (will fail again) or
* when we are in the middle of a shutdown operation (just logged out).
*/
if (fatalInitError) {
logger.warn("Fatal VC init error");
throw VcException.INIT_ERROR();
}
if (shutdown) {
logger.warn("initVcContext during shutdown");
throw VcException.SHUTDOWN_ERROR();
}
/* No partial initialization tolerated. */
AuAssert.check(vcCleaner == null &&
vcService == null &&
eventService == null);
vcCleaner = new VcCleaner();
try {
VmodlContext.getContext();
} catch(IllegalStateException ex) {
//Context has not been initialized. Continue to initialize
VmodlContext.initContext(new String[] { "com.vmware.vim.binding.vim" });
}
try {
vcService = new VcService("VcService");
info = vcService.getServiceInstanceContent().getAbout();
serverGuid = info.getInstanceUuid();
vcVersion = info.getVersion();
} catch (Exception e) {
logger.error("init vc context failed (vc session)");
initFailure(VcException.LOGIN_ERROR(e), null, false); // Retry later.
}
checkVcVersion(info);