예제 #1
0
  @Override
  public int complete(String buffer, int cursor, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    String versionName = null;
    try {
      Version defaultVersion = fabricService.getDefaultVersion();
      if (defaultVersion != null) {
        versionName = defaultVersion.getName();
      }
      if (versionName == null) {
        versionName = ZkDefs.DEFAULT_VERSION;
      }

      Profile[] profiles = fabricService.getProfiles(versionName);
      for (Profile profile : profiles) {
        delegate.getStrings().add(profile.getId());
      }
    } catch (Exception ex) {
      // Ignore Exceptions
    }
    return delegate.complete(buffer, cursor, candidates);
  }
예제 #2
0
  /**
   * Adds a feature to the profile and tests it on the container.
   *
   * <p>Note: Before and after the test the container moves to default profile.
   *
   * @param featureNames
   * @param profileName
   * @param expectedSymbolicNames
   */
  public void assertProvisionedFeature(
      Set<Container> containers,
      String featureNames,
      String profileName,
      String expectedSymbolicNames)
      throws Exception {
    IZKClient zooKeeper = getZookeeper();
    StringBuilder sb = new StringBuilder();
    sb.append("[ ");
    for (Container container : containers) {
      sb.append(container.getId()).append(" ");
    }
    sb.append("]");

    System.out.println(
        "Testing profile:"
            + profileName
            + " on container:"
            + sb.toString()
            + " by adding feature:"
            + featureNames);
    FabricService fabricService = getFabricService();
    Version version = fabricService.getDefaultVersion();

    Profile defaultProfile = fabricService.getProfile(version.getName(), "default");
    Profile targetProfile = fabricService.getProfile(version.getName(), profileName);

    for (Container container : containers) {
      // We set container to default to clean the container up.
      container.setProfiles(new Profile[] {defaultProfile});
    }
    Provision.waitForContainerStatus(containers, PROVISION_TIMEOUT);

    for (String featureName : featureNames.split(" ")) {
      System.out.println(
          executeCommand(
              "fabric:profile-edit --features " + featureName + " " + targetProfile.getId()));
    }

    for (Container container : containers) {
      // Test the modified profile.
      if (!defaultProfile.configurationEquals(targetProfile)) {
        ZooKeeperUtils.set(
            getZookeeper(),
            ZkPath.CONTAINER_PROVISION_RESULT.getPath(container.getId()),
            "switching profile");
      }
      container.setProfiles(new Profile[] {targetProfile});
      // containerSetProfile(container.getId(), profileName, false);
    }

    Provision.waitForContainerStatus(containers, PROVISION_TIMEOUT);
    System.out.println(executeCommand("fabric:profile-display " + profileName));
    System.out.println(executeCommand("fabric:container-list"));

    for (Container container : containers) {
      for (String symbolicName : expectedSymbolicNames.split(" ")) {
        System.out.println(
            executeCommand(
                "container-connect -u admin -p admin " + container.getId() + " osgi:list -s -t 0"));
        String bundles =
            executeCommand(
                "container-connect -u admin -p admin "
                    + container.getId()
                    + " osgi:list -s -t 0 | grep "
                    + symbolicName);
        System.out.flush();
        Assert.assertNotNull(bundles);
        Assert.assertTrue(
            "Expected to find symbolic name:" + symbolicName, bundles.contains(symbolicName));
        System.out.println(bundles);
      }
    }

    for (Container container : containers) {
      // We set the container to default to clean up the profile.
      if (!defaultProfile.configurationEquals(targetProfile)) {
        ZooKeeperUtils.set(
            getZookeeper(),
            ZkPath.CONTAINER_PROVISION_RESULT.getPath(container.getId()),
            "switching profile");
      }
      container.setProfiles(new Profile[] {defaultProfile});
    }

    Provision.waitForContainerStatus(containers, PROVISION_TIMEOUT);
    for (String featureName : featureNames.split(" ")) {
      System.out.println(
          executeCommand(
              "fabric:profile-edit --delete --features "
                  + featureName
                  + " "
                  + targetProfile.getId()));
    }
  }
예제 #3
0
 public VersionDTO(Version version) {
   this.id = version.getName();
   this.attributes = version.getAttributes();
 }