private String createSubTemplateLockMessage(VmTemplate template) {
   return String.format(
       "%s$templateName %s$templateId %s",
       EngineMessage.ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_SET_AS_BASE_TEMPLATE,
       template.getName(),
       template.getId());
 }
 @Override
 protected MapSqlParameterSource createFullParametersMapper(VmTemplate template) {
   return createBaseParametersMapper(template)
       .addValue("child_count", template.getChildCount())
       .addValue("name", template.getName())
       .addValue("status", template.getStatus())
       .addValue("is_disabled", template.isDisabled())
       .addValue("template_type", template.getTemplateType().name())
       .addValue("base_template_id", template.getBaseTemplateId())
       .addValue("template_version_name", template.getTemplateVersionName());
 }
  @Override
  protected void readGeneralData(XmlNode content) {
    // General Vm
    XmlNode node = content.SelectSingleNode(OvfProperties.NAME);
    if (node != null) {
      _vmTemplate.setName(node.innerText);
      name = _vmTemplate.getName();
    }
    node = content.SelectSingleNode(OvfProperties.TEMPLATE_ID);
    if (node != null) {
      if (StringUtils.isNotEmpty(node.innerText)) {
        _vmTemplate.setId(new Guid(node.innerText));
      }
    }

    node = content.SelectSingleNode(OvfProperties.IS_DISABLED);
    if (node != null) {
      _vmTemplate.setDisabled(Boolean.parseBoolean(node.innerText));
    }

    node = content.SelectSingleNode(OvfProperties.TRUSTED_SERVICE);
    if (node != null) {
      _vmTemplate.setTrustedService(Boolean.parseBoolean(node.innerText));
    }

    node = content.SelectSingleNode(OvfProperties.TEMPLATE_TYPE);
    if (node != null) {
      _vmTemplate.setTemplateType(VmEntityType.valueOf(node.innerText));
    }

    node = content.SelectSingleNode(OvfProperties.BASE_TEMPLATE_ID);
    if (node != null) {
      _vmTemplate.setBaseTemplateId(Guid.createGuidFromString(node.innerText));
    } else {
      // in case base template is missing, we assume it is a base template
      _vmTemplate.setBaseTemplateId(_vmTemplate.getId());
    }

    node = content.SelectSingleNode(OvfProperties.TEMPLATE_VERSION_NUMBER);
    if (node != null) {
      _vmTemplate.setTemplateVersionNumber(Integer.parseInt(node.innerText));
    }

    node = content.SelectSingleNode(OvfProperties.TEMPLATE_VERSION_NAME);
    if (node != null) {
      _vmTemplate.setTemplateVersionName(node.innerText);
    }

    node = content.SelectSingleNode("AutoStartup");
    if (node != null) {
      _vmTemplate.setAutoStartup(Boolean.parseBoolean(node.innerText));
    }
  }
Exemple #4
0
 private void loadVmData(VM vm) {
   if (vm.getInterfaces().isEmpty()) {
     vm.setInterfaces(getDbFacade().getVmNetworkInterfaceDao().getAllForVm(vm.getId()));
   }
   if (StringUtils.isEmpty(vm.getVmtName())) {
     if (!Guid.Empty.equals(vm.getVmtGuid())) {
       VmTemplate t = getDbFacade().getVmTemplateDao().get(vm.getVmtGuid());
       vm.setVmtName(t.getName());
     } else {
       vm.setVmtName(VmTemplateHandler.BLANK_VM_TEMPLATE_NAME);
     }
   }
 }