@Test public void containsVMWithThatOvfIdTest() { boolean response = OVFUtils.containsVMWithThatOvfId(threeTierWebAppOvfString, "haproxy"); assertTrue(response); response = OVFUtils.containsVMWithThatOvfId(threeTierWebAppOvfString, "pepito"); assertFalse(response); response = OVFUtils.containsVMWithThatOvfId(threeTierWebAppOvfString, null); assertFalse(response); }
public static boolean containsVMWithThatOvfId(String ovf, String ovfId) { if(ovfId == null) { return false; } try { OvfDefinition ovfDocument = OvfDefinition.Factory.newInstance(ovf); VirtualSystemCollection vsc = ovfDocument.getVirtualSystemCollection(); for(int i = 0; i < vsc.getVirtualSystemArray().length; i++) { VirtualSystem virtualSystem = vsc.getVirtualSystemAtIndex(i); String ovfVirtualSystemID = virtualSystem.getId(); if(ovfId.equals(ovfVirtualSystemID)) { return true; } } } catch(OvfRuntimeException ex) { logger.info("Error parsing OVF file: " + ex.getMessage()); ex.printStackTrace(); return false; } return false; }
OVFUtils { public static boolean containsVMWithThatOvfId(String ovf, String ovfId) { if(ovfId == null) { return false; } try { OvfDefinition ovfDocument = OvfDefinition.Factory.newInstance(ovf); VirtualSystemCollection vsc = ovfDocument.getVirtualSystemCollection(); for(int i = 0; i < vsc.getVirtualSystemArray().length; i++) { VirtualSystem virtualSystem = vsc.getVirtualSystemAtIndex(i); String ovfVirtualSystemID = virtualSystem.getId(); if(ovfId.equals(ovfVirtualSystemID)) { return true; } } } catch(OvfRuntimeException ex) { logger.info("Error parsing OVF file: " + ex.getMessage()); ex.printStackTrace(); return false; } return false; } }
OVFUtils { public static boolean containsVMWithThatOvfId(String ovf, String ovfId) { if(ovfId == null) { return false; } try { OvfDefinition ovfDocument = OvfDefinition.Factory.newInstance(ovf); VirtualSystemCollection vsc = ovfDocument.getVirtualSystemCollection(); for(int i = 0; i < vsc.getVirtualSystemArray().length; i++) { VirtualSystem virtualSystem = vsc.getVirtualSystemAtIndex(i); String ovfVirtualSystemID = virtualSystem.getId(); if(ovfId.equals(ovfVirtualSystemID)) { return true; } } } catch(OvfRuntimeException ex) { logger.info("Error parsing OVF file: " + ex.getMessage()); ex.printStackTrace(); return false; } return false; }  }
OVFUtils { public static boolean containsVMWithThatOvfId(String ovf, String ovfId) { if(ovfId == null) { return false; } try { OvfDefinition ovfDocument = OvfDefinition.Factory.newInstance(ovf); VirtualSystemCollection vsc = ovfDocument.getVirtualSystemCollection(); for(int i = 0; i < vsc.getVirtualSystemArray().length; i++) { VirtualSystem virtualSystem = vsc.getVirtualSystemAtIndex(i); String ovfVirtualSystemID = virtualSystem.getId(); if(ovfId.equals(ovfVirtualSystemID)) { return true; } } } catch(OvfRuntimeException ex) { logger.info("Error parsing OVF file: " + ex.getMessage()); ex.printStackTrace(); return false; } return false; }  static String getApplicationName(String ovf); static String getDeploymentName(String ovf); static OvfDefinition getOvfDefinition(String ovf); static int getDiskCapacityInGb(int capacity, String units); static String getIsoPathFromVm(VirtualHardwareSection virtHwSection, OvfDefinition ovfDocument); static boolean usesACacheImage(VirtualSystem virtualSystem1); static boolean containsVMWithThatOvfId(String ovf, String ovfId); static VMLimits getUpperAndLowerVMlimits(VirtualSystem virtualSystem); static int getPriceSchema(ProductSection productSection); static ProductSection getProductionSectionForOvfID(String ovf, String ovfId); static VirtualSystem getVirtualSystemForOvfId(String ovf, String ovfId); static String getDiskId(VirtualHardwareSection virtualHardwareSection); static int getCapacity(OvfDefinition ovfDocument, String diskId); static String getFileId(String diskId, Disk[] diskList); static String getUrlImg(OvfDefinition ovfDocument, String fileId); static AsceticSLAInfo getVMSlaInfo(OvfDefinition ovfDocument, String slaInfoTerm, String ovfId); static AsceticSLAInfo getAppSlaInfo(OvfDefinition ovfDocument, String slaInfoTerm); static List<AsceticTermMeasurement> getVMTermMeasurement(OvfDefinition ovfDocument, String ovfId); static List<String> getOVFVMIds(OvfDefinition ovfDocument); }
OVFUtils { public static boolean containsVMWithThatOvfId(String ovf, String ovfId) { if(ovfId == null) { return false; } try { OvfDefinition ovfDocument = OvfDefinition.Factory.newInstance(ovf); VirtualSystemCollection vsc = ovfDocument.getVirtualSystemCollection(); for(int i = 0; i < vsc.getVirtualSystemArray().length; i++) { VirtualSystem virtualSystem = vsc.getVirtualSystemAtIndex(i); String ovfVirtualSystemID = virtualSystem.getId(); if(ovfId.equals(ovfVirtualSystemID)) { return true; } } } catch(OvfRuntimeException ex) { logger.info("Error parsing OVF file: " + ex.getMessage()); ex.printStackTrace(); return false; } return false; }  static String getApplicationName(String ovf); static String getDeploymentName(String ovf); static OvfDefinition getOvfDefinition(String ovf); static int getDiskCapacityInGb(int capacity, String units); static String getIsoPathFromVm(VirtualHardwareSection virtHwSection, OvfDefinition ovfDocument); static boolean usesACacheImage(VirtualSystem virtualSystem1); static boolean containsVMWithThatOvfId(String ovf, String ovfId); static VMLimits getUpperAndLowerVMlimits(VirtualSystem virtualSystem); static int getPriceSchema(ProductSection productSection); static ProductSection getProductionSectionForOvfID(String ovf, String ovfId); static VirtualSystem getVirtualSystemForOvfId(String ovf, String ovfId); static String getDiskId(VirtualHardwareSection virtualHardwareSection); static int getCapacity(OvfDefinition ovfDocument, String diskId); static String getFileId(String diskId, Disk[] diskList); static String getUrlImg(OvfDefinition ovfDocument, String fileId); static AsceticSLAInfo getVMSlaInfo(OvfDefinition ovfDocument, String slaInfoTerm, String ovfId); static AsceticSLAInfo getAppSlaInfo(OvfDefinition ovfDocument, String slaInfoTerm); static List<AsceticTermMeasurement> getVMTermMeasurement(OvfDefinition ovfDocument, String ovfId); static List<String> getOVFVMIds(OvfDefinition ovfDocument);  }