/** * Retrieve a storage domain using a specified storage domain ID. * * @param storageDomainId the domain's ID * @return the storage domain */ @SuppressWarnings("unchecked") protected StorageDomain getStorageDomainById(Guid storageDomainId) { VDSReturnValue returnValue; try { returnValue = executeHSMGetStorageDomainInfo( new HSMGetStorageDomainInfoVDSCommandParameters( getParameters().getVdsId(), storageDomainId)); } catch (RuntimeException e) { log.error( "Could not get info for storage domain ID: '{}': {}", storageDomainId, e.getMessage()); log.debug("Exception", e); return null; } Pair<StorageDomainStatic, SANState> result = (Pair<StorageDomainStatic, SANState>) returnValue.getReturnValue(); StorageDomainStatic storageDomainStatic = result.getFirst(); storageDomainStatic.setStorageType(getParameters().getStorageType()); StorageDomain storageDomain = new StorageDomain(); storageDomain.setStorageStaticData(storageDomainStatic); return storageDomain; }
private static Pair<StorageDomainStatic, Guid> BuildStorageStaticFromXmlRpcStruct( Map<String, Object> xmlRpcStruct) { Pair<StorageDomainStatic, Guid> returnValue = new Pair<StorageDomainStatic, Guid>(); StorageDomainStatic sdStatic = new StorageDomainStatic(); if (xmlRpcStruct.containsKey("name")) { sdStatic.setStorageName(xmlRpcStruct.get("name").toString()); } if (xmlRpcStruct.containsKey("type")) { sdStatic.setStorageType( EnumUtils.valueOf(StorageType.class, xmlRpcStruct.get("type").toString(), true)); } if (xmlRpcStruct.containsKey("class")) { String domainType = xmlRpcStruct.get("class").toString(); if ("backup".equalsIgnoreCase(domainType)) { sdStatic.setStorageDomainType(StorageDomainType.ImportExport); } else { sdStatic.setStorageDomainType(EnumUtils.valueOf(StorageDomainType.class, domainType, true)); } } if (xmlRpcStruct.containsKey("version")) { sdStatic.setStorageFormat(StorageFormatType.forValue(xmlRpcStruct.get("version").toString())); } if (sdStatic.getStorageType() != StorageType.UNKNOWN) { if (sdStatic.getStorageType().isFileDomain() && xmlRpcStruct.containsKey("remotePath")) { String path = xmlRpcStruct.get("remotePath").toString(); List<StorageServerConnections> connections = DbFacade.getInstance().getStorageServerConnectionDao().getAllForStorage(path); if (connections.isEmpty()) { sdStatic.setConnection(new StorageServerConnections()); sdStatic.getConnection().setconnection(path); sdStatic.getConnection().setstorage_type(sdStatic.getStorageType()); } else { sdStatic.setStorage(connections.get(0).getid()); sdStatic.setConnection(connections.get(0)); } } else if (sdStatic.getStorageType() != StorageType.NFS && (xmlRpcStruct.containsKey("vguuid"))) { sdStatic.setStorage(xmlRpcStruct.get("vguuid").toString()); } } if (xmlRpcStruct.containsKey("state")) { sdStatic.setSanState( EnumUtils.valueOf( SANState.class, xmlRpcStruct.get("state").toString().toUpperCase(), false)); } returnValue.setFirst(sdStatic); Object[] poolUUIDs = (Object[]) xmlRpcStruct.get("pool"); if (poolUUIDs.length != 0) { returnValue.setSecond(Guid.createGuidFromString(poolUUIDs[0].toString())); } return returnValue; }