Ejemplo n.º 1
0
  /**
   * @param resSpecID
   * @return the OfferedService having the given ID
   * @author ctranoris
   */
  private OfferedService FindOfferedServiceFromName(String resName) {
    // we can search for the proper service  by browsing
    for (int i = 0; i < broker.getOfferedServices().size(); i++) {
      if (broker.getOfferedServices().get(i).getName().equalsIgnoreCase(resName)) {
        log("FindOfferedServiceFromName offServ=" + resName + ", exists!");
        return broker.getOfferedServices().get(i);
      }
    }

    return null;
  }
Ejemplo n.º 2
0
  private void CreateOfferedService_Resource_Contract(
      String serviceName, Site partnerSite, Node resNode, Boolean createResource) {

    String resourceName = xmlutl.getNodeValueFromObject(resNode, "@component_name");
    log("resourceName : " + resourceName);
    String resourceSpecID = xmlutl.getNodeValueFromObject(resNode, "@component_id");

    if (resourceName.equals("")) {
      resourceName = xmlutl.getNodeValueFromObject(resNode, "hostname/text()");
    }

    //		NodeList resourceSpecNodes = xmlutl.getNodeListFromObject( resourceSpecDocument,
    // "//resourceSpec [@id="+resourceSpecID+"]");
    String offeredServiceName = serviceName;

    log("offeredService offeredServiceName: " + offeredServiceName);
    String offeredServiceDescr = "sfa " + offeredServiceName;
    //		//add back these for the service settings
    //		String configParamCompositeId = xmlutl.getNodeValueFromObject(resourceSpecNodes.item(0),
    // "configurationParameters/@id");
    //		log("configParamCompositeId offServ="+offeredServiceName+", configParamCompositeId
    // ="+configParamCompositeId);
    //
    //		//before creating the service, check if exists
    Boolean newServiceCreated = false;

    //		OfferedService offService = FindOfferedServiceFromID(  resourceSpecID );
    //		if (offService==null)
    OfferedService offService = FindOfferedServiceFromName(offeredServiceName);

    if (offService == null) {
      offService = ServicesFactory.eINSTANCE.createOfferedService();
      offService.setId(0); // not used in SFA?!
      //			offService.setUniqueID("os"+Integer.parseInt(resourceSpecID));
      offService.setUniqueID("os" + offeredServiceName);
      offService.setName(offeredServiceName);

      // offService.setDefaultValue();
      offService.setDescription(offeredServiceDescr);
      log("offeredService offeredServiceDescr: " + offeredServiceDescr);
      broker.getOfferedServices().add(offService);
      newServiceCreated = true;
    }

    // IF <configParamType>reference</configParamType> can be assigned

    // add the service as offered Resource also of Partner...a Contract must be also created here!
    OfferedResource offeredResource = null;
    if (createResource) {
      offeredResource = ResourcesFactory.eINSTANCE.createOfferedResource();
      partnerSite.getOfferedResourcesList().add(offeredResource);
      offeredResource.setBelongsToSite(partnerSite);
      offeredResource.setId(0); // not used in SFA?!
      offeredResource.setUniqueID(resourceName);
      //			String prefix="";
      //			if ((partnerSite.getPtm() != null) && (partnerSite.getPtm().getName() != null))
      //				prefix = partnerSite.getPtm().getName();
      offeredResource.setName(
          resourceName); // in SFA seems node names are unique//Will replace . with _
      offeredResource.setDescription(offeredServiceDescr);
      offeredResource.setImplOfferedService(offService);
      offeredResource.setMultitonMaxOccur(
          1); // we have atleast one of these resources to be reserved

      int prefix = partnerSite.getBelongsToProvider().getId();

      offeredResource.setGeocoords("-170, 50");

      CreateResourceContract(offeredResource);
    }

    CreateSetting(
        "hostname",
        "defvalHostNameSet",
        "node hostname",
        newServiceCreated,
        offService,
        offeredResource,
        true,
        false,
        true);
    CreateSetting(
        "vsys",
        "",
        "request access to a vsys script on the selected node",
        newServiceCreated,
        offService,
        offeredResource,
        true,
        true,
        true);
    CreateSetting(
        "initscript",
        "",
        "initscript on the selected node",
        newServiceCreated,
        offService,
        offeredResource,
        true,
        true,
        true);
    CreateSetting(
        "vsys_vnet",
        "",
        "initscript on the selected node",
        newServiceCreated,
        offService,
        offeredResource,
        true,
        true,
        true);

    // Finally add service to the general ServiceCategories
    generalTaxonomy.getTaxonomies().get(0).getHasServices().add(offService);
  }