Пример #1
0
 private Tab createLiveDeploymentsTab() {
   Tab tab = new Tab(MSG.view_bundle_deployments());
   Criteria criteria = new Criteria();
   criteria.setAttribute("bundleVersionId", version.getId());
   tab.setPane(new BundleDeploymentListView(criteria, this.canDeploy));
   return tab;
 }
  /**
   * 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);
  }
  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
            + "]");
  }
  public ControlResults invoke(String operation, Configuration params) {
    ControlResults results = new ControlResults();

    try {
      Bundle bundle = getBundle();
      BundleVersion bundleVersion = getBundleVersion(bundle);

      Configuration bundleConfig = new Configuration();
      File clusterDir = new File(params.getSimpleValue("clusterDirectory"));
      int numNodes = Integer.parseInt(params.getSimpleValue("numberOfNodes"));
      int replicationFactor = Integer.parseInt(params.getSimpleValue("replicationFactor", "1"));
      String hostname = params.getSimpleValue("host");

      Resource platform = getPlatform(hostname);
      ResourceGroup group = getPlatformGroup(platform, hostname);

      Set<String> ipAddresses = calculateLocalIPAddresses(numNodes);

      for (int i = 0; i < numNodes; ++i) {
        Set<String> seeds = getSeeds(ipAddresses, i + 1);
        int jmxPort = 7200 + i;

        Configuration deploymentConfig = new Configuration();
        deploymentConfig.put(new PropertySimple("cluster.name", "rhqdev"));
        deploymentConfig.put(new PropertySimple("cluster.dir", clusterDir.getAbsolutePath()));
        deploymentConfig.put(new PropertySimple("auto.bootstrap", "false"));
        deploymentConfig.put(new PropertySimple("data.dir", "data"));
        deploymentConfig.put(new PropertySimple("commitlog.dir", "commit_log"));
        deploymentConfig.put(new PropertySimple("log.dir", "logs"));
        deploymentConfig.put(new PropertySimple("saved.caches.dir", "saved_caches"));
        deploymentConfig.put(new PropertySimple("hostname", getLocalIPAddress(i + 1)));
        deploymentConfig.put(new PropertySimple("seeds", collectionToString(seeds)));
        deploymentConfig.put(new PropertySimple("jmx.port", Integer.toString(jmxPort)));
        deploymentConfig.put(new PropertySimple("initial.token", generateToken(i, numNodes)));
        deploymentConfig.put(new PropertySimple("install.schema", i == 0));
        deploymentConfig.put(new PropertySimple("replication.factor", replicationFactor));

        String destinationName = "cassandra-node[" + i + "]-deployment";
        String deployDir = new File(clusterDir, "node" + i).getAbsolutePath();

        BundleDestination bundleDestination =
            getBundleDestination(bundleVersion, destinationName, group, deployDir);

        BundleDeployment bundleDeployment =
            bundleManager.createBundleDeployment(
                overlord,
                bundleVersion.getId(),
                bundleDestination.getId(),
                destinationName,
                deploymentConfig);

        bundleManager.scheduleBundleDeployment(overlord, bundleDeployment.getId(), true);
      }

      return new ControlResults();
    } catch (ResourceNotFoundException e) {
      results.setError(e.getMessage());
      return results;

    } catch (Exception e) {
      results.setError(e);
      return results;
    }
  }
Пример #5
0
 private Tab createFilesTab() {
   Tab tab = new Tab(MSG.view_bundle_files());
   FileListView filesView = new FileListView(version.getId());
   tab.setPane(filesView);
   return tab;
 }
Пример #6
0
 public List<PackageVersion> getAllBundleVersionPackageVersions(BundleVersion bundleVersion)
     throws Exception {
   int bvId = bundleVersion.getId();
   List<PackageVersion> pvs = getBundleServerService().getAllBundleVersionPackageVersions(bvId);
   return pvs;
 }