@Override
    public VmTemplate mapRow(ResultSet rs, int rowNum) throws SQLException {
      final VmTemplate entity = new VmTemplate();
      map(rs, entity);

      entity.setId(getGuidDefaultEmpty(rs, "vmt_guid"));
      entity.setChildCount(rs.getInt("child_count"));
      entity.setName(rs.getString("name"));
      entity.setVdsGroupId(getGuid(rs, "vds_group_id"));
      entity.setAllowConsoleReconnect(rs.getBoolean("allow_console_reconnect"));
      entity.setStatus(VmTemplateStatus.forValue(rs.getInt("status")));
      entity.setVdsGroupName(rs.getString("vds_group_name"));
      entity.setStoragePoolId(getGuid(rs, "storage_pool_id"));
      entity.setStoragePoolName(rs.getString("storage_pool_name"));
      entity.setQuotaName(rs.getString("quota_name"));
      entity.setQuotaEnforcementType(
          QuotaEnforcementTypeEnum.forValue(rs.getInt("quota_enforcement_type")));
      entity.setDisabled(rs.getBoolean("is_disabled"));
      entity.setTrustedService(rs.getBoolean("trusted_service"));
      entity.setTemplateType(VmEntityType.valueOf(rs.getString("entity_type")));
      entity.setClusterArch(ArchitectureType.forValue(rs.getInt("architecture")));
      entity.setBaseTemplateId(getGuidDefaultEmpty(rs, "base_template_id"));
      entity.setTemplateVersionNumber(rs.getInt("template_version_number"));
      entity.setTemplateVersionName(rs.getString("template_version_name"));
      return entity;
    }
Esempio n. 2
0
  @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));
    }
  }
Esempio n. 3
0
 @Override
 protected void readOsSection(XmlNode section) {
   _vmTemplate.setId(new Guid(section.attributes.get("ovf:id").getValue()));
   XmlNode node = section.SelectSingleNode("Description");
   if (node != null) {
     int osId = osRepository.getOsIdByUniqueName(node.innerText);
     _vmTemplate.setOsId(osId);
     _vmTemplate.setClusterArch(osRepository.getArchitectureFromOS(osId));
   } else {
     _vmTemplate.setClusterArch(ArchitectureType.undefined);
   }
 }