Fix NPE in adding host and also put back lost change in deployDataCenter

due to rebase with master.
This commit is contained in:
Min Chen 2013-05-11 22:00:40 -07:00
parent 1bd216fc48
commit 0d580ccb26
4 changed files with 30 additions and 7 deletions

View File

@ -463,7 +463,9 @@ public class TemplateServiceImpl implements TemplateService {
if (callbackResult.isFailed()) {
template.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
result.setResult(callbackResult.getResult());
parentCallback.complete(result);
if ( parentCallback != null ){
parentCallback.complete(result);
}
return null;
}
@ -471,7 +473,9 @@ public class TemplateServiceImpl implements TemplateService {
template.processEvent(ObjectInDataStoreStateMachine.Event.OperationSuccessed);
} catch (Exception e) {
result.setResult(e.toString());
parentCallback.complete(result);
if ( parentCallback != null ){
parentCallback.complete(result);
}
return null;
}

View File

@ -736,7 +736,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
DataStoreRole.Primary);
}
HostScope scope = new HostScope(host.getId(), pool.getDataCenterId());
HostScope scope = new HostScope(host.getId(), host.getDataCenterId());
lifeCycle.attachHost(store, scope, pInfo);
} catch (Exception e) {
s_logger.warn("Unable to setup the local storage pool for " + host, e);

View File

@ -106,7 +106,7 @@
],
"cacheStorages": [
{
"url": "nfs://192.168.56.10/opt/storage/cache",
"url": "nfs://192.168.56.10/opt/storage/secondary",
"providerName": "NFS",
"details": [
]

View File

@ -138,10 +138,28 @@ class deployDataCenters():
if secondaryStorages is None:
return
for secondary in secondaryStorages:
secondarycmd = addSecondaryStorage.addSecondaryStorageCmd()
secondarycmd = addImageStore.addImageStoreCmd()
secondarycmd.url = secondary.url
secondarycmd.zoneid = zoneId
self.apiClient.addSecondaryStorage(secondarycmd)
secondarycmd.provider = secondary.providerName
secondarycmd.details = []
for item in secondary.details:
secondarycmd.details.append(item.__dict__)
if secondarycmd.provider == "NFS":
secondarycmd.zoneid = zoneId
self.apiClient.addImageStore(secondarycmd)
def createCacheStorages(self, cacheStorages, zoneId):
if cacheStorages is None:
return
for cache in cacheStorages:
cachecmd = createCacheStore.createCacheStoreCmd()
cachecmd.url = cache.url
cachecmd.provider = cache.providerName
cachecmd.zoneid = zoneId
cachecmd.details = []
for item in cache.details:
cachecmd.details.append(item.__dict__)
self.apiClient.createCacheStore(cachecmd)
def createnetworks(self, networks, zoneId):
if networks is None:
@ -328,6 +346,7 @@ class deployDataCenters():
zoneId)
self.createSecondaryStorages(zone.secondaryStorages, zoneId)
self.createCacheStorages(zone.cacheStorages, zoneId)
enabled = getattr(zone, 'enabled', 'True')
if enabled == 'True' or enabled is None: