private boolean isALogicalRouter(IResource resource) {
    ResourceDescriptor resourceDescriptor = resource.getResourceDescriptor();
    /* Check that the logical router exists */
    if (resourceDescriptor == null || resourceDescriptor.getProperties() == null) return false;

    return (resourceDescriptor.getProperties().get(ResourceDescriptor.VIRTUAL) != null
        && resourceDescriptor.getProperties().get(ResourceDescriptor.VIRTUAL).equals("true"));
  }
Example #2
0
  public void initResource() {

    /* initialize model */
    mockResource = new MockResource();
    mockResource.setModel(new ComputerSystem());
    mockResource.setBootstrapper(new MockBootstrapper());

    List<String> capabilities = new ArrayList<String>();

    capabilities.add("chassis");
    capabilities.add("queue");
    ResourceDescriptor resourceDescriptor =
        ResourceDescriptorFactory.newResourceDescriptor(deviceID, "router", capabilities);
    mockResource.setResourceDescriptor(resourceDescriptor);
    mockResource.setResourceIdentifier(
        new ResourceIdentifier(
            resourceDescriptor.getInformation().getType(), resourceDescriptor.getId()));
  }
Example #3
0
  /**
   * @param description
   * @param name
   * @param type
   * @param version
   * @return
   */
  private ResourceDescriptor getBoDResourceDescriptor(
      String description, String name, String type, String version) {
    ResourceDescriptor resourceDescriptor = new ResourceDescriptor();
    resourceDescriptor.setInformation(
        DescriptorUtils.getInformation(name, description, type, version));

    CapabilityDescriptor capabilityDescriptor =
        DescriptorUtils.getCapabilityDescriptor(
            "l2bod capability", "l2bod capability", "l2bod", "autobahn", "1.0");

    resourceDescriptor.setCapabilityDescriptors(new ArrayList<CapabilityDescriptor>());
    resourceDescriptor.getCapabilityDescriptors().add(capabilityDescriptor);

    capabilityDescriptor =
        DescriptorUtils.getCapabilityDescriptor(
            "Queue capability", "Queue capability", "queue", "autobahn", "1.0");
    resourceDescriptor.getCapabilityDescriptors().add(capabilityDescriptor);

    return resourceDescriptor;
  }
  private ResourceDescriptor newResourceDescriptor(
      ResourceDescriptor resourceDescriptor, String nameResource) throws ResourceException {

    try {
      ResourceDescriptor newResourceDescriptor = (ResourceDescriptor) resourceDescriptor.clone();

      // the profiles will not be cloned
      newResourceDescriptor.setProfileId("");
      // we delete chassis capability, a logical resource can't create new logical devices or new
      // interfaces
      newResourceDescriptor.removeCapabilityDescriptor("chassis");
      // Wet set the resource name
      newResourceDescriptor.getInformation().setName(nameResource);

      /* added virtual description */
      Map<String, String> properties = new HashMap<String, String>();
      properties.put(ResourceDescriptor.VIRTUAL, "true");
      newResourceDescriptor.setProperties(properties);

      return newResourceDescriptor;
    } catch (Exception e) {
      throw new ResourceException(e.getMessage());
    }
  }
Example #5
0
 public void setResourceId(String resourceId) {
   resourceDescriptor.setId(resourceId);
 }
Example #6
0
 public String getResourceId() {
   return resourceDescriptor.getId();
 }
Example #7
0
 public MockResource() {
   resourceDescriptor = new ResourceDescriptor();
   capabilityDescriptors = new ArrayList<CapabilityDescriptor>();
   resourceDescriptor.setCapabilityDescriptors(capabilityDescriptors);
 }