/**
   * deploys a bundle
   *
   * @param input bundle distribution ZIP file
   * @param group to be deployed to (a BundleDestination is created on top of given group), group
   *     must be compatible and it's resources must support bundle deployment
   * @param config input configuration for bundle (for passing input-parameter values)
   * @param destinationName - name for new destination being created
   * @param baseDirName - baseDir for deployment - this must match to resourceType contained in
   *     given group
   * @param deployDir - directory to deploy to - relative path based on baseDir
   * @return bundleDeployment where deployment has finished (either failed or success)
   * @throws Exception
   */
  public BundleDeployment deployBundle(
      File input,
      ResourceGroup group,
      Configuration config,
      String destinationName,
      String baseDirName,
      String deployDir)
      throws Exception {
    BundleVersion version = createBundleVersion(input);
    BundleDestination destination =
        bundleManager.createBundleDestination(
            client.getSubject(),
            version.getBundle().getId(),
            destinationName,
            "",
            baseDirName,
            deployDir,
            group.getId());

    BundleDeployment deployment =
        bundleManager.createBundleDeployment(
            client.getSubject(), version.getId(), destination.getId(), "", config);
    deployment =
        bundleManager.scheduleBundleDeployment(client.getSubject(), deployment.getId(), false);
    return waitForBundleDeployment(deployment);
  }
Ejemplo n.º 2
0
  private void viewBundleVersion(BundleVersion version, ViewId nextViewId) {
    // Whenever a new view request comes in, make sure to clean house to avoid ID conflicts for
    // sub-widgets
    this.destroyMembers();

    this.version = version;

    addMember(
        new BackButton(
            MSG.view_bundle_version_backToBundle() + ": " + version.getBundle().getName(),
            LinkManager.getBundleLink(version.getBundle().getId())));

    addMember(
        new HeaderLabel(
            Canvas.getImgURL("subsystems/bundle/BundleVersion_24.png"),
            version.getName() + ": " + version.getVersion()));

    // conditionally add tags. Defaults to true, not available in JON builds.
    if (CoreGUI.isTagsEnabledForUI()) {
      addMember(createTagEditor());
    }

    addMember(createSummaryForm());

    TabSet tabs = new TabSet();
    tabs.addTab(createRecipeTab());
    tabs.addTab(createLiveDeploymentsTab());
    tabs.addTab(createFilesTab());
    addMember(tabs);

    if (nextViewId != null) {
      if (nextViewId.getPath().equals("recipe")) {
        tabs.selectTab(0);
      } else if (nextViewId.getPath().equals("deployments")) {
        tabs.selectTab(1);
      } else if (nextViewId.getPath().equals("files")) {
        tabs.selectTab(2);
      } else {
        // should we throw an exception? someone gave a bad URL; just bring them to first tab
        tabs.selectTab(0);
      }
    }

    markForRedraw();
  }
  private BundleDestination getBundleDestination(
      BundleVersion bundleVersion, String destinationName, ResourceGroup group, String deployDir)
      throws Exception {
    BundleDestinationCriteria criteria = new BundleDestinationCriteria();
    criteria.addFilterBundleId(bundleVersion.getBundle().getId());
    // criteria.addFilterBundleVersionId(bundleVersion.getId());
    criteria.addFilterGroupId(group.getId());

    PageList<BundleDestination> bundleDestinations =
        bundleManager.findBundleDestinationsByCriteria(overlord, criteria);

    if (bundleDestinations.isEmpty()) {
      return bundleManager.createBundleDestination(
          overlord,
          bundleVersion.getBundle().getId(),
          destinationName,
          destinationName,
          "Root File System",
          deployDir,
          group.getId());
    }

    for (BundleDestination destination : bundleDestinations) {
      if (destination.getDeployDir().equals(deployDir)) {
        return destination;
      }
    }

    throw new RuntimeException(
        "Unable to get bundle destination for [bundleId: "
            + bundleVersion.getBundle().getId()
            + ", bunldleVersionId: "
            + bundleVersion.getId()
            + ", destination: "
            + destinationName
            + ", deployDir: "
            + deployDir
            + "]");
  }