Exemplo n.º 1
0
  protected void updateSingleNic(XmlNode node, VmNetworkInterface iface) {
    String networkName = selectSingleNode(node, OvfProperties.VMD_CONNECTION, _xmlNS).innerText;
    iface.setNetworkName(StringUtils.defaultIfEmpty(networkName, null));

    XmlNode vnicProfileNameNode =
        selectSingleNode(node, OvfProperties.VMD_VNIC_PROFILE_NAME, _xmlNS);
    iface.setVnicProfileName(
        vnicProfileNameNode == null
            ? null
            : StringUtils.defaultIfEmpty(vnicProfileNameNode.innerText, null));

    XmlNode linkedNode = selectSingleNode(node, OvfProperties.VMD_LINKED, _xmlNS);
    iface.setLinked(linkedNode == null ? true : Boolean.valueOf(linkedNode.innerText));

    iface.setName(selectSingleNode(node, OvfProperties.VMD_NAME, _xmlNS).innerText);

    String resourceSubType = selectSingleNode(node, "rasd:ResourceSubType", _xmlNS).innerText;
    if (StringUtils.isNotEmpty(resourceSubType)) {
      iface.setType(Integer.parseInt(resourceSubType));
    }

    XmlNode speed = selectSingleNode(node, "rasd:speed", _xmlNS);
    iface.setSpeed(
        (speed != null)
            ? Integer.parseInt(speed.innerText)
            : VmInterfaceType.forValue(iface.getType()).getSpeed());
  }