/** * Create a one time activation key for use with a kickstart * * @param creator of the key * @param ksdata associated with the key * @param server being kickstarted (can be null) * @param session associated with the kickstart (NOT NULL) * @param note to add to key * @param usageLimit to apply to the key. null for unlimited. * @return ActivationKey that has been saved to the DB. */ public static ActivationKey createKickstartActivationKey( User creator, KickstartData ksdata, Server server, KickstartSession session, Long usageLimit, String note) { // Now create ActivationKey ActivationKey key = ActivationKeyManager.getInstance().createNewReActivationKey(creator, server, note, session); key.addEntitlement(ServerConstants.getServerGroupTypeProvisioningEntitled()); key.setDeployConfigs(false); key.setUsageLimit(usageLimit); if (KickstartVirtualizationType.paraHost() .equals(ksdata.getKickstartDefaults().getVirtualizationType())) { // we'll have to setup the key for virt key.addEntitlement(ServerConstants.getServerGroupTypeVirtualizationEntitled()); } ActivationKeyFactory.save(key); // Add child channels to the key if (ksdata.getChildChannels() != null && ksdata.getChildChannels().size() > 0) { Iterator i = ksdata.getChildChannels().iterator(); log.debug("Add the child Channels"); while (i.hasNext()) { key.addChannel((Channel) i.next()); } } log.debug("** Saving new token"); ActivationKeyFactory.save(key); log.debug("** Saved new token: " + key.getId()); return key; }
public void testDeployConfig() throws Exception { UserTestUtils.addUserRole(user, RoleFactory.ACTIVATION_KEY_ADMIN); // need a tools channel for config deploy Channel base = ChannelTestUtils.createBaseChannel(user); ChannelTestUtils.setupBaseChannelForVirtualization(user, base); ActivationKey key = createActivationKey(); // Create a config channel ConfigChannel cc = ConfigTestUtils.createConfigChannel(user.getOrg()); ConfigChannelListProcessor proc = new ConfigChannelListProcessor(); proc.add(key.getConfigChannelsFor(user), cc); key.setDeployConfigs(true); ActivationKeyFactory.save(key); assertTrue(key.getDeployConfigs()); assertFalse(key.getChannels().isEmpty()); assertFalse(key.getPackages().isEmpty()); }