예제 #1
0
 public void testDeleteChannel() throws Exception {
   Channel c = ChannelFactoryTest.createTestChannel(user);
   Long id = c.getId();
   assertNotNull(c);
   ChannelFactory.save(c);
   assertNotNull(ChannelFactory.lookupById(id));
   ChannelFactory.remove(c);
   TestUtils.flushAndEvict(c);
   assertNull(ChannelFactory.lookupById(id));
 }
예제 #2
0
  public void testChannel() throws Exception {
    Channel c = ChannelFactoryTest.createTestChannel(user);
    // add an errata
    Errata e = ErrataFactoryTest.createTestPublishedErrata(user.getId());
    c.addErrata(e);
    assertEquals(c.getErratas().size(), 1);
    ChannelFactory.save(c);

    log.debug("Looking up id [" + c.getId() + "]");
    Channel c2 = ChannelFactory.lookupById(c.getId());
    log.debug("Finished lookup");
    assertEquals(c2.getErratas().size(), 1);

    assertEquals(c.getLabel(), c2.getLabel());
    assertNotNull(c.getChannelArch());

    Channel c3 = ChannelFactoryTest.createTestChannel(user);

    c.setParentChannel(c3);
    assertEquals(c.getParentChannel().getId(), c3.getId());

    // Test isGloballySubscribable
    assertTrue(c.isGloballySubscribable(c.getOrg()));
    c.setGloballySubscribable(false, c.getOrg());
    assertFalse(c.isGloballySubscribable(c.getOrg()));
    c.setGloballySubscribable(true, c.getOrg());
    assertTrue(c.isGloballySubscribable(c.getOrg()));
  }
예제 #3
0
  private Channel makePrivate(DynaActionForm form, ActionErrors errors, RequestContext ctx) {

    User user = ctx.getCurrentUser();
    Long cid = ctx.getParamAsLong("cid");
    Channel channel = ChannelFactory.lookupById(cid);
    unsubscribeOrgsFromChannel(user, channel, Channel.PRIVATE);
    return edit(form, errors, ctx);
  }
예제 #4
0
 public void testEquals() throws Exception {
   Channel c1 = ChannelFactoryTest.createTestChannel(user);
   Channel c2 = ChannelFactoryTest.createTestChannel(user);
   assertFalse(c1.equals(c2));
   Channel c3 = ChannelFactory.lookupById(c1.getId());
   Set<Channel> testSet = new HashSet<Channel>();
   testSet.add(c1);
   testSet.add(c2);
   testSet.add(c3);
   assertTrue(testSet.size() == 2);
 }
예제 #5
0
  public void testIsProxy() throws Exception {
    Channel c = ChannelFactoryTest.createTestChannel(user);
    ChannelFamily cfam =
        ChannelFamilyFactoryTest.createTestChannelFamily(
            user, false, ChannelFamilyFactory.PROXY_CHANNEL_FAMILY_LABEL);

    c.setChannelFamily(cfam);

    TestUtils.saveAndFlush(c);

    Channel c2 = ChannelFactory.lookupById(c.getId());
    assertTrue(c2.isProxy());
  }
  /**
   * Get the id of the Package installed for this KS. Here we'll verify that the kickstart package
   * exists in the host server's tools channel. The host server will need it to perform necessary
   * actions on either itself or the target system (if different).
   *
   * @return Long id of Package used for this KS.
   */
  public ValidatorError validateKickstartPackage() {
    if (cobblerOnly) {
      return null;
    }

    Server hostServer = getHostServer();
    Set<Long> serverChannelIds = new HashSet<Long>();
    Iterator<Channel> i = hostServer.getChannels().iterator();
    while (i.hasNext()) {
      Channel c = i.next();
      serverChannelIds.add(c.getId());
    }

    // check for package among channels the server is subscribed to.
    // If one is found, return
    Map<String, Long> pkgToInstall = findKickstartPackageToInstall(hostServer, serverChannelIds);
    if (pkgToInstall != null) {
      this.packagesToInstall.add(pkgToInstall);
      log.debug("    packagesToInstall: " + packagesToInstall);
      return null;
    }

    // otherwise search in channels that can be subscribed.
    // If one is found, subscribe channel and return
    Set<Long> subscribableChannelIds =
        SystemManager.subscribableChannelIds(
            hostServer.getId(), this.user.getId(), hostServer.getBaseChannel().getId());
    pkgToInstall = findKickstartPackageToInstall(hostServer, subscribableChannelIds);

    if (pkgToInstall != null) {
      this.packagesToInstall.add(pkgToInstall);
      log.debug("    packagesToInstall: " + packagesToInstall);
      Long cid = pkgToInstall.get("channel_id");
      log.debug("    Subscribing to: " + cid);
      Channel c = ChannelFactory.lookupById(cid);
      try {
        SystemManager.subscribeServerToChannel(this.user, server, c);
        log.debug("    Subscribed: " + cid);
      } catch (PermissionException pe) {
        return new ValidatorError("kickstart.schedule.cantsubscribe");
      } catch (Exception e) {
        return new ValidatorError(
            "kickstart.schedule.cantsubscribe.channel", c.getName(), server.getName());
      }
      return null;
    }

    return new ValidatorError(
        "kickstart.schedule.nopackage", this.getKsdata().getChannel().getName());
  }