public boolean validateCustomProperties(List<String> messages) { StoragePool dataCenter = getDbFacade().getStoragePoolDao().get(getNetwork().getDataCenterId()); List<ValidationError> errors = DevicePropertiesUtils.getInstance() .validateProperties( dataCenter.getCompatibilityVersion(), VmDeviceGeneralType.INTERFACE, vnicProfile.getCustomProperties()); if (!errors.isEmpty()) { DevicePropertiesUtils.getInstance().handleCustomPropertiesError(errors, messages); return false; } return true; }
/** * This method is called upon the bean creation as part of the management Service bean life cycle. */ @Override @PostConstruct public void create() { try { // This must be done before starting to sample the hosts status from VDSM since the sampling // will turn such host from Reboot to NonResponsive loadService(PmHealthCheckManager.class); loadService(EngineBackupAwarenessManager.class); CommandCoordinatorUtil.initAsyncTaskManager(); loadService(ResourceManager.class); OvfDataUpdater.getInstance().initOvfDataUpdater(); ThreadPoolUtil.execute( new Runnable() { @Override public void run() { MacPoolPerDcSingleton.getInstance().initialize(); } }); StoragePoolStatusHandler.init(); GlusterJobsManager.init(); try { log.info("Init VM custom properties utilities"); VmPropertiesUtils.getInstance().init(); } catch (InitializationException e) { log.error("Initialization of vm custom properties failed.", e); } try { log.info("Init device custom properties utilities"); DevicePropertiesUtils.getInstance().init(); } catch (InitializationException e) { log.error("Initialization of device custom properties failed.", e); } loadService(SchedulingManager.class); SessionDataContainer.getInstance().cleanupEngineSessionsOnStartup(); loadService(HostDeviceManager.class); loadService(DwhHeartBeat.class); if (Config.<Boolean>getValue(ConfigValues.AffinityRulesEnforcementManagerEnabled)) { loadService(AffinityRulesEnforcementManager.class); } loadService(CertificationValidityChecker.class); } catch (Exception ex) { log.error("Failed to initialize backend", ex); throw ex; } }
/** Reads vm device attributes from OVF and stores it in the collection */ private VmDevice readVmDevice(XmlNode node, Guid deviceId) { VmDevice vmDevice = new VmDevice(); vmDevice.setId(new VmDeviceId(deviceId, vmBase.getId())); if (selectSingleNode(node, OvfProperties.VMD_ADDRESS, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_ADDRESS, _xmlNS).innerText)) { vmDevice.setAddress( String.valueOf(selectSingleNode(node, OvfProperties.VMD_ADDRESS, _xmlNS).innerText)); } else { vmDevice.setAddress(""); } if (selectSingleNode(node, OvfProperties.VMD_ALIAS, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_ALIAS, _xmlNS).innerText)) { vmDevice.setAlias( String.valueOf(selectSingleNode(node, OvfProperties.VMD_ALIAS, _xmlNS).innerText)); } else { vmDevice.setAlias(""); } XmlNode specParamsNode = selectSingleNode(node, OvfProperties.VMD_SPEC_PARAMS, _xmlNS); if (specParamsNode != null && !StringUtils.isEmpty(specParamsNode.innerText)) { vmDevice.setSpecParams(getMapNode(specParamsNode)); } else { // Empty map vmDevice.setSpecParams(Collections.<String, Object>emptyMap()); } if (selectSingleNode(node, OvfProperties.VMD_TYPE, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, OvfProperties.VMD_TYPE, _xmlNS).innerText)) { vmDevice.setType( VmDeviceGeneralType.forValue( String.valueOf(selectSingleNode(node, OvfProperties.VMD_TYPE, _xmlNS).innerText))); } else { int resourceType = getResourceType(node, OvfProperties.VMD_RESOURCE_TYPE); vmDevice.setType(VmDeviceGeneralType.forValue(VmDeviceType.getoVirtDevice(resourceType))); } if (selectSingleNode(node, OvfProperties.VMD_DEVICE, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_DEVICE, _xmlNS).innerText)) { vmDevice.setDevice( String.valueOf(selectSingleNode(node, OvfProperties.VMD_DEVICE, _xmlNS).innerText)); } else { setDeviceByResource(node, vmDevice); } if (selectSingleNode(node, OvfProperties.VMD_BOOT_ORDER, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_BOOT_ORDER, _xmlNS).innerText)) { vmDevice.setBootOrder( Integer.parseInt(selectSingleNode(node, OvfProperties.VMD_BOOT_ORDER, _xmlNS).innerText)); } else { vmDevice.setBootOrder(0); } if (selectSingleNode(node, OvfProperties.VMD_IS_PLUGGED, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_IS_PLUGGED, _xmlNS).innerText)) { vmDevice.setIsPlugged( Boolean.valueOf(selectSingleNode(node, OvfProperties.VMD_IS_PLUGGED, _xmlNS).innerText)); } else { vmDevice.setIsPlugged(Boolean.TRUE); } if (selectSingleNode(node, OvfProperties.VMD_IS_READONLY, _xmlNS) != null && !StringUtils.isEmpty( selectSingleNode(node, OvfProperties.VMD_IS_READONLY, _xmlNS).innerText)) { vmDevice.setIsReadOnly( Boolean.valueOf(selectSingleNode(node, OvfProperties.VMD_IS_READONLY, _xmlNS).innerText)); } else { vmDevice.setIsReadOnly(Boolean.FALSE); } if (selectSingleNode(node, OvfProperties.VMD_CUSTOM_PROP, _xmlNS) != null && StringUtils.isNotEmpty( selectSingleNode(node, OvfProperties.VMD_CUSTOM_PROP, _xmlNS).innerText)) { vmDevice.setCustomProperties( DevicePropertiesUtils.getInstance() .convertProperties( String.valueOf( selectSingleNode(node, OvfProperties.VMD_CUSTOM_PROP, _xmlNS).innerText))); } else { vmDevice.setCustomProperties(null); } if (selectSingleNode(node, OvfProperties.VMD_SNAPSHOT_PROP, _xmlNS) != null && StringUtils.isNotEmpty( selectSingleNode(node, OvfProperties.VMD_SNAPSHOT_PROP, _xmlNS).innerText)) { vmDevice.setSnapshotId( new Guid( String.valueOf( selectSingleNode(node, OvfProperties.VMD_CUSTOM_PROP, _xmlNS).innerText))); } return vmDevice; }