コード例 #1
0
  public void testShouldExportIPManifestAsString() throws XmlException {
    // given a new IP Manifest exists

    Manifest im = Manifest.Factory.newInstance(getManifest().toXmlBeanObject());

    // when we export the manifest as string
    String exportedManifest = im.toString();

    // then both manifests are equal
    assertTrue(
        "exported string does not match orginal",
        exportedManifest.equals(getManifest().toString()));
  }
コード例 #2
0
  private void getManifestValues(String instanceId, Manifest mani) {

    System.out.println("instanceId: " + instanceId);
    // Get IP Extensions
    VirtualHardwareSection vhs =
        mani.getInfrastructureProviderExtensions()
            .getVirtualSystem(instanceId)
            .getVirtualHardwareSection();

    int vhscpuSpeed = vhs.getCPUSpeed();
    int vhsMemorySize = vhs.getMemorySize();
    int vhsNumCPU = vhs.getNumberOfVirtualCPUs();

    System.out.println("smcpuspeed " + vhscpuSpeed);
    System.out.println("smmemorysize " + vhsMemorySize);
    System.out.println("smnumcpu " + vhsNumCPU);
  }
コード例 #3
0
  public SetAdmissionControlDecision(String serviceManifest, String ACdecision, Logger log) {
    log.info("Ready to attach AdmissionControlDecision to SM");

    // log.info("serviceManifest : "+serviceManifest);
    // Manifest ipManifest = Manifest.Factory.newInstance(serviceManifest);

    Manifest ipManifest = null;
    try {
      // ipManifest = Manifest.Factory.newInstance(serviceManifest);

      ipManifest = eu.optimis.manifest.api.ip.Manifest.Factory.newInstance(serviceManifest);

      // XmlBeanServiceManifestDocument xmlBeanManifest =
      // XmlBeanServiceManifestDocument.Factory.parse(serviceManifest);

      // ipManifest = Manifest.Factory.newInstance(xmlBeanManifest);

      if (ipManifest.isSetInfrastructureProviderExtensions())
        if (ipManifest.getInfrastructureProviderExtensions().isSetAllocationOffer())
          ipManifest.getInfrastructureProviderExtensions().unsetAllocationOffer();
      /*
      } catch (XmlException x) {
      	String Message="XmlException "+x.getMessage();
      	System.out.println(Message);
      	log.error(x.getMessage());
      	x.printStackTrace();
      */
    } catch (RuntimeException re) {
      String Message = "RuntimeException " + re.getMessage();
      System.out.println(Message);
      log.error(re.getMessage());
      // e.printStackTrace();

    } catch (Exception e) {
      String Message = "RuntimeException " + e.getMessage();
      System.out.println(Message);
      log.error(e.getMessage());
      // e.printStackTrace();

    }

    ipManifest.initializeInfrastructureProviderExtensions();

    log.info("initializeInfrastructureProviderExtensions");

    String AdmissionControlDecision = null;

    if (ACdecision.contains("Accepted"))
      AdmissionControlDecision = AllocationOfferDecision.accepted.toString();
    else if (ACdecision.contains("Rejected"))
      AdmissionControlDecision = AllocationOfferDecision.rejected.toString();
    else if (ACdecision.contains("Partial accepted"))
      AdmissionControlDecision = AllocationOfferDecision.partial.toString();

    ipManifest.getInfrastructureProviderExtensions().addNewAllocationOffer();
    ipManifest
        .getInfrastructureProviderExtensions()
        .getAllocationOffer()
        .setDecision(AdmissionControlDecision);

    String smg = " ACdecision " + AdmissionControlDecision + " Attached to SM";
    System.out.println(smg);
    log.info(smg);

    // serviceManifestWithACdecision = ipManifest.toString();

    try {
      serviceManifestWithACdecision = ipManifest.toString();

    } catch (Exception e) {
      String Message = "RuntimeException " + e.getMessage() + " Ignored";
      System.out.println(Message);
      log.error(e.getMessage());
      e.printStackTrace();
    }

    log.info("Finish of attach AdmissionControlDecision to SM");
  } // constructor
コード例 #4
0
 public void testShouldLoadManifestFromFile() throws XmlException, IOException {
   InputStream in = this.getClass().getResourceAsStream("/SP-ManifestExample.xml");
   XmlBeanServiceManifestDocument doc = XmlBeanServiceManifestDocument.Factory.parse(in);
   Manifest manifest = Manifest.Factory.newInstance(doc);
   assertFalse(manifest.hasErrors());
 }
コード例 #5
0
 @Override
 public void replaceServiceManifest(Manifest serviceManifest) {
   delegate.setServiceManifest(serviceManifest.toXmlBeanObject().getServiceManifest());
 }