backend/satellite_tools/satCerts.py
| 1
backend/satellite_tools/sync_handlers.py
| 89
backend/server/handlers/xmlrpc/registration.py
| 44
backend/server/importlib/backend.py
| 2
backend/server/importlib/importLib.py
| 1
backend/server/rhnServer/satellite_cert.py
| 2
backend/server/rhnVirtualization.py
| 4
java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
| 52
java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
| 4
java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
| 58
java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
| 76
java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
| 3
java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
| 35
java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
| 27
java/code/src/com/redhat/rhn/domain/channel/test/ChannelFamilyFactoryTest.java
| 17
java/code/src/com/redhat/rhn/domain/server/ServerGroupType.java
| 10
java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
| 78
java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
| 30
java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
| 45
java/code/src/com/redhat/rhn/frontend/action/channel/ChannelEntitlementSetupAction.java
| 39
java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgNameFilter.java
| 42
java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
| 162 -
java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
| 235 +
java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsAction.java
| 24
java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsFilter.java
| 42
java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/EligibleFlexGuestAction.java
| 89
java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/FlexGuestAction.java
| 60
java/code/src/com/redhat/rhn/frontend/dto/BaseDto.java
| 35
java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
| 135
java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
| 117
java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
| 72
java/code/src/com/redhat/rhn/frontend/dto/MultiOrgEntitlementsDto.java
| 75
java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
| 88
java/code/src/com/redhat/rhn/frontend/dto/OrgSoftwareEntitlementDto.java
| 128
java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
| 14
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
| 193 +
java/code/src/com/redhat/rhn/frontend/struts/Expandable.java
| 5
java/code/src/com/redhat/rhn/frontend/struts/SelectableAdapter.java
| 55
java/code/src/com/redhat/rhn/frontend/taglibs/list/ColumnTag.java
| 19
java/code/src/com/redhat/rhn/frontend/taglibs/list/row/DuplicateSystemsRowRenderer.java
| 42
java/code/src/com/redhat/rhn/frontend/taglibs/list/row/ExpandableRowRenderer.java
| 5
java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
| 5
java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
| 47
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
| 90
java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
| 108
java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
| 20
java/code/src/com/redhat/rhn/manager/system/SystemManager.java
| 33
java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
| 46
java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
| 219 +
java/code/src/com/redhat/rhn/testing/UserTestUtils.java
| 14
java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
| 7
java/code/webapp/WEB-INF/nav/virt_entitlements.xml
| 7
java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
| 115
java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
| 96
java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
| 171 -
java/code/webapp/WEB-INF/pages/channel/entitlements.jsp
| 60
java/code/webapp/WEB-INF/pages/systems/duplicate/duplicatesystems.jsp
| 2
java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
| 128
java/code/webapp/WEB-INF/struts-config.xml
| 22
schema/spacewalk/common/data/rhnException.sql
| 6
schema/spacewalk/common/data/rhnVirtualInstanceType.sql
| 11
schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
| 4
schema/spacewalk/common/tables/rhnServerChannel.sql
| 4
schema/spacewalk/common/views/rhnChannelFamilyOverview.sql
| 2
schema/spacewalk/common/views/rhnChannelFamilyPermissions.sql
| 4
schema/spacewalk/common/views/rhnChannelFamilyServerFve.sql
| 34
schema/spacewalk/common/views/rhnChannelFamilyServerPhysical.sql
| 1
schema/spacewalk/common/views/rhnChannelFamilyServerVirtual.sql
| 1
schema/spacewalk/common/views/rhnOrgChannelFamilyPermissions.sql
| 40
schema/spacewalk/oracle/packages/rhn_channel.pkb
| 414 +-
schema/spacewalk/oracle/packages/rhn_channel.pks
| 54
schema/spacewalk/oracle/packages/rhn_entitlements.pkb
| 1460 +++++-----
schema/spacewalk/oracle/packages/rhn_entitlements.pks
| 13
schema/spacewalk/oracle/views/rhnOrgChannelFamilyPermissions.sql
| 46
schema/spacewalk/postgres/packages/rhn_channel.pkb
| 134
schema/spacewalk/postgres/views/rhnOrgChannelFamilyPermissions.sql
| 36
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
| 3
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/004-rhnServerChannel.sql
| 4
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/005-rhnVirtualInstanceType.sql
| 2
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/006-rhnChannelFamilyOverview.sql
| 40
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/007-rhnOrgChannelFamilyPermissions.sql
| 50
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/008-rhnChannelFamilyServerPhysical.sql
| 52
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/009-rhnChannelFamilyServerVirtual.sql
| 54
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnChannelFamilyServerFve.sql
| 34
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnVirtualInstanceType.sql
| 9
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/011-rhnChannelFamilyPermissions.sql
| 39
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
| 26
web/html/javascript/multiorg-entitlements.js
| 163 -
88 files changed, 4253 insertions(+), 1931 deletions(-)
New commits:
commit 83c1510e1706ae6f17b95798598c533549be073c
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Jun 28 11:57:54 2010 -0400
Fixed a compile error....
diff --git
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
index f75f95d..b369e06 100644
---
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
+++
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
@@ -53,7 +53,7 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
Long origValue = fam.getMaxMembers(OrgFactory.getSatelliteOrg());
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), 1L, 0L);
assertNull(cmd.store());
reloadFamilies();
@@ -65,14 +65,14 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
public void testUpdateTooMany() throws Exception {
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(Integer.MAX_VALUE));
+ fam.getLabel(), user.getOrg(), new Long(Integer.MAX_VALUE), 0L);
assertNotNull(cmd.store());
}
public void testReUpdateToConsumeAll() throws Exception {
Long firstAllocation = ChannelFamilyFactoryTest.ENTITLEMENT_ALLOCATION / 2;
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), firstAllocation);
+ fam.getLabel(), user.getOrg(), firstAllocation, 0L);
assertNull(cmd.store());
TestUtils.reload(fam);
for (PrivateChannelFamily privFam : fam.getPrivateChannelFamilies()) {
commit 435657a8cfaf6d853481791c24cda8b5922cdad4
Author: Partha Aji <paji(a)redhat.com>
Date: Fri Jun 25 18:53:42 2010 -0400
Added more tests on Orphaned gets entitlements
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
index 61fa278..c2b2b17 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
@@ -28,6 +28,8 @@ import org.hibernate.Session;
import java.util.Date;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
@@ -40,7 +42,7 @@ public class HostBuilder {
private User owner;
private Server host;
-
+
public HostBuilder(User theOwner) {
owner = theOwner;
}
@@ -159,9 +161,11 @@ public class HostBuilder {
return this;
}
- private void createGuests(int numberOfGuests, boolean register) throws Exception {
+ private List<VirtualInstance> createGuests(int numberOfGuests,
+ boolean register) throws Exception {
VirtualInstance virtualInstance = null;
Server guest = null;
+ List<VirtualInstance> guests = new LinkedList<VirtualInstance>();
for (int i = 0; i < numberOfGuests; ++i) {
virtualInstance = new VirtualInstance();
@@ -172,11 +176,18 @@ public class HostBuilder {
ServerFactoryTest.TYPE_SERVER_NORMAL , new Date());
virtualInstance.setGuestSystem(guest);
}
-
- host.addGuest(virtualInstance);
- TestUtils.saveAndFlush(host);
+ if (host != null) {
+ host.addGuest(virtualInstance);
+ TestUtils.saveAndFlush(host);
+ }
TestUtils.saveAndFlush(guest);
+ guests.add(virtualInstance);
}
+ return guests;
+ }
+
+ public List<VirtualInstance> withOrphanedGuests(int numberOfGuests) throws
Exception {
+ return createGuests(numberOfGuests, true);
}
}
diff --git
a/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
b/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
index 9e5dca4..448a541 100644
---
a/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
+++
b/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
@@ -43,6 +43,7 @@ import com.redhat.rhn.testing.UserTestUtils;
import org.apache.commons.lang.RandomStringUtils;
+import java.util.Collection;
import java.util.List;
@@ -76,37 +77,8 @@ public class VirtualizationEntitlementsManagerTest extends
RhnBaseTestCase {
UpdateOrgSoftwareEntitlementsCommand(rhelFamily.getLabel(),
org, ents, flexEnts);
assertNull(cmd2.store());
- Channel rhelChannel = ChannelFactoryTest.createBaseChannel(user, rhelFamily);
-
-
- HibernateFactory.getSession().clear();
- rhelChannel = ChannelFactory.lookupById(rhelChannel.getId());
- assertNotNull(rhelChannel.getId());
- assertNotNull(rhelChannel);
-
- rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
- assertNotNull(rhelFamily);
- assertNotNull(rhelFamily.getMaxFlex(org));
- assertEquals(Long.valueOf(flexEnts), rhelFamily.getMaxFlex(org));
-
- HostBuilder builder = new HostBuilder(org.getActiveOrgAdmins().get(0));
- builder.createNonVirtHost().withGuests(guestsToCreate);
- Server host = builder.build();
- ServerFactory.save(host);
-
- SystemManager.subscribeServerToChannel(user, host, rhelChannel);
-
- ServerFactory.save(host);
-
- for (VirtualInstance inst : host.getGuests()) {
- SystemManager.subscribeServerToChannel(user,
- inst.getGuestSystem(), rhelChannel);
- SystemManager.entitleServer(inst.getGuestSystem(),
- EntitlementManager.MANAGEMENT);
- ServerFactory.save(inst.getGuestSystem());
- }
-
- HibernateFactory.getSession().clear();
+ rhelFamily = setupGuests(org, user, guestsToCreate,
+ flexEnts, rhelFamily, true);
//Verify everything is as it should be
@@ -125,8 +97,19 @@ public class VirtualizationEntitlementsManagerTest extends
RhnBaseTestCase {
assertEquals(1, l.size());
assertEquals(guestsToCreate, l.get(0).expand().size());
}
+
+
+ public void testNonVirtHostEligibleFlexGuests() throws Exception {
+ executeEligibleGuestTests(false);
+ }
+
+ public void testOrphanedEligibleFlexGuests() throws Exception {
+ executeEligibleGuestTests(true);
+ }
+
+
- public void testListEligibleFlexGuests() throws Exception {
+ private void executeEligibleGuestTests(boolean isOrphaned) throws Exception {
Org org =
UserTestUtils.createNewOrgFull(RandomStringUtils.randomAlphabetic(10));
User user = UserTestUtils.createUser(RandomStringUtils.randomAlphabetic(10),
org.getId());
@@ -134,8 +117,12 @@ public class VirtualizationEntitlementsManagerTest extends
RhnBaseTestCase {
UserFactory.save(user);
int guestsToCreate = 6;
long flexEnts = guestsToCreate;
- long ents = guestsToCreate + 1; //+ 1 for host
- long sysEnts = guestsToCreate + 1; //+ 1 for host
+ long ents = guestsToCreate;
+ long sysEnts = guestsToCreate; //+ 1 for host
+ if (!isOrphaned) {
+ ents++;
+ sysEnts++;
+ }
//Give it some system entitlements
UpdateOrgSystemEntitlementsCommand cmd1 = new
UpdateOrgSystemEntitlementsCommand(
EntitlementManager.MANAGEMENT, org, sysEnts);
@@ -152,37 +139,7 @@ public class VirtualizationEntitlementsManagerTest extends
RhnBaseTestCase {
UpdateOrgSoftwareEntitlementsCommand(rhelFamily.getLabel(),
org, ents, 0L);
assertNull(cmd2.store());
- Channel rhelChannel = ChannelFactoryTest.createBaseChannel(user, rhelFamily);
-
-
- HibernateFactory.getSession().clear();
- rhelChannel = ChannelFactory.lookupById(rhelChannel.getId());
- assertNotNull(rhelChannel.getId());
- assertNotNull(rhelChannel);
-
- rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
- assertNotNull(rhelFamily);
- assertNotNull(rhelFamily.getMaxFlex(org));
- assertEquals(Long.valueOf(0), rhelFamily.getMaxFlex(org));
-
- HostBuilder builder = new HostBuilder(org.getActiveOrgAdmins().get(0));
- builder.createNonVirtHost().withGuests(guestsToCreate);
- Server host = builder.build();
- ServerFactory.save(host);
-
- SystemManager.subscribeServerToChannel(user, host, rhelChannel);
-
- ServerFactory.save(host);
- for (VirtualInstance inst : host.getGuests()) {
- SystemManager.subscribeServerToChannel(user,
- inst.getGuestSystem(), rhelChannel);
- SystemManager.entitleServer(inst.getGuestSystem(),
- EntitlementManager.MANAGEMENT);
- ServerFactory.save(inst.getGuestSystem());
- }
-
- HibernateFactory.getSession().clear();
-
+ rhelFamily = setupGuests(org, user, guestsToCreate, 0, rhelFamily, !isOrphaned);
//Verify everything is as it should be
EntitlementServerGroup mgmnt =
@@ -209,12 +166,54 @@ public class VirtualizationEntitlementsManagerTest extends
RhnBaseTestCase {
List<ChannelFamilySystemGroup> l = VirtualizationEntitlementsManager.
getInstance().listEligibleFlexGuests(user);
-
-
assertTrue(!l.isEmpty());
assertEquals(1, l.size());
- assertEquals(guestsToCreate, l.get(0).expand().size());
- }
+ assertEquals(guestsToCreate, l.get(0).expand().size());
+ }
+ private ChannelFamily setupGuests(Org org, User user,
+ int guestsToCreate, long flexEnts, ChannelFamily rhelFamily,
+ boolean addNonVirtHost) throws Exception {
+ Channel rhelChannel = ChannelFactoryTest.createBaseChannel(user, rhelFamily);
+ HibernateFactory.getSession().clear();
+ rhelChannel = ChannelFactory.lookupById(rhelChannel.getId());
+ assertNotNull(rhelChannel.getId());
+ assertNotNull(rhelChannel);
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertNotNull(rhelFamily);
+ assertNotNull(rhelFamily.getMaxFlex(org));
+ assertEquals(Long.valueOf(flexEnts), rhelFamily.getMaxFlex(org));
+
+ HostBuilder builder = new HostBuilder(org.getActiveOrgAdmins().get(0));
+ Collection<VirtualInstance> guests = null;
+ if (addNonVirtHost) {
+ builder.createNonVirtHost();
+ builder.withGuests(guestsToCreate);
+ }
+ else {
+ guests = builder.withOrphanedGuests(guestsToCreate);
+ }
+
+ if (addNonVirtHost) {
+ Server host = builder.build();
+ ServerFactory.save(host);
+
+ SystemManager.subscribeServerToChannel(user, host, rhelChannel);
+
+ ServerFactory.save(host);
+ guests = host.getGuests();
+ }
+
+ for (VirtualInstance inst : guests) {
+ SystemManager.subscribeServerToChannel(user,
+ inst.getGuestSystem(), rhelChannel);
+ SystemManager.entitleServer(inst.getGuestSystem(),
+ EntitlementManager.MANAGEMENT);
+ ServerFactory.save(inst.getGuestSystem());
+ }
+ HibernateFactory.getSession().clear();
+ return rhelFamily;
+ }
}
commit a49f28c0619a5d193f2afe6323207345ae35eb82
Author: Partha Aji <paji(a)redhat.com>
Date: Fri Jun 25 14:51:29 2010 -0400
Added unit tests for VirtEntitlementsManager
diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
index d7d48e3..d33e07c 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java
@@ -89,11 +89,29 @@ public class ChannelFactoryTest extends RhnBaseTestCase {
ChannelFactory.save(c);
return c;
}
+
+ public static Channel createBaseChannel(User user,
+ ChannelFamily fam) throws Exception {
+ Channel c = createTestChannel(null, fam);
+ ProductName pn = lookupOrCreateProductName(ChannelManager.RHEL_PRODUCT_NAME);
+ c.setProductName(pn);
+ ChannelFactory.save(c);
+ return (Channel)TestUtils.saveAndReload(c);
+ }
+
public static Channel createTestChannel(User user) throws Exception {
Org org = user.getOrg();
ChannelFamily cfam = user.getOrg().getPrivateChannelFamily();
+ Channel c = createTestChannel(org, cfam);
+ // assume we want the user to have access to this channel once created
+ UserManager.addChannelPerm(user, c.getId(), "subscribe");
+ UserManager.addChannelPerm(user, c.getId(), "manage");
+ ChannelFactory.save(c);
+ return c;
+ }
+ public static Channel createTestChannel(Org org, ChannelFamily cfam) throws Exception
{
String label = "ChannelLabel" + TestUtils.randomString();
String basedir = "TestChannel basedir";
String name = "ChannelName" + TestUtils.randomString();
@@ -108,11 +126,10 @@ public class ChannelFactoryTest extends RhnBaseTestCase {
Calendar cal = Calendar.getInstance();
cal.roll(Calendar.DATE, true);
Date endoflife = new Date(System.currentTimeMillis() + Integer.MAX_VALUE);
-
+
Long testid = new Long(500);
String query = "ChannelArch.findById";
ChannelArch arch = (ChannelArch) TestUtils.lookupFromCacheById(testid, query);
-
Channel c = new Channel();
c.setOrg(org);
c.setLabel(label);
@@ -129,12 +146,6 @@ public class ChannelFactoryTest extends RhnBaseTestCase {
c.setEndOfLife(endoflife);
c.setChannelArch(arch);
c.setChannelFamily(cfam);
-
- ChannelFactory.save(c);
-
- // assume we want the user to have access to this channel once created
- UserManager.addChannelPerm(user, c.getId(), "subscribe");
- UserManager.addChannelPerm(user, c.getId(), "manage");
ChannelFactory.save(c);
return c;
}
diff --git
a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFamilyFactoryTest.java
b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFamilyFactoryTest.java
index 66bf9b1..6389262 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFamilyFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFamilyFactoryTest.java
@@ -14,6 +14,7 @@
*/
package com.redhat.rhn.domain.channel.test;
+import com.redhat.rhn.common.hibernate.HibernateFactory;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import com.redhat.rhn.domain.channel.PrivateChannelFamily;
@@ -31,7 +32,8 @@ import java.util.List;
*/
public class ChannelFamilyFactoryTest extends RhnBaseTestCase {
- public static final Long ENTITLEMENT_ALLOCATION = new Long(10000);
+ public static final long ENTITLEMENT_ALLOCATION = 10000;
+ public static final long FLEX_ALLOCATION = ENTITLEMENT_ALLOCATION;
public void testChannelFamilyFactory() throws Exception {
ChannelFamily cfam = createTestChannelFamily();
@@ -105,6 +107,11 @@ public class ChannelFamilyFactoryTest extends RhnBaseTestCase {
}
public static ChannelFamily createTestChannelFamily(User user) throws Exception {
+ return createTestChannelFamily(user, ENTITLEMENT_ALLOCATION, FLEX_ALLOCATION);
+ }
+
+ public static ChannelFamily createTestChannelFamily(User user,
+ Long ents, Long flexEnts) throws Exception {
Org org = user.getOrg();
String label = "ChannelFamilyLabel" + TestUtils.randomString();
String name = "ChannelFamilyName" + TestUtils.randomString();
@@ -123,8 +130,12 @@ public class ChannelFamilyFactoryTest extends RhnBaseTestCase {
pcf.setOrg(user.getOrg());
pcf.setChannelFamily(cfam);
pcf.setCurrentMembers(new Long(0));
- pcf.setMaxMembers(ENTITLEMENT_ALLOCATION);
- pcf = (PrivateChannelFamily) TestUtils.saveAndReload(pcf);
+ pcf.setMaxMembers(ents);
+ pcf.setCurrentFlex(0L);
+ pcf.setMaxFlex(flexEnts);
+ HibernateFactory.getSession().save(pcf);
+
+
cfam.addPrivateChannelFamily(pcf);
cfam = (ChannelFamily) TestUtils.reload(cfam);
return cfam;
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerGroupType.java
b/java/code/src/com/redhat/rhn/domain/server/ServerGroupType.java
index ede23eb..7a458f9 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerGroupType.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerGroupType.java
@@ -15,6 +15,8 @@
package com.redhat.rhn.domain.server;
import com.redhat.rhn.domain.AbstractLabelNameHelper;
+import com.redhat.rhn.domain.entitlement.Entitlement;
+import com.redhat.rhn.manager.entitlement.EntitlementManager;
import java.util.HashSet;
import java.util.Set;
@@ -74,4 +76,12 @@ public class ServerGroupType extends AbstractLabelNameHelper {
public void setFeatures(Set<Feature> featuresIn) {
features = featuresIn;
}
+
+ /**
+ * Get the associated Entitlement
+ * @return the Entitlement
+ */
+ public Entitlement getAssociatedEntitlement() {
+ return EntitlementManager.getByName(this.getLabel());
+ }
}
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
index 299067f..61fa278 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
@@ -20,10 +20,13 @@ import com.redhat.rhn.domain.server.ServerConstants;
import com.redhat.rhn.domain.server.ServerGroupType;
import com.redhat.rhn.domain.server.VirtualInstance;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.manager.entitlement.EntitlementManager;
+import com.redhat.rhn.manager.system.SystemManager;
import com.redhat.rhn.testing.TestUtils;
import org.hibernate.Session;
+import java.util.Date;
import java.util.Iterator;
@@ -80,6 +83,9 @@ public class HostBuilder {
private HostBuilder createHost(ServerGroupType type) throws Exception {
host = ServerFactoryTest.createTestServer(owner, true, type);
+ if (host.getBaseEntitlement() == null) {
+ SystemManager.entitleServer(host, EntitlementManager.MANAGEMENT);
+ }
return this;
}
@@ -162,11 +168,14 @@ public class HostBuilder {
virtualInstance.setUuid(TestUtils.randomString());
if (register) {
- guest = ServerFactoryTest.createTestServer(owner);
+ guest = ServerFactoryTest.createUnentitledTestServer(owner, true,
+ ServerFactoryTest.TYPE_SERVER_NORMAL , new Date());
virtualInstance.setGuestSystem(guest);
}
host.addGuest(virtualInstance);
+ TestUtils.saveAndFlush(host);
+ TestUtils.saveAndFlush(guest);
}
}
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
index 68f3016..42ef538 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
@@ -535,36 +535,42 @@ public class ServerFactoryTest extends RhnBaseTestCase {
new Date());
}
- public static Server createTestServer(User owner, boolean ensureOwnerAccess,
- ServerGroupType type, Date dateCreated) throws Exception {
- return createTestServer(owner, ensureOwnerAccess, type, TYPE_SERVER_NORMAL,
- dateCreated);
- }
public static Server createTestServer(User owner, boolean ensureOwnerAccess,
ServerGroupType type, int stype) throws Exception {
return createTestServer(owner, ensureOwnerAccess, type, stype, new Date());
}
+
+ private static Server createTestServer(User owner, boolean ensureOwnerAccess,
+ ServerGroupType type, int stype, Date dateCreated)
+ throws Exception {
+
+ Server newS = createUnentitledTestServer(owner, ensureOwnerAccess, stype,
+ dateCreated);
+
+ if (!type.getAssociatedEntitlement().isBase()) {
+ SystemManager.entitleServer(newS, EntitlementManager.MANAGEMENT);
+ }
+
+
+ EntitlementServerGroup sg = ServerGroupTestUtils.createEntitled(owner.getOrg(),
+ type);
+ SystemManager.entitleServer(newS, sg.getGroupType().getAssociatedEntitlement());
+ return (Server) TestUtils.saveAndReload(newS);
+ }
+
/**
* Create a test Server and commit it to the DB.
* @param owner the owner of this Server
* @param ensureOwnerAccess this flag will make sure the owner passed in has
* access to the new server.
* @return Server that was created
+ * @throws Exception if there are server creation errors
*/
- private static Server createTestServer(User owner, boolean ensureOwnerAccess,
- ServerGroupType type, int stype, Date dateCreated)
- throws Exception {
-
- //Create a server and a server group
- EntitlementServerGroup sg = ServerGroupTestUtils.createEntitled(owner.getOrg(),
- type);
- if (sg.getMaxMembers() != null) {
- sg.setMaxMembers(new Long(sg.getMaxMembers().longValue() + 10L));
- }
+ public static Server createUnentitledTestServer(User owner, boolean
ensureOwnerAccess,
+ int stype, Date dateCreated) throws Exception {
Server newS = createServer(stype);
-
// We have to commit this change manually since
// ServerGroups aren't actually mapped from within
// the Server class.
@@ -587,9 +593,11 @@ public class ServerFactoryTest extends RhnBaseTestCase {
newS.addNetworkInterface(netint);
+
ServerFactory.save(newS);
- ServerFactory.addServerToGroup(newS, sg);
+ TestUtils.saveAndReload(newS);
+
/* Since we added a server to the Org we need
* to update the User's permissions as associated with
@@ -705,7 +713,7 @@ public class ServerFactoryTest extends RhnBaseTestCase {
throws Exception {
return createTestServer(owner, ensureOwnerAccess,
- ServerConstants.getServerGroupTypeUpdateEntitled());
+ ServerConstants.getServerGroupTypeEnterpriseEntitled());
}
private static Server createServer(int type) {
@@ -988,4 +996,3 @@ public class ServerFactoryTest extends RhnBaseTestCase {
}
}
-
diff --git
a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
index 4f10446..2c9d9d5 100644
--- a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
@@ -22,9 +22,6 @@ import com.redhat.rhn.domain.server.VirtualInstanceFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
-import org.apache.commons.lang.BooleanUtils;
-
-import java.sql.Types;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -137,26 +134,4 @@ public class VirtualizationEntitlementsManager {
"Channel_queries", "convert_to_flex");
m.execute(in, new HashMap());
}
-
-
- /**
- * True if the passed in server can be converted to flex
- * @param sid the server id
- * @param cfid the channel family id
- * @return true if the server can be converted to flex
- */
- public boolean canConvertToFlex(Long sid, Long cfid) {
- Map in = new HashMap();
- in.put("sid", sid);
- in.put("cfid", cfid);
- Map outParams = new HashMap();
- outParams.put("result", new Integer(Types.NUMERIC));
-
- CallableMode m = ModeFactory.getCallableMode(
- "Channel_queries", "can_convert_to_flex");
-
- Map result = m.execute(in, outParams);
- return BooleanUtils.toBoolean(
- ((Long)result.get("result")).intValue());
- }
}
diff --git
a/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
b/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
new file mode 100644
index 0000000..9e5dca4
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/manager/system/test/VirtualizationEntitlementsManagerTest.java
@@ -0,0 +1,220 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.manager.system.test;
+
+import com.redhat.rhn.common.hibernate.HibernateFactory;
+import com.redhat.rhn.domain.channel.Channel;
+import com.redhat.rhn.domain.channel.ChannelFactory;
+import com.redhat.rhn.domain.channel.ChannelFamily;
+import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
+import com.redhat.rhn.domain.channel.test.ChannelFactoryTest;
+import com.redhat.rhn.domain.channel.test.ChannelFamilyFactoryTest;
+import
com.redhat.rhn.domain.org.Org;
+import com.redhat.rhn.domain.org.OrgFactory;
+import com.redhat.rhn.domain.role.RoleFactory;
+import com.redhat.rhn.domain.server.EntitlementServerGroup;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
+import com.redhat.rhn.domain.server.VirtualInstance;
+import com.redhat.rhn.domain.server.test.HostBuilder;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.domain.user.UserFactory;
+import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
+import com.redhat.rhn.manager.entitlement.EntitlementManager;
+import com.redhat.rhn.manager.org.UpdateOrgSoftwareEntitlementsCommand;
+import com.redhat.rhn.manager.org.UpdateOrgSystemEntitlementsCommand;
+import com.redhat.rhn.manager.system.ServerGroupManager;
+import com.redhat.rhn.manager.system.SystemManager;
+import com.redhat.rhn.manager.system.VirtualizationEntitlementsManager;
+import com.redhat.rhn.testing.RhnBaseTestCase;
+import com.redhat.rhn.testing.UserTestUtils;
+
+import org.apache.commons.lang.RandomStringUtils;
+
+import java.util.List;
+
+
+/**
+ * VirtualizationEntitlementsManagerTest
+ * @version $Rev$
+ */
+public class VirtualizationEntitlementsManagerTest extends RhnBaseTestCase {
+
+ public void testListFlexGuests() throws Exception {
+ Org org =
UserTestUtils.createNewOrgFull(RandomStringUtils.randomAlphabetic(10));
+ User user = UserTestUtils.createUser(RandomStringUtils.randomAlphabetic(10),
+ org.getId());
+ user.addRole(RoleFactory.ORG_ADMIN);
+ UserFactory.save(user);
+ long ents = 3;
+ int guestsToCreate = 6;
+ long flexEnts = guestsToCreate;
+ long sysEnts = guestsToCreate + 1; // 1 for host
+ //Give it some system entitlements
+ UpdateOrgSystemEntitlementsCommand cmd1 = new
UpdateOrgSystemEntitlementsCommand(
+ EntitlementManager.MANAGEMENT, org, sysEnts);
+ assertNull(cmd1.store());
+
+ ChannelFamily rhelFamily = ChannelFamilyFactoryTest.createTestChannelFamily(
+ UserFactory.findRandomOrgAdmin(OrgFactory.getSatelliteOrg()),
+ ents, flexEnts);
+ assertEquals(Long.valueOf(flexEnts),
+ rhelFamily.getMaxFlex(OrgFactory.getSatelliteOrg()));
+ UpdateOrgSoftwareEntitlementsCommand cmd2 = new
+ UpdateOrgSoftwareEntitlementsCommand(rhelFamily.getLabel(),
+ org, ents, flexEnts);
+ assertNull(cmd2.store());
+ Channel rhelChannel = ChannelFactoryTest.createBaseChannel(user, rhelFamily);
+
+
+ HibernateFactory.getSession().clear();
+ rhelChannel = ChannelFactory.lookupById(rhelChannel.getId());
+ assertNotNull(rhelChannel.getId());
+ assertNotNull(rhelChannel);
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertNotNull(rhelFamily);
+ assertNotNull(rhelFamily.getMaxFlex(org));
+ assertEquals(Long.valueOf(flexEnts), rhelFamily.getMaxFlex(org));
+
+ HostBuilder builder = new HostBuilder(org.getActiveOrgAdmins().get(0));
+ builder.createNonVirtHost().withGuests(guestsToCreate);
+ Server host = builder.build();
+ ServerFactory.save(host);
+
+ SystemManager.subscribeServerToChannel(user, host, rhelChannel);
+
+ ServerFactory.save(host);
+
+ for (VirtualInstance inst : host.getGuests()) {
+ SystemManager.subscribeServerToChannel(user,
+ inst.getGuestSystem(), rhelChannel);
+ SystemManager.entitleServer(inst.getGuestSystem(),
+ EntitlementManager.MANAGEMENT);
+ ServerFactory.save(inst.getGuestSystem());
+ }
+
+ HibernateFactory.getSession().clear();
+
+
+ //Verify everything is as it should be
+ EntitlementServerGroup mgmnt =
+ ServerGroupManager.getInstance().lookupEntitled(
+ EntitlementManager.MANAGEMENT, user);
+ assertEquals(Long.valueOf(sysEnts), mgmnt.getCurrentMembers());
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertEquals(Long.valueOf(1), rhelFamily.getCurrentMembers(org));
+ assertEquals(Long.valueOf(guestsToCreate), rhelFamily.getCurrentFlex(org));
+
+ List<ChannelFamilySystemGroup> l =
VirtualizationEntitlementsManager.getInstance().
+ listFlexGuests(user);
+ assertTrue(!l.isEmpty());
+ assertEquals(1, l.size());
+ assertEquals(guestsToCreate, l.get(0).expand().size());
+ }
+
+ public void testListEligibleFlexGuests() throws Exception {
+ Org org =
UserTestUtils.createNewOrgFull(RandomStringUtils.randomAlphabetic(10));
+ User user = UserTestUtils.createUser(RandomStringUtils.randomAlphabetic(10),
+ org.getId());
+ user.addRole(RoleFactory.ORG_ADMIN);
+ UserFactory.save(user);
+ int guestsToCreate = 6;
+ long flexEnts = guestsToCreate;
+ long ents = guestsToCreate + 1; //+ 1 for host
+ long sysEnts = guestsToCreate + 1; //+ 1 for host
+ //Give it some system entitlements
+ UpdateOrgSystemEntitlementsCommand cmd1 = new
UpdateOrgSystemEntitlementsCommand(
+ EntitlementManager.MANAGEMENT, org, sysEnts);
+ assertNull(cmd1.store());
+
+ ChannelFamily rhelFamily = ChannelFamilyFactoryTest.createTestChannelFamily(
+ UserFactory.findRandomOrgAdmin(OrgFactory.getSatelliteOrg()),
+ ents, flexEnts);
+ assertEquals(Long.valueOf(flexEnts),
+ rhelFamily.getMaxFlex(OrgFactory.getSatelliteOrg()));
+
+ //No flex initially
+ UpdateOrgSoftwareEntitlementsCommand cmd2 = new
+ UpdateOrgSoftwareEntitlementsCommand(rhelFamily.getLabel(),
+ org, ents, 0L);
+ assertNull(cmd2.store());
+ Channel rhelChannel = ChannelFactoryTest.createBaseChannel(user, rhelFamily);
+
+
+ HibernateFactory.getSession().clear();
+ rhelChannel = ChannelFactory.lookupById(rhelChannel.getId());
+ assertNotNull(rhelChannel.getId());
+ assertNotNull(rhelChannel);
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertNotNull(rhelFamily);
+ assertNotNull(rhelFamily.getMaxFlex(org));
+ assertEquals(Long.valueOf(0), rhelFamily.getMaxFlex(org));
+
+ HostBuilder builder = new HostBuilder(org.getActiveOrgAdmins().get(0));
+ builder.createNonVirtHost().withGuests(guestsToCreate);
+ Server host = builder.build();
+ ServerFactory.save(host);
+
+ SystemManager.subscribeServerToChannel(user, host, rhelChannel);
+
+ ServerFactory.save(host);
+ for (VirtualInstance inst : host.getGuests()) {
+ SystemManager.subscribeServerToChannel(user,
+ inst.getGuestSystem(), rhelChannel);
+ SystemManager.entitleServer(inst.getGuestSystem(),
+ EntitlementManager.MANAGEMENT);
+ ServerFactory.save(inst.getGuestSystem());
+ }
+
+ HibernateFactory.getSession().clear();
+
+
+ //Verify everything is as it should be
+ EntitlementServerGroup mgmnt =
+ ServerGroupManager.getInstance().lookupEntitled(
+ EntitlementManager.MANAGEMENT, user);
+ assertEquals(Long.valueOf(sysEnts), mgmnt.getCurrentMembers());
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertEquals(Long.valueOf(ents), rhelFamily.getCurrentMembers(org));
+ assertEquals(Long.valueOf(0), rhelFamily.getCurrentFlex(org));
+
+ assertTrue(VirtualizationEntitlementsManager.getInstance().
+ listFlexGuests(user).isEmpty());
+
+ //Now Uodate the rhenChannelFamily's flex entitlements
+
+ cmd2 = new UpdateOrgSoftwareEntitlementsCommand(rhelFamily.getLabel(),
+ org, ents, flexEnts);
+ assertNull(cmd2.store());
+ HibernateFactory.getSession().clear();
+
+ rhelFamily = ChannelFamilyFactory.lookupById(rhelFamily.getId());
+ assertEquals(Long.valueOf(flexEnts), rhelFamily.getMaxFlex(org));
+
+ List<ChannelFamilySystemGroup> l = VirtualizationEntitlementsManager.
+ getInstance().listEligibleFlexGuests(user);
+
+
+ assertTrue(!l.isEmpty());
+ assertEquals(1, l.size());
+ assertEquals(guestsToCreate, l.get(0).expand().size());
+ }
+
+
+}
diff --git a/java/code/src/com/redhat/rhn/testing/UserTestUtils.java
b/java/code/src/com/redhat/rhn/testing/UserTestUtils.java
index 308e2d1..04f61d9 100644
--- a/java/code/src/com/redhat/rhn/testing/UserTestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/UserTestUtils.java
@@ -53,15 +53,25 @@ public class UserTestUtils extends Assert {
* @return long The Org id.
*/
public static Long createOrg(String orgName) {
+ return createNewOrgFull(orgName).getId();
+ }
+
+ /**
+ * Creates a new Org with the given orgName.
+ * The current time is appended to the given orgName.
+ * @param orgName Name of org.
+ * @return long The Org
+ */
+ public static Org createNewOrgFull(String orgName) {
Org org1 = OrgFactory.createOrg();
org1.setName(orgName + TestUtils.randomString());
org1.setCustomerType("B");
org1 = OrgFactory.save(org1);
assertTrue(org1.getId().longValue() > 0);
-
- return org1.getId();
+ return org1;
}
+
/**
* Creates a new User and Org with the given userName and orgName.
* The current time is appended to the given username and orgName.
commit ed2d90da352118d0c1fd79113c27db3f74b56053
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 24 12:24:37 2010 -0400
Fixed some typos
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 559206f..b317046 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4465,14 +4465,14 @@ button below, and <b>will be unable to log back
in</b>.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
- <trans-unit id="Used/Alloted">
-<source>Used/Alloted</source>
+ <trans-unit id="Used/Allotted">
+<source>Used/Allotted</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
<trans-unit id="None Allocated">
-<source>None Alloted</source>
+<source>None Allotted</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
@@ -4516,8 +4516,8 @@ button below, and <b>will be unable to log back
in</b>.</source>
</context-group>
</trans-unit>
- <trans-unit id="Used/Alloted.tip">
-<source>'Alloted' refers to the total number of entitlements allocated to
any organization from initial pool as reflected in this @@PRODUCT_NAME@@'s
certificate. 'Used' refers to entitlements that have been consumed by systems in
various organizations.</source>
+ <trans-unit id="Used/Allotted.tip">
+<source>'Allotted' refers to the total number of entitlements allocated to
any organization from initial pool as reflected in this @@PRODUCT_NAME@@'s
certificate. 'Used' refers to entitlements that have been consumed by systems in
various organizations.</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
@@ -4732,8 +4732,8 @@ deducted from the default organization.</source>
</context-group>
</trans-unit>
- <trans-unit id="softwareEntitlementSubs.Used/Alloted">
-<source>'Alloted' refers to the total available entitlements to the
organizations (excluding the default @@PRODUCT_NAME@@ organization) on this
@@PRODUCT_NAME@@. It is not equal to the total available in the @@PRODUCT_NAME@@
certificate.</source>
+ <trans-unit id="softwareEntitlementSubs.Used/Allotted">
+<source>'Allotted' refers to the total available entitlements to the
organizations (excluding the default @@PRODUCT_NAME@@ organization) on this
@@PRODUCT_NAME@@. It is not equal to the total available in the @@PRODUCT_NAME@@
certificate.</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index f2b3505..f0ac87f 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -57,9 +57,17 @@
<a
href="/rhn/admin/multiorg/SoftwareEntitlementDetails.do?cfid=${current.id}"
tabindex="-1"><c:out value="${current.name}" /></a>
</rl:column>
<rl:column styleclass="center"
- headertext="${rhn:localize('Regular Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
- <c:out value="${current.currentMembers} / ${current.maxMembers}"
/>
- </rl:column>
+ headertext="${rhn:localize('Regular Usage')}
<br/>(${rhn:localize('Used/Allotted')})*">
+ <c:choose>
+ <c:when test="${empty current.maxMembers or current.maxMembers ==
0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ <c:out value="${current.currentMembers} /
${current.maxMembers}" />
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+
<rl:column
headerkey="Regular Proposed Total">
<c:choose>
@@ -83,8 +91,18 @@
</c:choose>
</rl:column>
<rl:column styleclass="center"
- headertext="${rhn:localize('Flex Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
- <c:out value="${current.currentFlex} / ${current.maxFlex}"
/>
+ headertext="${rhn:localize('Flex Usage')}
<br/>(${rhn:localize('Used/Allotted')})*">
+
+ <c:choose>
+ <c:when test="${empty current.maxFlex or current.maxFlex ==
0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ <c:out value="${current.currentFlex} / ${current.maxFlex}"
/>
+ </c:otherwise>
+ </c:choose>
+
+
</rl:column>
<rl:column bound="false"
@@ -110,7 +128,8 @@
</c:otherwise>
</c:choose>
</rl:column>
- </rl:list>
+ </rl:list>
+<p><rhn:tooltip>*-<bean:message key =
"Used/Allotted.tip"/></rhn:tooltip></p>
<c:if test="${param.oid != 1}">
<div align="right">
<hr/>
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
index 3443ed8..e449ace 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
@@ -65,7 +65,7 @@
<c:if test="${orgCount > 1}">
<rl:column
- headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Alloted')})**">
+ headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Allotted')})**">
<c:choose>
<c:when test="${empty current.allocated or current.allocated ==
0}">
<bean:message key="None Allocated"/>
@@ -92,7 +92,7 @@
<c:if test="${orgCount > 1}">
<rl:column bound="false"
- headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Alloted')})**"
+ headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Allotted')})**"
styleclass="${usagestyle}">
<c:choose>
@@ -110,6 +110,6 @@
</rl:listset>
<rhn:tooltip typeKey="Tip">*-<bean:message key =
"Available/Total.tip"/></rhn:tooltip>
-<rhn:tooltip typeKey="Tip">**-<bean:message key =
"Used/Alloted.tip"/></rhn:tooltip>
+<rhn:tooltip typeKey="Tip">**-<bean:message key =
"Used/Allotted.tip"/></rhn:tooltip>
</body>
</html:html>
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
index a19ce7d..9165ebf 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
@@ -50,7 +50,7 @@
</rl:column>
<c:if test="${not empty requestScope.regularAvailable}">
<rl:column
- headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Alloted')})*"
+ headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Allotted')})*"
<c:choose>
<c:when test="${empty current.maxMembers or current.maxMembers ==
0}">
@@ -86,7 +86,7 @@
</c:if>
<c:if test="${not empty requestScope.flexAvailable}">
<rl:column
- headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Alloted')})*"
+ headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Allotted')})*"
<c:choose>
<c:when test="${empty current.maxFlex or current.maxFlex ==
0}">
@@ -136,7 +136,7 @@
</rl:list>
</rl:listset>
</p>
-<rhn:tooltip key="softwareEntitlementSubs.Used/Alloted"/>
+<rhn:tooltip key="softwareEntitlementSubs.Used/Allotted"/>
<c:if test="${not empty requestScope.regularAvailable}">
<h2><bean:message
key="softwareEntitlementSubs.systemWideCounts.header.regular"/></h2>
commit c1599656ed63473691aa0841330575574c230946
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 20:49:00 2010 -0400
Added page sizes to flex multiorg pages
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index 7aeebdc..f2b3505 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -49,7 +49,7 @@
alphabarcolumn="name"
styleclass="list"
emptykey="orgsoftwaresubs.jsp.nochannelfams">
-
+ <rl:decorator name="PageSizeDecorator"/>
<rl:column
filterattr="name"
sortattr = "name"
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
index 367b72c..3443ed8 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
@@ -39,7 +39,7 @@
<rl:list alphabarcolumn="name"
styleclass="list"
emptykey="softwareentitlements.noentitlements">
-
+ <rl:decorator name="PageSizeDecorator"/>
<rl:column
sortattr="name"
filterattr="name"
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
index 1d7eec0..a19ce7d 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
@@ -38,7 +38,7 @@
styleId="multiorg-entitlement-listview"
alphabarcolumn="orgName"
emptykey="softwareEntitlementSubs.noOrgsFound">
-
+ <rl:decorator name="PageSizeDecorator"/>
<rl:column
filterattr="orgName"
sortattr="orgName"
commit 1ee80b0576ce1f0999b80652bb3b4836bc28b7be
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 20:44:47 2010 -0400
fixed a line typo where I forgot to clear the map create in session
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
index 206b7d1..55efd7d 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
@@ -112,6 +112,7 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
implements
getStrutsDelegate().saveMessages(request, ae);
}
else {
+ request.getSession().removeAttribute(makeLabel(request));
createSuccessMessage(request,
"softwareEntitlementSubs.successMessage",
org.getName());
retval = getStrutsDelegate().forwardParam(
commit 72299c7dcaebdc961977b0ccaa6fd7dccfee6f2b
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 20:39:04 2010 -0400
Added sorting to channel family-> orgs page
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
index 791f922..1d7eec0 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
@@ -31,7 +31,7 @@
<!-- Reuse the form opened by the list tag -->
<html:hidden property="submitted" value="true"/>
<html:hidden property="cfid" value="${channelFamily.id}"/>
- <html:hidden property="orgClicked" value="0"/>
+ <html:hidden property="orgClicked" value=""/>
<rl:list
styleclass="list"
@@ -41,6 +41,7 @@
<rl:column
filterattr="orgName"
+ sortattr="orgName"
headerkey="softwareEntitlementSubs.column.orgName"
styleclass="first-column">
<a
href="/rhn/admin/multiorg/OrgDetails.do?oid=${current.org.id}"
tabindex="-1">
commit 2a8a26ee6fc28bb98d9f7579ef359f677b4d4dc9
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 20:25:05 2010 -0400
Added flex magic to ChannelFamily -> Orgs page
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index 8e4b073..6d5c259 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -380,7 +380,9 @@ ORDER by cfo.name DESC
<mode name="channel_entitlement"
class="com.redhat.rhn.frontend.dto.ChannelOverview">
<query params="org_id, entitlement_id">
-SELECT CFO.id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url
+SELECT CFO.id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
+CFO.fve_current_members as current_flex, CFO.fve_max_members as max_flex,
+ CFO.has_subscription, CFO.url
FROM rhnChannelFamilyOverview CFO
WHERE CFO.org_id = :org_id
AND CFO.id = :entitlement_id
@@ -390,7 +392,9 @@ SELECT CFO.id, CFO.name, CFO.label, CFO.current_members,
CFO.max_members, CFO.ha
<mode name="channel_entitlement_for_all_orgs"
class="com.redhat.rhn.frontend.dto.ChannelOverview">
<query params="entitlement_id">
-SELECT CFO.id, CFO.org_id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url
+SELECT CFO.id, CFO.org_id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
+ CFO.fve_current_members as current_flex, CFO.fve_max_members as max_flex,
+ CFO.has_subscription, CFO.url
FROM rhnChannelFamilyOverview CFO
WHERE CFO.id = :entitlement_id
AND CFO.org_id in (SELECT ID FROM WEB_CUSTOMER)
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
index 9a032ac..adfbd69 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
@@ -246,7 +246,7 @@ public class ChannelFamily extends BaseDomainHelper {
*/
private PrivateChannelFamily getAllocation(Org orgIn) {
for (PrivateChannelFamily alloc : getPrivateChannelFamilies()) {
- if (orgIn.equals(alloc.getOrg())) {
+ if (orgIn.getId().equals(alloc.getOrg().getId())) {
return alloc;
}
}
diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgNameFilter.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgNameFilter.java
deleted file mode 100644
index 79bc10b..0000000
--- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgNameFilter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2009--2010 Red Hat, Inc.
- *
- * This software is licensed to you under the GNU General Public License,
- * version 2 (GPLv2). There is NO WARRANTY for this software, express or
- * implied, including the implied warranties of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
- * along with this software; if not, see
- *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * Red Hat trademarks are not licensed under GPLv2. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-package com.redhat.rhn.frontend.action.multiorg;
-
-import com.redhat.rhn.common.localization.LocalizationService;
-import com.redhat.rhn.frontend.taglibs.list.BaseListFilter;
-
-import java.util.Locale;
-import java.util.Map;
-
-
-/**
- * SoftwareEntitlementsFilter
- * @version $Rev$
- */
-public class OrgNameFilter extends BaseListFilter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void processMap(Map map, Locale userLocale) {
- LocalizationService ls =
- LocalizationService.getInstance();
- String filterBy = ls.getMessage("softwareEntitlementSubs.filterBy",
- userLocale);
- map.put(filterBy, "orgName");
- }
-
-}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
index b5841ab..206b7d1 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
@@ -14,20 +14,6 @@
*/
package com.redhat.rhn.frontend.action.multiorg;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.struts.action.ActionErrors;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionForward;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.DynaActionForm;
-
import com.redhat.rhn.common.validator.ValidatorError;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
@@ -39,19 +25,45 @@ import com.redhat.rhn.frontend.dto.OrgSoftwareEntitlementDto;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.org.OrgManager;
import com.redhat.rhn.manager.org.UpdateOrgSoftwareEntitlementsCommand;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* SoftwareEntitlementSubscriptionsAction
* @version $Rev$
*/
-public class SoftwareEntitlementSubscriptionsAction extends RhnAction {
+public class SoftwareEntitlementSubscriptionsAction extends RhnAction implements Listable
{
private static Logger log = Logger.getLogger(
SoftwareEntitlementSubscriptionsAction.class);
+ private static final String ORGS = "orgs";
+
+ private static String makeLabel(HttpServletRequest request) {
+ RequestContext ctx = new RequestContext(request);
+ Long cfid = ctx.getParamAsLong("cfid");
+ return "SoftwareEntitlementSubscriptionsAction" + cfid;
+ }
+
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
@@ -65,26 +77,36 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
Long cfid = ctx.getParamAsLong("cfid");
ChannelFamily channelFamily = ChannelFamilyFactory.lookupById(cfid);
-
+
// custom channel, redirect to entitlement page
Long max = channelFamily.getMaxMembers(OrgFactory.getSatelliteOrg());
if (max == null) {
return mapping.findForward("unlimited");
}
- ActionForward retval = getStrutsDelegate().forwardParam(mapping.findForward(
- "default"), "cfid", cfid.toString());
+ Map params = new HashMap();
+ params.put("cfid", cfid);
+ ListHelper helper = new ListHelper(this, request, params);
+ helper.execute();
+ ActionForward retval = mapping.findForward("default");
if (isSubmitted(dynaForm)) {
+
+ Map <String, String> subsMap = (Map <String, String>)
+ request.getSession().getAttribute(makeLabel(request));
+ for (String id : subsMap.keySet()) {
+ if (request.getParameter(id) != null) {
+ subsMap.put(id, request.getParameter(id));
+ }
+ }
+
String orgClickedStr = request.getParameter("orgClicked");
- String newCountStr = request.getParameter("newCount_" +
orgClickedStr);
-
- if (newCountStr != null && !StringUtils.isEmpty(newCountStr)) {
+ if (!StringUtils.isBlank(orgClickedStr)) {
Long orgId = Long.parseLong(orgClickedStr);
Org org = OrgFactory.lookupById(orgId);
ActionErrors ae = updateSubscriptions(org, dynaForm, request,
- channelFamily, newCountStr);
+ channelFamily, subsMap);
if (ae != null && ae.size() > 0) {
getStrutsDelegate().saveMessages(request, ae);
@@ -101,7 +123,21 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
log.debug("Ignoring form submit (likely a page change)");
}
}
-
+ else {
+ Map<String, String> subsMap = new HashMap<String, String>();
+ List <OrgSoftwareEntitlementDto> subs = helper.getDataSet();
+ for (OrgSoftwareEntitlementDto sub : subs) {
+ if (sub.getMaxPossibleAllocation() > 0) {
+ subsMap.put(sub.getKey(), sub.getMaxMembers().toString());
+ }
+ if (sub.getMaxPossibleFlexAllocation() > 0) {
+ subsMap.put(sub.getFlexKey(), sub.getMaxFlex().toString());
+ }
+ }
+ request.getSession().setAttribute(makeLabel(request), subsMap);
+ }
+ request.setAttribute(ORGS,
+ request.getSession().getAttribute(makeLabel(request)));
setupFormValues(request, user, cfid, channelFamily);
return retval;
@@ -110,10 +146,8 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
private void setupFormValues(HttpServletRequest request, User user,
Long cfid, ChannelFamily channelFamily) {
Org satelliteOrg = OrgFactory.getSatelliteOrg();
-
setupOrgEntitlementUsageList(request, user, satelliteOrg, channelFamily);
setupEntitlementUsageTotals(request, cfid, satelliteOrg, user);
-
request.setAttribute("channelFamily", channelFamily);
}
@@ -122,28 +156,13 @@ public class SoftwareEntitlementSubscriptionsAction extends
RhnAction {
*/
private void setupOrgEntitlementUsageList(HttpServletRequest request,
User user, Org satelliteOrg, ChannelFamily cf) {
-
- List<OrgSoftwareEntitlementDto> entitlementUsage =
- ChannelManager.listEntitlementsForAllOrgsWithEmptyOrgs(cf,
user);
-
- for (Iterator <OrgSoftwareEntitlementDto> itr =
- entitlementUsage.iterator(); itr.hasNext();) {
- OrgSoftwareEntitlementDto dto = itr.next();
- if (satelliteOrg.equals(dto.getOrg())) {
- itr.remove();
- }
- }
-
ChannelOverview satelliteOrgOverview = ChannelManager.getEntitlement(
satelliteOrg.getId(), cf.getId());
if (satelliteOrgOverview == null) {
log.error("Default org does not appear to have been allocated
entitlement:" +
cf.getId());
}
- request.setAttribute("pageList", entitlementUsage);
- request.setAttribute("parentUrl", request.getRequestURI());
request.setAttribute("satelliteOrgOverview", satelliteOrgOverview);
-
}
private void setupEntitlementUsageTotals(HttpServletRequest request,
@@ -151,79 +170,131 @@ public class SoftwareEntitlementSubscriptionsAction extends
RhnAction {
List<ChannelOverview> channelOverviews =
ChannelManager.getEntitlementForAllOrgs(cfid);
- Long entitlementsMaxMembers = new Long(0);
- Long entitlementsCurrentMembers = new Long(0);
+ Long maxMembers = new Long(0);
+ Long currMembers = new Long(0);
Long entitlementRatio = new Long(0);
Long orgRatio = new Long(0);
Long entitledOrgs = new Long(0);
+ boolean regularAvailable = false;
+
+
+ long currFlex = 0;
+ long maxFlex = 0;
+ long flexEntRatio = 0;
+ long flexOrgRatio = 0;
+ long flexEntitledOrgs = 0;
+ boolean flexAvailable = false;
+
// don't include default org
Long orgCount = OrgManager.getTotalOrgCount(user) - 1;
-
for (ChannelOverview co : channelOverviews) {
if (co.getOrgId().equals(satelliteOrg.getId())) {
+ flexAvailable = co.getFreeFlex() > 0;
+ regularAvailable = co.getFreeMembers() > 0;
continue;
}
- entitlementsCurrentMembers += co.getCurrentMembers();
-
- entitlementsMaxMembers += co.getMaxMembers();
+
+ currMembers += co.getCurrentMembers();
+ maxMembers += co.getMaxMembers();
+ currFlex += co.getCurrentFlex();
+ maxFlex += co.getMaxFlex();
+
if (co.getMaxMembers() > 0) {
// manually count rather then use list size since max mem can be 0
entitledOrgs++;
+ regularAvailable = true;
}
+
+ if (co.getMaxFlex() > 0) {
+ flexAvailable = true;
+ flexEntitledOrgs++;
+ }
}
try {
- entitlementRatio = entitlementsCurrentMembers * 100 /
entitlementsMaxMembers;
+ if (maxMembers > 0) {
+ entitlementRatio = currMembers * 100 / maxMembers;
+ }
+ if (maxFlex > 0) {
+ flexEntRatio = currFlex * 100 / maxFlex;
+ }
+ if (orgCount > 0) {
+ orgRatio = entitledOrgs * 100 / orgCount;
+ flexOrgRatio = flexEntitledOrgs * 100 / orgCount;
+ }
+
}
catch (Exception e) {
//default to 0
}
- try {
- orgRatio = entitledOrgs * 100 / orgCount;
- }
- catch (Exception e) {
- //default to 0
- }
request.setAttribute("orgCount", orgCount);
request.setAttribute("entitledOrgs", entitledOrgs);
- request.setAttribute("maxMem", entitlementsMaxMembers);
- request.setAttribute("curMem", entitlementsCurrentMembers);
+ request.setAttribute("maxMem", maxMembers);
+ request.setAttribute("curMem", currMembers);
request.setAttribute("entRatio", entitlementRatio);
request.setAttribute("orgRatio", orgRatio);
+ if (regularAvailable) {
+ request.setAttribute("regularAvailable", Boolean.TRUE);
+ }
+
+
+ request.setAttribute("flexEntitledOrgs", flexEntitledOrgs);
+ request.setAttribute("maxFlex", maxFlex);
+ request.setAttribute("curFlex", currFlex);
+ request.setAttribute("flexEntRatio", flexEntRatio);
+ request.setAttribute("flexOrgRatio", flexOrgRatio);
+ if (flexAvailable) {
+ request.setAttribute("flexAvailable", Boolean.TRUE);
+ }
}
private ActionErrors updateSubscriptions(Org org, DynaActionForm dynaForm,
- HttpServletRequest request, ChannelFamily channelFamily, String newCountStr)
{
+ HttpServletRequest request, ChannelFamily channelFamily,
+ Map<String, String> subsMap) {
ActionErrors ae = new ActionErrors();
- Long newCount = null;
- try {
- newCount = Long.parseLong(newCountStr.trim());
+ long regCount = 0;
+ long flexCount = 0;
+
+ if (subsMap.containsKey(OrgSoftwareEntitlementDto.makeFlexKey(org.getId()))) {
+ try {
+ String flexValue = subsMap.get(
+ OrgSoftwareEntitlementDto.makeFlexKey(org.getId()));
+ flexCount = Long.parseLong(flexValue.trim());
+ }
+ catch (NumberFormatException e) {
+ ValidatorError error = new ValidatorError(
+ "softwareEntitlementSubs.invalidInput");
+ ae.add(RhnValidationHelper.validatorErrorToActionErrors(error));
+ }
}
- catch (NumberFormatException e) {
- ValidatorError error = new ValidatorError(
- "softwareEntitlementSubs.invalidInput");
- ae.add(RhnValidationHelper.validatorErrorToActionErrors(error));
- return ae;
+
+ if (subsMap.containsKey(OrgSoftwareEntitlementDto.makeKey(org.getId()))) {
+ try {
+ String value = subsMap.get(
+ OrgSoftwareEntitlementDto.makeKey(org.getId()));
+ regCount = Long.parseLong(value.trim());
+ }
+ catch (NumberFormatException e) {
+ ValidatorError error = new ValidatorError(
+ "softwareEntitlementSubs.invalidInput");
+ ae.add(RhnValidationHelper.validatorErrorToActionErrors(error));
+ }
}
- if (newCount < 0) {
- ValidatorError error = new ValidatorError(
- "softwareEntitlementSubs.invalidInput");
- ae.add(RhnValidationHelper.validatorErrorToActionErrors(error));
+ if (ae.size() > 0) {
return ae;
}
-
if (org.getId().equals(OrgFactory.getSatelliteOrg().getId())) {
createErrorMessage(request, "org.entitlements.system.defaultorg",
null);
return null;
}
-
+
UpdateOrgSoftwareEntitlementsCommand updateCmd = null;
try {
updateCmd = new
UpdateOrgSoftwareEntitlementsCommand(channelFamily.getLabel(),
- org, newCount, 0L);
+ org, regCount, flexCount);
}
catch (IllegalArgumentException e) {
ValidatorError error = new ValidatorError(
@@ -242,4 +313,25 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
}
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ ChannelFamily cf = ChannelFamilyFactory.
+ lookupById(contextIn.getParamAsLong("cfid"));
+ List<OrgSoftwareEntitlementDto> entitlementUsage =
+ ChannelManager.listEntitlementsForAllOrgsWithEmptyOrgs(cf,
+
contextIn.getLoggedInUser());
+ Org satelliteOrg = OrgFactory.getSatelliteOrg();
+
+ for (Iterator <OrgSoftwareEntitlementDto> itr =
+ entitlementUsage.iterator(); itr.hasNext();) {
+ OrgSoftwareEntitlementDto dto = itr.next();
+ if (satelliteOrg.equals(dto.getOrg())) {
+ itr.remove();
+ }
+ }
+ return entitlementUsage;
+ }
+
}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
index 53d8d36..1ffd4aa 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
@@ -33,6 +33,11 @@ public class ChannelOverview extends BaseDto implements Comparable {
private Long currentFlex;
private Long maxFlex;
private Long subscribeCount;
+ private Long hasSubscription;
+ private String url;
+ private Long relevantPackages;
+ private Long originalId;
+ private List<PackageDto> packages = new ArrayList<PackageDto>();
/**
@@ -88,14 +93,17 @@ public class ChannelOverview extends BaseDto implements Comparable {
this.maxFlex = maxFlexIn;
}
-
-
- private Long hasSubscription;
- private String url;
- private Long relevantPackages;
- private Long originalId;
- private List<PackageDto> packages = new ArrayList<PackageDto>();
-
+ /**
+ * @return Returns the free flex members.
+ */
+ public Long getFreeFlex() {
+ // Looks like the schema sadly allows this to be null:
+ Long max = maxFlex;
+ if (max == null || max == 0) {
+ return 0L;
+ }
+ return max - currentFlex;
+ }
/**
* @return Returns the originalId.
@@ -146,8 +154,8 @@ public class ChannelOverview extends BaseDto implements Comparable {
public Long getFreeMembers() {
// Looks like the schema sadly allows this to be null:
Long max = maxMembers;
- if (max == null) {
- max = new Long(0);
+ if (max == null || max == 0) {
+ return 0L;
}
return max - currentMembers;
}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/OrgSoftwareEntitlementDto.java
b/java/code/src/com/redhat/rhn/frontend/dto/OrgSoftwareEntitlementDto.java
index 114e066..768993f 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/OrgSoftwareEntitlementDto.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/OrgSoftwareEntitlementDto.java
@@ -28,23 +28,42 @@ public class OrgSoftwareEntitlementDto {
private Long currentMembers;
private Long maxMembers;
private Long maxPossibleAllocation;
+ private Long currentFlex;
+ private Long maxFlex;
+ private Long maxPossibleFlexAllocation;
/**
- * Constructor
- * @param orgIn Org
- * @param currentMembersIn Current member count
- * @param maxMembersIn Current max member count
- * @param maxPossibleAllocationIn Maximum possible allocation
+ * @param orgIn The org to set.
*/
- public OrgSoftwareEntitlementDto(Org orgIn, Long currentMembersIn, Long maxMembersIn,
- Long maxPossibleAllocationIn) {
-
this.org = orgIn;
- this.currentMembers = currentMembersIn;
- this.maxMembers = maxMembersIn;
- this.maxPossibleAllocation = maxPossibleAllocationIn;
+ public void setOrg(Org orgIn) {
+ org = orgIn;
}
+
/**
+ * @param currentMembersIn The currentMembers to set.
+ */
+ public void setCurrentMembers(Long currentMembersIn) {
+ currentMembers = currentMembersIn;
+ }
+
+
+ /**
+ * @param maxMembersIn The maxMembers to set.
+ */
+ public void setMaxMembers(Long maxMembersIn) {
+ maxMembers = maxMembersIn;
+ }
+
+
+ /**
+ * @param maxPossibleAllocationIn The maxPossibleAllocation to set.
+ */
+ public void setMaxPossibleAllocation(Long maxPossibleAllocationIn) {
+ maxPossibleAllocation = maxPossibleAllocationIn;
+ }
+
+ /**
* @return The org in question.
*/
public Org getOrg() {
@@ -93,6 +112,93 @@ public class OrgSoftwareEntitlementDto {
* @return Max possible allocation.
*/
public Long getMaxPossibleAllocation() {
+ if (maxPossibleAllocation == null) {
+ return 0L;
+ }
return maxPossibleAllocation;
}
+
+
+ /**
+ * @return Returns the currentFlex.
+ */
+ public Long getCurrentFlex() {
+ return currentFlex;
+ }
+
+
+ /**
+ * @param currentFlexIn The currentFlex to set.
+ */
+ public void setCurrentFlex(Long currentFlexIn) {
+ currentFlex = currentFlexIn;
+ }
+
+
+ /**
+ * @return Returns the maxFlex.
+ */
+ public Long getMaxFlex() {
+ return maxFlex;
+ }
+
+
+ /**
+ * @param maxFlexIn The maxFlex to set.
+ */
+ public void setMaxFlex(Long maxFlexIn) {
+ maxFlex = maxFlexIn;
+ }
+
+
+ /**
+ * @return Returns the maxPossibleFlexAllocation.
+ */
+ public Long getMaxPossibleFlexAllocation() {
+ if (maxPossibleFlexAllocation == null) {
+ return 0L;
+ }
+ return maxPossibleFlexAllocation;
+ }
+
+
+ /**
+ * @param maxPossibleFlexAllocationIn The maxPossibleFlexAllocation to set.
+ */
+ public void setMaxPossibleFlexAllocation(Long maxPossibleFlexAllocationIn) {
+ maxPossibleFlexAllocation = maxPossibleFlexAllocationIn;
+ }
+
+
+ /**
+ * @return the key
+ */
+ public String getKey() {
+ return makeKey(getOrg().getId());
+ }
+
+ /**
+ * @return the key
+ */
+ public String getFlexKey() {
+ return makeFlexKey(getOrg().getId());
+ }
+
+
+ /**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeKey(Long id) {
+ return String.valueOf(id);
+ }
+
+
+ /**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeFlexKey(Long id) {
+ return id + "-flex";
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 8c59f44..559206f 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4701,12 +4701,18 @@ deducted from the default organization.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareEntitlementSubs.systemWideCounts.header">
-<source>System-Wide Entitlement Counts</source>
+ <trans-unit
id="softwareEntitlementSubs.systemWideCounts.header.regular">
+<source>System-Wide Regular Entitlement Counts</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
+ <trans-unit
id="softwareEntitlementSubs.systemWideCounts.header.flex">
+<source>System-Wide Flex Entitlement Counts</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="softwareEntitlementSubs.submit">
<source>Update</source>
<context-group name="ctx">
@@ -4725,14 +4731,15 @@ deducted from the default organization.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareEntitlementSubs.totaltip">
-<source><strong>Tip:</strong> 'Total' refers to
the total available entitlements to the organizations (excluding the default
@@PRODUCT_NAME@@ organization) on this @@PRODUCT_NAME@@. It is not equal to the total
available in the @@PRODUCT_NAME@@ certificate.</source>
+
+ <trans-unit id="softwareEntitlementSubs.Used/Alloted">
+<source>'Alloted' refers to the total available entitlements to the
organizations (excluding the default @@PRODUCT_NAME@@ organization) on this
@@PRODUCT_NAME@@. It is not equal to the total available in the @@PRODUCT_NAME@@
certificate.</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
<trans-unit
id="softwareEntitlementSubs.systemWideCounts.totaltip">
-<source><strong>Tip:</strong> This total corresponds to
your @@PRODUCT_NAME@@ certificate's
+<source> This total corresponds to your @@PRODUCT_NAME@@ certificate's
value for this entitlement, excluding the default organization's
consumption.</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
@@ -4744,12 +4751,14 @@ value for this entitlement, excluding the default
organization's consumption.</s
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
+
<trans-unit
id="softwareEntitlementSubs.systemWideCounts.orgUsage">
<source>Organization Usage</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
+
<trans-unit
id="softwareEntitlementSubs.systemWideCounts.entUsageData">
<source>{0} of {1} ({2}%)</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index c773824..1e30559 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -325,8 +325,8 @@ public class ChannelManager extends BaseManager {
// Create a mapping of org ID's to the channel overview returned, we'll
need this
// when iterating the list of all orgs shortly:
- Map<Long, ChannelOverview> orgEntitlementUsage =
- new HashMap<Long, ChannelOverview>();
+ Map<Long, ChannelOverview> orgEntitlementUsage = new
+ HashMap<Long, ChannelOverview>();
for (ChannelOverview o : entitlementUsage) {
orgEntitlementUsage.put(o.getOrgId(), o);
}
@@ -344,24 +344,42 @@ public class ChannelManager extends BaseManager {
for (Org org : allOrgs) {
if (orgEntitlementUsage.containsKey(org.getId())) {
ChannelOverview co = orgEntitlementUsage.get(org.getId());
- if (co.getMaxMembers() == 0) {
+ if (co.getMaxMembers() == 0 && co.getMaxFlex() == 0) {
continue;
}
- Long maxPossibleAllocation = null;
- if (co.getMaxMembers() != null &&
- satelliteOrgOverview.getFreeMembers() != null) {
- maxPossibleAllocation = co.getMaxMembers() +
- satelliteOrgOverview.getFreeMembers();
- }
- OrgSoftwareEntitlementDto seDto = new OrgSoftwareEntitlementDto(org,
- co.getCurrentMembers(), co.getMaxMembers(), maxPossibleAllocation);
- ret.add(seDto);
+ ret.add(makeOrgSoftwareEntitlement(co, org, satelliteOrgOverview));
}
}
return ret;
}
+
+ private static OrgSoftwareEntitlementDto makeOrgSoftwareEntitlement(
+ ChannelOverview co,
+ Org org,
+ ChannelOverview satelliteOrgOverview) {
+ OrgSoftwareEntitlementDto seDto = new OrgSoftwareEntitlementDto();
+ seDto.setOrg(org);
+ seDto.setCurrentMembers(co.getCurrentMembers());
+ seDto.setMaxMembers(co.getMaxMembers());
+ if (co.getMaxMembers() != null &&
+ satelliteOrgOverview.getFreeMembers() != null) {
+ seDto.setMaxPossibleAllocation(co.getMaxMembers() +
+ satelliteOrgOverview.getFreeMembers());
+ }
+
+ seDto.setCurrentFlex(co.getCurrentFlex());
+ seDto.setMaxFlex(co.getMaxFlex());
+
+ if (co.getMaxFlex() != null &&
+ satelliteOrgOverview.getFreeFlex() != null) {
+ seDto.setMaxPossibleFlexAllocation(co.getMaxFlex() +
+ satelliteOrgOverview.getFreeFlex());
+ }
+ return seDto;
+ }
+
/**
* Given a channel family, this method returns entitlement information on a per org
* basis. This call will return all organizations, even if it does not have any
@@ -399,28 +417,23 @@ public class ChannelManager extends BaseManager {
List<Org> allOrgs = OrgManager.allOrgs(user);
for (Org org : allOrgs) {
- Long maxPossibleAllocation = null;
-
if (orgEntitlementUsage.containsKey(org.getId())) {
ChannelOverview co = orgEntitlementUsage.get(org.getId());
-
- if (co.getMaxMembers() != null &&
- satelliteOrgOverview.getFreeMembers() != null) {
- maxPossibleAllocation = co.getMaxMembers() +
- satelliteOrgOverview.getFreeMembers();
- }
- OrgSoftwareEntitlementDto seDto = new OrgSoftwareEntitlementDto(org,
- co.getCurrentMembers(), co.getMaxMembers(), maxPossibleAllocation);
- ret.add(seDto);
+ ret.add(makeOrgSoftwareEntitlement(co, org, satelliteOrgOverview));
}
else {
- maxPossibleAllocation = satelliteOrgOverview.getFreeMembers();
- OrgSoftwareEntitlementDto seDto =
- new OrgSoftwareEntitlementDto(org, 0L, 0L, maxPossibleAllocation);
+ OrgSoftwareEntitlementDto seDto = new OrgSoftwareEntitlementDto();
+ seDto.setOrg(org);
+ seDto.setCurrentMembers(0L);
+ seDto.setMaxMembers(0L);
+ seDto.setMaxPossibleAllocation(satelliteOrgOverview.getFreeMembers());
+ seDto.setCurrentFlex(0L);
+ seDto.setMaxFlex(0L);
+ seDto.setMaxPossibleFlexAllocation(satelliteOrgOverview.getFreeFlex());
ret.add(seDto);
}
+
}
-
return ret;
}
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
index c24736a..791f922 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlementsubs.jsp
@@ -7,10 +7,9 @@
<html:html xhtml="true">
<head>
-<script src="/javascript/multiorg-entitlements.js"
type="text/javascript"> </script>
</head>
-<body onload="onLoadStuff(4);">
+<body>
<rhn:toolbar base="h1" img="/img/rhn-icon-channels.gif"
miscUrl="${url}"
miscAcl="user_role(org_admin)"
@@ -34,68 +33,111 @@
<html:hidden property="cfid" value="${channelFamily.id}"/>
<html:hidden property="orgClicked" value="0"/>
- <rl:list dataset="pageList"
- width="100%"
- name="pageList"
- filter="com.redhat.rhn.frontend.action.multiorg.OrgNameFilter"
+ <rl:list
styleclass="list"
styleId="multiorg-entitlement-listview"
alphabarcolumn="orgName"
emptykey="softwareEntitlementSubs.noOrgsFound">
- <rl:column bound="false"
- sortable="false"
+ <rl:column
+ filterattr="orgName"
headerkey="softwareEntitlementSubs.column.orgName"
styleclass="first-column">
- <a
href="/rhn/admin/multiorg/OrgDetails.do?oid=${current.org.id}">
+ <a
href="/rhn/admin/multiorg/OrgDetails.do?oid=${current.org.id}"
tabindex="-1">
${current.orgName}
</a>
</rl:column>
-
- <rl:column bound="true"
- sortable="false"
- headerkey="softwareEntitlementSubs.column.total"
- attr="maxMembersDisplay"/>
-
- <rl:column bound="true"
- sortable="false"
- headerkey="softwareEntitlementSubs.column.currentMembers"
- attr="currentMembers"/>
-
- <rl:column bound="false"
- sortable="false"
- headerkey="softwareEntitlementSubs.column.proposedTotal"
- styleclass="last-column"
- attr="maxMembers">
-
- <c:choose>
- <c:when test="${current.maxMembers != null}">
- <div id="id${current.org.id}">
- <html:text property="newCount_${current.org.id}"
size="5" value="${current.maxMembers}"
+ <c:if test="${not empty requestScope.regularAvailable}">
+ <rl:column
+ headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Alloted')})*"
+ >
+ <c:choose>
+ <c:when test="${empty current.maxMembers or current.maxMembers ==
0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ ${current.currentMembers}/${current.maxMembers}
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+
+ <rl:column
+ headerkey="Regular Proposed Total">
+ <c:choose>
+ <c:when test = "${current.maxPossibleAllocation == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <div id="id${current.key}">
+ <html:text property="${current.key}" size="10"
value="${requestScope.orgs[current.key]}"
onkeydown="return blockEnter(event)"
-
onclick="rowHash['id${current.org.id}'].toggleVisibility();"/>
- <html:submit onclick="this.form.orgClicked.value =
'${current.org.id}';">
- <bean:message
key="softwareEntitlementSubs.submit"/>
- </html:submit>
+ />
<br/>
- <div class="small-text"
id="id${current.org.id}-tooltip">
+ <div class="small-text"
id="id${current.key}-tooltip">
<bean:message
key="softwareEntitlementSubs.possibleValues"
arg0="0"
arg1="${current.maxMembers +
satelliteOrgOverview.freeMembers}"/>
</div>
</div>
- </c:when>
- </c:choose>
-
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ </c:if>
+ <c:if test="${not empty requestScope.flexAvailable}">
+ <rl:column
+ headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Alloted')})*"
+ >
+ <c:choose>
+ <c:when test="${empty current.maxFlex or current.maxFlex ==
0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ ${current.currentFlex}/${current.maxFlex}
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+
+ <rl:column
+ headerkey="Flex Proposed Total">
+ <c:choose>
+ <c:when test = "${current.maxPossibleFlexAllocation == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <div id="id${current.flexKey}">
+ <html:text property="${current.flexKey}"
size="10" value="${requestScope.orgs[current.flexKey]}"
+ onkeydown="return blockEnter(event)"
+ />
+ <br/>
+ <div class="small-text"
id="id${current.flexKey}-tooltip">
+ <bean:message
key="softwareEntitlementSubs.possibleValues"
+ arg0="0"
+ arg1="${current.maxFlex +
satelliteOrgOverview.freeFlex}"/>
+ </div>
+ </div>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ </c:if>
+
+ <rl:column
+ headerkey="emptyspace.jsp"
+ styleclass="last-column"
+ >
+ <c:if test = "${current.maxPossibleAllocation > 0 ||
current.maxPossibleFlexAllocation > 0}">
+ <html:submit onclick="this.form.orgClicked.value =
'${current.org.id}';">
+ <bean:message
key="softwareEntitlementSubs.submit"/>
+ </html:submit>
+ </c:if>
+
</rl:column>
</rl:list>
</rl:listset>
</p>
- <span class="small-text">
- <bean:message key="softwareEntitlementSubs.totaltip"/>
- </span>
-<h2><bean:message
key="softwareEntitlementSubs.systemWideCounts.header"/></h2>
+<rhn:tooltip key="softwareEntitlementSubs.Used/Alloted"/>
+<c:if test="${not empty requestScope.regularAvailable}">
+<h2><bean:message
key="softwareEntitlementSubs.systemWideCounts.header.regular"/></h2>
<table class="details">
<tr>
@@ -105,8 +147,7 @@
<td>
${maxMem}
<p/>
- <span class="small-text">
- <bean:message
key="softwareEntitlementSubs.systemWideCounts.totaltip"/></em>
+ <rhn:tooltip
key="softwareEntitlementSubs.systemWideCounts.totaltip"/>
</span>
</td>
</tr>
@@ -127,9 +168,44 @@
<bean:message
key="softwareEntitlementSubs.systemWideCounts.orgUsageData"
arg0="${entitledOrgs}" arg1="${orgCount}"
arg2="${orgRatio}" />
</td>
- </tr>
+ </tr>
</table>
+</c:if>
+<c:if test="${not empty requestScope.flexAvailable}">
+<h2><bean:message
key="softwareEntitlementSubs.systemWideCounts.header.flex"/></h2>
+<table class="details">
+ <tr>
+ <th>
+ <strong><bean:message
key="softwareEntitlementSubs.systemWideCounts.total"/>:</strong>
+ </th>
+ <td>
+ ${maxFlex}
+ <p/>
+ <rhn:tooltip
key="softwareEntitlementSubs.systemWideCounts.totaltip"/>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <strong><bean:message
key="softwareEntitlementSubs.systemWideCounts.entUsage"/>:</strong>
+ </th>
+ <td>
+ <bean:message
key="softwareEntitlementSubs.systemWideCounts.entUsageData"
+ arg0="${curFlex}" arg1="${maxFlex}"
arg2="${flexEntRatio}" />
+ </td>
+ </tr>
+ <tr>
+ <th>
+ <strong><bean:message
key="softwareEntitlementSubs.systemWideCounts.orgUsage"/>:</strong>
+ </th>
+ <td>
+ <bean:message
key="softwareEntitlementSubs.systemWideCounts.orgUsageData"
+ arg0="${flexEntitledOrgs}" arg1="${orgCount}"
arg2="${flexOrgRatio}" />
+ </td>
+ </tr>
+</table>
+</c:if>
</body>
</html:html>
diff --git a/web/html/javascript/multiorg-entitlements.js
b/web/html/javascript/multiorg-entitlements.js
deleted file mode 100644
index a54ee17..0000000
--- a/web/html/javascript/multiorg-entitlements.js
+++ /dev/null
@@ -1,163 +0,0 @@
-var rowHash = new Array();
-var browserType;
-var columnsPerRow;
-
-// tip of the Red Hat to Mar Orlygsson for this little IE detection script
-var is_ie/*@cc_on = {
- quirksmode : (document.compatMode=="BackCompat"),
- version : parseFloat(navigator.appVersion.match(/MSIE (.+?);/)[1])
-}@*/;
-browserType = is_ie;
-
-function onLoadStuff(columns) {
- var channelTable = document.getElementById('multiorg-entitlement-listview');
- createParentRows(channelTable, rowHash);
- reuniteChildrenWithParents(channelTable, rowHash);
- hideAllRows();
-}
-
-function createParentRows(channelTable, rowHash) {
- for (var i = 0; i < channelTable.rows.length; i++) {
- tableRowNode = channelTable.rows[i];
-
- var rowParentDiv = getRowParentDiv(tableRowNode);
- if (rowParentDiv) {
- tableRowNode = rowParentDiv;
- if (!tableRowNode.id) { continue; }
- id = tableRowNode.id;
- var toolTip = findRowToolTip(id);
- if (!toolTip) { continue; }
- rowHash[id] = new Row(rowParentDiv, toolTip);
- }
- }
- return;
-}
-
-function Row(parentDiv, toolTip) {
- this.parentDiv = parentDiv;
- this.children = parentDiv.children;
- this.toolTip = toolTip;
- this.isHidden = 1; // 1 = hidden; 0 = visible. all rows are hidden by default
-
- // Row object methods below!
- this.toggleVisibility = function() {
- hideAllRows();
- this.show();
- return;
- }
-
- this.hide = function hide() {
- this.toolTip.style.visibility = 'hidden';
- this.isHidden = 1;
- return;
- }
-
- this.show = function show() {
- this.toolTip.style.visibility = 'visible';
- this.isHidden = 0;
- return;
- }
-}
-
-/* return 0 if not a parent, if a parent of a parent, return the node for the parent div
*/
-function getRowParentDiv(node) {
- /* make sure it's a tr */
- var trNodeInLowercase = getNodeTagName(node);
- var tdNode = null;
- var divNode = null;
-
- if (trNodeInLowercase != 'tr') { return 0; }
-
- /* now, iterate through the tds */
- for (var j = 0; j < node.childNodes.length; j++) {
- tdNode = node.childNodes[j];
- if (getNodeTagName(tdNode) != 'td') { continue; }
- if (tdNode.childNodes.length >= 3) {
- for (var k = 0; tdNode.childNodes[k]; k++) {
- divNode = tdNode.childNodes[k];
- if (getNodeTagName(divNode) != 'div') { continue; }
- if (divNode.id.indexOf('id')) { return 0; }
- return divNode;
- }
- }
- }
-}
-
-function findRowToolTip(id) {
- var toolTipId = id + '-tooltip';
- return document.getElementById(toolTipId);
-}
-
-function hideAllRows() {
- var row;
- for (var i in rowHash) {
- row = rowHash[i];
- if (!row) { continue; }
- if (!rowHash[i].toolTip) { continue; }
- row.hide();
- }
- return;
-}
-
-function showAllRows() {
- var row;
- for (var i in rowHash) {
- row = rowHash[i];
- if (!row) { continue; }
- if (!rowHash[i].toolTip) { continue; }
- row.show();
- }
- return;
-}
-
-
-
-
-// called from clicking the show/hide button on individual rows in the page
-function toggleRowVisibility(id) {
- if (!rowHash[id]) { return; }
- if (!rowHash[id].hasChildren) { return; }
- rowHash[id].toggleVisibility();
- return;
-}
-
-function reuniteChildrenWithParents(channelTable, rowHash) {
- var parentNode;
- var childId;
- var tableChildRowNode;
- for (var i = 0; i < channelTable.rows.length; i++) {
- tableChildRowNode = channelTable.rows[i];
- // when we find a parent, set it as parent for the children after it
- if (getRowParentDiv(tableChildRowNode) && tableChildRowNode.id) {
- parentNode = tableChildRowNode;
- continue;
- }
- if (!parentNode) { continue; }
-
- // it its not a child node we bail here
- if (!isChildRowNode(tableChildRowNode)) { continue; }
- // FIXME: chceck child id against parent id
- if (!rowHash[parentNode.id]) { continue; }
- for (var j = 0; j < tableChildRowNode.cells.length; j++) {
- rowHash[parentNode.id].cells.push(tableChildRowNode.cells[j]);
- rowHash[parentNode.id].hasChildren = 1;
- }
- }
- return;
-}
-
-function getNodeTagName(node) {
- var tagName;
- var nodeId;
- tagName = new String(node.tagName);
- return tagName.toLowerCase();
-}
-
-function isChildRowNode(node) {
- var nodeInLowercase = getNodeTagName(node);
- var nodeId;
- if (nodeInLowercase != 'tr') { return 0; }
- nodeId = node.id;
- if (nodeId.indexOf('child')) { return 0; }
- return 1;
-}
commit 8fff528d4406edff60f95d304568874f223327b3
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 14:16:54 2010 -0400
Added alphabar columns for the mutli org pages
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index 29fb8f4..7aeebdc 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -45,8 +45,8 @@
<rhn:submitted/>
<input type="hidden" name="oid"
value="${param.oid}"/>
- <rl:list
- width="100%"
+ <rl:list
+ alphabarcolumn="name"
styleclass="list"
emptykey="orgsoftwaresubs.jsp.nochannelfams">
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
index a11c4e1..367b72c 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
@@ -36,7 +36,7 @@
<rl:listset name="entitlementSet">
- <rl:list
+ <rl:list alphabarcolumn="name"
styleclass="list"
emptykey="softwareentitlements.noentitlements">
commit 4032f4accc87be723ae75774d83cd03014b2d9c1
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 14:12:13 2010 -0400
More verbiage on software entitlements page
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 402af22..8c59f44 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4465,6 +4465,12 @@ button below, and <b>will be unable to log back
in</b>.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
+ <trans-unit id="Used/Alloted">
+<source>Used/Alloted</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="None Allocated">
<source>None Alloted</source>
<context-group name="ctx">
@@ -4503,13 +4509,20 @@ button below, and <b>will be unable to log back
in</b>.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareentitlements.tip">
-<source><strong>*Tip:</strong> 'Total' refers
to the total available to the @@PRODUCT_NAME@@
-as reflected in this @@PRODUCT_NAME@@'s certificate.</source>
+ <trans-unit id="Available/Total.tip">
+<source>'Total' refers to the total available entitlements to the
@@PRODUCT_NAME@@ as reflected in this @@PRODUCT_NAME@@'s certificate.
'Available' refers to the number entitlements that are available to be allocated
to various organizations.</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
</context-group>
</trans-unit>
+
+ <trans-unit id="Used/Alloted.tip">
+<source>'Alloted' refers to the total number of entitlements allocated to
any organization from initial pool as reflected in this @@PRODUCT_NAME@@'s
certificate. 'Used' refers to entitlements that have been consumed by systems in
various organizations.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlementSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="satusers.tip">
<source><strong>*Tip:</strong> Organization
administrator privileges can
not be modified on this page. Instead, please visit the "Users" top-level
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
index 6675676..a11c4e1 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
@@ -52,7 +52,7 @@
</rl:column>
<rl:column
- headertext="${rhn:localize('Regular Counts')} <br/>
(${rhn:localize('Available/Total')}*)">
+ headertext="${rhn:localize('Regular Counts')} <br/>
(${rhn:localize('Available/Total')})*">
<c:choose>
<c:when test="${empty current.total or current.total ==
0}">
<bean:message key="softwareentitlements.noentitlements"/>
@@ -64,7 +64,8 @@
</rl:column>
<c:if test="${orgCount > 1}">
- <rl:column headerkey="Regular Usage">
+ <rl:column
+ headertext="${rhn:localize('Regular Usage')} <br/>
(${rhn:localize('Used/Alloted')})**">
<c:choose>
<c:when test="${empty current.allocated or current.allocated ==
0}">
<bean:message key="None Allocated"/>
@@ -78,7 +79,7 @@
<rl:column
styleclass="${countstyle}"
- headertext="${rhn:localize('Flex Counts')} <br/>
(${rhn:localize('Available/Total')}*)">
+ headertext="${rhn:localize('Flex Counts')} <br/>
(${rhn:localize('Available/Total')})*">
<c:choose>
<c:when test="${empty current.totalFlex or current.totalFlex ==
0}">
<bean:message key="softwareentitlements.noentitlements"/>
@@ -91,7 +92,7 @@
<c:if test="${orgCount > 1}">
<rl:column bound="false"
- headerkey="Flex Usage"
+ headertext="${rhn:localize('Flex Usage')} <br/>
(${rhn:localize('Used/Alloted')})**"
styleclass="${usagestyle}">
<c:choose>
@@ -102,17 +103,13 @@
<bean:message key="softwareentitlements.usagedata"
arg0="${current.usedFlex}" arg1="${current.allocatedFlex}"
arg2="${current.flexRatio}"/>
</c:otherwise>
</c:choose>
-
-
- </rl:column>
+ </rl:column>
</c:if>
</rl:list>
</rl:listset>
-<span class="small-text">
- <bean:message key="softwareentitlements.tip"/>
-</span>
-
+<rhn:tooltip typeKey="Tip">*-<bean:message key =
"Available/Total.tip"/></rhn:tooltip>
+<rhn:tooltip typeKey="Tip">**-<bean:message key =
"Used/Alloted.tip"/></rhn:tooltip>
</body>
</html:html>
commit 4a379d7479964b6105dd9da4413b324b29f62546
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 13:14:09 2010 -0400
Updated the software entitlements page to deal with FVE
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index f43463e..8e4b073 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -362,14 +362,18 @@ SELECT MAX(cfo.id) as id,
SUM(cfo.max_members) as total,
SUM(cfo.current_members) as used,
(SELECT (cfo2.max_members) - (cfo2.current_members)
- FROM rhnChannelFamilyOverview cfo2
- WHERE 1=1
- AND cfo2.name = cfo.name
- AND cfo2.org_id = 1) as available
+ FROM rhnChannelFamilyOverview cfo2
+ WHERE cfo2.label = cfo.label
+ AND cfo2.org_id = 1) as available,
+ SUM(cfo.fve_max_members) as total_flex,
+ SUM(cfo.fve_current_members) as used_flex,
+ (SELECT (cfo2.fve_max_members) - (cfo2.fve_current_members)
+ FROM rhnChannelFamilyOverview cfo2
+ WHERE cfo2.label = cfo.label AND cfo2.org_id = 1) as available_flex
FROM rhnChannelFamilyOverview cfo
-WHERE cfo.max_members is not null
+WHERE cfo.max_members is not null
GROUP BY cfo.label, cfo.name
-HAVING SUM(cfo.max_members) is not null
+HAVING (SUM(cfo.max_members) is not null)
ORDER by cfo.name DESC
</query>
</mode>
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsAction.java
index 61deb7a..f5ebb98 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsAction.java
@@ -14,11 +14,11 @@
*/
package com.redhat.rhn.frontend.action.multiorg;
-import com.redhat.rhn.common.db.datasource.DataList;
import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.frontend.dto.MultiOrgEntitlementsDto;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.org.OrgManager;
@@ -26,6 +26,8 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -34,7 +36,7 @@ import javax.servlet.http.HttpServletResponse;
* SoftwareEntitlementsAction
* @version $Rev$
*/
-public class SoftwareEntitlementsAction extends RhnAction {
+public class SoftwareEntitlementsAction extends RhnAction implements Listable {
/**
* ${@inheritDoc}
@@ -44,17 +46,19 @@ public class SoftwareEntitlementsAction extends RhnAction {
RequestContext requestContext = new RequestContext(request);
User u = requestContext.getLoggedInUser();
-
- DataList<MultiOrgEntitlementsDto> result =
- ChannelManager.entitlementsForAllMOrgs();
-
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
Long orgCount = OrgManager.getTotalOrgCount(u);
-
request.setAttribute("orgCount", orgCount);
- request.setAttribute("pageList", result);
- request.setAttribute("parentUrl", request.getRequestURI());
return mapping.findForward("default");
}
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ return ChannelManager.entitlementsForAllMOrgs();
+ }
+
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsFilter.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsFilter.java
deleted file mode 100644
index 5b0d420..0000000
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementsFilter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2009--2010 Red Hat, Inc.
- *
- * This software is licensed to you under the GNU General Public License,
- * version 2 (GPLv2). There is NO WARRANTY for this software, express or
- * implied, including the implied warranties of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
- * along with this software; if not, see
- *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * Red Hat trademarks are not licensed under GPLv2. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-package com.redhat.rhn.frontend.action.multiorg;
-
-import com.redhat.rhn.common.localization.LocalizationService;
-import com.redhat.rhn.frontend.taglibs.list.BaseListFilter;
-
-import java.util.Locale;
-import java.util.Map;
-
-
-/**
- * SoftwareEntitlementsFilter
- * @version $Rev$
- */
-public class SoftwareEntitlementsFilter extends BaseListFilter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void processMap(Map map, Locale userLocale) {
- LocalizationService ls =
- LocalizationService.getInstance();
- String filterBy =
ls.getMessage("softwareentitlements.header.entitlement.name",
- userLocale);
- map.put(filterBy, "name");
- }
-
-}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/MultiOrgEntitlementsDto.java
b/java/code/src/com/redhat/rhn/frontend/dto/MultiOrgEntitlementsDto.java
index c4012cd..8f26351 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/MultiOrgEntitlementsDto.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/MultiOrgEntitlementsDto.java
@@ -24,6 +24,7 @@ import java.math.BigDecimal;
public class MultiOrgEntitlementsDto extends BaseDto {
private Long id;
private Long total, used, available;
+ private Long totalFlex, usedFlex, availableFlex;
private String label;
private String name;
@@ -108,6 +109,9 @@ public class MultiOrgEntitlementsDto extends BaseDto {
* @return the number of used slots.
*/
public Long getAllocated() {
+ if (getTotal() == null || getAvailable() == null) {
+ return 0L;
+ }
return getTotal() - getAvailable();
}
@@ -143,5 +147,76 @@ public class MultiOrgEntitlementsDto extends BaseDto {
*/
public void setName(String nameIn) {
this.name = nameIn;
+ }
+
+
+ /**
+ * @return Returns the totalFlex.
+ */
+ public Long getTotalFlex() {
+ return totalFlex;
+ }
+
+
+ /**
+ * @param totalFlexIn The totalFlex to set.
+ */
+ public void setTotalFlex(Long totalFlexIn) {
+ totalFlex = totalFlexIn;
+ }
+
+
+ /**
+ * @return Returns the usedFlex.
+ */
+ public Long getUsedFlex() {
+ return usedFlex;
+ }
+
+
+ /**
+ * @param usedFlexIn The usedFlex to set.
+ */
+ public void setUsedFlex(Long usedFlexIn) {
+ usedFlex = usedFlexIn;
+ }
+
+
+ /**
+ * @return Returns the availableFlex.
+ */
+ public Long getAvailableFlex() {
+ return availableFlex;
+ }
+
+
+ /**
+ * @param availableFlexIn The availableFlex to set.
+ */
+ public void setAvailableFlex(Long availableFlexIn) {
+ availableFlex = availableFlexIn;
+ }
+
+ /**
+ * @return the number of used slots.
+ */
+ public Long getAllocatedFlex() {
+ if (getTotal() == null || getAvailable() == null) {
+ return 0L;
+ }
+ return getTotalFlex() - getAvailableFlex();
+ }
+
+ /**
+ * @return the ratio of current: allocated
+ */
+ public BigDecimal getFlexRatio() {
+ BigDecimal allocated = BigDecimal.valueOf(getAllocatedFlex());
+ if (!allocated.equals(BigDecimal.ZERO)) {
+ BigDecimal hundred = BigDecimal.TEN.multiply(BigDecimal.TEN);
+ BigDecimal dividend = BigDecimal.valueOf(getUsedFlex()).multiply(hundred);
+ return dividend.divide(allocated, BigDecimal.ROUND_UP);
+ }
+ return BigDecimal.ZERO;
}
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 98cc570..402af22 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4459,24 +4459,44 @@ button below, and <b>will be unable to log back
in</b>.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareentitlements.header.available">
-<source>Available</source>
+ <trans-unit id="Available/Total">
+<source>Available/Total</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareentitlements.header.total">
-<source>Total*</source>
+ <trans-unit id="None Allocated">
+<source>None Alloted</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="Regular Counts">
+<source>Regular Entitlement Counts</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
- <trans-unit id="softwareentitlements.header.usage">
-<source>Usage</source>
+ <trans-unit id="Regular Usage">
+<source>Regular Usage</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
</context-group>
</trans-unit>
+ <trans-unit id="Flex Counts">
+<source>Flex Entitlement Counts</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Flex Usage">
+<source>Flex Usage</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="softwareentitlements.usagedata">
<source>{0} of {1} ({2}%)</source>
<context-group name="ctx">
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
index c4b6a9e..6675676 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/softwareentitlements.jsp
@@ -22,15 +22,27 @@
<p/>
+<c:choose>
+ <c:when test = "${orgCount > 1}">
+ <c:set var = "countstyle" value= ""/>
+ <c:set var = "usagestyle" value = "last-column"/>
+ </c:when>
+ <c:otherwise>
+ <c:set var = "countstyle" value= "last-column"/>
+ <c:set var = "usagestyle" value = ""/>
+ </c:otherwise>
+</c:choose>
+
+
+
<rl:listset name="entitlementSet">
- <rl:list dataset="pageList"
- width="100%"
- name="pageList"
-
filter="com.redhat.rhn.frontend.action.multiorg.SoftwareEntitlementsFilter"
+ <rl:list
styleclass="list"
- emptykey="softwareentitlements.noentitlements">
- <rl:column bound="false"
- sortable="false"
+ emptykey="softwareentitlements.noentitlements">
+
+ <rl:column
+ sortattr="name"
+ filterattr="name"
headerkey="softwareentitlements.header.entitlement.name"
styleclass="first-column"
@@ -39,26 +51,61 @@
</a>
</rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="softwareentitlements.header.total">
- ${current.total}
+ <rl:column
+ headertext="${rhn:localize('Regular Counts')} <br/>
(${rhn:localize('Available/Total')}*)">
+ <c:choose>
+ <c:when test="${empty current.total or current.total ==
0}">
+ <bean:message key="softwareentitlements.noentitlements"/>
+ </c:when>
+ <c:otherwise>
+ ${current.available} / ${current.total}
+ </c:otherwise>
+ </c:choose>
</rl:column>
+
+ <c:if test="${orgCount > 1}">
+ <rl:column headerkey="Regular Usage">
+ <c:choose>
+ <c:when test="${empty current.allocated or current.allocated ==
0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ <bean:message key="softwareentitlements.usagedata"
arg0="${current.used}" arg1="${current.allocated}"
arg2="${current.ratio}"/>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ </c:if>
- <rl:column bound="false"
- sortable="false"
- headerkey="softwareentitlements.header.available">
- ${current.available}
- </rl:column>
+ <rl:column
+ styleclass="${countstyle}"
+ headertext="${rhn:localize('Flex Counts')} <br/>
(${rhn:localize('Available/Total')}*)">
+ <c:choose>
+ <c:when test="${empty current.totalFlex or current.totalFlex ==
0}">
+ <bean:message key="softwareentitlements.noentitlements"/>
+ </c:when>
+ <c:otherwise>
+ ${current.availableFlex} / ${current.totalFlex}
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
<c:if test="${orgCount > 1}">
<rl:column bound="false"
- sortable="false"
- headerkey="softwareentitlements.header.usage"
- styleclass="last-column">
- <bean:message key="softwareentitlements.usagedata"
arg0="${current.used}" arg1="${current.allocated}"
arg2="${current.ratio}"/>
+ headerkey="Flex Usage"
+ styleclass="${usagestyle}">
+ <c:choose>
+
+ <c:when test="${empty current.allocatedFlex or current.allocatedFlex
== 0}">
+ <bean:message key="None Allocated"/>
+ </c:when>
+ <c:otherwise>
+ <bean:message key="softwareentitlements.usagedata"
arg0="${current.usedFlex}" arg1="${current.allocatedFlex}"
arg2="${current.flexRatio}"/>
+ </c:otherwise>
+ </c:choose>
+
+
</rl:column>
- </c:if>
+ </c:if>
</rl:list>
</rl:listset>
commit b55401bd9f1786e1d2c62aa1cb0ef03462a76587
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 11:10:19 2010 -0400
Added a couple of enhancements on the Org software subs pager
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index d2f2314..29fb8f4 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -52,8 +52,9 @@
<rl:column
filterattr="name"
+ sortattr = "name"
headerkey="entitlements.jsp.channel"
styleclass="first-column">
- <a
href="/rhn/admin/multiorg/SoftwareEntitlementDetails.do?cfid=${current.id}"><c:out
value="${current.name}" /></a>
+ <a
href="/rhn/admin/multiorg/SoftwareEntitlementDetails.do?cfid=${current.id}"
tabindex="-1"><c:out value="${current.name}" /></a>
</rl:column>
<rl:column styleclass="center"
headertext="${rhn:localize('Regular Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
commit 8ba0a8e17f466d0f7f12cd6bf9bd5b5735e598a1
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 00:11:22 2010 -0400
Fixed checkstyle errors
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
index ea05a15..f531858 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
@@ -36,8 +36,6 @@ import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.action.ActionMessages;
import java.util.HashMap;
import java.util.List;
diff --git
a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
index 0f67f81..72e2e34 100644
--- a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
@@ -24,7 +24,6 @@ import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import org.apache.log4j.Logger;
-import org.apache.tools.ant.taskdefs.condition.IsFileSelected;
import java.util.HashMap;
import java.util.Map;
commit 79d30d97afae2c83782abb41b802f4550ac3b865
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 00:07:07 2010 -0400
Added code to get multiorgs org -> software channel ents page work with flex
entitlements
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index 85ef770..f43463e 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -354,14 +354,6 @@ SELECT CFO.id, CFO.name, CFO.label, CFO.current_members,
CFO.max_members, CFO.ha
</query>
</mode>
-<mode name="channel_entitlements_for_all_orgs"
class="com.redhat.rhn.frontend.dto.ChannelOverview">
- <query params="">
-SELECT CFO.id, CFO.org_id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url
- FROM rhnChannelFamilyOverview CFO
- ORDER BY CFO.name DESC
- </query>
-</mode>
-
<mode name="channel_entitlements_for_all_m_orgs"
class="com.redhat.rhn.frontend.dto.MultiOrgEntitlementsDto">
<query params="">
SELECT MAX(cfo.id) as id,
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
index b5a7924..916463a 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
@@ -182,8 +182,8 @@ AND sg.org_id != 1
</callable-mode>
<callable-mode name="assign_software_entitlements">
- <query params="channel_family_label from_org_id, to_org_id, quantity">
- {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity,
0)}
+ <query params="channel_family_label from_org_id, to_org_id, quantity,
flex_quantity">
+ {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity,
:flex_quantity)}
</query>
</callable-mode>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
index e749c04..9a032ac 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
@@ -23,7 +23,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
/**
@@ -40,7 +39,8 @@ public class ChannelFamily extends BaseDomainHelper {
private Set<Channel> channels = new HashSet<Channel>();
private Set virtSubscriptionLevels = new HashSet();
- private Set<PrivateChannelFamily> privateChannelFamilies;
+ private Set<PrivateChannelFamily> privateChannelFamilies =
+ new HashSet<PrivateChannelFamily>();
/**
* @return Returns the channels.
@@ -190,18 +190,11 @@ public class ChannelFamily extends BaseDomainHelper {
* @return maxmembers of this channelfamily. NULL == unlimited
*/
public Long getMaxMembers(Org orgIn) {
- Long retval = null;
- if (this.privateChannelFamilies != null &&
- this.privateChannelFamilies.size() > 0) {
- Iterator i = this.privateChannelFamilies.iterator();
- while (i.hasNext()) {
- PrivateChannelFamily pcf = (PrivateChannelFamily) i.next();
- if (pcf.getOrg().getId().equals(orgIn.getId())) {
- retval = pcf.getMaxMembers();
- }
- }
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getMaxMembers();
}
- return retval;
+ return null;
}
/**
@@ -210,20 +203,55 @@ public class ChannelFamily extends BaseDomainHelper {
* @return currentMembers of this channelfamily.
*/
public Long getCurrentMembers(Org orgIn) {
- Long retval = null;
- if (this.privateChannelFamilies != null &&
- this.privateChannelFamilies.size() > 0) {
- Iterator i = this.privateChannelFamilies.iterator();
- while (i.hasNext()) {
- PrivateChannelFamily pcf = (PrivateChannelFamily) i.next();
- if (pcf.getOrg().equals(orgIn)) {
- retval = pcf.getCurrentMembers();
- }
- }
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getCurrentMembers();
}
- return retval;
+ return null;
}
+
+ /**
+ * Get max flex members of this channel family. NULL means unlimited
+ * @param orgIn org to lookup the max flex embers for
+ * @return max flex members of this channelfamily. NULL == unlimited
+ */
+ public Long getMaxFlex(Org orgIn) {
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getMaxFlex();
+ }
+ return null;
+ }
+
+ /**
+ * Get current flex members of this channel family.
+ * @param orgIn org to lookup the current flex members for
+ * @return currentflex Members of this channelfamily.
+ */
+ public Long getCurrentFlex(Org orgIn) {
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getCurrentFlex();
+ }
+ return null;
+ }
+
+
+ /**
+ * returns the channel family allocation of this channel family
+ * in the given org
+ * @param orgIn the org whose allocation is requested
+ * @return the channel allocation
+ */
+ private PrivateChannelFamily getAllocation(Org orgIn) {
+ for (PrivateChannelFamily alloc : getPrivateChannelFamilies()) {
+ if (orgIn.equals(alloc.getOrg())) {
+ return alloc;
+ }
+ }
+ return null;
+ }
/**
* @return Returns the privateChannelFamilies.
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
index 2294739..ea05a15 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
@@ -15,14 +15,18 @@
package com.redhat.rhn.frontend.action.multiorg;
import com.redhat.rhn.common.validator.ValidatorError;
+import com.redhat.rhn.common.validator.ValidatorException;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.frontend.dto.ChannelOverview;
+import com.redhat.rhn.frontend.dto.OrgChannelFamily;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.org.UpdateOrgSoftwareEntitlementsCommand;
@@ -34,10 +38,10 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
-import org.apache.struts.action.DynaActionForm;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -47,33 +51,61 @@ import javax.servlet.http.HttpServletResponse;
* OrgSoftwareSubscriptionsAction - updates the Channel subs for a single org
* @version $Rev: 1 $
*/
-public class OrgSoftwareSubscriptionsAction extends RhnAction {
-
+public class OrgSoftwareSubscriptionsAction extends RhnAction implements Listable {
+ private static final String SUBSCRIPTIONS = "subscriptions";
private static Logger log = Logger.getLogger(OrgSoftwareSubscriptionsAction.class);
+ private static String makeLabel(HttpServletRequest request) {
+ RequestContext ctx = new RequestContext(request);
+ Long oid = ctx.getParamAsLong(RequestContext.ORG_ID);
+ return "OrgSoftwareSubscriptions" + oid;
+ }
+
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
ActionForm formIn,
HttpServletRequest request,
HttpServletResponse response) {
- DynaActionForm dynaForm = (DynaActionForm) formIn;
RequestContext ctx = new RequestContext(request);
Long oid = ctx.getParamAsLong(RequestContext.ORG_ID);
Org org = OrgFactory.lookupById(oid);
request.setAttribute("org", org);
- request.setAttribute("parentUrl", request.getRequestURI());
+
+ Map params = new HashMap();
+ params.put(RequestContext.ORG_ID, oid);
+ ListHelper helper = new ListHelper(this, request, params);
+ helper.execute();
+ if (!ctx.isSubmitted()) {
+ Map<String, String> subsMap = new HashMap<String, String>();
+ List <OrgChannelFamily> subs = helper.getDataSet();
+ for (OrgChannelFamily sub : subs) {
+ if (sub.getMaxAvailable() > 0) {
+ subsMap.put(sub.getKey(), sub.getMaxMembers().toString());
+ }
+ if (sub.getMaxAvailableFlex() > 0) {
+ subsMap.put(sub.getFlexKey(), sub.getMaxFlex().toString());
+ }
+ }
+ request.getSession().setAttribute(makeLabel(request), subsMap);
+ }
+ else {
+ Map <String, String> subsMap = (Map <String, String>)
+
request.getSession().getAttribute(makeLabel(request));
+ for (String id : subsMap.keySet()) {
+ if (request.getParameter(id) != null) {
+ subsMap.put(id, request.getParameter(id));
+ }
+ }
+ }
+ request.setAttribute(SUBSCRIPTIONS,
+ request.getSession().getAttribute(makeLabel(request)));
+
ActionForward retval =
- getStrutsDelegate().forwardParam(mapping.findForward("default"),
- "oid", oid.toString());
+ mapping.findForward("default");
- // Used to tell if we're submitting the form for pagination or an actual
- // form submit.
- String updateOrgs = request.getParameter("updateOrganizations");
- boolean update = (updateOrgs != null) &&
(!updateOrgs.equals("0"));
- if (isSubmitted(dynaForm) && update) {
-
+ if (ctx.wasDispatched("orgdetails.jsp.submit")) {
ActionErrors ae = updateSubscriptions(org, request);
if (ae != null && ae.size() > 0) {
getStrutsDelegate().saveMessages(request, ae);
@@ -81,68 +113,88 @@ public class OrgSoftwareSubscriptionsAction extends RhnAction {
"oid", oid.toString());
}
- else {
+ else {
createSuccessMessage(request,
"org.entitlements.syssoft.success", null);
retval =
getStrutsDelegate().forwardParam(mapping.findForward("success"),
"oid", oid.toString());
+ request.getSession().removeAttribute(makeLabel(request));
}
}
- setupFormValues(org, request);
-
return retval;
}
- void setupFormValues(Org org, HttpServletRequest request) {
- request.setAttribute("pageList", ChannelManager.
- listChannelFamilySubscriptionsFor(org));
- }
- private ActionErrors updateSubscriptions(Org org, HttpServletRequest request) {
- List entitlements = ChannelManager.entitlements(
- OrgFactory.getSatelliteOrg().getId(), null);
-
+ private ActionErrors updateSubscriptions(Org org, HttpServletRequest request) {
if (org.getId().equals(OrgFactory.getSatelliteOrg().getId())) {
return RhnValidationHelper.validatorErrorToActionErrors(
new ValidatorError("org.entitlements.system.defaultorg"));
}
ActionErrors errors = new ActionErrors();
- Iterator i = entitlements.iterator();
- while (i.hasNext()) {
- ChannelOverview co = (ChannelOverview) i.next();
+
+ Map <String, String> subsMap = (Map <String, String>)
+ request.getAttribute(SUBSCRIPTIONS);
+
+ List <ChannelOverview> entitlements = ChannelManager.entitlements(
+ OrgFactory.getSatelliteOrg().getId(), null);
+
+ for (ChannelOverview co : entitlements) {
ChannelFamily cfm = ChannelFamilyFactory.lookupById(co.getId().longValue());
- String count = (String) request.getParameter(co.getId().toString());
- // check for bad numbers
- if (count != null) {
- // check for invalid number format
- try {
- Long.parseLong(count.trim());
+ String regCountKey = OrgChannelFamily.makeKey(co.getId());
+ try {
+ Long regCount = subsMap.containsKey(regCountKey) ?
+ processCount(subsMap.get(regCountKey), errors, cfm) : 0;
+ if (regCount != null) {
+ String flexCountKey = OrgChannelFamily.makeFlexKey(co.getId());
+ Long flex = subsMap.containsKey(flexCountKey) ?
+ processCount(subsMap.get(flexCountKey), errors, cfm) : 0;
+
+ if (flex != null && regCount != null) {
+ UpdateOrgSoftwareEntitlementsCommand cmd =
+ new UpdateOrgSoftwareEntitlementsCommand(cfm.getLabel(), org,
+ regCount, flex);
+ ValidatorError ve = cmd.store();
+ if (ve != null) {
+ errors.add(
+
RhnValidationHelper.validatorErrorToActionErrors(ve));
+ }
+ }
}
- catch (NumberFormatException ex) {
- ValidatorError error = new ValidatorError(
- "orgsoftwaresubs.invalid", cfm.getName());
- return (RhnValidationHelper.validatorErrorToActionErrors(error));
- }
}
-
- if (count != null && !StringUtils.isEmpty(count)) {
- //Test id is a number
- if (!StringUtils.isNumeric(count)) {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("orgsoftwaresubs.edit.ent",
cfm.getName()));
- continue;
- }
- UpdateOrgSoftwareEntitlementsCommand cmd =
- new UpdateOrgSoftwareEntitlementsCommand(cfm.getLabel(), org,
- new Long(count));
- ValidatorError ve = cmd.store();
- if (ve != null) {
- errors.add(RhnValidationHelper.validatorErrorToActionErrors(ve));
- }
+ catch (ValidatorException ve) {
+ errors.add(RhnValidationHelper.validatorErrorToActionErrors(
+ ve.getResult().getErrors().get(0)));
}
}
return errors;
}
+
+
+ private Long processCount(String count, ActionErrors errors, ChannelFamily cfm) {
+ if (!StringUtils.isBlank(count)) {
+ // check for invalid number format
+ try {
+ return Long.parseLong(count.trim());
+ }
+ catch (NumberFormatException ex) {
+ ValidatorException.raiseException("orgsoftwaresubs.invalid",
cfm.getName());
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ Org org = (Org)contextIn.getRequest().getAttribute("org");
+ List<OrgChannelFamily> subs = ChannelManager.
+ listChannelFamilySubscriptionsFor(org);
+ return subs;
+ }
+
+
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
index 2292227..b5841ab 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
@@ -223,7 +223,7 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
UpdateOrgSoftwareEntitlementsCommand updateCmd = null;
try {
updateCmd = new
UpdateOrgSoftwareEntitlementsCommand(channelFamily.getLabel(),
- org, newCount);
+ org, newCount, 0L);
}
catch (IllegalArgumentException e) {
ValidatorError error = new ValidatorError(
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
b/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
index 939bd79..50b4fa3 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
@@ -14,6 +14,8 @@
*/
package com.redhat.rhn.frontend.dto;
+import com.redhat.rhn.domain.org.OrgFactory;
+
/**
* OrgChannelFamily
@@ -23,8 +25,73 @@ public class OrgChannelFamily extends ChannelOverview {
private Long satelliteMaxMembers;
private Long satelliteCurrentMembers;
+ private Long satelliteMaxFlexMembers;
+ private Long satelliteCurrentFlexMembers;
+
+ /**
+ * @return the key
+ */
+ public String getKey() {
+ return makeKey(getId());
+ }
+
+ /**
+ * @return the key
+ */
+ public String getFlexKey() {
+ return makeFlexKey(getId());
+ }
+
+
+ /**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeKey(Long id) {
+ return String.valueOf(id);
+ }
/**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeFlexKey(Long id) {
+ return id + "-flex";
+ }
+
+
+ /**
+ * @return Returns the satelliteMaxFlexMembers.
+ */
+ public Long getSatelliteMaxFlex() {
+ return satelliteMaxFlexMembers;
+ }
+
+
+ /**
+ * @param satelliteMaxFlexMembersIn The satelliteMaxFlexMembers to set.
+ */
+ public void setSatelliteMaxFlex(Long satelliteMaxFlexMembersIn) {
+ satelliteMaxFlexMembers = satelliteMaxFlexMembersIn;
+ }
+
+
+ /**
+ * @return Returns the satelliteCurrentFlexMembers.
+ */
+ public Long getSatelliteCurrentFlex() {
+ return satelliteCurrentFlexMembers;
+ }
+
+
+ /**
+ * @param satelliteCurrentFlexMembersIn The satelliteCurrentFlexMembers to set.
+ */
+ public void setSatelliteCurrentFlex(Long satelliteCurrentFlexMembersIn) {
+ satelliteCurrentFlexMembers = satelliteCurrentFlexMembersIn;
+ }
+
+ /**
* @return Returns the satelliteMaxMembers.
*/
public Long getSatelliteMaxMembers() {
@@ -52,4 +119,25 @@ public class OrgChannelFamily extends ChannelOverview {
this.satelliteCurrentMembers = satelliteCurrentMembersIn;
}
+ /**
+ * the maximum number of the available slots
+ * @return the number of slots
+ */
+ public long getMaxAvailable() {
+ if (OrgFactory.getSatelliteOrg().getId().equals(getOrgId())) {
+ return getMaxMembers();
+ }
+ return getSatelliteMaxMembers() - getSatelliteCurrentMembers() +
getMaxMembers();
+ }
+
+ /**
+ * the maximum number of the available flex slots
+ * @return the number of slots
+ */
+ public long getMaxAvailableFlex() {
+ if (OrgFactory.getSatelliteOrg().getId().equals(getOrgId())) {
+ return getMaxFlex();
+ }
+ return getSatelliteMaxFlex() - getSatelliteCurrentFlex() + getMaxFlex();
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 3987ef8..d8a94a6 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -7992,8 +7992,12 @@ Follow this url to see the full list of inactive systems:
<source>Entitlements successfully updated.</source>
</trans-unit>
- <trans-unit id="org.entitlements.software.toomany">
- <source>You attempted to give {0} too many {1} entitlements. Please
enter a value lower than or equal to {2}</source>
+ <trans-unit id="org.entitlements.software.not_in_range">
+ <source>You attempted to give {0} too many {1} entitlements. Please
enter a value between {2} and {3}</source>
+ </trans-unit>
+
+ <trans-unit id="org.entitlements.software.not_in_range.flex">
+ <source>You attempted to give {0} too many {1} flex entitlements. Please
enter a value between {2} and {3}</source>
</trans-unit>
<trans-unit id="org.entitlements.software.proposedwarning">
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 205a90d..98cc570 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4563,6 +4563,51 @@ deducted from the default organization.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
</context-group>
</trans-unit>
+ <trans-unit id="No Entitlements Available">
+<source>No Entitlements Available</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Regular Usage">
+<source>Regular Usage</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Regular Proposed Total">
+<source>Regular Proposed Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Flex Usage">
+<source>Flex Usage</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Flex Proposed Total">
+<source>Flex Proposed Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Entitlement Usage Type">
+<source>Used / Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+
+
+
<trans-unit id="softwareEntitlementDetails.noChannelsFound">
<source>No channels found.</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
index 482d139..7773785 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
@@ -508,13 +508,12 @@ public class OrgHandler extends BaseHandler {
String channelFamilyLabel, Integer allocation) {
getSatAdmin(sessionKey);
-
Org org = verifyOrgExists(orgId);
lookupChannelFamily(channelFamilyLabel);
UpdateOrgSoftwareEntitlementsCommand cmd =
new UpdateOrgSoftwareEntitlementsCommand(channelFamilyLabel, org,
- new Long(allocation));
+ Long.valueOf(allocation), 0L);
ValidatorError ve = cmd.store();
if (ve != null) {
throw new ValidationException(ve.getMessage());
@@ -524,6 +523,50 @@ public class OrgHandler extends BaseHandler {
}
/**
+ * Set an organizations entitlement allocation for a channel family.
+ *
+ * If increasing the entitlement allocation, the default organization
+ * must have a sufficient number of free entitlements.
+ *
+ * @param sessionKey User's session key.
+ * @param orgId Organization ID to set allocation for.
+ * @param channelFamilyLabel Channel family to set allocation for.
+ * @param allocation New flex entitlement allocation.
+ * @return 1 on success.
+ *
+ * @xmlrpc.doc Set an organization's flex entitlement allocation for the given
software
+ * entitlement.
+ *
+ * If increasing the flex entitlement allocation, the default organization
+ * (i.e. orgId=1) must have a sufficient number of free flex entitlements.
+ *
+ * @xmlrpc.param #param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "orgId")
+ * @xmlrpc.param #param_desc("string", "label", "Software
entitlement label.")
+ * @xmlrpc.param #param("int", "allocation")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int setSoftwareFlexEntitlements(String sessionKey, Integer orgId,
+ String channelFamilyLabel, Integer allocation) {
+
+ getSatAdmin(sessionKey);
+ Org org = verifyOrgExists(orgId);
+ lookupChannelFamily(channelFamilyLabel);
+
+ UpdateOrgSoftwareEntitlementsCommand cmd =
+ new UpdateOrgSoftwareEntitlementsCommand(channelFamilyLabel, org,
+ 0L, Long.valueOf(allocation));
+ ValidatorError ve = cmd.store();
+ if (ve != null) {
+ throw new ValidationException(ve.getMessage());
+ }
+
+ return 1;
+ }
+
+
+
+ /**
* Lookup a channel family, throwing an exception if it cannot be found.
*
* @param channelFamilyLabel Channel family label to look up.
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 253676b..c773824 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -248,20 +248,28 @@ public class ChannelManager extends BaseManager {
}
for (ChannelOverview sato : satEntitlements) {
- ChannelOverview orgo = orgMap.get(sato.getId());
OrgChannelFamily ocf = new OrgChannelFamily();
+
ocf.setSatelliteCurrentMembers(sato.getCurrentMembers());
ocf.setSatelliteMaxMembers(sato.getMaxMembers());
+ ocf.setSatelliteCurrentFlex(sato.getCurrentFlex());
+ ocf.setSatelliteMaxFlex(sato.getMaxFlex());
ocf.setId(sato.getId());
ocf.setName(sato.getName());
ocf.setLabel(sato.getLabel());
+
+ ChannelOverview orgo = orgMap.get(sato.getId());
if (orgo == null) {
ocf.setCurrentMembers(new Long(0));
ocf.setMaxMembers(new Long(0));
+ ocf.setMaxFlex(0L);
+ ocf.setCurrentFlex(0L);
}
else {
ocf.setCurrentMembers(orgo.getCurrentMembers());
ocf.setMaxMembers(orgo.getMaxMembers());
+ ocf.setMaxFlex(orgo.getMaxFlex());
+ ocf.setCurrentFlex(orgo.getCurrentFlex());
}
if (ocf.getSatelliteMaxMembers() != null) {
ret.add(ocf);
@@ -272,19 +280,6 @@ public class ChannelManager extends BaseManager {
/**
* Returns a list channel entitlements for all orgs.
- * @param pc The PageControl
- * @return channel entitlements
- */
- public static DataResult<ChannelOverview> entitlementsForAllOrgs(PageControl
pc) {
- SelectMode m = ModeFactory.getMode("Channel_queries",
- "channel_entitlements_for_all_orgs");
-
- Map params = new HashMap();
- return makeDataResult(params, params, pc, m);
- }
-
- /**
- * Returns a list channel entitlements for all orgs.
* @return channel entitlements for multiorgs
*/
public static DataList<MultiOrgEntitlementsDto> entitlementsForAllMOrgs() {
diff --git
a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
index 069e60b..0f67f81 100644
--- a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
@@ -24,6 +24,7 @@ import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import org.apache.log4j.Logger;
+import org.apache.tools.ant.taskdefs.condition.IsFileSelected;
import java.util.HashMap;
import java.util.Map;
@@ -42,6 +43,7 @@ public class UpdateOrgSoftwareEntitlementsCommand {
private Org org;
private long newTotal;
+ private long newFlexTotal;
private ChannelFamily channelFamily;
/**
@@ -49,14 +51,17 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* @param channelFamilyLabel label of entitlement to update
* @param orgIn to update totals for
* @param newTotalIn This is the *proposed* new total for the org you are passing
in.
+ * @param newFlexTotalIn This is the *proposed* new flex total
+ * for the org you are passing in.
*/
public UpdateOrgSoftwareEntitlementsCommand(String channelFamilyLabel,
- Org orgIn, Long newTotalIn) {
+ Org orgIn, Long newTotalIn, Long newFlexTotalIn) {
if (orgIn.getId().equals(OrgFactory.getSatelliteOrg().getId())) {
throw new IllegalArgumentException("Cant update the default org");
}
this.org = orgIn;
this.newTotal = newTotalIn;
+ this.newFlexTotal = newFlexTotalIn;
this.channelFamily = ChannelFamilyFactory.lookupByLabel(channelFamilyLabel,
OrgFactory.getSatelliteOrg());
if (this.channelFamily == null) {
@@ -70,16 +75,13 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* @return if we should force unentitlement if
* current members is greater then proposed entitlement count
*/
- private boolean forceUnentitlement() {
+ private boolean forceUnentitlement(Long orgCur, Long orgProposedMax) {
boolean retval = true;
-
- Long orgCur = this.channelFamily.getCurrentMembers(this.org);
-
if (orgCur == null) {
- orgCur = new Long(0);
+ orgCur = 0L;
}
- if (orgCur > this.newTotal &&
!ConfigDefaults.get().forceUnentitlement()) {
+ if (orgCur > orgProposedMax &&
!ConfigDefaults.get().forceUnentitlement()) {
retval = false;
}
return retval;
@@ -89,32 +91,62 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* Update the entitlements in the DB.
* @return ValidatorError if there were any problems with the proposed total
*/
- public ValidatorError store() {
-
+ public ValidatorError store() {
+ ValidatorError err = null;
+ err = storeRegular();
+ if (err == null) {
+ return storeFlex();
+ }
+ return err;
+ }
+
+ private ValidatorError storeRegular() {
// Check available entitlements
Org satOrg = OrgFactory.getSatelliteOrg();
- Long avail = new Long(0);
- Long maxMem = this.channelFamily.getMaxMembers(satOrg);
- Long current = this.channelFamily.getMaxMembers(this.org);
-
- if (current == null) {
- current = new Long(0);
+ return store(channelFamily.getMaxMembers(satOrg),
+ channelFamily.getMaxMembers(org),
+ channelFamily.getCurrentMembers(satOrg),
+ channelFamily.getCurrentMembers(org),
+ newTotal, false);
+ }
+
+ private ValidatorError storeFlex() {
+ // Check available entitlements
+ Org satOrg = OrgFactory.getSatelliteOrg();
+ return store(channelFamily.getMaxFlex(satOrg),
+ channelFamily.getMaxFlex(org),
+ channelFamily.getCurrentFlex(satOrg),
+ channelFamily.getCurrentFlex(org),
+ newFlexTotal, true);
+ }
+
+ private ValidatorError store(Long satMax, Long orgMax,
+ Long satCurrent, Long orgCurrent,
+ Long proposed, boolean isFlex) {
+ // No sense making the call if its the same.
+ if (orgMax == proposed) {
+ return null;
}
- if (maxMem != null) {
- avail = maxMem -
- this.channelFamily.getCurrentMembers(satOrg) +
- current;
+
+ if (orgMax == null) {
+ orgMax = 0L;
+ }
+
+ Long avail = 0L;
+ if (satMax != null) {
+ avail = satMax - satCurrent + orgMax;
}
-
- if (avail < this.newTotal) {
- return new ValidatorError("org.entitlements.software.toomany",
- this.org.getName(),
- this.channelFamily.getName(),
- avail);
+
+ if (proposed == null || proposed < 0 || avail < proposed) {
+ String key = isFlex ? "org.entitlements.software.not_in_range.flex"
:
+ "org.entitlements.software.not_in_range";
+
+ return new ValidatorError(key, this.org.getName(),
+ this.channelFamily.getName(), 0, avail);
}
// Proposed cannot be lower than current members
- if (!forceUnentitlement()) {
+ if (!forceUnentitlement(orgCurrent, proposed)) {
return new ValidatorError(
"org.entitlements.software.proposedwarning",
this.channelFamily.getName(),
@@ -122,25 +154,21 @@ public class UpdateOrgSoftwareEntitlementsCommand {
);
}
- // No sense making the call if its the same.
- if (current.longValue() == this.newTotal) {
- return null;
- }
-
+
Long toOrgId;
Long fromOrgId;
long actualTotal;
// If we are decreasing the # of entitlements
// we give back to the default org.
- if (current.longValue() > this.newTotal) {
+ if (orgMax.longValue() > proposed) {
fromOrgId = this.org.getId();
toOrgId = OrgFactory.getSatelliteOrg().getId();
- actualTotal = current.longValue() - this.newTotal;
+ actualTotal = orgMax.longValue() - proposed;
}
else {
toOrgId = this.org.getId();
fromOrgId = OrgFactory.getSatelliteOrg().getId();
- actualTotal = this.newTotal - current.longValue();
+ actualTotal = proposed - orgMax.longValue();
}
Map in = new HashMap();
@@ -148,12 +176,19 @@ public class UpdateOrgSoftwareEntitlementsCommand {
in.put("channel_family_label", channelFamily.getLabel());
in.put("from_org_id", fromOrgId);
in.put("to_org_id", toOrgId);
- in.put("quantity", actualTotal);
+ if (isFlex) {
+ in.put("quantity", 0);
+ in.put("flex_quantity", actualTotal);
+
+ }
+ else {
+ in.put("quantity", actualTotal);
+ in.put("flex_quantity", 0);
+
+ }
CallableMode m = ModeFactory.getCallableMode(
"Org_queries", "assign_software_entitlements");
m.execute(in, new HashMap());
return null;
}
-
-
}
diff --git
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
index f69ab00..f75f95d 100644
---
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
+++
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
@@ -83,7 +83,7 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
// Now give the remaining:
cmd = new UpdateOrgSoftwareEntitlementsCommand(fam.getLabel(), user.getOrg(),
- ChannelFamilyFactoryTest.ENTITLEMENT_ALLOCATION);
+ ChannelFamilyFactoryTest.ENTITLEMENT_ALLOCATION, 0L);
assertNull(cmd.store());
}
@@ -91,18 +91,18 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
Long orig = fam.getMaxMembers(OrgFactory.getSatelliteOrg());
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
Long now = fam.getMaxMembers(OrgFactory.getSatelliteOrg()).longValue();
assertEquals(orig.longValue() - 1, now.longValue());
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
assertEquals(orig.longValue() - 1, now.longValue());
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(0));
+ fam.getLabel(), user.getOrg(), new Long(0), 0L);
cmd.store();
reloadFamilies();
now = fam.getMaxMembers(OrgFactory.getSatelliteOrg()).longValue();
@@ -114,11 +114,11 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
Long origValue = fam.getMaxMembers(OrgFactory.getSatelliteOrg());
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(2));
+ fam.getLabel(), user.getOrg(), new Long(2), 0L);
assertNull(cmd.store());
reloadFamilies();
assertEquals(2, fam.getMaxMembers(user.getOrg()).longValue());
@@ -135,7 +135,7 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
}
}
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
}
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index 58f3ee0..d2f2314 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -44,55 +44,76 @@
<rl:listset name="entitlementSet">
<rhn:submitted/>
<input type="hidden" name="oid"
value="${param.oid}"/>
- <!-- Hack to get around the problem with form submitting when doing
- pagination. See javascript attached to the submit button below. -->
- <input type="hidden" name="updateOrganizations"
value="0"/>
-
- <rl:list dataset="pageList"
+ <rl:list
width="100%"
- name="userList"
styleclass="list"
emptykey="orgsoftwaresubs.jsp.nochannelfams">
- <rl:column bound="false"
- sortable="false"
+ <rl:column
+ filterattr="name"
headerkey="entitlements.jsp.channel"
styleclass="first-column">
<a
href="/rhn/admin/multiorg/SoftwareEntitlementDetails.do?cfid=${current.id}"><c:out
value="${current.name}" /></a>
</rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.total">
- <c:out value="${current.maxMembers}" />
- </rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.usage">
- <c:out value="${current.currentMembers}" />
+ <rl:column styleclass="center"
+ headertext="${rhn:localize('Regular Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
+ <c:out value="${current.currentMembers} / ${current.maxMembers}"
/>
</rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.proposed_total"
styleclass="last-column">
- <c:choose>
- <c:when test="${param.oid != 1}">
- <input name="${current.id}"
value="${current.maxMembers}" type="text"
- onkeydown="return blockEnter(event)">
- <br>
- <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
- arg0="0" arg1="${current.satelliteMaxMembers -
current.satelliteCurrentMembers + current.maxMembers}"/></span>
- </c:when>
- <c:otherwise>
- ${current.maxMembers}
- </c:otherwise>
- </c:choose>
+ <rl:column
+ headerkey="Regular Proposed Total">
+ <c:choose>
+ <c:when test = "${current.maxAvailable == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <c:choose>
+ <c:when test="${param.oid != 1}">
+ <input name="${current.key}"
value="${requestScope.subscriptions[current.key]}" type="text" size =
"13"
+ onkeydown="return blockEnter(event)">
+ <br>
+ <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
+ arg0="0"
arg1="${current.maxAvailable}"/></span>
+ </c:when>
+ <c:otherwise>
+ ${current.maxAvailable}
+ </c:otherwise>
+ </c:choose>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ <rl:column styleclass="center"
+ headertext="${rhn:localize('Flex Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
+ <c:out value="${current.currentFlex} / ${current.maxFlex}"
/>
</rl:column>
+ <rl:column bound="false"
+ sortable="false"
+ headerkey="Flex Proposed Total"
styleclass="last-column">
+ <c:choose>
+ <c:when test = "${current.maxAvailableFlex == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <c:choose>
+ <c:when test="${param.oid != 1}">
+ <input name="${current.flexKey}"
value="${requestScope.subscriptions[current.flexKey]}" type="text"
size = "13"
+ onkeydown="return blockEnter(event)">
+ <br>
+ <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
+ arg0="0"
arg1="${current.maxAvailableFlex}"/></span>
+ </c:when>
+ <c:otherwise>
+ ${current.maxAvailableFlex}
+ </c:otherwise>
+ </c:choose>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
</rl:list>
<c:if test="${param.oid != 1}">
<div align="right">
<hr/>
- <input type="submit" name="dispatch"
value="${rhn:localize('orgdetails.jsp.submit')}"
- onclick="this.form.updateOrganizations.value = '1';return
true;">
+ <input type="submit" name="dispatch"
value="${rhn:localize('orgdetails.jsp.submit')}"/>
</div>
</c:if>
</rl:listset>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 205b830..774bee6 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -4536,7 +4536,7 @@
<forward name="success"
path="/admin/multiorg/OrgSoftwareSubscriptions.do"
redirect="true" />
<forward name="error"
- path="/admin/multiorg/OrgSoftwareSubscriptions.do"
redirect="true" />
+ path="/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp"/>
</action>
<action path="/admin/multiorg/SoftwareEntitlements"
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index cffb79e..b26fdf9 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -1152,8 +1152,8 @@ is
flex_in in number
)
is
- prev_ent_count number;
- prev_ent_count_flex number;
+ from_org_prev_ent_count number;
+ from_org_prev_ent_count_flex number;
new_ent_count number;
new_ent_count_flex number;
to_org_prev_ent_count number;
@@ -1165,7 +1165,7 @@ is
begin
select max_members
- into prev_ent_count
+ into from_org_prev_ent_count
from rhnChannelFamily cf,
rhnPrivateChannelFamily pcf
where pcf.org_id = from_org_id_in
@@ -1192,7 +1192,7 @@ is
begin
select fve_max_members
- into prev_ent_count_flex
+ into from_org_prev_ent_count_flex
from rhnChannelFamily cf,
rhnPrivateChannelFamily pcf
where pcf.org_id = from_org_id_in
@@ -1214,7 +1214,7 @@ is
and cf.label = channel_family_label_in;
exception
when NO_DATA_FOUND then
- to_org_prev_ent_count := 0;
+ to_org_prev_ent_count_flex := 0;
end;
begin
@@ -1228,14 +1228,14 @@ is
'invalid_channel_family');
end;
- new_ent_count := prev_ent_count - quantity_in;
- new_ent_count_flex := prev_ent_count_flex - flex_in;
+ new_ent_count := from_org_prev_ent_count - quantity_in;
+ new_ent_count_flex := from_org_prev_ent_count_flex - flex_in;
- if prev_ent_count > new_ent_count then
+ if from_org_prev_ent_count >= new_ent_count then
new_quantity := to_org_prev_ent_count + quantity_in;
end if;
- if prev_ent_count_flex > new_ent_count_flex then
+ if from_org_prev_ent_count_flex >= new_ent_count_flex then
new_flex := to_org_prev_ent_count_flex + flex_in;
end if;
commit 77c7563f2389b9da9e03e8df5899a283debea483
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 17 17:55:12 2010 -0400
Forgot to commit EligibleFlexGuestAction
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/EligibleFlexGuestAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/EligibleFlexGuestAction.java
new file mode 100644
index 0000000..ce61f6f
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/EligibleFlexGuestAction.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.systems.entitlements;
+
+import com.redhat.rhn.frontend.dto.ChannelFamilySystem;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
+import com.redhat.rhn.manager.system.VirtualizationEntitlementsManager;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * EligibleFlexGuestAction
+ * @version $Rev$
+ */
+public class EligibleFlexGuestAction extends RhnAction implements Listable {
+
+ private static final String SELECTABLE = "selectable";
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ request.setAttribute(SELECTABLE, Boolean.TRUE);
+ ListSessionSetHelper helper = new ListSessionSetHelper(this, request);
+ helper.execute();
+ if (helper.isDispatched()) {
+ RequestContext context = new RequestContext(request);
+ return handleConfirm(helper, context, mapping);
+ }
+
+ return mapping.findForward("default");
+ }
+
+
+ private ActionForward handleConfirm(ListSessionSetHelper helper, RequestContext
context,
+ ActionMapping mapping) {
+ Set <Long> serverIds = new HashSet<Long>();
+ for (String selectionKey : helper.getSet()) {
+ Long sid = ChannelFamilySystem.parseServerId(selectionKey);
+ Long cfid = ChannelFamilySystem.parseChannelFamilyId(selectionKey);
+ VirtualizationEntitlementsManager.getInstance().convertToFlex(sid, cfid,
+
context.getLoggedInUser());
+ serverIds.add(sid);
+ }
+ helper.destroy();
+
+
getStrutsDelegate().saveMessage("eligible.flexguest.systems.confirm.message",
+ new String [] { String.valueOf(serverIds.size())},
+ context.getRequest());
+ return mapping.findForward("success");
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ return VirtualizationEntitlementsManager.getInstance().
+ listEligibleFlexGuests(contextIn.getLoggedInUser());
+ }
+}
commit 443e2cdc73dac7787dfd6368d30f9839db049fb3
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 17 12:05:50 2010 -0400
Added the convert to flex plsql operation
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index 6ac036c..85ef770 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -1231,6 +1231,19 @@ GROUP BY C.id, C.name
</query>
</mode>
+<callable-mode name="convert_to_flex">
+ <query params="sid, cfid, uid">
+BEGIN
+ rhn_channel.convert_to_fve(:sid, :cfid);
+END;
+ </query>
+</callable-mode>
+
+<callable-mode name="can_convert_to_flex">
+ <query params="result, sid, cfid">
+ {:result = call rhn_channel.convert_to_fve(:sid, :cfid)}
+ </query>
+</callable-mode>
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index 8f97a59..79e10de 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1745,8 +1745,5 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
)
</query>
</mode>
-
-
-
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
index 01d3674..a9a3c20 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
@@ -114,4 +114,22 @@ public class ChannelFamilySystem extends SelectableAdapter {
public String getSelectionKey() {
return group.getId() + "|" + id;
}
+
+ /**
+ * Returns the channel family Id
+ * @param selectionKey the selection key used for this
+ * @return the channel family id
+ */
+ public static Long parseChannelFamilyId(String selectionKey) {
+ return Long.valueOf(selectionKey.split("\\|")[0]);
+ }
+
+ /**
+ * Returns the system Id
+ * @param selectionKey the selection key used for this
+ * @return the system id
+ */
+ public static Long parseServerId(String selectionKey) {
+ return Long.valueOf(selectionKey.split("\\|")[1]);
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index e97a9c3..205a90d 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -6219,7 +6219,13 @@ value for this entitlement, excluding the default
organization's consumption.</s
<trans-unit id="flexguest.jsp.no-systems">
<source>There are no systems consuming Flex Guest entitlements.</source>
</trans-unit>
+ <trans-unit id="Make Flex">
+ <source>Convert To Flex Guest Entitlement</source>
+ </trans-unit>
+ <trans-unit id="eligible.flexguest.systems.confirm.message">
+ <source>Converted <strong>{0}</strong> system(s) to
use Flex Guest Entitlement.</source>
+ </trans-unit>
</group>
<!-- System search -->
diff --git a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
index be532f1..2b2e47c 100644
--- a/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/SystemManager.java
@@ -891,21 +891,11 @@ public class SystemManager extends BaseManager {
public static Server lookupByIdAndUser(Long sid, User userIn) {
Server server = ServerFactory.lookupByIdAndOrg(sid,
userIn.getOrg());
-
- if (!isAvailableToUser(userIn, sid)) {
- LocalizationService ls = LocalizationService.getInstance();
- LookupException e = new LookupException("Could not find server " +
sid +
- " for user " + userIn.getId());
- e.setLocalizedTitle(ls.getMessage("lookup.jsp.title.system"));
- e.setLocalizedReason1(ls.getMessage("lookup.jsp.reason1.system"));
- e.setLocalizedReason2(ls.getMessage("lookup.jsp.reason2.system"));
- throw e;
- }
- else {
- return server;
- }
+ ensureAvailableToUser(userIn, sid);
+ return server;
}
+
/**
* Returns a List of hydrated server objects from server ids.
* @param serverIds the list of server ids to hyrdrate
@@ -2063,6 +2053,23 @@ public class SystemManager extends BaseManager {
params.put("sid", sid);
return m.execute(params).size() >= 1;
}
+
+ /**
+ * Checks if the user has permissions to see the Server
+ * @param user User being checked
+ * @param sid ID of the Server being checked
+ */
+ public static void ensureAvailableToUser(User user, Long sid) {
+ if (!isAvailableToUser(user, sid)) {
+ LocalizationService ls = LocalizationService.getInstance();
+ LookupException e = new LookupException("Could not find server " +
sid +
+ " for user " + user.getId());
+ e.setLocalizedTitle(ls.getMessage("lookup.jsp.title.system"));
+ e.setLocalizedReason1(ls.getMessage("lookup.jsp.reason1.system"));
+ e.setLocalizedReason2(ls.getMessage("lookup.jsp.reason2.system"));
+ throw e;
+ }
+ }
/**
* Return systems in the current set without a base channel.
diff --git
a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
index be95619..4f10446 100644
--- a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
@@ -14,14 +14,21 @@
*/
package com.redhat.rhn.manager.system;
+import com.redhat.rhn.common.db.datasource.CallableMode;
+import com.redhat.rhn.common.db.datasource.ModeFactory;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.server.VirtualInstanceFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
+import org.apache.commons.lang.BooleanUtils;
+
+import java.sql.Types;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
/**
@@ -100,7 +107,7 @@ public class VirtualizationEntitlementsManager {
public List<ChannelFamilySystemGroup> listFlexGuests(User user) {
return VirtualInstanceFactory.getInstance().listFlexGuests(user);
- }
+ }
/**
@@ -111,6 +118,45 @@ public class VirtualizationEntitlementsManager {
public List<ChannelFamilySystemGroup> listEligibleFlexGuests(User user) {
return VirtualInstanceFactory.getInstance().listEligibleFlexGuests(user);
- }
-
+ }
+
+ /**
+ * Converts a given server to flex entitlement
+ * @param systemId the server id
+ * @param channelFamilyId the channel family id
+ * @param user the user object
+ */
+ public void convertToFlex(Long systemId,
+ Long channelFamilyId,
+ User user) {
+ SystemManager.ensureAvailableToUser(user, systemId);
+ Map in = new HashMap();
+ in.put("sid", systemId);
+ in.put("cfid", channelFamilyId);
+ CallableMode m = ModeFactory.getCallableMode(
+ "Channel_queries", "convert_to_flex");
+ m.execute(in, new HashMap());
+ }
+
+
+ /**
+ * True if the passed in server can be converted to flex
+ * @param sid the server id
+ * @param cfid the channel family id
+ * @return true if the server can be converted to flex
+ */
+ public boolean canConvertToFlex(Long sid, Long cfid) {
+ Map in = new HashMap();
+ in.put("sid", sid);
+ in.put("cfid", cfid);
+ Map outParams = new HashMap();
+ outParams.put("result", new Integer(Types.NUMERIC));
+
+ CallableMode m = ModeFactory.getCallableMode(
+ "Channel_queries", "can_convert_to_flex");
+
+ Map result = m.execute(in, outParams);
+ return BooleanUtils.toBoolean(
+ ((Long)result.get("result")).intValue());
+ }
}
diff --git a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
index cfc2d18..88f7024 100644
--- a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
@@ -10,7 +10,7 @@
<c:set var="headerkey"
value="eligible.flexguest.jsp.header"/>
<c:set var="messagekey"
value="eligible.flexguest.jsp.message"/>
<c:set var="namestyle" value="first-column"/>
- <c:set var="empty_msg"
value="eligible-flexguest.jsp.no-systems"/>
+ <c:set var="empty_msg"
value="eligible.flexguest.jsp.no-systems"/>
</c:when>
<c:otherwise>
<c:set var="headerkey" value="flexguest.jsp.header"/>
@@ -109,7 +109,7 @@
</rl:list>
<rhn:submitted/>
-<c:if test="${not empty requestScope.selectable}">
+<c:if test="${not empty requestScope.selectable && not empty
requestScope.dataset}">
<div align="right">
<hr />
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 2eaaaa9..205b830 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -6358,7 +6358,7 @@
className="com.redhat.rhn.frontend.struts.RhnActionMapping">
<set-property property="acls"
value="user_role(org_admin)"/>
<forward name="default"
path="/WEB-INF/pages/systems/entitlements/flexguests.jsp"/>
- <forward name="success"
path="/systems/entitlements/FlexGuests.do" redirect="true"/>
+ <forward name="success"
path="/systems/entitlements/EligibleFlexGuests.do"
redirect="true"/>
</action>
<action path="/channels/manage/errata/Add"
@@ -6367,8 +6367,7 @@
type="com.redhat.rhn.frontend.action.channel.manage.AddErrataAction"
className="com.redhat.rhn.frontend.struts.RhnActionMapping">
<forward name="default"
path="/WEB-INF/pages/channel/manage/add.jsp" />
-
- </action>
+ </action>
<action path="/channels/manage/errata/ListRemove"
scope="request"
diff --git a/schema/spacewalk/common/data/rhnException.sql
b/schema/spacewalk/common/data/rhnException.sql
index 8112644..fd10137 100644
--- a/schema/spacewalk/common/data/rhnException.sql
+++ b/schema/spacewalk/common/data/rhnException.sql
@@ -114,6 +114,11 @@ insert into rhnException values (-20292,
'package_provider_not_found', 'The spec
insert into rhnException values (-20293, 'package_key_type_not_found', 'The
specified package key type could not be found.');
insert into rhnException values (-20294,
'not_enough_flex_entitlements_in_base_org', 'You do not have enough
entitlements in the base org.');
+insert into rhnException values (-20295, 'server_cannot_convert_to_flex',
'The given server cannot be converted to a flex entitlement.');
+
+insert into rhnException values (-20296, 'not_enough_flex_entitlements', 'You
do not have enough entitlements in your org..');
+
+
commit;
--
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb
b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index baf6ade..64ac7f0 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -161,6 +161,96 @@ IS
END IF;
END subscribe_server;
+
+
+
+ FUNCTION can_convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER)
+ RETURN NUMBER
+ IS
+ CURSOR fve_convertible_entries IS
+ select 1 from
+ RhnVirtualInstance vi
+ inner join rhnServer s on vi.virtual_system_id = s.id
+ inner join rhnServerChannel sc on sc.server_id = s.id
+ inner join rhnChannelFamilyMembers cfm on cfm.channel_id =
sc.channel_id
+ inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
+ inner join rhnPrivateChannelFamily pcf on pcf.channel_family_id =
cf.id and pcf.org_id = s.org_id
+ where sc.is_fve = 'N'
+ AND sc.server_id = server_id_in
+ AND cf.id = channel_family_id_val
+ AND (vi.host_system_id is null OR
+ exists (
+ select sg.id from rhnServerGroupMembers sgm
+ inner join rhnServerGroup sg on sgm.server_group_id = sg.id
+ inner join rhnServerGroupType sgt on sgt.id = sg.group_type
+ inner join rhnServer s2 on s2.id = sgm.server_id
+ where
+ s2.org_id = s.org_id
+ and s2.id = vi.host_system_id
+ and sgt.label not in ('virtualization_host'
,'virtualization_host_platform') )
+ );
+
+ BEGIN
+ FOR entry IN fve_convertible_entries LOOP
+ return 1;
+ END LOOP;
+ RETURN 0;
+ END can_convert_to_fve;
+
+
+ -- Converts server channel_family to use a flex entitlement
+ PROCEDURE convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER)
+ IS
+ available_fve_subs NUMBER;
+ server_org_id_val NUMBER;
+ BEGIN
+
+ --
+ -- Use the org_id of the server only if the org_id of the channel = NULL.
+ -- This is required for subscribing to shared channels.
+ --
+ SELECT org_id
+ INTO server_org_id_val
+ FROM rhnServer
+ WHERE id = server_id_in;
+
+ begin
+ obtain_read_lock(channel_family_id_val, server_org_id_val);
+ exception
+ when no_data_found then
+
rhn_exception.raise_exception('channel_family_no_subscriptions');
+ end;
+ IF (can_convert_to_fve(server_id_in, channel_family_id_val ) = 0)
+ THEN
+ rhn_exception.raise_exception('server_cannot_convert_to_flex');
+ END IF;
+
+ available_fve_subs :=
rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
+
+ IF (available_fve_subs > 0)
+ THEN
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ server_id_in,
+ 'converted to flex entitlement' || SUBSTR(cf.label, 0,
99),
+ cf.label
+ from rhnChannelFamily cf
+ where cf.id = channel_family_id_val
+ );
+
+ UPDATE rhnServerChannel sc set sc.is_fve = 'Y'
+ where sc.server_id = server_id_in and
+ sc.channel_id in
+ (select cfm.channel_id from rhnChannelFamilyMembers
cfm
+ where cfm.CHANNEL_FAMILY_ID =
channel_family_id_val);
+
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ ELSE
+ rhn_exception.raise_exception('not_enough_flex_entitlements');
+ END IF;
+
+ END convert_to_fve;
function can_server_consume_virt_channl(
server_id_in in number,
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pks
b/schema/spacewalk/oracle/packages/rhn_channel.pks
index d9ab7b6..3896f0d 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pks
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pks
@@ -52,6 +52,10 @@ IS
deleting_server in number := 0,
update_family_countsYN IN NUMBER := 1);
PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in
NUMBER := 1, user_id_in number := null, recalcfamily_in number := 1);
+
+ PROCEDURE convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER);
+
+ FUNCTION can_convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER)
RETURN NUMBER;
function can_server_consume_virt_channl(
server_id_in IN NUMBER,
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
index 9d8e856..4e274a3 100644
---
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
@@ -18,7 +18,9 @@
-- data for rhnException
insert into rhnException values (-20294,
'not_enough_flex_entitlements_in_base_org', 'You do not have enough
entitlements in the base org.');
+insert into rhnException values (-20295, 'server_cannot_convert_to_flex',
'The given server cannot be converted to a flex entitlement.');
+insert into rhnException values (-20296, 'not_enough_flex_entitlements', 'You
do not have enough entitlements in your org..');
commit;
commit f05fa1d7aa4704c39fcf62a99b4bfb8ad84a9b7b
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Jun 14 17:20:30 2010 -0400
Wiped out unused bulk procs
diff --git a/schema/spacewalk/postgres/packages/rhn_channel.pkb
b/schema/spacewalk/postgres/packages/rhn_channel.pkb
index 09f78f9..2f61396 100644
--- a/schema/spacewalk/postgres/packages/rhn_channel.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_channel.pkb
@@ -218,105 +218,6 @@ update pg_settings set setting = 'rhn_channel,' || setting
where name = 'search_
end$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION bulk_server_base_change(channel_id_in IN NUMERIC,
set_label_in IN VARCHAR, set_uid_in IN NUMERIC) returns void
- AS $$
- DECLARE
- server RECORD;
- BEGIN
- FOR server IN
- SELECT user_id, label, element, element_two
- FROM rhnSet
- WHERE label = set_label_in
- AND user_id = set_uid_in
- LOOP
- IF rhn_server.can_change_base_channel(server.element) = 1
- THEN
- perform rhn_channel.clear_subscriptions(server.element);
- perform rhn_channel.subscribe_server(server.element, channel_id_in, 0,
set_uid_in);
- END IF;
- END LOOP;
- END$$ language plpgsql;
-
- create or replace function bulk_server_basechange_from(
- set_label_in in varchar,
- set_uid_in in numeric,
- old_channel_id_in in numeric,
- new_channel_id_in in numeric
- ) returns void
- as $$
- declare
- servers cursor for
- select sc.server_id id
- from rhnChannel nc,
- rhnServerChannelArchCompat scac,
- rhnServer s,
- rhnChannel oc,
- rhnServerChannel sc,
- rhnSet st
- where 1=1
- -- first, find the servers we're looking for.
- and st.label = set_label_in
- and st.user_id = set_uid_in
- and st.element = sc.server_id
- -- now, filter out anything that's not in the
- -- old base channel.
- and sc.channel_id = old_channel_id_in
- and sc.channel_id = oc.id
- and oc.parent_channel is null
- -- now, see if it's compatible with the new base channel
- and nc.id = new_channel_id_in
- and nc.parent_channel is null
- and sc.server_id = s.id
- and s.server_arch_id = scac.server_arch_id
- and scac.channel_arch_id = nc.channel_arch_id;
- begin
- for s in servers loop
- insert into rhnSet (
- user_id, label, element
- ) values (
- set_uid_in,
- set_label_in || 'basechange',
- s.id
- );
- end loop;
- perform rhn_channel.bulk_server_base_change(new_channel_id_in,
- set_label_in || 'basechange',
- set_uid_in);
- delete from rhnSet
- where label = set_label_in||'basechange'
- and user_id = set_uid_in;
- end$$ language plpgsql;
-
- create or replace function bulk_guess_server_base(
- set_label_in in varchar,
- set_uid_in in numeric
- ) returns void
- as $$
- declare
- server RECORD;
- channel_id numeric;
- begin
- for server in
- SELECT user_id, label, element, element_two
- FROM rhnSet
- WHERE label = set_label_in
- AND user_id = set_uid_in
- loop
- -- anything that doesn't work, we just ignore
- begin
- if rhn_server.can_change_base_channel(server.element) = 1
- then
- channel_id := rhn_channel.guess_server_base(server.element);
- perform rhn_channel.clear_subscriptions(server.element);
- perform rhn_channel.subscribe_server(server.element, channel_id, 0,
set_uid_in);
- end if;
- exception when others then
- null;
- end;
- end loop;
- end$$ language plpgsql;
-
create or replace function guess_server_base(
server_id_in in numeric
) RETURNS numeric as $$
@@ -480,41 +381,6 @@ update pg_settings set setting = 'rhn_channel,' || setting
where name = 'search_
return NULL;
end$$ language plpgsql;
- create or replace function bulk_guess_server_base_from(
- set_label_in in varchar,
- set_uid_in in numeric,
- channel_id_in in numeric
- ) returns void
- as $$
- declare
- server RECORD;
- channels cursor(server_id_in numeric) for
- select rsc.channel_id
- from rhnServerChannel rsc,
- rhnChannel rc
- where server_id_in = rsc.server_id
- and rsc.channel_id = rc.id
- and rc.parent_channel is null;
- begin
- for server in
- SELECT user_id, label, element, element_two
- FROM rhnSet
- WHERE label = set_label_in
- AND user_id = set_uid_in
- loop
- for channel in channels(server.element)
- loop
- if channel.channel_id = channel_id_in
- then
- insert into rhnSet (user_id, label, element) values (set_uid_in,
set_label_in || 'baseguess', server.element);
- end if;
- end loop;
- end loop;
- perform
rhn_channel.bulk_guess_server_base(set_label_in||'baseguess',set_uid_in);
- delete from rhnSet where label = set_label_in||'baseguess' and user_id =
set_uid_in;
- end$$ language plpgsql;
-
-
CREATE OR REPLACE FUNCTION clear_subscriptions(server_id_in IN NUMERIC,
deleting_server IN NUMERIC default 0 ) returns void
AS $$
declare
commit 0fac8ac20da2d8c2f926e54744a567db46ca395b
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Jun 14 17:17:25 2010 -0400
Removed unused stored procedures
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb
b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index 3de8129..baf6ade 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -209,89 +209,6 @@ IS
RETURN 0;
END;
- PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2,
set_uid_in IN NUMBER)
- IS
- BEGIN
- FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
- LOOP
- IF rhn_server.can_change_base_channel(server.element) = 1
- THEN
- rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
- rhn_channel.subscribe_server(server.element, channel_id_in, 0,
set_uid_in);
- END IF;
- END LOOP server;
- END bulk_server_base_change;
-
- procedure bulk_server_basechange_from(
- set_label_in in varchar2,
- set_uid_in in number,
- old_channel_id_in in number,
- new_channel_id_in in number
- ) is
- cursor servers is
- select sc.server_id id
- from rhnChannel nc,
- rhnServerChannelArchCompat scac,
- rhnServer s,
- rhnChannel oc,
- rhnServerChannel sc,
- rhnSet st
- where 1=1
- -- first, find the servers we're looking for.
- and st.label = set_label_in
- and st.user_id = set_uid_in
- and st.element = sc.server_id
- -- now, filter out anything that's not in the
- -- old base channel.
- and sc.channel_id = old_channel_id_in
- and sc.channel_id = oc.id
- and oc.parent_channel is null
- -- now, see if it's compatible with the new base channel
- and nc.id = new_channel_id_in
- and nc.parent_channel is null
- and sc.server_id = s.id
- and s.server_arch_id = scac.server_arch_id
- and scac.channel_arch_id = nc.channel_arch_id;
- begin
- for s in servers loop
- insert into rhnSet (
- user_id, label, element
- ) values (
- set_uid_in,
- set_label_in || 'basechange',
- s.id
- );
- end loop channel;
- bulk_server_base_change(new_channel_id_in,
- set_label_in || 'basechange',
- set_uid_in);
- delete from rhnSet
- where label = set_label_in||'basechange'
- and user_id = set_uid_in;
- end bulk_server_basechange_from;
-
- procedure bulk_guess_server_base(
- set_label_in in varchar2,
- set_uid_in in number
- ) is
- channel_id number;
- begin
- for server in rhn_set.set_iterator(set_label_in, set_uid_in)
- loop
- -- anything that doesn't work, we just ignore
- begin
- if rhn_server.can_change_base_channel(server.element) = 1
- then
- channel_id := guess_server_base(TO_NUMBER(server.element));
- rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
- rhn_channel.subscribe_server(TO_NUMBER(server.element), channel_id,
0, set_uid_in);
- end if;
- exception when others then
- null;
- end;
- end loop server;
- end;
-
function guess_server_base(
server_id_in in number
) RETURN number is
@@ -414,34 +331,6 @@ IS
return NULL;
end base_channel_rel_archid;
- procedure bulk_guess_server_base_from(
- set_label_in in varchar2,
- set_uid_in in number,
- channel_id_in in number
- ) is
- cursor channels(server_id_in in number) is
- select rsc.channel_id
- from rhnServerChannel rsc,
- rhnChannel rc
- where server_id_in = rsc.server_id
- and rsc.channel_id = rc.id
- and rc.parent_channel is null;
- begin
- for server in rhn_set.set_iterator(set_label_in, set_uid_in)
- loop
- for channel in channels(server.element)
- loop
- if channel.channel_id = channel_id_in
- then
- insert into rhnSet (user_id, label, element) values (set_uid_in,
set_label_in || 'baseguess', server.element);
- end if;
- end loop channel;
- end loop server;
- bulk_guess_server_base(set_label_in||'baseguess',set_uid_in);
- delete from rhnSet where label = set_label_in||'baseguess' and user_id =
set_uid_in;
- end;
-
-
PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server IN NUMBER :=
0,
update_family_countsYN IN NUMBER := 1)
IS
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pks
b/schema/spacewalk/oracle/packages/rhn_channel.pks
index 906a7c7..d9ab7b6 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pks
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pks
@@ -71,22 +71,6 @@ IS
FUNCTION channel_priority(channel_id_in in number) RETURN number;
- PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2,
set_uid_in IN NUMBER);
- procedure bulk_server_basechange_from(
- set_label_in in varchar2,
- set_uid_in in number,
- old_channel_id_in in number,
- new_channel_id_in in number);
-
- procedure bulk_guess_server_base(
- set_label_in in varchar2,
- set_uid_in in number);
-
- procedure bulk_guess_server_base_from(
- set_label_in in varchar2,
- set_uid_in in number,
- channel_id_in in number);
-
PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server in number :=
0,
update_family_countsYN IN NUMBER := 1);
commit 8831c55fd26a210e9ca8cc8a3149a18ffaeb693c
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 16:33:04 2010 -0400
More updates to the UI
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 07112e5..e97a9c3 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -6179,6 +6179,9 @@ value for this entitlement, excluding the default organization's
consumption.</s
<context
context-type="sourcefile">rhn/systems/entitlements/FlexGuests.do</context>
<context
context-type="sourcefile">rhn/systems/entitlements/EligibleFlexGuests.do</context>
</context-group>
+ <trans-unit id="Registered">
+ <source>Registered</source>
+ </trans-unit>
<trans-unit
id="flexguest.jsp.entitlement_counts_message_unlimited">
<source>{0} consumed, unlimited available entitlements</source>
</trans-unit>
@@ -6188,7 +6191,35 @@ value for this entitlement, excluding the default
organization's consumption.</s
</trans-unit>
<trans-unit id="flexguest.jsp.entitlement_counts_message_1">
<source>{0} consumed, {1} available entitlements</source>
+ </trans-unit>
+ <trans-unit id="flexguest.jsp.header">
+ <source>Flex Guest Entitlement Consumers</source>
+ </trans-unit>
+ <trans-unit id="flexguest.jsp.message">
+ <source>The following is a list of guest systems that are currently consuming
<a href="{0}"> Flex Guest entitlements</a>.
These entitlements are used when registering virtual guests that are not associated with a
registered host system or that are associated with a host system that is not
Virtualization or Virtualization Platform entitled. Flex Guest Entitlement
Consumers</source>
+ </trans-unit>
+ <trans-unit id="floating.guests">
+ <source>Flex Guest Entitlement Consumers</source>
+ </trans-unit>
+
+ <trans-unit id="eligible.floating.guests">
+ <source>Guests Consuming Regular Entitlements</source>
</trans-unit>
+ <trans-unit id="eligible.flexguest.jsp.header">
+ <source>Guests Consuming Regular Entitlements</source>
+ </trans-unit>
+ <trans-unit id="eligible.flexguest.jsp.message">
+ <source>The following is a list of guest systems that are not associated with a
virtual entitled (either Virtualization or Virtualization Platform) host system in RHN or
for whom there are no remaining <a href="{0}">
Virtualization inherited guest entitlements</a>. These systems are consuming
the same software and system entitlements as a physical system.</source>
+ </trans-unit>
+
+ <trans-unit id="eligible.flexguest.jsp.no-systems">
+ <source>There are no eligible flex guest systems consuming regular
entitlements.</source>
+ </trans-unit>
+
+ <trans-unit id="flexguest.jsp.no-systems">
+ <source>There are no systems consuming Flex Guest entitlements.</source>
+ </trans-unit>
+
</group>
<!-- System search -->
diff --git a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
index ecb25dd..cfc2d18 100644
--- a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
@@ -10,11 +10,13 @@
<c:set var="headerkey"
value="eligible.flexguest.jsp.header"/>
<c:set var="messagekey"
value="eligible.flexguest.jsp.message"/>
<c:set var="namestyle" value="first-column"/>
+ <c:set var="empty_msg"
value="eligible-flexguest.jsp.no-systems"/>
</c:when>
<c:otherwise>
<c:set var="headerkey" value="flexguest.jsp.header"/>
<c:set var="messagekey" value="flexguest.jsp.message"/>
<c:set var="namestyle" value=""/>
+ <c:set var="empty_msg" value="flexguest.jsp.no-systems"/>
</c:otherwise>
</c:choose>
@@ -25,22 +27,22 @@
<meta name="page-decorator" content="none" />
</head>
<body>
-<rhn:toolbar base="h1" img="/img/rhn-icon-system.gif"
imgAlt="system.common.systemAlt"
-
helpUrl="/rhn/help/reference/en-US/s1-sm-systems.jsp#s3-sm-system-list-ood">
- <bean:message key="flexguest.jsp.header"/>
-</rhn:toolbar>
+ <rhn:toolbar base="h1" img="/img/rhn-icon-system.gif"
imgAlt="system.common.systemAlt">
+ <bean:message key="virtualentitlements.toolbar" />
+ </rhn:toolbar>
-<rl:listset name="FlexSet">
<rhn:dialogmenu mindepth="0"
maxdepth="1"
definition="/WEB-INF/nav/virt_entitlements.xml"
renderer="com.redhat.rhn.frontend.nav.DialognavRenderer"/>
- <p><bean:message key="flexguest.jsp.message"/>
+<h2><bean:message key="${headerkey}"/></h2>
+ <p><bean:message key="${messagekey}"
arg0="http://kbase.redhat.com/faq/docs/DOC-17424"/>
</p>
-
+
+<rl:listset name="FlexSet">
<rl:list
- emptykey="nosystems.message"
+ emptykey="${empty_msg}"
parentiselement = "false"
searchparent="false"
searchchild="true"
@@ -98,7 +100,7 @@
</rl:non-expandable>
</rl:column>
- <rl:column headerkey="systemlist.jsp.registered"
+ <rl:column headerkey="Registered"
styleclass="last-column">
<rl:expandable></rl:expandable>
<rl:non-expandable>${current.registeredString}</rl:non-expandable>
commit 4ee55967d2e42601e7be7df5e4f8e326fea5ca64
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 16:08:19 2010 -0400
More UI updates on the Flex Guest Pages added Nav stuff
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
index dc68082..62c09f4 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
@@ -43,11 +43,13 @@ public class ChannelFamilySystemGroup implements Identifiable,
Expandable {
return
ls.getMessage("flexguest.jsp.entitlement_counts_message_unlimited",
currentMembers);
}
+ String key = "flexguest.jsp.entitlement_counts_message";
+ long available = maxMembers - currentMembers;
+ if (available > 1) {
+ key = key + "_1";
+ }
-
- return ls.getMessage("flexguest.jsp.entitlement_counts_message",
- currentMembers, maxMembers - currentMembers);
-
+ return ls.getMessage(key, currentMembers, available);
}
/**
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index e5cc410..3987ef8 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -557,6 +557,12 @@
http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd&q...
<context context-type="sourcefile">Navigation
Menu</context>
</context-group>
</trans-unit>
+ <trans-unit id="Active">
+<source>Active</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">Navigation
Menu</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="IP Ranges">
<source>IP Ranges</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index d53ca85..07112e5 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -6186,6 +6186,9 @@ value for this entitlement, excluding the default organization's
consumption.</s
<trans-unit id="flexguest.jsp.entitlement_counts_message">
<source>{0} consumed, {1} available entitlement</source>
</trans-unit>
+ <trans-unit id="flexguest.jsp.entitlement_counts_message_1">
+ <source>{0} consumed, {1} available entitlements</source>
+ </trans-unit>
</group>
<!-- System search -->
diff --git a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
index 78d8838..e514848 100644
--- a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
+++ b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml
@@ -15,7 +15,12 @@
<rhn-tab name="Locale Preferences"
url="/rhn/account/LocalePreferences.do" />
<rhn-tab name="Subscription Management"
url="/rhn/systems/SystemEntitlements.do" acl="user_role(org_admin)"
>
<rhn-tab name="System Entitlements"
url="/rhn/systems/SystemEntitlements.do" acl="user_role(org_admin)"
/>
- <rhn-tab name="virtualization.entitlements"
url="/rhn/systems/entitlements/GuestLimitedHosts.do"
acl="user_role(org_admin)"/>
+ <rhn-tab name="virtualization.entitlements"
url="/rhn/systems/entitlements/GuestLimitedHosts.do"
acl="user_role(org_admin)">
+
<rhn-tab-url>/rhn/systems/entitlements/GuestUnlimitedHosts.do</rhn-tab-url>
+
<rhn-tab-url>/rhn/systems/entitlements/PhysicalHosts.do</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/entitlements/FlexGuests.do</rhn-tab-url>
+
<rhn-tab-url>/rhn/systems/entitlements/EligibleFlexGuests.do</rhn-tab-url>
+ </rhn-tab>
<rhn-tab name="Software Channel Entitlements"
url="/rhn/channels/software/Entitlements.do"
acl="user_role(org_admin)" />
</rhn-tab>
<rhn-tab name="Organization Trusts"
url="/rhn/multiorg/Organizations.do" acl="user_role(org_admin)">
diff --git a/java/code/webapp/WEB-INF/nav/virt_entitlements.xml
b/java/code/webapp/WEB-INF/nav/virt_entitlements.xml
index 188bccd..76a954c 100644
--- a/java/code/webapp/WEB-INF/nav/virt_entitlements.xml
+++ b/java/code/webapp/WEB-INF/nav/virt_entitlements.xml
@@ -10,4 +10,11 @@
<rhn-tab name="guests.without.hosts">
<rhn-tab-url>/rhn/systems/entitlements/PhysicalHosts.do</rhn-tab-url>
</rhn-tab>
+ <rhn-tab name="floating.guests">
+ <rhn-tab-url>/rhn/systems/entitlements/FlexGuests.do</rhn-tab-url>
+</rhn-tab>
+ <rhn-tab name="eligible.floating.guests">
+
<rhn-tab-url>/rhn/systems/entitlements/EligibleFlexGuests.do</rhn-tab-url>
+ </rhn-tab>
+
</rhn-navi-tree>
diff --git a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
index 7224c62..ecb25dd 100644
--- a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
@@ -1,9 +1,24 @@
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-html"
prefix="html" %>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
+<c:choose>
+ <c:when test="${not empty requestScope.selectable}">
+ <c:set var="headerkey"
value="eligible.flexguest.jsp.header"/>
+ <c:set var="messagekey"
value="eligible.flexguest.jsp.message"/>
+ <c:set var="namestyle" value="first-column"/>
+ </c:when>
+ <c:otherwise>
+ <c:set var="headerkey" value="flexguest.jsp.header"/>
+ <c:set var="messagekey" value="flexguest.jsp.message"/>
+ <c:set var="namestyle" value=""/>
+ </c:otherwise>
+</c:choose>
+
+
<html:xhtml/>
<html>
<head>
@@ -17,11 +32,13 @@
<rl:listset name="FlexSet">
+ <rhn:dialogmenu mindepth="0"
+ maxdepth="1"
+ definition="/WEB-INF/nav/virt_entitlements.xml"
+
renderer="com.redhat.rhn.frontend.nav.DialognavRenderer"/>
<p><bean:message key="flexguest.jsp.message"/>
</p>
-<%-- <rhn:dialogmenu mindepth="0" maxdepth="1"
definition="/WEB-INF/nav/duplicate_systems_tabs.xml"
- renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" />
--%>
-<br/>
+
<rl:list
emptykey="nosystems.message"
parentiselement = "false"
@@ -32,9 +49,26 @@
<rl:rowrenderer name="ExpandableRowRenderer" />
<rl:decorator name="ExpansionDecorator"/>
+ <c:if test="${not empty requestScope.selectable}">
+ <rl:decorator name="SelectableDecorator"/>
+ <c:choose>
+ <c:when test = "${rl:expandable(current)}">
+ <rl:selectablecolumn value="${current.id}"
+ styleclass="first-column"/>
+ </c:when>
+ <c:otherwise>
+ <rl:selectablecolumn value="${current.selectionKey}"
+ styleclass="first-column"/>
+
+ </c:otherwise>
+ </c:choose>
+ </c:if>
+
+
<!-- Name Column -->
- <rl:column headerkey="systemlist.jsp.system" filterattr="name"
filtermessage="${filtermessage}" styleclass="first-column">
- <rl:expandable rendericon="true">${current.name}
<em>(${current.entitlementCountMessage})</em> </rl:expandable>
+ <rl:column headerkey="systemlist.jsp.system" filterattr="name"
filtermessage="${filtermessage}" styleclass="${namestyle}">
+ <rl:expandable rendericon="true"> <a
href="/rhn/software/channels/ChannelFamilyTree.do?cfid=${current.id}">${current.name}
<em>(${current.entitlementCountMessage})</em> </a>
+ </rl:expandable>
<rl:non-expandable rendericon="true">
<c:out value="<a
href=\"/rhn/systems/details/Overview.do?sid=${current.id}\">"
escapeXml="false" />
@@ -49,9 +83,19 @@
</rl:non-expandable>
</rl:column>
- <rl:column headerkey="systemlist.jsp.active">
+ <rl:column headerkey="Status">
<rl:expandable></rl:expandable>
- <rl:non-expandable>${current.active}</rl:non-expandable>
+ <rl:non-expandable>
+ <c:choose>
+ <c:when test="${current.active}">
+ <bean:message key="Active"/>
+ </c:when>
+ <c:otherwise>
+ <bean:message key="Inactive"/>
+ </c:otherwise>
+ </c:choose>
+
+ </rl:non-expandable>
</rl:column>
<rl:column headerkey="systemlist.jsp.registered"
@@ -63,6 +107,18 @@
</rl:list>
<rhn:submitted/>
+<c:if test="${not empty requestScope.selectable}">
+ <div align="right">
+
+ <hr />
+ <html:submit property="dispatch">
+ <bean:message key="Make Flex"/>
+ </html:submit>
+
+ </div>
+</c:if>
+
+
</rl:listset>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 561d957..2eaaaa9 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -6358,6 +6358,7 @@
className="com.redhat.rhn.frontend.struts.RhnActionMapping">
<set-property property="acls"
value="user_role(org_admin)"/>
<forward name="default"
path="/WEB-INF/pages/systems/entitlements/flexguests.jsp"/>
+ <forward name="success"
path="/systems/entitlements/FlexGuests.do" redirect="true"/>
</action>
<action path="/channels/manage/errata/Add"
commit 5a14c45f543d7c42e21b85bdf56f7a6579a06883
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 14:37:04 2010 -0400
Made the Flexguest page show entitlements
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index 3970308..8f97a59 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1694,7 +1694,9 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
s.id as system_id,
s.name as system_name,
(select count(*) from rhnServerInfo Si2 where S.id = Si2.server_id and Si2.checkin
< sysdate - :checkin_threshold) as inactive,
- TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered
+ TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered,
+ pcf.FVE_CURRENT_MEMBERS as current_members,
+ pcf.FVE_MAX_MEMBERS as max_members
from
RhnVirtualInstance vi
inner join rhnServer s on vi.virtual_system_id = s.id
@@ -1702,6 +1704,7 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
inner join rhnServerChannel sc on sc.server_id = s.id
inner join rhnChannelFamilyMembers cfm on cfm.channel_id = sc.channel_id
inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
+ inner join rhnPrivateChannelFamily pcf on pcf.channel_family_id = cf.id and
pcf.org_id = s.org_id
where sc.is_fve = 'Y'
AND USP.user_id = :user_id
</query>
@@ -1716,7 +1719,9 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
s.id as system_id,
s.name as system_name,
(select count(*) from rhnServerInfo Si2 where S.id = Si2.server_id and Si2.checkin
< sysdate - :checkin_threshold) as inactive,
- TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered
+ TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered,
+ pcf.FVE_CURRENT_MEMBERS as current_members,
+ pcf.FVE_MAX_MEMBERS as max_members
from
RhnVirtualInstance vi
inner join rhnServer s on vi.virtual_system_id = s.id
@@ -1724,6 +1729,7 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
inner join rhnServerChannel sc on sc.server_id = s.id
inner join rhnChannelFamilyMembers cfm on cfm.channel_id = sc.channel_id
inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
+ inner join rhnPrivateChannelFamily pcf on pcf.channel_family_id = cf.id and
pcf.org_id = s.org_id
where sc.is_fve = 'N'
AND USP.user_id = :user_id
AND (vi.host_system_id is null OR
diff --git a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
index 85862fc..f4cf0cc 100644
--- a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
@@ -354,6 +354,8 @@ public class VirtualInstanceFactory extends HibernateFactory {
String systemName = (String) row.get("system_name");
Long inactive = (Long) row.get("inactive");
String registered = (String) row.get("registered");
+ Long currentMembers = (Long) row.get("current_members");
+ Long maxMembers = (Long) row.get("max_members");
ChannelFamilySystemGroup cfg = map.get(cfId);
@@ -363,6 +365,8 @@ public class VirtualInstanceFactory extends HibernateFactory {
}
cfg.setId(cfId);
cfg.setName(cfName);
+ cfg.setCurrentMembers(currentMembers);
+ cfg.setMaxMembers(maxMembers);
ChannelFamilySystem ov = new ChannelFamilySystem();
ov.setId(systemId);
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
index ff3e317..dc68082 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
@@ -14,6 +14,7 @@
*/
package com.redhat.rhn.frontend.dto;
+import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.domain.Identifiable;
import com.redhat.rhn.frontend.struts.Expandable;
@@ -30,8 +31,40 @@ public class ChannelFamilySystemGroup implements Identifiable,
Expandable {
private String name;
private Long id;
private List<ChannelFamilySystem> systems = new
LinkedList<ChannelFamilySystem>();
+ private Long currentMembers;
+ private Long maxMembers;
+
+ /**
+ * @return the entitlements count message
+ */
+ public String getEntitlementCountMessage() {
+ LocalizationService ls = LocalizationService.getInstance();
+ if (maxMembers == null) {
+ return
ls.getMessage("flexguest.jsp.entitlement_counts_message_unlimited",
+ currentMembers);
+ }
+
+
+ return ls.getMessage("flexguest.jsp.entitlement_counts_message",
+ currentMembers, maxMembers - currentMembers);
+
+ }
+
+ /**
+ * @param currentMembersIn The currentMembers to set.
+ */
+ public void setCurrentMembers(Long currentMembersIn) {
+ currentMembers = currentMembersIn;
+ }
/**
+ * @param maxMembersIn The maxMembers to set.
+ */
+ public void setMaxMembers(Long maxMembersIn) {
+ maxMembers = maxMembersIn;
+ }
+
+ /**
* {@inheritDoc}
*/
public Long getId() {
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 3541076..d53ca85 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -6173,6 +6173,21 @@ value for this entitlement, excluding the default
organization's consumption.</s
</group>
+
+ <group>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">rhn/systems/entitlements/FlexGuests.do</context>
+ <context
context-type="sourcefile">rhn/systems/entitlements/EligibleFlexGuests.do</context>
+ </context-group>
+ <trans-unit
id="flexguest.jsp.entitlement_counts_message_unlimited">
+ <source>{0} consumed, unlimited available entitlements</source>
+ </trans-unit>
+
+ <trans-unit id="flexguest.jsp.entitlement_counts_message">
+ <source>{0} consumed, {1} available entitlement</source>
+ </trans-unit>
+ </group>
+
<!-- System search -->
<trans-unit id="search.alt.img">
diff --git a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
index d20b3e6..7224c62 100644
--- a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
@@ -34,7 +34,7 @@
<!-- Name Column -->
<rl:column headerkey="systemlist.jsp.system" filterattr="name"
filtermessage="${filtermessage}" styleclass="first-column">
- <rl:expandable rendericon="true">${current.name}
<em>(<bean:message key="manysystems.message"
arg0="${rl:countChildren(current)}"/>)</em> </rl:expandable>
+ <rl:expandable rendericon="true">${current.name}
<em>(${current.entitlementCountMessage})</em> </rl:expandable>
<rl:non-expandable rendericon="true">
<c:out value="<a
href=\"/rhn/systems/details/Overview.do?sid=${current.id}\">"
escapeXml="false" />
commit eae2d2789efbd9b19f34ff08e6ee6f4e95aadfd4
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 13:49:54 2010 -0400
Initial cut to list eligible flex guests page
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index eb3409c..3970308 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1686,7 +1686,7 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
</mode>
-<mode name="virtual_floating_guests">
+<mode name="flex_guests">
<query params="user_id, checkin_threshold ">
select
cf.name cf_name,
@@ -1698,11 +1698,45 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
from
RhnVirtualInstance vi
inner join rhnServer s on vi.virtual_system_id = s.id
+ inner join rhnUserServerPerms USP on s.id = USP.server_id
inner join rhnServerChannel sc on sc.server_id = s.id
inner join rhnChannelFamilyMembers cfm on cfm.channel_id = sc.channel_id
inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
where sc.is_fve = 'Y'
- AND EXISTS (SELECT 1 FROM rhnUserServerPerms USP WHERE USP.user_id = :user_id AND
USP.server_id = S.id)
+ AND USP.user_id = :user_id
+ </query>
+</mode>
+
+
+<mode name="eligible_flex_guests">
+ <query params="user_id, checkin_threshold ">
+ select
+ cf.name cf_name,
+ cf.id as cf_id,
+ s.id as system_id,
+ s.name as system_name,
+ (select count(*) from rhnServerInfo Si2 where S.id = Si2.server_id and Si2.checkin
< sysdate - :checkin_threshold) as inactive,
+ TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered
+ from
+ RhnVirtualInstance vi
+ inner join rhnServer s on vi.virtual_system_id = s.id
+ inner join rhnUserServerPerms USP on s.id = USP.server_id
+ inner join rhnServerChannel sc on sc.server_id = s.id
+ inner join rhnChannelFamilyMembers cfm on cfm.channel_id = sc.channel_id
+ inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
+ where sc.is_fve = 'N'
+ AND USP.user_id = :user_id
+ AND (vi.host_system_id is null OR
+ exists (
+ select sg.id from rhnServerGroupMembers sgm
+ inner join rhnServerGroup sg on sgm.server_group_id = sg.id
+ inner join rhnServerGroupType sgt on sgt.id = sg.group_type
+ inner join rhnServer s2 on s2.id = sgm.server_id
+ where
+ s2.org_id = s.org_id
+ and s2.id = vi.host_system_id
+ and sgt.label not in ('virtualization_host'
,'virtualization_host_platform') )
+ )
</query>
</mode>
diff --git a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
index 2fad6d0..85862fc 100644
--- a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
@@ -321,9 +321,24 @@ public class VirtualInstanceFactory extends HibernateFactory {
* @return a list of ChannelFamilySystemGroups
*/
public List<ChannelFamilySystemGroup> listFlexGuests(User user) {
+ return runFlexGuestsQuery(user, "flex_guests");
+ }
+
+ /**
+ * Returns a list of eligible systems who could become floating guests
+ * with a channel family grouping
+ * @param user the user object needed for perms checking
+ * @return a list of ChannelFamilySystemGroups
+ */
+ public List<ChannelFamilySystemGroup> listEligibleFlexGuests(User user) {
+ return runFlexGuestsQuery(user, "eligible_flex_guests");
+ }
+
+
+ private List<ChannelFamilySystemGroup> runFlexGuestsQuery(User user, String
query) {
List<ChannelFamilySystemGroup> ret = new
LinkedList<ChannelFamilySystemGroup>();
- SelectMode m = ModeFactory.getMode("System_queries",
"virtual_floating_guests");
+ SelectMode m = ModeFactory.getMode("System_queries", query);
Map params = new HashMap();
params.put("user_id", user.getId());
params.put("checkin_threshold", Config.get().getInt(ConfigDefaults
@@ -361,4 +376,6 @@ public class VirtualInstanceFactory extends HibernateFactory {
}
+
+
}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
index 5e86e4f..01d3674 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
@@ -101,6 +101,13 @@ public class ChannelFamilySystem extends SelectableAdapter {
public void setId(Long idIn) {
id = idIn;
}
+
+ /**
+ * @return returns server id
+ */
+ public Long getId() {
+ return id;
+ }
/**
* {@inheritDoc}
*/
diff --git
a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
index c900882..be95619 100644
--- a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
@@ -101,5 +101,16 @@ public class VirtualizationEntitlementsManager {
return VirtualInstanceFactory.getInstance().listFlexGuests(user);
}
+
+ /**
+ * Returns a list of eligible guest systems that could be moved to FVE bucket
+ * @param user user for access checks
+ * @return a list of ChannelFamilySystemGroup
+ */
+ public List<ChannelFamilySystemGroup> listEligibleFlexGuests(User user) {
+ return VirtualInstanceFactory.getInstance().listEligibleFlexGuests(user);
+
+ }
+
}
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 4e98fdd..561d957 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -6350,7 +6350,15 @@
className="com.redhat.rhn.frontend.struts.RhnActionMapping">
<set-property property="acls"
value="user_role(org_admin)"/>
<forward name="default"
path="/WEB-INF/pages/systems/entitlements/flexguests.jsp"/>
- </action>
+ </action>
+
+ <action path="/systems/entitlements/EligibleFlexGuests"
+ scope="request"
+
type="com.redhat.rhn.frontend.action.systems.entitlements.EligibleFlexGuestAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="acls"
value="user_role(org_admin)"/>
+ <forward name="default"
path="/WEB-INF/pages/systems/entitlements/flexguests.jsp"/>
+ </action>
<action path="/channels/manage/errata/Add"
scope="request"
commit 30002b23a9259586d48ef420f1bbf48affbfaecf
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 12:54:09 2010 -0400
Added an rhnException data
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
new file mode 100644
index 0000000..9d8e856
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/012-rhnException_data.sql
@@ -0,0 +1,24 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+-- data for rhnException
+
+insert into rhnException values (-20294,
'not_enough_flex_entitlements_in_base_org', 'You do not have enough
entitlements in the base org.');
+
+commit;
+
+
commit 23c6644f3584b74ec5ebc5a39db4fb18b2d9636b
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 12:47:38 2010 -0400
Added channel family permissions to upgrade
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/011-rhnChannelFamilyPermissions.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/011-rhnChannelFamilyPermissions.sql
new file mode 100644
index 0000000..071e0f0
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/011-rhnChannelFamilyPermissions.sql
@@ -0,0 +1,39 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace view rhnChannelFamilyPermissions as
+ select channel_family_id,
+ to_number(null, null) as org_id,
+ to_number(null, null) as max_members,
+ 0 as current_members,
+ 0 as fve_max_members,
+ 0 as fve_current_members,
+ created,
+ modified
+ from rhnPublicChannelFamily
+ union
+ select channel_family_id,
+ org_id,
+ max_members,
+ current_members,
+ fve_max_members,
+ fve_current_members,
+ created,
+ modified
+ from rhnPrivateChannelFamily;
+
commit 05573bea60cbc938aba81f3190bdeead2978b604
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jun 10 12:10:30 2010 -0400
Slight refactoring of Virtual Enttitlements
diff --git a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
index 26ca490..2fad6d0 100644
--- a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
@@ -22,6 +22,7 @@ import com.redhat.rhn.common.db.datasource.SelectMode;
import com.redhat.rhn.common.hibernate.HibernateFactory;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.dto.ChannelFamilySystem;
import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
import org.apache.log4j.Logger;
@@ -348,8 +349,7 @@ public class VirtualInstanceFactory extends HibernateFactory {
cfg.setId(cfId);
cfg.setName(cfName);
- ChannelFamilySystemGroup.SystemInfo ov = new
- ChannelFamilySystemGroup.SystemInfo();
+ ChannelFamilySystem ov = new ChannelFamilySystem();
ov.setId(systemId);
ov.setName(systemName);
ov.setActive(1 != inactive.intValue());
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/BaseDto.java
b/java/code/src/com/redhat/rhn/frontend/dto/BaseDto.java
index 9da1d13..99647ab 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/BaseDto.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/BaseDto.java
@@ -16,7 +16,7 @@ package com.redhat.rhn.frontend.dto;
import com.redhat.rhn.domain.Identifiable;
import com.redhat.rhn.domain.rhnset.RhnSet;
-import com.redhat.rhn.frontend.struts.Selectable;
+import com.redhat.rhn.frontend.struts.SelectableAdapter;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -26,9 +26,9 @@ import org.apache.commons.lang.builder.ToStringBuilder;
* select all.
* @version $Rev: 60953 $
*/
-public abstract class BaseDto implements Selectable, Identifiable {
+public abstract class BaseDto extends SelectableAdapter implements Identifiable {
+
- private boolean selected;
protected static final Integer ONE = new Integer(1);
protected static final Integer ZERO = new Integer(0);
@@ -39,18 +39,6 @@ public abstract class BaseDto implements Selectable, Identifiable {
public abstract Long getId();
/**
- * This says whether this object is selectable on a page with a set The
- * default as can be seen is true. Any dto class that cares should override
- * this method. This is used by RhnSet in the select all method. In order to
- * disable checkboxes on a page use <code><rhn:set
value="${current.id}"
- * disabled="${not current.selectable}" /></code>
- * @return whether this object is selectable for RhnSet
- */
- public boolean isSelectable() {
- return true;
- }
-
- /**
* Adds the id of this object to a given set. For adding IdCombos to a set,
* @see com.redhat.rhn.frontend.dto.IdComboDto
* @param set The set to which we are adding an element.
@@ -59,23 +47,6 @@ public abstract class BaseDto implements Selectable, Identifiable {
set.addElement(new Long(getId().longValue()));
}
-
-
- /**
- * @return the selected
- */
- public boolean isSelected() {
- return selected;
- }
-
-
- /**
- * @param isSelected the selected to set
- */
- public void setSelected(boolean isSelected) {
- this.selected = isSelected;
- }
-
/**
*
* {@inheritDoc}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
new file mode 100644
index 0000000..5e86e4f
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystem.java
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.dto;
+
+import com.redhat.rhn.common.util.StringUtil;
+import com.redhat.rhn.frontend.struts.SelectableAdapter;
+
+import java.util.Date;
+
+
+/**
+ * ChannelFamilySystem
+ * @version $Rev$
+ */
+public class ChannelFamilySystem extends SelectableAdapter {
+ private String name;
+ private Long id;
+ private boolean active;
+ private Date registered;
+ private ChannelFamilySystemGroup group;
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * @return Returns the group.
+ */
+ public ChannelFamilySystemGroup getGroup() {
+ return group;
+ }
+
+
+ /**
+ * @param groupIn The group to set.
+ */
+ public void setGroup(ChannelFamilySystemGroup groupIn) {
+ group = groupIn;
+ }
+
+ /**
+ * @param nameIn The name to set.
+ */
+ public void setName(String nameIn) {
+ name = nameIn;
+ }
+
+ /**
+ * @return Returns the active.
+ */
+ public boolean isActive() {
+ return active;
+ }
+
+ /**
+ * @param activeIn The active to set.
+ */
+ public void setActive(boolean activeIn) {
+ active = activeIn;
+ }
+
+ /**
+ * @return Returns the registered.
+ */
+ public Date getRegistered() {
+ return registered;
+ }
+
+ /**
+ * @return Returns the registered.
+ */
+ public String getRegisteredString() {
+ return StringUtil.categorizeTime(registered.getTime(), StringUtil.YEARS_UNITS);
+ }
+ /**
+ * @param registeredIn The registered to set.
+ */
+ public void setRegistered(Date registeredIn) {
+ registered = registeredIn;
+ }
+
+ /**
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ id = idIn;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getSelectionKey() {
+ return group.getId() + "|" + id;
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
index 0903de2..ff3e317 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
@@ -14,11 +14,9 @@
*/
package com.redhat.rhn.frontend.dto;
-import com.redhat.rhn.common.util.StringUtil;
import com.redhat.rhn.domain.Identifiable;
import com.redhat.rhn.frontend.struts.Expandable;
-import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -31,7 +29,7 @@ public class ChannelFamilySystemGroup implements Identifiable,
Expandable {
private String name;
private Long id;
- private List<SystemInfo> systems = new LinkedList<SystemInfo>();
+ private List<ChannelFamilySystem> systems = new
LinkedList<ChannelFamilySystem>();
/**
* {@inheritDoc}
@@ -44,8 +42,9 @@ public class ChannelFamilySystemGroup implements Identifiable,
Expandable {
* adds a system to the grouping
* @param sys a System overview object
*/
- public void add(SystemInfo sys) {
+ public void add(ChannelFamilySystem sys) {
systems.add(sys);
+ sys.setGroup(this);
}
@@ -76,83 +75,8 @@ public class ChannelFamilySystemGroup implements Identifiable,
Expandable {
*
* {@inheritDoc}
*/
- public List<? extends Identifiable> expand() {
+ public List<ChannelFamilySystem> expand() {
return systems;
}
-
- /**
- *
- * SystemInfo
- * @version $Rev$
- */
- public static class SystemInfo implements Identifiable {
- private String name;
- private Long id;
- private boolean active;
- private Date registered;
-
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param nameIn The name to set.
- */
- public void setName(String nameIn) {
- name = nameIn;
- }
-
- /**
- * @return Returns the active.
- */
- public boolean isActive() {
- return active;
- }
-
- /**
- * @param activeIn The active to set.
- */
- public void setActive(boolean activeIn) {
- active = activeIn;
- }
-
- /**
- * @return Returns the registered.
- */
- public Date getRegistered() {
- return registered;
- }
-
- /**
- * @return Returns the registered.
- */
- public String getRegisteredString() {
- return StringUtil.categorizeTime(registered.getTime(),
StringUtil.YEARS_UNITS);
- }
- /**
- * @param registeredIn The registered to set.
- */
- public void setRegistered(Date registeredIn) {
- registered = registeredIn;
- }
-
- /**
- * @param idIn The id to set.
- */
- public void setId(Long idIn) {
- id = idIn;
- }
- /**
- * {@inheritDoc}
- */
- public Long getId() {
- return id;
- }
-
- }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/struts/Expandable.java
b/java/code/src/com/redhat/rhn/frontend/struts/Expandable.java
index 9444233..7204e44 100644
--- a/java/code/src/com/redhat/rhn/frontend/struts/Expandable.java
+++ b/java/code/src/com/redhat/rhn/frontend/struts/Expandable.java
@@ -14,8 +14,6 @@
*/
package com.redhat.rhn.frontend.struts;
-import com.redhat.rhn.domain.Identifiable;
-
import java.util.List;
@@ -28,8 +26,9 @@ import java.util.List;
public interface Expandable {
/**
* Expands and returns the children
+ * List needs to be either Identifiable or Selectable
* @return the child object
*/
- List<? extends Identifiable> expand();
+ List expand();
}
diff --git a/java/code/src/com/redhat/rhn/frontend/struts/SelectableAdapter.java
b/java/code/src/com/redhat/rhn/frontend/struts/SelectableAdapter.java
new file mode 100644
index 0000000..48448a9
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/struts/SelectableAdapter.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.struts;
+
+
+/**
+ * SelectableAdapter
+ * @version $Rev$
+ */
+public abstract class SelectableAdapter implements Selectable {
+ private boolean selected;
+ /**
+ * {@inheritDoc}
+ */
+ public abstract String getSelectionKey();
+
+ /**
+ * This says whether this object is selectable on a page with a set The
+ * default as can be seen is true. Any dto class that cares should override
+ * this method. This is used by RhnSet in the select all method. In order to
+ * disable checkboxes on a page use <code><rhn:set
value="${current.id}"
+ * disabled="${not current.selectable}" /></code>
+ * @return whether this object is selectable for RhnSet
+ */
+ public boolean isSelectable() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSelected() {
+ return selected;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setSelected(boolean selectedIn) {
+ selected = selectedIn;
+ }
+
+}
commit 4f0209ef9c88bc15e8e1c3a5679ec61ca1e3ca27
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 9 21:25:37 2010 -0400
Initial cut of the Flex Guests Page
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index 9d89f37..eb3409c 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1686,6 +1686,27 @@ DELETE FROM rhnSatelliteChannelFamily WHERE server_id = :sid
</mode>
+<mode name="virtual_floating_guests">
+ <query params="user_id, checkin_threshold ">
+ select
+ cf.name cf_name,
+ cf.id as cf_id,
+ s.id as system_id,
+ s.name as system_name,
+ (select count(*) from rhnServerInfo Si2 where S.id = Si2.server_id and Si2.checkin
< sysdate - :checkin_threshold) as inactive,
+ TO_CHAR(s.created, 'YYYY-MM-DD HH24:MI:SS') as registered
+ from
+ RhnVirtualInstance vi
+ inner join rhnServer s on vi.virtual_system_id = s.id
+ inner join rhnServerChannel sc on sc.server_id = s.id
+ inner join rhnChannelFamilyMembers cfm on cfm.channel_id = sc.channel_id
+ inner join rhnChannelFamily cf on cf.id = cfm.channel_family_id
+ where sc.is_fve = 'Y'
+ AND EXISTS (SELECT 1 FROM rhnUserServerPerms USP WHERE USP.user_id = :user_id AND
USP.server_id = S.id)
+ </query>
+</mode>
+
+
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
index b120f94..26ca490 100644
--- a/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/VirtualInstanceFactory.java
@@ -14,16 +14,26 @@
*/
package com.redhat.rhn.domain.server;
+import com.redhat.rhn.common.conf.Config;
+import com.redhat.rhn.common.conf.ConfigDefaults;
+import com.redhat.rhn.common.db.datasource.DataResult;
+import com.redhat.rhn.common.db.datasource.ModeFactory;
+import com.redhat.rhn.common.db.datasource.SelectMode;
import com.redhat.rhn.common.hibernate.HibernateFactory;
import
com.redhat.rhn.domain.org.Org;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
import org.apache.log4j.Logger;
import org.hibernate.Session;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/**
@@ -302,6 +312,53 @@ public class VirtualInstanceFactory extends HibernateFactory {
"VirtualInstanceState.findByLabel").setString("label",
"unknown")
.uniqueResult();
}
+
+
+ /**
+ * Returns a list of floating guests with a channel family grouping
+ * @param user the user object needed for perms checking
+ * @return a list of ChannelFamilySystemGroups
+ */
+ public List<ChannelFamilySystemGroup> listFlexGuests(User user) {
+ List<ChannelFamilySystemGroup> ret = new
LinkedList<ChannelFamilySystemGroup>();
+
+ SelectMode m = ModeFactory.getMode("System_queries",
"virtual_floating_guests");
+ Map params = new HashMap();
+ params.put("user_id", user.getId());
+ params.put("checkin_threshold", Config.get().getInt(ConfigDefaults
+ .SYSTEM_CHECKIN_THRESHOLD));
+ DataResult<Map<String, Object>> result = m.execute(params);
+ Map<Long, ChannelFamilySystemGroup> map = new HashMap<Long,
+ ChannelFamilySystemGroup>();
+
+ for (Map<String, Object> row : result) {
+ Long cfId = (Long)row.get("cf_id");
+ String cfName = (String) row.get("cf_name");
+ Long systemId = (Long) row.get("system_id");
+ String systemName = (String) row.get("system_name");
+ Long inactive = (Long) row.get("inactive");
+ String registered = (String) row.get("registered");
+
+
+ ChannelFamilySystemGroup cfg = map.get(cfId);
+ if (cfg == null) {
+ cfg = new ChannelFamilySystemGroup();
+ map.put(cfId, cfg);
+ }
+ cfg.setId(cfId);
+ cfg.setName(cfName);
+
+ ChannelFamilySystemGroup.SystemInfo ov = new
+ ChannelFamilySystemGroup.SystemInfo();
+ ov.setId(systemId);
+ ov.setName(systemName);
+ ov.setActive(1 != inactive.intValue());
+ ov.setRegistered(java.sql.Timestamp.valueOf((registered)));
+ cfg.add(ov);
+ }
+ ret.addAll(map.values());
+ return ret;
+ }
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/FlexGuestAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/FlexGuestAction.java
new file mode 100644
index 0000000..da1fbb1
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/systems/entitlements/FlexGuestAction.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.systems.entitlements;
+
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
+import com.redhat.rhn.manager.system.VirtualizationEntitlementsManager;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * FloatingVirtualizationAction
+ * @version $Rev$
+ */
+public class FlexGuestAction extends RhnAction implements Listable {
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
+ return mapping.findForward("default");
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ return VirtualizationEntitlementsManager.getInstance().
+ listFlexGuests(contextIn.getLoggedInUser());
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
new file mode 100644
index 0000000..0903de2
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelFamilySystemGroup.java
@@ -0,0 +1,158 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.dto;
+
+import com.redhat.rhn.common.util.StringUtil;
+import com.redhat.rhn.domain.Identifiable;
+import com.redhat.rhn.frontend.struts.Expandable;
+
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+
+/**
+ * ChannelSystemGrouping
+ * @version $Rev$
+ */
+public class ChannelFamilySystemGroup implements Identifiable, Expandable {
+
+ private String name;
+ private Long id;
+ private List<SystemInfo> systems = new LinkedList<SystemInfo>();
+
+ /**
+ * {@inheritDoc}
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * adds a system to the grouping
+ * @param sys a System overview object
+ */
+ public void add(SystemInfo sys) {
+ systems.add(sys);
+ }
+
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * @param nameIn The name to set.
+ */
+ public void setName(String nameIn) {
+ name = nameIn;
+ }
+
+
+ /**
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ id = idIn;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public List<? extends Identifiable> expand() {
+ return systems;
+ }
+
+ /**
+ *
+ * SystemInfo
+ * @version $Rev$
+ */
+ public static class SystemInfo implements Identifiable {
+ private String name;
+ private Long id;
+ private boolean active;
+ private Date registered;
+
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param nameIn The name to set.
+ */
+ public void setName(String nameIn) {
+ name = nameIn;
+ }
+
+ /**
+ * @return Returns the active.
+ */
+ public boolean isActive() {
+ return active;
+ }
+
+ /**
+ * @param activeIn The active to set.
+ */
+ public void setActive(boolean activeIn) {
+ active = activeIn;
+ }
+
+ /**
+ * @return Returns the registered.
+ */
+ public Date getRegistered() {
+ return registered;
+ }
+
+ /**
+ * @return Returns the registered.
+ */
+ public String getRegisteredString() {
+ return StringUtil.categorizeTime(registered.getTime(),
StringUtil.YEARS_UNITS);
+ }
+ /**
+ * @param registeredIn The registered to set.
+ */
+ public void setRegistered(Date registeredIn) {
+ registered = registeredIn;
+ }
+
+ /**
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ id = idIn;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Long getId() {
+ return id;
+ }
+
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/DuplicateSystemsRowRenderer.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/DuplicateSystemsRowRenderer.java
new file mode 100644
index 0000000..eb47e8d
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/DuplicateSystemsRowRenderer.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.taglibs.list.row;
+
+import com.redhat.rhn.frontend.dto.NetworkDto;
+import com.redhat.rhn.frontend.taglibs.RhnListTagFunctions;
+
+
+/**
+ * DuplicateSystemsRowRenderer
+ * @version $Rev$
+ */
+public class DuplicateSystemsRowRenderer extends ExpandableRowRenderer {
+ /**
+ * get the row style for the current object
+ * @param current the current object that is being rendered
+ * @return the string that is the style to add to the row
+ */
+ @Override
+ public String getRowClass(Object current) {
+ if (!RhnListTagFunctions.isExpandable(current)) {
+ NetworkDto dto = (NetworkDto) current;
+ if (dto.getInactive() > 0) {
+ return " inactive";
+ }
+ }
+ return super.getRowClass(current);
+ }
+
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/ExpandableRowRenderer.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/ExpandableRowRenderer.java
index 24707cd..03ee4f3 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/ExpandableRowRenderer.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/row/ExpandableRowRenderer.java
@@ -14,7 +14,6 @@
*/
package com.redhat.rhn.frontend.taglibs.list.row;
-import com.redhat.rhn.frontend.dto.NetworkDto;
import com.redhat.rhn.frontend.taglibs.RhnListTagFunctions;
import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
@@ -45,10 +44,6 @@ public class ExpandableRowRenderer extends RowRenderer {
return rowClasses[rowNum % rowClasses.length];
}
else {
- NetworkDto dto = (NetworkDto) current;
- if (dto.getInactive() > 0) {
- return " inactive";
- }
return rowClasses[rowNum % rowClasses.length];
}
}
diff --git
a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
index b18368c..c900882 100644
--- a/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
+++ b/java/code/src/com/redhat/rhn/manager/system/VirtualizationEntitlementsManager.java
@@ -17,6 +17,8 @@ package com.redhat.rhn.manager.system;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.server.VirtualInstanceFactory;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.dto.ChannelFamilySystemGroup;
import java.util.LinkedList;
import java.util.List;
@@ -88,6 +90,16 @@ public class VirtualizationEntitlementsManager {
findGuestsWithoutAHostByOrg(org));
return guestsWithoutHosts;
+ }
+
+ /**
+ * Returns a list of guests using FVE
+ * @param user user for access checks
+ * @return a list of ChannelFamilySystemGroup
+ */
+ public List<ChannelFamilySystemGroup> listFlexGuests(User user) {
+ return VirtualInstanceFactory.getInstance().listFlexGuests(user);
+
}
}
diff --git a/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicatesystems.jsp
b/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicatesystems.jsp
index b791500..0e3fc52 100644
--- a/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicatesystems.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/duplicate/duplicatesystems.jsp
@@ -65,7 +65,7 @@
searchchild="false"
- <rl:rowrenderer name="ExpandableRowRenderer" />
+ <rl:rowrenderer name="DuplicateSystemsRowRenderer" />
<rl:decorator name="SelectableDecorator"/>
<rl:decorator name="ExpansionDecorator"/>
<rl:decorator name="ExtraButtonDecorator"/>
diff --git a/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
new file mode 100644
index 0000000..d20b3e6
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/systems/entitlements/flexguests.jsp
@@ -0,0 +1,70 @@
+<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
+<%@ taglib
uri="http://jakarta.apache.org/struts/tags-html"
prefix="html" %>
+<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
+<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
+
+<html:xhtml/>
+<html>
+<head>
+ <meta name="page-decorator" content="none" />
+</head>
+<body>
+<rhn:toolbar base="h1" img="/img/rhn-icon-system.gif"
imgAlt="system.common.systemAlt"
+
helpUrl="/rhn/help/reference/en-US/s1-sm-systems.jsp#s3-sm-system-list-ood">
+ <bean:message key="flexguest.jsp.header"/>
+</rhn:toolbar>
+
+<rl:listset name="FlexSet">
+
+ <p><bean:message key="flexguest.jsp.message"/>
+ </p>
+<%-- <rhn:dialogmenu mindepth="0" maxdepth="1"
definition="/WEB-INF/nav/duplicate_systems_tabs.xml"
+ renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" />
--%>
+<br/>
+<rl:list
+ emptykey="nosystems.message"
+ parentiselement = "false"
+ searchparent="false"
+ searchchild="true"
+ >
+
+ <rl:rowrenderer name="ExpandableRowRenderer" />
+ <rl:decorator name="ExpansionDecorator"/>
+
+ <!-- Name Column -->
+ <rl:column headerkey="systemlist.jsp.system" filterattr="name"
filtermessage="${filtermessage}" styleclass="first-column">
+ <rl:expandable rendericon="true">${current.name}
<em>(<bean:message key="manysystems.message"
arg0="${rl:countChildren(current)}"/>)</em> </rl:expandable>
+
+ <rl:non-expandable rendericon="true">
+ <c:out value="<a
href=\"/rhn/systems/details/Overview.do?sid=${current.id}\">"
escapeXml="false" />
+ <c:choose>
+ <c:when test="${empty current.name}">
+ <bean:message key="sdc.details.overview.unknown"/>
+ </c:when>
+ <c:otherwise>
+ <c:out value="${current.name}</a>" escapeXml="false"
/>
+ </c:otherwise>
+ </c:choose>
+ </rl:non-expandable>
+ </rl:column>
+
+ <rl:column headerkey="systemlist.jsp.active">
+ <rl:expandable></rl:expandable>
+ <rl:non-expandable>${current.active}</rl:non-expandable>
+ </rl:column>
+
+ <rl:column headerkey="systemlist.jsp.registered"
+ styleclass="last-column">
+ <rl:expandable></rl:expandable>
+ <rl:non-expandable>${current.registeredString}</rl:non-expandable>
+ </rl:column>
+
+</rl:list>
+<rhn:submitted/>
+
+</rl:listset>
+
+
+</body>
+</html>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index c0a33b8..4e98fdd 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -6344,6 +6344,14 @@
<forward name="success"
path="/WEB-INF/pages/systems/entitlements/physicalhosts.jsp"/>
</action>
+ <action path="/systems/entitlements/FlexGuests"
+ scope="request"
+
type="com.redhat.rhn.frontend.action.systems.entitlements.FlexGuestAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="acls"
value="user_role(org_admin)"/>
+ <forward name="default"
path="/WEB-INF/pages/systems/entitlements/flexguests.jsp"/>
+ </action>
+
<action path="/channels/manage/errata/Add"
scope="request"
input="/WEB-INF/pages/channel/manage/add.jsp"
commit 5913b5b8c0c0cd6918f4d009d86a59e8ed3295a9
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Jun 9 13:55:32 2010 -0400
adding flex guest entitlement columns on the org entitlments page
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index d49c568..6ac036c 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -342,7 +342,12 @@ ORDER BY UPPER(C.name)
<mode name="channel_entitlements"
class="com.redhat.rhn.frontend.dto.ChannelOverview">
<query params="org_id">
-SELECT CFO.id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url
+SELECT CFO.id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url,
+ CFO.fve_current_members as current_flex, CFO.fve_max_members as max_flex,
+ (select count(*)
+ from rhnServerChannel sc inner join
+ rhnChannelFamilyMembers CFM on CFM.channel_id = sc.channel_id
+ where CFM.channel_family_id = CFO.id) as subscribe_count
FROM rhnChannelFamilyOverview CFO
WHERE CFO.org_id = :org_id
ORDER BY CFO.name ASC
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelEntitlementSetupAction.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelEntitlementSetupAction.java
index df3f68f..94d78f3 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelEntitlementSetupAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/channel/ChannelEntitlementSetupAction.java
@@ -18,24 +18,51 @@ import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import com.redhat.rhn.frontend.dto.ChannelOverview;
-import com.redhat.rhn.frontend.listview.PageControl;
-import com.redhat.rhn.frontend.struts.BaseListAction;
import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* ChannelEntitlementSetupAction
* @version $Rev$
*/
-public class ChannelEntitlementSetupAction extends BaseListAction {
+public class ChannelEntitlementSetupAction extends RhnAction implements Listable {
+
/**
+ *
* {@inheritDoc}
*/
- protected DataResult getDataResult(RequestContext rctx, PageControl pc) {
- DataResult<ChannelOverview> list = ChannelManager.entitlements(
- rctx.getCurrentUser().getOrg().getId(), pc);
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
+ return mapping.findForward("default");
+
+ }
+
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext context) {
+ DataResult<ChannelOverview> list = ChannelManager.entitlements(
+ context.getCurrentUser().getOrg().getId(), null);
/* hate doing this, as we should really change the view and queries to support
this
* This is for bz 435894 Opened bz 445260 to fix this properly. Simply need
to
* change the rhnChannelFamilyOverview view to also return the channel
family's
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
b/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
index daca4da..53d8d36 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/ChannelOverview.java
@@ -30,6 +30,66 @@ public class ChannelOverview extends BaseDto implements Comparable {
private String label;
private Long currentMembers;
private Long maxMembers;
+ private Long currentFlex;
+ private Long maxFlex;
+ private Long subscribeCount;
+
+
+ /**
+ * @return Returns the subscribeCount.
+ */
+ public Long getSubscribeCount() {
+ return subscribeCount;
+ }
+
+
+
+
+ /**
+ * @param subscribeCountIn The subscribeCountIn to set.
+ */
+ public void setSubscribeCount(Long subscribeCountIn) {
+ this.subscribeCount = subscribeCountIn;
+ }
+
+
+
+ /**
+ * @return Returns the currentFlex.
+ */
+ public Long getCurrentFlex() {
+ return currentFlex;
+ }
+
+
+
+ /**
+ * @param currentFlexIn The currentFlex to set.
+ */
+ public void setCurrentFlex(Long currentFlexIn) {
+ this.currentFlex = currentFlexIn;
+ }
+
+
+
+ /**
+ * @return Returns the maxFlex.
+ */
+ public Long getMaxFlex() {
+ return maxFlex;
+ }
+
+
+
+ /**
+ * @param maxFlexIn The maxFlex to set.
+ */
+ public void setMaxFlex(Long maxFlexIn) {
+ this.maxFlex = maxFlexIn;
+ }
+
+
+
private Long hasSubscription;
private String url;
private Long relevantPackages;
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 7613e05..3541076 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -5140,13 +5140,32 @@ value for this entitlement, excluding the default
organization's consumption.</s
</context-group>
</trans-unit>
<trans-unit id="entitlements.jsp.subscribed">
-<source>Systems Entitled</source>
+<source>Systems Subscribed</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/channels/Entitlements</context>
</context-group>
</trans-unit>
+ <trans-unit id="entitlements.jsp.consumed">
+<source>Regular Consumed</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/channels/Entitlements</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="entitlements.jsp.subscribed_flex">
+<source>Consumed Flex Guests</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/channels/Entitlements</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="entitlements.jsp.avaible_flex">
+<source>Available Flex Guests</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/channels/Entitlements</context>
+ </context-group>
+ </trans-unit>
+
<trans-unit id="entitlements.jsp.available">
-<source>Available Entitlements</source>
+<source>Regular Available</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/channels/Entitlements</context>
</context-group>
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ColumnTag.java
b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ColumnTag.java
index 0e9bf7a..d4ce099 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/list/ColumnTag.java
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/list/ColumnTag.java
@@ -38,6 +38,7 @@ public class ColumnTag extends BodyTagSupport {
private static final long serialVersionUID = -1139212563984660282L;
protected String styleClass;
+
protected String attributeName;
protected String sortAttribute;
protected boolean isBound;
@@ -49,6 +50,18 @@ public class ColumnTag extends BodyTagSupport {
private String defaultSortDir;
private String filterAttr;
private String filterMessage;
+ private String width;
+
+
+
+
+
+ /**
+ * @param widthIn The width to set.
+ */
+ public void setWidth(String widthIn) {
+ this.width = widthIn;
+ }
/**
* @param filterMessageIn The filterMessage to set.
@@ -186,6 +199,7 @@ public class ColumnTag extends BodyTagSupport {
* ${@inheritDoc}
*/
public void release() {
+ width = null;
styleClass = null;
attributeName = null;
isBound = false;
@@ -366,6 +380,11 @@ public class ColumnTag extends BodyTagSupport {
}
ListTagUtil.write(pageContext, "\"");
}
+ if (!StringUtils.isBlank(width)) {
+ ListTagUtil.write(pageContext, " width=\"");
+ ListTagUtil.write(pageContext, width);
+ ListTagUtil.write(pageContext, "\"");
+ }
ListTagUtil.write(pageContext, ">");
}
diff --git a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
index e3b91cd..83664b2 100644
--- a/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
+++ b/java/code/src/com/redhat/rhn/frontend/taglibs/rhn-list.tld
@@ -216,6 +216,11 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+ <attribute>
+ <name>width</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
<attribute>
<name>filterattr</name>
<required>false</required>
diff --git a/java/code/webapp/WEB-INF/pages/channel/entitlements.jsp
b/java/code/webapp/WEB-INF/pages/channel/entitlements.jsp
index c759a26..b330269 100644
--- a/java/code/webapp/WEB-INF/pages/channel/entitlements.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/entitlements.jsp
@@ -2,6 +2,8 @@
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-html"
prefix="html" %>
<%@ taglib
uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean" %>
+<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
+
<html:xhtml/>
<html>
@@ -23,13 +25,20 @@
<c:set var="pageList" value="${requestScope.pageList}" />
<form method="post" name="rhn_list"
action="/rhn/channels/software/EntitlementsSubmit.do">
-<rhn:list pageList="${requestScope.pageList}"
noDataText="entitlements.jsp.noentitlements">
- <rhn:listdisplay>
- <rhn:column header="entitlements.jsp.channel"
-
url="/rhn/software/channels/ChannelFamilyTree.do?cfid=${current.id}">
- ${current.name}
- </rhn:column>
- <rhn:column header="entitlements.jsp.subscribed">
+<rl:listset name="entitlements">
+ <rl:list emptykey="entitlements.jsp.noentitlements">
+
+
+ <rl:column headerkey="entitlements.jsp.channel"
+ styleclass="first-column"
+ sortattr="name"
+ filterattr="name"
+ defaultsort="asc"
+ width="40%">
+ <a
href="/rhn/software/channels/ChannelFamilyTree.do?cfid=${current.id}">${current.name}</a>
+ </rl:column>
+
+ <rl:column headerkey="entitlements.jsp.consumed" >
<c:if test="${current.currentMembers == 0}">
${current.currentMembers}
</c:if>
@@ -37,18 +46,43 @@
<a
href="/network/systems/system_list/in_channel_family.pxt?cfam_id=${current.id}">
${current.currentMembers}</a>
</c:if>
- </rhn:column>
- <rhn:column header="entitlements.jsp.available">
+ </rl:column>
+
+ <rl:column headerkey="entitlements.jsp.available"
<c:if test="${current.orgId == null}">
${current.maxMembers - current.currentMembers}
</c:if>
<c:if test="${current.orgId != null}">
Unlimited
</c:if>
-
- </rhn:column>
- </rhn:listdisplay>
-</rhn:list>
+ </rl:column>
+
+ <rl:column headerkey="entitlements.jsp.subscribed_flex" >
+ ${current.currentFlex}
+ </rl:column>
+
+ <rl:column headerkey="entitlements.jsp.avaible_flex" >
+ <c:if test="${current.orgId == null}">
+ ${current.maxFlex - current.currentFlex}
+ </c:if>
+ <c:if test="${current.orgId != null}">
+ Unlimited
+ </c:if>
+ </rl:column>
+
+ <rl:column headerkey="entitlements.jsp.subscribed"
styleclass="last-column" >
+ <c:if test="${current.subscribeCount == 0}">
+ ${current.subscribeCount}
+ </c:if>
+ <c:if test="${current.subscribeCount > 0}">
+ <a
href="/network/systems/system_list/in_channel_family.pxt?cfam_id=${current.id}">
+ ${current.subscribeCount}</a>
+ </c:if>
+ </rl:column>
+
+
+ </rl:list>
+</rl:listset>
</form>
</body>
</html>
commit 1829934b832656819d5776d0766c2617e7b8e900
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Tue Jun 8 11:53:33 2010 -0400
adding flex guest detection at registration time
diff --git a/backend/server/handlers/xmlrpc/registration.py
b/backend/server/handlers/xmlrpc/registration.py
index 90e5b6f..211702b 100644
--- a/backend/server/handlers/xmlrpc/registration.py
+++ b/backend/server/handlers/xmlrpc/registration.py
@@ -69,6 +69,38 @@ def RegistrationNumber(nr):
return None
return ret
+def parse_smbios(smbios):
+ vendor = smbios.get('smbios.bios.vendor')
+ serial = smbios.get('smbios.system.serial', '')
+ manufacturer = smbios.get('smbios.system.manufacturer')
+ product = smbios.get('smbios.system.product')
+
+ # XXX need to worry about uuid being none for other virt types and
+ # available subs check
+ uuid = None
+ if smbios.has_key('smbios.system.uuid'):
+ uuid = smbios['smbios.system.uuid']
+ uuid = uuid.replace('-', '')
+
+ if vendor == "QEMU" and uuid is not None:
+ return (rhnVirtualization.VirtualizationType.QEMU, uuid)
+ elif manufacturer == 'Microsoft Corporation' and \
+ product == 'Virtual Machine':
+ if uuid is None:
+ uuid = "flex-guest"
+ return (rhnVirtualization.VirtualizationType.HYPERV, uuid)
+ elif serial.startswith('VMware-'):
+ if uuid is None:
+ uuid = "flex-guest"
+ return (rhnVirtualization.VirtualizationType.VMWARE, uuid)
+ elif manufacturer == 'HITACHI' and product.endswith(' HVM LPAR'):
+ if uuid is None:
+ uuid = "flex-guest"
+ return (rhnVirtualization.VirtualizationType.VIRTAGE, uuid)
+ else:
+ return (None, None)
+
+
class Registration(rhnHandler):
""" encapsulate functions that we will provide for the outside world
"""
def __init__(self):
@@ -332,15 +364,11 @@ class Registration(rhnHandler):
newserv.virt_uuid = None
newserv.virt_type = None
- # check for kvm/qemu guest info
- if data.has_key('smbios'):
- smbios = data['smbios']
- if smbios.has_key('smbios.bios.vendor') and \
- smbios['smbios.bios.vendor'] == 'QEMU' and \
- smbios.has_key('smbios.system.uuid'):
- newserv.virt_type = rhnVirtualization.VirtualizationType.FULLY
- newserv.virt_uuid =
smbios['smbios.system.uuid'].replace('-', '')
+ # If we didn't find virt info from xen, check smbios
+ if data.has_key('smbios') and newserv.virt_uuid is None:
+ (newserv.virt_type, newserv.virt_uuid) = \
+ parse_smbios(data['smbios'])
if tokens_obj.forget_rereg_token:
# At this point we retained the server with re-activation
diff --git a/backend/server/rhnVirtualization.py b/backend/server/rhnVirtualization.py
index 53d0c0d..6101a99 100644
--- a/backend/server/rhnVirtualization.py
+++ b/backend/server/rhnVirtualization.py
@@ -62,6 +62,10 @@ class ServerStateType:
class VirtualizationType:
PARA = 'para_virtualized'
FULLY = 'fully_virtualized'
+ QEMU = 'qemu'
+ HYPERV = 'hyperv'
+ VMWARE = 'vmware'
+ VIRTAGE = 'virtage'
class IdentityType:
HOST = 'host'
diff --git a/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
b/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
index 7e5a112..dfeae9d 100644
--- a/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
+++ b/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
@@ -24,3 +24,11 @@ insert into rhnVirtualInstanceType (id, name, label)
insert into rhnVirtualInstanceType (id, name, label)
values (rhn_vit_id_seq.nextval, 'KVM/QEMU', 'qemu');
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'VMware', 'vmware');
+
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'Hyper-V', 'hyperv');
+
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'Virtage', 'virtage');
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnVirtualInstanceType.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnVirtualInstanceType.sql
new file mode 100644
index 0000000..3bc88f0
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnVirtualInstanceType.sql
@@ -0,0 +1,9 @@
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'VMware', 'vmware');
+
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'Hyper-V', 'hyperv');
+
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'Virtage', 'virtage');
+
commit 4801f0badbf3f903c33f353a4f7fa5d19ec1d141
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Jun 8 11:16:14 2010 -0400
Commiting the initial compilable merge of rhn_channel
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb
b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index 77377f5..3de8129 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -42,8 +42,6 @@ IS
and scac.server_arch_id = server_arch_id_in
and scac.channel_arch_id = c.channel_arch_id;
-
-
PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in
NUMBER := 1, user_id_in in number := null, recalcfamily_in NUMBER := 1)
IS
channel_parent_val rhnChannel.parent_channel%TYPE;
@@ -53,9 +51,11 @@ IS
channel_family_id_val NUMBER;
server_org_id_val NUMBER;
available_subscriptions NUMBER;
+ available_fve_subs NUMBER;
consenting_user NUMBER;
allowed number := 0;
- current_members_val number;
+ is_fve CHAR(1) := 'N';
+
BEGIN
if user_id_in is not null then
allowed := rhn_channel.user_role_check(channel_id_in, user_id_in,
'subscribe');
@@ -123,19 +123,24 @@ IS
FROM rhnChannel
WHERE id = channel_id_in;
- select current_members
- into current_members_val
- from rhnPrivateChannelFamily
- where org_id = server_org_id_val and channel_family_id = channel_family_id_val
- for update of current_members;
+ begin
+ obtain_read_lock(channel_family_id_val, server_org_id_val);
+ exception
+ when no_data_found then
+
rhn_exception.raise_exception('channel_family_no_subscriptions');
+ end;
available_subscriptions :=
rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
-
- IF available_subscriptions IS NULL OR
- available_subscriptions > 0 or
- can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1
+ available_fve_subs :=
rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
+
+ IF available_subscriptions IS NULL OR
+ available_subscriptions > 0 or
+ can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1 OR
+ (available_fve_subs > 0 AND can_server_consume_fve(server_id_in) = 1)
THEN
-
+ if can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 0
AND available_fve_subs > 0 AND can_server_consume_fve(server_id_in) = 1 THEN
+ is_fve := 'Y';
+ END IF;
insert into rhnServerHistory (id,server_id,summary,details) (
select rhn_event_id_seq.nextval,
server_id_in,
@@ -145,7 +150,7 @@ IS
where c.id = channel_id_in
);
UPDATE rhnServer SET channels_changed = sysdate WHERE id = server_id_in;
- INSERT INTO rhnServerChannel (server_id, channel_id) VALUES (server_id_in,
channel_id_in);
+ INSERT INTO rhnServerChannel (server_id, channel_id, is_fve) VALUES
(server_id_in, channel_id_in, is_fve);
IF recalcfamily_in > 0
THEN
rhn_channel.update_family_counts(channel_family_id_val,
server_org_id_val);
@@ -188,6 +193,21 @@ IS
end;
+ FUNCTION can_server_consume_fve(server_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ CURSOR vi_entries IS
+ SELECT *
+ FROM rhnVirtualInstance
+ WHERE virtual_system_id = server_id_in;
+ vi_count NUMBER;
+
+ BEGIN
+ FOR vi_entry IN VI_ENTRIES LOOP
+ return 1;
+ END LOOP;
+ RETURN 0;
+ END;
PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2,
set_uid_in IN NUMBER)
IS
@@ -605,6 +625,45 @@ IS
-- otherwise, return the delta
RETURN max_members_val - current_members_val;
END available_family_subscriptions;
+
+ FUNCTION available_fve_family_subs(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER)
+ RETURN NUMBER
+ IS
+ cfp channel_family_perm_cursor%ROWTYPE;
+ fve_current_members_val NUMBER;
+ fve_max_members_val NUMBER;
+ found NUMBER;
+
+ BEGIN
+ IF NOT channel_family_perm_cursor%ISOPEN THEN
+ OPEN channel_family_perm_cursor(channel_family_id_in, org_id_in);
+ END IF;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+
+ WHILE channel_family_perm_cursor%FOUND LOOP
+ found := 1;
+ fve_current_members_val := cfp.fve_current_members;
+ fve_max_members_val := cfp.fve_max_members;
+ FETCH channel_family_perm_cursor INTO cfp;
+ END LOOP;
+
+ IF channel_family_perm_cursor%ISOPEN THEN
+ CLOSE channel_family_perm_cursor;
+ END IF;
+
+ IF found IS NULL THEN
+ RETURN 0;
+ END IF;
+
+ IF fve_max_members_val IS NULL THEN
+ RETURN NULL;
+ END IF;
+
+ RETURN fve_max_members_val - fve_current_members_val;
+
+ END available_fve_family_subs;
+
-- *******************************************************************
-- FUNCTION: channel_family_current_members
@@ -627,17 +686,42 @@ IS
return current_members_count;
end;
+
+ function cfam_curr_fve_members(
+ channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number
+ is
+ current_members_count number := 0;
+
+ begin
+ select count(sc.server_id)
+ into current_members_count
+ from rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm,
+ rhnServer s
+ where s.org_id = org_id_in
+ and s.id = sc.server_id
+ and cfm.channel_family_id = channel_family_id_in
+ and cfm.channel_id = sc.channel_id
+ and exists (
+ select 1
+ from rhnChannelFamilyServerFve cfsp
+ where cfsp.CHANNEL_FAMILY_ID = channel_family_id_in
+ and cfsp.server_id = s.id
+ );
+
+ return current_members_count;
+ end;
PROCEDURE update_family_counts(channel_family_id_in IN NUMBER,
org_id_in IN NUMBER)
IS
BEGIN
- update rhnPrivateChannelFamily
- set current_members = (
- channel_family_current_members(channel_family_id_in, org_id_in)
- )
- where org_id = org_id_in
- and channel_family_id = channel_family_id_in;
-
+ update rhnPrivateChannelFamily
+ set current_members = ( channel_family_current_members(channel_family_id_in,
org_id_in)),
+ fve_current_members = ( cfam_curr_fve_members(channel_family_id_in,
org_id_in))
+ where org_id = org_id_in
+ and channel_family_id = channel_family_id_in;
END update_family_counts;
PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2,
@@ -677,6 +761,20 @@ IS
channel_family_id_val, org_id_in);
END available_chan_subscriptions;
+ FUNCTION available_fve_chan_subs(channel_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_fve_family_subs( channel_family_id_val, org_id_in);
+ END available_fve_chan_subs;
+
-- *******************************************************************
-- PROCEDURE: entitle_customer
-- Creates a chan fam bucket, or sets max_members for an existing bucket
@@ -686,7 +784,8 @@ IS
-- *******************************************************************
procedure entitle_customer(customer_id_in in number,
channel_family_id_in in number,
- quantity_in in number)
+ quantity_in in number,
+ fve_quantity_in in number)
is
cursor permissions is
select 1
@@ -695,11 +794,13 @@ IS
and pcf.channel_family_id = channel_family_id_in;
begin
for perm in permissions loop
- set_family_maxmembers(
- customer_id_in,
- channel_family_id_in,
- quantity_in
- );
+ set_family_maxmembers(
+ customer_id_in,
+ channel_family_id_in,
+ quantity_in,
+ fve_quantity_in
+ );
+
rhn_channel.update_family_counts(
channel_family_id_in,
customer_id_in
@@ -708,9 +809,11 @@ IS
end loop;
insert into rhnPrivateChannelFamily pcf (
- channel_family_id, org_id, max_members, current_members
+ channel_family_id, org_id, max_members, current_members,
+ fve_max_members, fve_current_members
) values (
- channel_family_id_in, customer_id_in, quantity_in, 0
+ channel_family_id_in, customer_id_in, quantity_in, 0,
+ fve_quantity_in, 0
);
end;
@@ -723,31 +826,49 @@ IS
-- *******************************************************************
procedure set_family_maxmembers(customer_id_in in number,
channel_family_id_in in number,
- quantity_in in number)
+ quantity_in in number,
+ fve_quantity_in in number)
is
- cursor servers is
- select server_id from (
- select rownum row_number, server_id, modified from (
- select rcfsp.server_id,
- rcfsp.modified
- from rhnChannelFamilyServerPhysical rcfsp
- where rcfsp.customer_id = customer_id_in
- and rcfsp.channel_family_id = channel_family_id_in
- order by modified
- )
- where rownum > quantity_in
+ cursor phy_servers is
+ select server_id from (
+ select rownum row_number, server_id, modified from (
+ select rcfsp.server_id,
+ rcfsp.modified
+ from rhnChannelFamilyServerPhysical rcfsp
+ where rcfsp.customer_id = customer_id_in
+ and rcfsp.channel_family_id = channel_family_id_in
+ order by modified
+ )
+ where rownum > quantity_in
+ );
+ cursor fve_servers is
+ select server_id from (
+ select rownum row_number, server_id, modified from (
+ select rcfsp.server_id,
+ rcfsp.modified
+ from rhnChannelFamilyServerFve rcfsp
+ where rcfsp.customer_id = customer_id_in
+ and rcfsp.channel_family_id = channel_family_id_in
+ order by modified
+ )
+ where rownum > fve_quantity_in
);
begin
- -- prune subscribed servers
- for server in servers loop
- rhn_channel.unsubscribe_server_from_family(server.server_id,
+ for phy_server in phy_servers loop
+ rhn_channel.unsubscribe_server_from_family(phy_server.server_id,
+ channel_family_id_in);
+ end loop;
+
+ for fve_server in fve_servers loop
+ rhn_channel.unsubscribe_server_from_family(fve_server.server_id,
channel_family_id_in);
end loop;
- update rhnPrivateChannelFamily pcf
- set pcf.max_members = quantity_in
- where pcf.org_id = customer_id_in
- and pcf.channel_family_id = channel_family_id_in;
+ update rhnPrivateChannelFamily pcf
+ set pcf.max_members = quantity_in,
+ pcf.fve_max_members = fve_quantity_in
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
end;
procedure unsubscribe_server_from_family(server_id_in in number,
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pks
b/schema/spacewalk/oracle/packages/rhn_channel.pks
index 9385a2a..906a7c7 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pks
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pks
@@ -57,6 +57,7 @@ IS
server_id_in IN NUMBER,
family_id_in in number)
return number;
+ FUNCTION can_server_consume_fve( server_id_in IN NUMBER) RETURN NUMBER;
FUNCTION guess_server_base(server_id_in IN NUMBER) RETURN NUMBER;
@@ -91,9 +92,11 @@ IS
FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER) RETURN NUMBER;
- function channel_family_current_members(channel_family_id_in IN NUMBER,
- org_id_in IN NUMBER)
- return number;
+ FUNCTION available_fve_family_subs(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER) RETURN NUMBER;
+
+ FUNCTION channel_family_current_members(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER) return number;
+
+ FUNCTION cfam_curr_fve_members(channel_family_id_in IN NUMBER, org_id_in IN NUMBER)
return number;
PROCEDURE update_family_counts(channel_family_id_in IN NUMBER, org_id_in IN NUMBER);
PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2, org_id_in IN
NUMBER);
@@ -101,14 +104,25 @@ IS
FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER, org_id_in IN NUMBER)
RETURN NUMBER;
- procedure entitle_customer(customer_id_in in number, channel_family_id_in in number,
quantity_in in number);
- procedure set_family_maxmembers(customer_id_in in number, channel_family_id_in in
number, quantity_in in number);
- procedure unsubscribe_server_from_family(server_id_in in number, channel_family_id_in
in number);
+ FUNCTION available_fve_chan_subs(channel_id_in IN NUMBER, org_id_in IN NUMBER) RETURN
NUMBER;
- procedure delete_server_channels(server_id_in in number);
- procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2 :=
'(unknown)');
-
- function get_org_id(channel_id_in in number) return number;
+ PROCEDURE entitle_customer(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number,
+ fve_quantity_in in number);
+
+ PROCEDURE set_family_maxmembers(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number,
+ fve_quantity_in in number);
+
+ PROCEDURE unsubscribe_server_from_family(server_id_in in number, channel_family_id_in
in number);
+
+ PROCEDURE delete_server_channels(server_id_in in number);
+
+ PROCEDURE refresh_newest_package(channel_id_in in number, caller_in in varchar2 :=
'(unknown)');
+
+ FUNCTION get_org_id(channel_id_in in number) return number;
PRAGMA RESTRICT_REFERENCES(get_org_id, WNDS, RNPS, WNPS);
function get_org_access(channel_id_in in number, org_id_in in number) return number;
commit 47fb2e77a3ab7dddf81f0c50f6a68a1de77a4da2
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Jun 7 17:23:26 2010 -0400
Added rhnChannelFamilyServerFve in the hopes that it'll get used
diff --git a/schema/spacewalk/common/views/rhnChannelFamilyServerFve.sql
b/schema/spacewalk/common/views/rhnChannelFamilyServerFve.sql
new file mode 100644
index 0000000..c66de25
--- /dev/null
+++ b/schema/spacewalk/common/views/rhnChannelFamilyServerFve.sql
@@ -0,0 +1,34 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace view rhnChannelFamilyServerFve as
+ select rs.org_id customer_id,
+ rcfm.channel_family_id channel_family_id,
+ rsc.server_id server_id,
+ rsc.created created,
+ rsc.modified modified
+ from rhnChannelFamilyMembers rcfm,
+ rhnChannelFamily rcf,
+ rhnServerChannel rsc,
+ rhnServer rs
+ where
+ rcfm.channel_id = rsc.channel_id
+ and rcfm.channel_family_id = rcf.id
+ and rsc.server_id = rs.id
+ and rsc.is_fve = 'Y';
+
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnChannelFamilyServerFve.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnChannelFamilyServerFve.sql
new file mode 100644
index 0000000..c66de25
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/010-rhnChannelFamilyServerFve.sql
@@ -0,0 +1,34 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace view rhnChannelFamilyServerFve as
+ select rs.org_id customer_id,
+ rcfm.channel_family_id channel_family_id,
+ rsc.server_id server_id,
+ rsc.created created,
+ rsc.modified modified
+ from rhnChannelFamilyMembers rcfm,
+ rhnChannelFamily rcf,
+ rhnServerChannel rsc,
+ rhnServer rs
+ where
+ rcfm.channel_id = rsc.channel_id
+ and rcfm.channel_family_id = rcf.id
+ and rsc.server_id = rs.id
+ and rsc.is_fve = 'Y';
+
commit 1224cb4c2ae89d7a706cb59320c419a561038a29
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jun 7 13:26:13 2010 -0400
updating rhn_entitlement package for cert activation
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
index d3d17c1..b5a7924 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
@@ -183,7 +183,7 @@ AND sg.org_id != 1
<callable-mode name="assign_software_entitlements">
<query params="channel_family_label from_org_id, to_org_id, quantity">
- {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity)}
+ {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity,
0)}
</query>
</callable-mode>
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index 79f0e7b..cffb79e 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -582,6 +582,7 @@ is
org_id_val number;
max_members_val number;
+ max_flex_val number;
current_members_calc number;
sg_id number;
@@ -606,6 +607,12 @@ is
where channel_family_id = family.channel_family_id
and org_id = org_id_val;
+ select fve_max_members
+ into max_flex_val
+ from rhnPrivateChannelFamily
+ where channel_family_id = family.channel_family_id
+ and org_id = org_id_val;
+
if current_members_calc > max_members_val then
-- A virtualization_host* ent must have been removed, so we'll
-- unsubscribe guests from the host first.
@@ -630,7 +637,8 @@ is
-- argh, transposed again?!
set_family_count(org_id_val,
family.channel_family_id,
- max_members_val);
+ max_members_val, max_flex_val);
+ --TODO calculate this correctly
end if;
end if;
@@ -1140,13 +1148,18 @@ is
channel_family_label_in in varchar2,
from_org_id_in in number,
to_org_id_in in number,
- quantity_in in number
+ quantity_in in number,
+ flex_in in number
)
is
prev_ent_count number;
+ prev_ent_count_flex number;
new_ent_count number;
- to_org_prev_ent_count number;
- new_quantity number;
+ new_ent_count_flex number;
+ to_org_prev_ent_count number;
+ to_org_prev_ent_count_flex number;
+ new_quantity number;
+ new_flex number;
cfam_id number;
begin
@@ -1177,6 +1190,32 @@ is
to_org_prev_ent_count := 0;
end;
+ begin
+ select fve_max_members
+ into prev_ent_count_flex
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = from_org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'not_enough_flex_entitlements_in_base_org');
+ end;
+
+ begin
+ select fve_max_members
+ into to_org_prev_ent_count_flex
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = to_org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ to_org_prev_ent_count := 0;
+ end;
begin
select id
@@ -1187,13 +1226,18 @@ is
when NO_DATA_FOUND then
rhn_exception.raise_exception(
'invalid_channel_family');
- end;
+ end;
new_ent_count := prev_ent_count - quantity_in;
+ new_ent_count_flex := prev_ent_count_flex - flex_in;
- if prev_ent_count > new_ent_count then
+ if prev_ent_count > new_ent_count then
new_quantity := to_org_prev_ent_count + quantity_in;
- end if;
+ end if;
+
+ if prev_ent_count_flex > new_ent_count_flex then
+ new_flex := to_org_prev_ent_count_flex + flex_in;
+ end if;
if new_ent_count < 0 then
@@ -1201,13 +1245,19 @@ is
'not_enough_entitlements_in_base_org');
end if;
- rhn_entitlements.set_family_count(from_org_id_in,
- cfam_id,
- new_ent_count);
+ if new_ent_count_flex < 0 then
+ rhn_exception.raise_exception(
+ 'not_enough_flex_entitlements_in_base_org');
+ end if;
+
+
+
+ rhn_entitlements.set_family_count(from_org_id_in, cfam_id,
+ new_ent_count, new_ent_count_flex);
rhn_entitlements.set_family_count(to_org_id_in,
cfam_id,
- new_quantity);
+ new_quantity, new_flex);
end assign_channel_entitlement;
@@ -1360,9 +1410,8 @@ is
rhn_exception.raise_exception(
'not_enough_entitlements_in_base_org');
else
- rhn_entitlements.set_family_count(org_id_in,
- cfam_id,
- quantity_in);
+ rhn_entitlements.set_family_count(org_id_in, cfam_id,
+ quantity_in, flex_in);
end if;
end activate_channel_entitlement;
@@ -1442,8 +1491,11 @@ is
customer_id_in in number,
channel_family_id_in in number,
quantity_in in number,
- flex_in in number
+ flex_in in number
) is
+ is_fve_in char;
+ tmp_quantity number;
+
cursor serverchannels is
select sc.server_id,
sc.channel_id
@@ -1454,23 +1506,19 @@ is
and cfm.channel_id = sc.channel_id
and server_id in (
select server_id
- from (
- select server_id,
- time,
- rownum row_number
+ from (
+ select server_id, time, rownum row_number
from (
- select rs.id server_id,
- rcfm.modified time
- from
- rhnServerChannel rsc,
- rhnChannelFamilyMembers rcfm,
+ select rs.id server_id, rcfm.modified time
+ from rhnServerChannel rsc,
+ rhnChannelFamilyMembers rcfm,
rhnServer rs
where 1=1
and rs.org_id = customer_id_in
and rs.id = rsc.server_id
and rsc.channel_id = rcfm.channel_id
- and rcfm.channel_family_id =
- channel_family_id_in
+ and rcfm.channel_family_id = channel_family_id_in
+ and rsc.is_fve = is_fve_in
-- we only want to grab servers consuming
-- physical slots.
and exists (
@@ -1483,7 +1531,7 @@ is
order by time asc
)
)
- where row_number > quantity_in
+ where row_number > tmp_quantity
);
begin
-- if we get a null customer_id, this is completely bogus.
@@ -1491,15 +1539,22 @@ is
return;
end if;
- update rhnPrivateChannelFamily
- set max_members = quantity_in
- where 1=1
- and org_id = customer_id_in
- and channel_family_id = channel_family_id_in;
+ tmp_quantity := quantity_in;
+ is_fve_in := 'N';
for sc in serverchannels loop
rhn_channel.unsubscribe_server(sc.server_id, sc.channel_id, 1, 1,
update_family_countsYN => 0);
+
+ tmp_quantity := flex_in;
+ is_fve_in := 'Y';
+ for sc in serverchannels loop
+ rhn_channel.unsubscribe_server(sc.server_id, sc.channel_id, 1, 1,
+ update_family_countsYN => 0);
+ end loop;
+
+
+
end loop;
rhn_channel.update_family_counts(channel_family_id_in, customer_id_in);
end prune_family;
@@ -1507,7 +1562,8 @@ is
procedure set_family_count (
customer_id_in in number,
channel_family_id_in in number,
- quantity_in in number
+ quantity_in in number,
+ flex_in in number
) is
cursor privperms is
select 1
@@ -1521,31 +1577,40 @@ is
where pcf.channel_family_id = channel_family_id_in;
quantity number;
done number := 0;
+ flex number;
begin
quantity := quantity_in;
if quantity is not null and quantity < 0 then
quantity := 0;
end if;
+ flex := flex_in;
+ if flex is not null and flex < 0 then
+ flex := 0;
+ end if;
+
if customer_id_in is not null then
for perm in privperms loop
- rhn_entitlements.prune_family(
- customer_id_in,
- channel_family_id_in,
- quantity
- );
- update rhnPrivateChannelFamily
+ rhn_entitlements.prune_family(customer_id_in, channel_family_id_in,
+ quantity, flex);
+
+ update rhnPrivateChannelFamily
set max_members = quantity
where org_id = customer_id_in
and channel_family_id = channel_family_id_in;
+
+ update rhnPrivateChannelFamily
+ set fve_max_members = flex
+ where org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+
return;
end loop;
insert into rhnPrivateChannelFamily (
- channel_family_id, org_id, max_members, current_members
+ channel_family_id, org_id, max_members, current_members,
fve_max_members, fve_current_members
) values (
- channel_family_id_in, customer_id_in, quantity, 0
- );
+ channel_family_id_in, customer_id_in, quantity, 0, flex, 0 );
return;
end if;
@@ -1554,7 +1619,8 @@ is
rhn_entitlements.prune_family(
perm.org_id,
channel_family_id_in,
- quantity
+ quantity,
+ flex
);
if done = 0 then
delete from rhnPublicChannelFamily
@@ -1617,62 +1683,6 @@ is
end loop;
end entitle_last_modified_servers;
- procedure prune_everything (
- customer_id_in in number
- ) is
- cursor everything is
- -- all our server groups
- select sg.id id,
- 'S' type,
- sg.max_members quantity
- from rhnServerGroup sg
- where sg.org_id = customer_id_in
- union
- -- all our user groups
- select ug.id id,
- 'U' type,
- ug.max_members quantity
- from rhnUserGroup ug
- where ug.org_id = customer_id_in
- union (
- -- all the channel families we have perms to
- select cfp.channel_family_id id,
- 'C' type,
- cfp.max_members quantity
- from rhnOrgChannelFamilyPermissions cfp
- where cfp.org_id = customer_id_in
- union
- -- plus all the ones we're using that we have no perms for
- select cfm.channel_family_id id,
- 'C' type,
- 0 quantity
- from rhnChannelFamily cf,
- rhnChannelFamilyMembers cfm,
- rhnServerChannel sc,
- rhnServer s
- where s.org_id = customer_id_in
- and s.id = sc.server_id
- and sc.channel_id = cfm.channel_id
- and cfm.channel_family_id = cf.id
- and cf.org_id is not null
- and cf.org_id != customer_id_in
- and not exists (
- select 1
- from rhnOrgChannelFamilyPermissions cfp
- where cfp.org_id = customer_id_in
- and cfp.channel_family_id = cfm.channel_family_id
- )
- );
- begin
- for one in everything loop
- if one.type in ('U','S') then
- prune_group(one.id, one.type, one.quantity);
- else
- prune_family(customer_id_in, one.id, one.quantity);
- end if;
- end loop;
- end prune_everything;
-
procedure subscribe_newest_servers (
customer_id_in in number
) is
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pks
b/schema/spacewalk/oracle/packages/rhn_entitlements.pks
index b94399d..f319aa6 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pks
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pks
@@ -125,7 +125,8 @@ is
channel_family_label_in in varchar2,
from_org_id_in in number,
to_org_id_in in number,
- quantity_in in number
+ quantity_in in number,
+ flex_in in number
);
procedure activate_system_entitlement(
@@ -152,7 +153,8 @@ is
procedure set_family_count (
customer_id_in in number, -- customer_id
channel_family_id_in in number, -- 246
- quantity_in in number -- 3
+ quantity_in in number, -- 3
+ flex_in in number
);
-- this makes NO checks that the quantity is within max,
@@ -164,10 +166,6 @@ is
quantity_in in number -- 3
);
- procedure prune_everything (
- customer_id_in in number
- );
-
procedure subscribe_newest_servers (
customer_id_in in number
);
commit 466c4c0f8d0ea97b4d686dd76fbb0e390341c3aa
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Mon Jun 7 12:01:28 2010 -0400
convertin rhn_entitlements.pkb to use four spaces instead of tabs
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index 78d385e..79f0e7b 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -19,7 +19,7 @@
create or replace
package body rhn_entitlements
is
- body_version varchar2(100) := '';
+ body_version varchar2(100) := '';
-- *******************************************************************
@@ -79,77 +79,77 @@ is
end remove_org_entitlements;
- function entitlement_grants_service (
- entitlement_in in varchar2,
- service_level_in in varchar2
- ) return number is
- begin
- if service_level_in = 'provisioning' then
- if entitlement_in = 'provisioning_entitled' then
- return 1;
- else
- return 0;
- end if;
- elsif service_level_in = 'management' then
- if entitlement_in = 'enterprise_entitled' then
- return 1;
- else
- return 0;
- end if;
- elsif service_level_in = 'monitoring' then
- if entitlement_in = 'monitoring_entitled' then
- return 1;
- end if;
- elsif service_level_in = 'updates' then
- return 1;
- else
- return 0;
- end if;
- end entitlement_grants_service;
-
- function lookup_entitlement_group (
- org_id_in in number,
- type_label_in in varchar2 := 'sw_mgr_entitled'
- ) return number is
- cursor server_groups is
- select sg.id server_group_id
- from rhnServerGroup sg,
- rhnServerGroupType sgt
- where sgt.label = type_label_in
- and sgt.id = sg.group_type
- and sg.org_id = org_id_in;
- begin
- for sg in server_groups loop
- return sg.server_group_id;
- end loop;
- return rhn_entitlements.create_entitlement_group(
- org_id_in,
- type_label_in
- );
- end lookup_entitlement_group;
-
- function create_entitlement_group (
- org_id_in in number,
- type_label_in in varchar2 := 'sw_mgr_entitled'
- ) return number is
- sg_id_val number;
- begin
- select rhn_server_group_id_seq.nextval
- into sg_id_val
- from dual;
-
- insert into rhnServerGroup (
- id, name, description, max_members, current_members,
- group_type, org_id
- ) (
- select sg_id_val, sgt.label, sgt.label,
- 0, 0, sgt.id, org_id_in
- from rhnServerGroupType sgt
- where sgt.label = type_label_in
- );
-
- return sg_id_val;
- end create_entitlement_group;
+ function entitlement_grants_service (
+ entitlement_in in varchar2,
+ service_level_in in varchar2
+ ) return number is
+ begin
+ if service_level_in = 'provisioning' then
+ if entitlement_in = 'provisioning_entitled' then
+ return 1;
+ else
+ return 0;
+ end if;
+ elsif service_level_in = 'management' then
+ if entitlement_in = 'enterprise_entitled' then
+ return 1;
+ else
+ return 0;
+ end if;
+ elsif service_level_in = 'monitoring' then
+ if entitlement_in = 'monitoring_entitled' then
+ return 1;
+ end if;
+ elsif service_level_in = 'updates' then
+ return 1;
+ else
+ return 0;
+ end if;
+ end entitlement_grants_service;
+
+ function lookup_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number is
+ cursor server_groups is
+ select sg.id server_group_id
+ from rhnServerGroup sg,
+ rhnServerGroupType sgt
+ where sgt.label = type_label_in
+ and sgt.id = sg.group_type
+ and sg.org_id = org_id_in;
+ begin
+ for sg in server_groups loop
+ return sg.server_group_id;
+ end loop;
+ return rhn_entitlements.create_entitlement_group(
+ org_id_in,
+ type_label_in
+ );
+ end lookup_entitlement_group;
+
+ function create_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number is
+ sg_id_val number;
+ begin
+ select rhn_server_group_id_seq.nextval
+ into sg_id_val
+ from dual;
+
+ insert into rhnServerGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id
+ ) (
+ select sg_id_val, sgt.label, sgt.label,
+ 0, 0, sgt.id, org_id_in
+ from rhnServerGroupType sgt
+ where sgt.label = type_label_in
+ );
+
+ return sg_id_val;
+ end create_entitlement_group;
function can_entitle_server (
server_id_in in number,
@@ -300,21 +300,21 @@ is
return false;
end find_compatible_sg;
- procedure entitle_server (
- server_id_in in number,
- type_label_in in varchar2 := 'sw_mgr_entitled'
- ) is
+ procedure entitle_server (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) is
sgid number := 0;
is_virt number := 0;
- begin
+ begin
begin
select 1 into is_virt
from rhnServerEntitlementView
where server_id = server_id_in
and label in ('virtualization_host',
'virtualization_host_platform');
- exception
+ exception
when no_data_found then
is_virt := 0;
end;
@@ -357,15 +357,15 @@ is
end if;
end entitle_server;
- procedure remove_server_entitlement (
- server_id_in in number,
- type_label_in in varchar2 := 'sw_mgr_entitled',
+ procedure remove_server_entitlement (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled',
repoll_virt_guests in number := 1
- ) is
- group_id number;
+ ) is
+ group_id number;
type_is_base char;
is_virt number := 0;
- begin
+ begin
begin
@@ -380,18 +380,18 @@ is
is_virt := 0;
end;
- select sg.id, sgt.is_base
- into group_id, type_is_base
- from rhnServerGroupType sgt,
- rhnServerGroup sg,
- rhnServerGroupMembers sgm,
- rhnServer s
- where s.id = server_id_in
- and s.id = sgm.server_id
- and sgm.server_group_id = sg.id
- and sg.org_id = s.org_id
- and sgt.label = type_label_in
- and sgt.id = sg.group_type;
+ select sg.id, sgt.is_base
+ into group_id, type_is_base
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnServer s
+ where s.id = server_id_in
+ and s.id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.org_id = s.org_id
+ and sgt.label = type_label_in
+ and sgt.id = sg.group_type;
if ( type_is_base = 'Y' ) then
-- unentitle_server should handle everything, don't really need to do
anything else special here
@@ -438,12 +438,12 @@ is
end if;
end if;
- exception
- when no_data_found then
- rhn_exception.raise_exception('invalid_server_group_member');
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('invalid_server_group_member');
end;
- end remove_server_entitlement;
+ end remove_server_entitlement;
procedure unentitle_server (server_id_in in number) is
@@ -656,7 +656,7 @@ is
and org_id = org_id_val;
- select count(sep.server_id) into current_members_calc
+ select count(sep.server_id) into current_members_calc
from rhnServerEntitlementPhysical sep
where sep.server_group_id = sg_id
and sep.server_group_type_id = a_group_type.group_type;
@@ -683,241 +683,241 @@ is
end repoll_virt_guest_entitlements;
- function get_server_entitlement (
- server_id_in in number
- ) return ents_array is
-
- cursor server_groups is
- select sgt.label
- from rhnServerGroupType sgt,
- rhnServerGroup sg,
- rhnServerGroupMembers sgm
- where 1=1
- and sgm.server_id = server_id_in
- and sg.id = sgm.server_group_id
- and sgt.id = sg.group_type
- and sgt.label in (
- 'sw_mgr_entitled','enterprise_entitled',
- 'provisioning_entitled', 'nonlinux_entitled',
- 'monitoring_entitled', 'virtualization_host',
+ function get_server_entitlement (
+ server_id_in in number
+ ) return ents_array is
+
+ cursor server_groups is
+ select sgt.label
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm
+ where 1=1
+ and sgm.server_id = server_id_in
+ and sg.id = sgm.server_group_id
+ and sgt.id = sg.group_type
+ and sgt.label in (
+ 'sw_mgr_entitled','enterprise_entitled',
+ 'provisioning_entitled', 'nonlinux_entitled',
+ 'monitoring_entitled', 'virtualization_host',
'virtualization_host_platform'
- );
+ );
ent_array ents_array;
- begin
+ begin
ent_array := ents_array();
- for sg in server_groups loop
+ for sg in server_groups loop
ent_array.extend;
ent_array(ent_array.count) := sg.label;
- end loop;
-
- return ent_array;
-
- end get_server_entitlement;
-
-
- -- this desperately needs to be table driven.
- procedure modify_org_service (
- org_id_in in number,
- service_label_in in varchar2,
- enable_in in char
- ) is
- type roles_v is varray(10) of rhnUserGroupType.label%TYPE;
- roles_to_process roles_v;
- cursor roles(role_label_in in varchar2) is
- select label, id
- from rhnUserGroupType
- where label = role_label_in;
- cursor org_roles(role_label_in in varchar2) is
- select 1
- from rhnUserGroup ug,
- rhnUserGroupType ugt
- where ugt.label = role_label_in
- and ug.org_id = org_id_in
- and ugt.id = ug.group_type;
-
- type ents_v is varray(10) of rhnOrgEntitlementType.label%TYPE;
- ents_to_process ents_v;
- cursor ents(ent_label_in in varchar2) is
- select label, id
- from rhnOrgEntitlementType
- where label = ent_label_in;
- cursor org_ents(ent_label_in in varchar2) is
- select 1
- from rhnOrgEntitlements oe,
- rhnOrgEntitlementType oet
- where oet.label = ent_label_in
- and oe.org_id = org_id_in
- and oet.id = oe.entitlement_id;
- create_row char(1);
- begin
- ents_to_process := ents_v();
- roles_to_process := roles_v();
- -- a bit kludgy, but only for 3.4 really. Certainly no
- -- worse than the old code...
- if service_label_in = 'enterprise' or
+ end loop;
+
+ return ent_array;
+
+ end get_server_entitlement;
+
+
+ -- this desperately needs to be table driven.
+ procedure modify_org_service (
+ org_id_in in number,
+ service_label_in in varchar2,
+ enable_in in char
+ ) is
+ type roles_v is varray(10) of rhnUserGroupType.label%TYPE;
+ roles_to_process roles_v;
+ cursor roles(role_label_in in varchar2) is
+ select label, id
+ from rhnUserGroupType
+ where label = role_label_in;
+ cursor org_roles(role_label_in in varchar2) is
+ select 1
+ from rhnUserGroup ug,
+ rhnUserGroupType ugt
+ where ugt.label = role_label_in
+ and ug.org_id = org_id_in
+ and ugt.id = ug.group_type;
+
+ type ents_v is varray(10) of rhnOrgEntitlementType.label%TYPE;
+ ents_to_process ents_v;
+ cursor ents(ent_label_in in varchar2) is
+ select label, id
+ from rhnOrgEntitlementType
+ where label = ent_label_in;
+ cursor org_ents(ent_label_in in varchar2) is
+ select 1
+ from rhnOrgEntitlements oe,
+ rhnOrgEntitlementType oet
+ where oet.label = ent_label_in
+ and oe.org_id = org_id_in
+ and oet.id = oe.entitlement_id;
+ create_row char(1);
+ begin
+ ents_to_process := ents_v();
+ roles_to_process := roles_v();
+ -- a bit kludgy, but only for 3.4 really. Certainly no
+ -- worse than the old code...
+ if service_label_in = 'enterprise' or
service_label_in = 'management' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'org_admin';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'system_group_admin';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'activation_key_admin';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'org_applicant';
- elsif service_label_in = 'provisioning' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'rhn_provisioning';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'system_group_admin';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'activation_key_admin';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'config_admin';
- -- another nasty special case...
- if enable_in = 'Y' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
- end if;
- elsif service_label_in = 'monitoring' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'rhn_monitor';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'monitoring_admin';
- elsif service_label_in = 'virtualization' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'rhn_virtualization';
-
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'config_admin';
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'org_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'system_group_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'activation_key_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'org_applicant';
+ elsif service_label_in = 'provisioning' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_provisioning';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'system_group_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'activation_key_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ -- another nasty special case...
+ if enable_in = 'Y' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
+ end if;
+ elsif service_label_in = 'monitoring' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_monitor';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'monitoring_admin';
+ elsif service_label_in = 'virtualization' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_virtualization';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
elsif service_label_in = 'virtualization_platform' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'rhn_virtualization_platform';
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'config_admin';
- elsif service_label_in = 'nonlinux' then
- ents_to_process.extend;
- ents_to_process(ents_to_process.count) := 'rhn_nonlinux';
- roles_to_process.extend;
- roles_to_process(roles_to_process.count) := 'config_admin';
- end if;
-
- if enable_in = 'Y' then
- for i in 1..ents_to_process.count loop
- for ent in ents(ents_to_process(i)) loop
- create_row := 'Y';
- for oe in org_ents(ent.label) loop
- create_row := 'N';
- end loop;
- if create_row = 'Y' then
- insert into rhnOrgEntitlements(org_id, entitlement_id)
- values (org_id_in, ent.id);
- end if;
- end loop;
- end loop;
- for i in 1..roles_to_process.count loop
- for role in roles(roles_to_process(i)) loop
- create_row := 'Y';
- for o_r in org_roles(role.label) loop
- create_row := 'N';
- end loop;
- if create_row = 'Y' then
- insert into rhnUserGroup(
- id, name, description, current_members,
- group_type, org_id
- ) (
- select rhn_user_group_id_seq.nextval,
- ugt.name || 's',
- ugt.name || 's for Org ' ||
- o.name || ' ('|| o.id ||')',
- 0, ugt.id, o.id
- from rhnUserGroupType ugt,
- web_customer o
- where o.id = org_id_in
- and ugt.id = role.id
- );
- end if;
- end loop;
- end loop;
- else
- for i in 1..ents_to_process.count loop
- for ent in ents(ents_to_process(i)) loop
- delete from rhnOrgEntitlements
- where org_id = org_id_in
- and entitlement_id = ent.id;
- end loop;
- end loop;
- end if;
- end modify_org_service;
-
- procedure set_customer_enterprise (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'enterprise', 'Y');
- end set_customer_enterprise;
-
- procedure set_customer_provisioning (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'provisioning', 'Y');
- end set_customer_provisioning;
-
- procedure set_customer_monitoring (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'monitoring', 'Y');
- end set_customer_monitoring;
-
- procedure set_customer_nonlinux (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'nonlinux', 'Y');
- end set_customer_nonlinux;
-
- procedure unset_customer_enterprise (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'enterprise', 'N');
- end unset_customer_enterprise;
-
- procedure unset_customer_provisioning (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'provisioning', 'N');
- end unset_customer_provisioning;
-
- procedure unset_customer_monitoring (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'monitoring', 'N');
- end unset_customer_monitoring;
-
- procedure unset_customer_nonlinux (
- customer_id_in in number
- ) is
- begin
- modify_org_service(customer_id_in, 'nonlinux', 'N');
- end unset_customer_nonlinux;
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) :=
'rhn_virtualization_platform';
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ elsif service_label_in = 'nonlinux' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_nonlinux';
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ end if;
+
+ if enable_in = 'Y' then
+ for i in 1..ents_to_process.count loop
+ for ent in ents(ents_to_process(i)) loop
+ create_row := 'Y';
+ for oe in org_ents(ent.label) loop
+ create_row := 'N';
+ end loop;
+ if create_row = 'Y' then
+ insert into rhnOrgEntitlements(org_id, entitlement_id)
+ values (org_id_in, ent.id);
+ end if;
+ end loop;
+ end loop;
+ for i in 1..roles_to_process.count loop
+ for role in roles(roles_to_process(i)) loop
+ create_row := 'Y';
+ for o_r in org_roles(role.label) loop
+ create_row := 'N';
+ end loop;
+ if create_row = 'Y' then
+ insert into rhnUserGroup(
+ id, name, description, current_members,
+ group_type, org_id
+ ) (
+ select rhn_user_group_id_seq.nextval,
+ ugt.name || 's',
+ ugt.name || 's for Org ' ||
+ o.name || ' ('|| o.id ||')',
+ 0, ugt.id, o.id
+ from rhnUserGroupType ugt,
+ web_customer o
+ where o.id = org_id_in
+ and ugt.id = role.id
+ );
+ end if;
+ end loop;
+ end loop;
+ else
+ for i in 1..ents_to_process.count loop
+ for ent in ents(ents_to_process(i)) loop
+ delete from rhnOrgEntitlements
+ where org_id = org_id_in
+ and entitlement_id = ent.id;
+ end loop;
+ end loop;
+ end if;
+ end modify_org_service;
+
+ procedure set_customer_enterprise (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'enterprise', 'Y');
+ end set_customer_enterprise;
+
+ procedure set_customer_provisioning (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'provisioning', 'Y');
+ end set_customer_provisioning;
+
+ procedure set_customer_monitoring (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'monitoring', 'Y');
+ end set_customer_monitoring;
+
+ procedure set_customer_nonlinux (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'nonlinux', 'Y');
+ end set_customer_nonlinux;
+
+ procedure unset_customer_enterprise (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'enterprise', 'N');
+ end unset_customer_enterprise;
+
+ procedure unset_customer_provisioning (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'provisioning', 'N');
+ end unset_customer_provisioning;
+
+ procedure unset_customer_monitoring (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'monitoring', 'N');
+ end unset_customer_monitoring;
+
+ procedure unset_customer_nonlinux (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'nonlinux', 'N');
+ end unset_customer_nonlinux;
-- *******************************************************************
-- PROCEDURE: prune_group
@@ -925,37 +925,37 @@ is
-- limit.
-- Called by: set_group_count, prune_everything, repoll_virt_guest_entitlements
-- *******************************************************************
- procedure prune_group (
- group_id_in in number,
- type_in in char,
- quantity_in in number,
+ procedure prune_group (
+ group_id_in in number,
+ type_in in char,
+ quantity_in in number,
update_family_countsYN in number := 1
- ) is
- cursor usergroups is
- select user_id, user_group_id, ugt.label
- from rhnUserGroupType ugt,
- rhnUserGroup ug,
- rhnUserGroupMembers ugm
- where 1=1
- and ugm.user_group_id = group_id_in
- and ugm.user_id in (
- select user_id
- from (
- select rownum row_number,
- user_id,
- time
- from (
- select user_id,
- modified time
- from rhnUserGroupMembers
- where user_group_id = group_id_in
- order by time asc
- )
- )
- where row_number > quantity_in
- )
- and ugm.user_group_id = ug.id
- and ug.group_type = ugt.id;
+ ) is
+ cursor usergroups is
+ select user_id, user_group_id, ugt.label
+ from rhnUserGroupType ugt,
+ rhnUserGroup ug,
+ rhnUserGroupMembers ugm
+ where 1=1
+ and ugm.user_group_id = group_id_in
+ and ugm.user_id in (
+ select user_id
+ from (
+ select rownum row_number,
+ user_id,
+ time
+ from (
+ select user_id,
+ modified time
+ from rhnUserGroupMembers
+ where user_group_id = group_id_in
+ order by time asc
+ )
+ )
+ where row_number > quantity_in
+ )
+ and ugm.user_group_id = ug.id
+ and ug.group_type = ugt.id;
cursor servergroups is
select server_id, server_group_id, sgt.id as group_type_id, sgt.label
from rhnServerGroupType sgt,
@@ -984,22 +984,22 @@ is
and sgm.server_group_id = sg.id
and sg.group_type = sgt.id;
type_is_base char;
- begin
- if type_in = 'U' then
- update rhnUserGroup
- set max_members = quantity_in
- where id = group_id_in;
-
- for ug in usergroups loop
- rhn_user.remove_from_usergroup(ug.user_id, ug.user_group_id);
- end loop;
- elsif type_in = 'S' then
- update rhnServerGroup
- set max_members = quantity_in
- where id = group_id_in;
-
- for sg in servergroups loop
- remove_server_entitlement(sg.server_id, sg.label);
+ begin
+ if type_in = 'U' then
+ update rhnUserGroup
+ set max_members = quantity_in
+ where id = group_id_in;
+
+ for ug in usergroups loop
+ rhn_user.remove_from_usergroup(ug.user_id, ug.user_group_id);
+ end loop;
+ elsif type_in = 'S' then
+ update rhnServerGroup
+ set max_members = quantity_in
+ where id = group_id_in;
+
+ for sg in servergroups loop
+ remove_server_entitlement(sg.server_id, sg.label);
select is_base
into type_is_base
@@ -1009,13 +1009,13 @@ is
-- if we're removing a base ent, then be sure to
-- remove the server's channel subscriptions.
if ( type_is_base = 'Y' ) then
- rhn_channel.clear_subscriptions(sg.server_id,
+ rhn_channel.clear_subscriptions(sg.server_id,
update_family_countsYN =>
update_family_countsYN);
end if;
- end loop;
- end if;
- end prune_group;
+ end loop;
+ end if;
+ end prune_group;
-- *******************************************************************
-- PROCEDURE: assign_system_entitlement
@@ -1034,9 +1034,9 @@ is
)
is
prev_ent_count number;
- to_org_prev_ent_count number;
+ to_org_prev_ent_count number;
new_ent_count number;
- new_quantity number;
+ new_quantity number;
group_type number;
begin
@@ -1066,7 +1066,7 @@ is
when NO_DATA_FOUND then
to_org_prev_ent_count := 0;
end;
-
+
begin
select id
into group_type
@@ -1079,11 +1079,11 @@ is
end;
new_ent_count := prev_ent_count - quantity_in;
-
+
if prev_ent_count > new_ent_count then
new_quantity := to_org_prev_ent_count + quantity_in;
end if;
-
+
if new_ent_count < 0 then
rhn_exception.raise_exception(
'not_enough_entitlements_in_base_org');
@@ -1145,8 +1145,8 @@ is
is
prev_ent_count number;
new_ent_count number;
- to_org_prev_ent_count number;
- new_quantity number;
+ to_org_prev_ent_count number;
+ new_quantity number;
cfam_id number;
begin
@@ -1163,7 +1163,7 @@ is
rhn_exception.raise_exception(
'not_enough_entitlements_in_base_org');
end;
-
+
begin
select max_members
into to_org_prev_ent_count
@@ -1176,7 +1176,7 @@ is
when NO_DATA_FOUND then
to_org_prev_ent_count := 0;
end;
-
+
begin
select id
@@ -1190,11 +1190,11 @@ is
end;
new_ent_count := prev_ent_count - quantity_in;
-
- if prev_ent_count > new_ent_count then
+
+ if prev_ent_count > new_ent_count then
new_quantity := to_org_prev_ent_count + quantity_in;
- end if;
-
+ end if;
+
if new_ent_count < 0 then
rhn_exception.raise_exception(
@@ -1368,69 +1368,69 @@ is
end activate_channel_entitlement;
- procedure set_group_count (
- customer_id_in in number,
- type_in in char,
- group_type_in in number,
- quantity_in in number,
+ procedure set_group_count (
+ customer_id_in in number,
+ type_in in char,
+ group_type_in in number,
+ quantity_in in number,
update_family_countsYN in number := 1
- ) is
- group_id number;
- quantity number;
- begin
- quantity := quantity_in;
- if quantity is not null and quantity < 0 then
- quantity := 0;
- end if;
-
- if type_in = 'U' then
- select rug.id
- into group_id
- from rhnUserGroup rug
- where 1=1
- and rug.org_id = customer_id_in
- and rug.group_type = group_type_in;
- elsif type_in = 'S' then
- select rsg.id
- into group_id
- from rhnServerGroup rsg
- where 1=1
- and rsg.org_id = customer_id_in
- and rsg.group_type = group_type_in;
- end if;
-
- rhn_entitlements.prune_group(
- group_id,
- type_in,
- quantity,
+ ) is
+ group_id number;
+ quantity number;
+ begin
+ quantity := quantity_in;
+ if quantity is not null and quantity < 0 then
+ quantity := 0;
+ end if;
+
+ if type_in = 'U' then
+ select rug.id
+ into group_id
+ from rhnUserGroup rug
+ where 1=1
+ and rug.org_id = customer_id_in
+ and rug.group_type = group_type_in;
+ elsif type_in = 'S' then
+ select rsg.id
+ into group_id
+ from rhnServerGroup rsg
+ where 1=1
+ and rsg.org_id = customer_id_in
+ and rsg.group_type = group_type_in;
+ end if;
+
+ rhn_entitlements.prune_group(
+ group_id,
+ type_in,
+ quantity,
update_family_countsYN
- );
- exception
- when no_data_found then
- if type_in = 'U' then
- insert into rhnUserGroup (
- id, name, description, max_members, current_members,
- group_type, org_id, created, modified
- ) (
- select rhn_user_group_id_seq.nextval, name, name,
- quantity, 0, id, customer_id_in,
- sysdate, sysdate
- from rhnUserGroupType
- where id = group_type_in
- );
- elsif type_in = 'S' then
- insert into rhnServerGroup (
- id, name, description, max_members, current_members,
- group_type, org_id, created, modified
- ) (
- select rhn_server_group_id_seq.nextval, name, name,
- quantity, 0, id, customer_id_in,
- sysdate, sysdate
- from rhnServerGroupType
- where id = group_type_in
- );
- end if;
- end set_group_count;
+ );
+ exception
+ when no_data_found then
+ if type_in = 'U' then
+ insert into rhnUserGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id, created, modified
+ ) (
+ select rhn_user_group_id_seq.nextval, name, name,
+ quantity, 0, id, customer_id_in,
+ sysdate, sysdate
+ from rhnUserGroupType
+ where id = group_type_in
+ );
+ elsif type_in = 'S' then
+ insert into rhnServerGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id, created, modified
+ ) (
+ select rhn_server_group_id_seq.nextval, name, name,
+ quantity, 0, id, customer_id_in,
+ sysdate, sysdate
+ from rhnServerGroupType
+ where id = group_type_in
+ );
+ end if;
+ end set_group_count;
-- *******************************************************************
-- PROCEDURE: prune_family
@@ -1438,38 +1438,39 @@ is
-- that are over the org's limit.
-- Called by: set_family_count, prune_everything
-- *******************************************************************
- procedure prune_family (
- customer_id_in in number,
- channel_family_id_in in number,
- quantity_in in number
- ) is
- cursor serverchannels is
- select sc.server_id,
- sc.channel_id
- from rhnServerChannel sc,
- rhnChannelFamilyMembers cfm
- where 1=1
- and cfm.channel_family_id = channel_family_id_in
- and cfm.channel_id = sc.channel_id
- and server_id in (
- select server_id
- from (
- select server_id,
- time,
- rownum row_number
- from (
- select rs.id server_id,
- rcfm.modified time
- from
- rhnServerChannel rsc,
- rhnChannelFamilyMembers rcfm,
- rhnServer rs
- where 1=1
- and rs.org_id = customer_id_in
- and rs.id = rsc.server_id
- and rsc.channel_id = rcfm.channel_id
- and rcfm.channel_family_id =
- channel_family_id_in
+ procedure prune_family (
+ customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number,
+ flex_in in number
+ ) is
+ cursor serverchannels is
+ select sc.server_id,
+ sc.channel_id
+ from rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm
+ where 1=1
+ and cfm.channel_family_id = channel_family_id_in
+ and cfm.channel_id = sc.channel_id
+ and server_id in (
+ select server_id
+ from (
+ select server_id,
+ time,
+ rownum row_number
+ from (
+ select rs.id server_id,
+ rcfm.modified time
+ from
+ rhnServerChannel rsc,
+ rhnChannelFamilyMembers rcfm,
+ rhnServer rs
+ where 1=1
+ and rs.org_id = customer_id_in
+ and rs.id = rsc.server_id
+ and rsc.channel_id = rcfm.channel_id
+ and rcfm.channel_family_id =
+ channel_family_id_in
-- we only want to grab servers consuming
-- physical slots.
and exists (
@@ -1479,238 +1480,238 @@ is
and cfsp.channel_family_id =
channel_family_id_in
)
- order by time asc
- )
- )
- where row_number > quantity_in
- );
- begin
- -- if we get a null customer_id, this is completely bogus.
- if customer_id_in is null then
- return;
- end if;
-
- update rhnPrivateChannelFamily
- set max_members = quantity_in
- where 1=1
- and org_id = customer_id_in
- and channel_family_id = channel_family_id_in;
-
- for sc in serverchannels loop
- rhn_channel.unsubscribe_server(sc.server_id, sc.channel_id, 1, 1,
+ order by time asc
+ )
+ )
+ where row_number > quantity_in
+ );
+ begin
+ -- if we get a null customer_id, this is completely bogus.
+ if customer_id_in is null then
+ return;
+ end if;
+
+ update rhnPrivateChannelFamily
+ set max_members = quantity_in
+ where 1=1
+ and org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+
+ for sc in serverchannels loop
+ rhn_channel.unsubscribe_server(sc.server_id, sc.channel_id, 1, 1,
update_family_countsYN => 0);
- end loop;
+ end loop;
rhn_channel.update_family_counts(channel_family_id_in, customer_id_in);
- end prune_family;
-
- procedure set_family_count (
- customer_id_in in number,
- channel_family_id_in in number,
- quantity_in in number
- ) is
- cursor privperms is
- select 1
- from rhnPrivateChannelFamily
- where org_id = customer_id_in
- and channel_family_id = channel_family_id_in;
- cursor pubperms is
- select o.id org_id
- from web_customer o,
- rhnPublicChannelFamily pcf
- where pcf.channel_family_id = channel_family_id_in;
- quantity number;
- done number := 0;
- begin
- quantity := quantity_in;
- if quantity is not null and quantity < 0 then
- quantity := 0;
- end if;
-
- if customer_id_in is not null then
- for perm in privperms loop
- rhn_entitlements.prune_family(
- customer_id_in,
- channel_family_id_in,
- quantity
- );
- update rhnPrivateChannelFamily
- set max_members = quantity
- where org_id = customer_id_in
- and channel_family_id = channel_family_id_in;
- return;
- end loop;
-
- insert into rhnPrivateChannelFamily (
- channel_family_id, org_id, max_members, current_members
- ) values (
- channel_family_id_in, customer_id_in, quantity, 0
- );
- return;
- end if;
-
- for perm in pubperms loop
- if quantity = 0 then
- rhn_entitlements.prune_family(
- perm.org_id,
- channel_family_id_in,
- quantity
- );
- if done = 0 then
- delete from rhnPublicChannelFamily
- where channel_family_id = channel_family_id_in;
- end if;
- end if;
- done := 1;
- end loop;
- -- if done's not 1, then we don't have any entitlements
- if done != 1 then
- insert into rhnPublicChannelFamily (
- channel_family_id
- ) values (
- channel_family_id_in
- );
- end if;
- end set_family_count;
-
- -- this expects quantity_in to be the number of available slots, not the
- -- max_members of the server group. If you give it too many, it'll fail
- -- and raise servergroup_max_members.
- -- We should NEVER run this unless we're SURE that we won't
- -- be violating the max.
- procedure entitle_last_modified_servers (
- customer_id_in in number,
- type_label_in in varchar2,
- quantity_in in number
- ) is
- -- find the servers that aren't currently in slots
- cursor servers(cid_in in number, quant_in in number) is
- select server_id
- from (
- select rownum row_number,
- server_id
- from (
- select rs.id server_iD
- from rhnServer rs
- where 1=1
- and rs.org_id = cid_in
- and not exists (
- select 1
- from rhnServerGroup sg,
- rhnServerGroupMembers rsgm
- where rsgm.server_id = rs.id
- and rsgm.server_group_id = sg.id
- and sg.group_type is not null
- )
+ end prune_family;
+
+ procedure set_family_count (
+ customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number
+ ) is
+ cursor privperms is
+ select 1
+ from rhnPrivateChannelFamily
+ where org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+ cursor pubperms is
+ select o.id org_id
+ from web_customer o,
+ rhnPublicChannelFamily pcf
+ where pcf.channel_family_id = channel_family_id_in;
+ quantity number;
+ done number := 0;
+ begin
+ quantity := quantity_in;
+ if quantity is not null and quantity < 0 then
+ quantity := 0;
+ end if;
+
+ if customer_id_in is not null then
+ for perm in privperms loop
+ rhn_entitlements.prune_family(
+ customer_id_in,
+ channel_family_id_in,
+ quantity
+ );
+ update rhnPrivateChannelFamily
+ set max_members = quantity
+ where org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+ return;
+ end loop;
+
+ insert into rhnPrivateChannelFamily (
+ channel_family_id, org_id, max_members, current_members
+ ) values (
+ channel_family_id_in, customer_id_in, quantity, 0
+ );
+ return;
+ end if;
+
+ for perm in pubperms loop
+ if quantity = 0 then
+ rhn_entitlements.prune_family(
+ perm.org_id,
+ channel_family_id_in,
+ quantity
+ );
+ if done = 0 then
+ delete from rhnPublicChannelFamily
+ where channel_family_id = channel_family_id_in;
+ end if;
+ end if;
+ done := 1;
+ end loop;
+ -- if done's not 1, then we don't have any entitlements
+ if done != 1 then
+ insert into rhnPublicChannelFamily (
+ channel_family_id
+ ) values (
+ channel_family_id_in
+ );
+ end if;
+ end set_family_count;
+
+ -- this expects quantity_in to be the number of available slots, not the
+ -- max_members of the server group. If you give it too many, it'll fail
+ -- and raise servergroup_max_members.
+ -- We should NEVER run this unless we're SURE that we won't
+ -- be violating the max.
+ procedure entitle_last_modified_servers (
+ customer_id_in in number,
+ type_label_in in varchar2,
+ quantity_in in number
+ ) is
+ -- find the servers that aren't currently in slots
+ cursor servers(cid_in in number, quant_in in number) is
+ select server_id
+ from (
+ select rownum row_number,
+ server_id
+ from (
+ select rs.id server_iD
+ from rhnServer rs
+ where 1=1
+ and rs.org_id = cid_in
+ and not exists (
+ select 1
+ from rhnServerGroup sg,
+ rhnServerGroupMembers rsgm
+ where rsgm.server_id = rs.id
+ and rsgm.server_group_id = sg.id
+ and sg.group_type is not null
+ )
and not exists (
select 1
from rhnVirtualInstance vi
where vi.virtual_system_id =
rs.id
)
order by modified desc
- )
- )
- where row_number <= quant_in;
- begin
- for server in servers(customer_id_in, quantity_in) loop
- rhn_entitlements.entitle_server(server.server_id, type_label_in);
- end loop;
- end entitle_last_modified_servers;
-
- procedure prune_everything (
- customer_id_in in number
- ) is
- cursor everything is
- -- all our server groups
- select sg.id id,
- 'S' type,
- sg.max_members quantity
- from rhnServerGroup sg
- where sg.org_id = customer_id_in
- union
- -- all our user groups
- select ug.id id,
- 'U' type,
- ug.max_members quantity
- from rhnUserGroup ug
- where ug.org_id = customer_id_in
- union (
- -- all the channel families we have perms to
- select cfp.channel_family_id id,
- 'C' type,
- cfp.max_members quantity
- from rhnOrgChannelFamilyPermissions cfp
- where cfp.org_id = customer_id_in
- union
- -- plus all the ones we're using that we have no perms for
- select cfm.channel_family_id id,
- 'C' type,
- 0 quantity
- from rhnChannelFamily cf,
- rhnChannelFamilyMembers cfm,
- rhnServerChannel sc,
- rhnServer s
- where s.org_id = customer_id_in
- and s.id = sc.server_id
- and sc.channel_id = cfm.channel_id
- and cfm.channel_family_id = cf.id
- and cf.org_id is not null
- and cf.org_id != customer_id_in
- and not exists (
- select 1
- from rhnOrgChannelFamilyPermissions cfp
- where cfp.org_id = customer_id_in
- and cfp.channel_family_id = cfm.channel_family_id
- )
- );
- begin
- for one in everything loop
- if one.type in ('U','S') then
- prune_group(one.id, one.type, one.quantity);
- else
- prune_family(customer_id_in, one.id, one.quantity);
- end if;
- end loop;
- end prune_everything;
-
- procedure subscribe_newest_servers (
- customer_id_in in number
- ) is
- -- find servers without base channels
- cursor servers(cid_in in number) is
- select s.id
- from rhnServer s
- where 1=1
- and s.org_id = cid_in
- and not exists (
- select 1
- from rhnChannel c,
- rhnServerChannel sc
- where sc.server_id = s.id
- and sc.channel_id = c.id
- and c.parent_channel is null
- )
+ )
+ )
+ where row_number <= quant_in;
+ begin
+ for server in servers(customer_id_in, quantity_in) loop
+ rhn_entitlements.entitle_server(server.server_id, type_label_in);
+ end loop;
+ end entitle_last_modified_servers;
+
+ procedure prune_everything (
+ customer_id_in in number
+ ) is
+ cursor everything is
+ -- all our server groups
+ select sg.id id,
+ 'S' type,
+ sg.max_members quantity
+ from rhnServerGroup sg
+ where sg.org_id = customer_id_in
+ union
+ -- all our user groups
+ select ug.id id,
+ 'U' type,
+ ug.max_members quantity
+ from rhnUserGroup ug
+ where ug.org_id = customer_id_in
+ union (
+ -- all the channel families we have perms to
+ select cfp.channel_family_id id,
+ 'C' type,
+ cfp.max_members quantity
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = customer_id_in
+ union
+ -- plus all the ones we're using that we have no perms for
+ select cfm.channel_family_id id,
+ 'C' type,
+ 0 quantity
+ from rhnChannelFamily cf,
+ rhnChannelFamilyMembers cfm,
+ rhnServerChannel sc,
+ rhnServer s
+ where s.org_id = customer_id_in
+ and s.id = sc.server_id
+ and sc.channel_id = cfm.channel_id
+ and cfm.channel_family_id = cf.id
+ and cf.org_id is not null
+ and cf.org_id != customer_id_in
+ and not exists (
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = customer_id_in
+ and cfp.channel_family_id = cfm.channel_family_id
+ )
+ );
+ begin
+ for one in everything loop
+ if one.type in ('U','S') then
+ prune_group(one.id, one.type, one.quantity);
+ else
+ prune_family(customer_id_in, one.id, one.quantity);
+ end if;
+ end loop;
+ end prune_everything;
+
+ procedure subscribe_newest_servers (
+ customer_id_in in number
+ ) is
+ -- find servers without base channels
+ cursor servers(cid_in in number) is
+ select s.id
+ from rhnServer s
+ where 1=1
+ and s.org_id = cid_in
+ and not exists (
+ select 1
+ from rhnChannel c,
+ rhnServerChannel sc
+ where sc.server_id = s.id
+ and sc.channel_id = c.id
+ and c.parent_channel is null
+ )
and not exists (
select 1
from rhnVirtualInstance vi
where vi.virtual_system_id = s.id
)
- order by s.modified desc;
- channel_id number;
- begin
- for server in servers(customer_id_in) loop
- channel_id := rhn_channel.guess_server_base(server.id);
- if channel_id is not null then
- begin
- rhn_channel.subscribe_server(server.id, channel_id);
- commit;
- -- exception is really channel_family_no_subscriptions
- exception
- when others then
- null;
- end;
- end if;
- end loop;
- end subscribe_newest_servers;
+ order by s.modified desc;
+ channel_id number;
+ begin
+ for server in servers(customer_id_in) loop
+ channel_id := rhn_channel.guess_server_base(server.id);
+ if channel_id is not null then
+ begin
+ rhn_channel.subscribe_server(server.id, channel_id);
+ commit;
+ -- exception is really channel_family_no_subscriptions
+ exception
+ when others then
+ null;
+ end;
+ end if;
+ end loop;
+ end subscribe_newest_servers;
end rhn_entitlements;
/
show errors
commit c1c15d108a7dd2b7f16e53af5f5824aa1941741b
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Fri Jun 4 15:43:05 2010 -0400
having setters do the right thing
diff --git a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
index c2e9bee..1689603 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
@@ -51,7 +51,7 @@ public class PrivateChannelFamily implements Serializable {
* @param maxFlexIn the max flex
*/
public void setMaxFlex(Long maxFlexIn) {
- this.maxFlex = maxFlex;
+ this.maxFlex = maxFlexIn;
}
/**
@@ -67,7 +67,7 @@ public class PrivateChannelFamily implements Serializable {
* @param currentFlexIn the current flex to set
*/
public void setCurrentFlex(Long currentFlexIn) {
- this.currentFlex = currentFlex;
+ this.currentFlex = currentFlexIn;
}
/**
commit 74e906730b83464af5ec49322e2aa7d18713ede0
Author: Partha Aji <paji(a)redhat.com>
Date: Fri Jun 4 18:04:04 2010 -0400
Updated some views using hosted changes
diff --git a/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
b/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
index c4e3a10..7e5a112 100644
--- a/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
+++ b/schema/spacewalk/common/data/rhnVirtualInstanceType.sql
@@ -21,3 +21,6 @@ insert into rhnVirtualInstanceType (id, name, label)
insert into rhnVirtualInstanceType (id, name, label)
values (rhn_vit_id_seq.nextval, 'Para-Virtualized',
'para_virtualized');
+insert into rhnVirtualInstanceType (id, name, label)
+ values (rhn_vit_id_seq.nextval, 'KVM/QEMU', 'qemu');
+
diff --git a/schema/spacewalk/common/views/rhnChannelFamilyOverview.sql
b/schema/spacewalk/common/views/rhnChannelFamilyOverview.sql
index 0616a62..6ef6d64 100644
--- a/schema/spacewalk/common/views/rhnChannelFamilyOverview.sql
+++ b/schema/spacewalk/common/views/rhnChannelFamilyOverview.sql
@@ -31,6 +31,8 @@ select pcf.org_id as org_id,
f.label as label,
coalesce(pcf.current_members,0) as current_members,
pcf.max_members as max_members,
+ coalesce(pcf.fve_current_members,0) as fve_current_members,
+ pcf.fve_max_members as fve_max_members,
1 as has_subscription
from rhnChannelFamily f,
rhnPrivateChannelFamily pcf
diff --git a/schema/spacewalk/common/views/rhnChannelFamilyServerPhysical.sql
b/schema/spacewalk/common/views/rhnChannelFamilyServerPhysical.sql
index 9d03b94..780333d 100644
--- a/schema/spacewalk/common/views/rhnChannelFamilyServerPhysical.sql
+++ b/schema/spacewalk/common/views/rhnChannelFamilyServerPhysical.sql
@@ -28,6 +28,7 @@ create or replace view rhnChannelFamilyServerPhysical as
where
rcfm.channel_id = rsc.channel_id
and rsc.server_id = rs.id
+ and rsc.is_fve = 'N'
and not exists (
select 1
from
diff --git a/schema/spacewalk/common/views/rhnChannelFamilyServerVirtual.sql
b/schema/spacewalk/common/views/rhnChannelFamilyServerVirtual.sql
index 4e688cc..d62fc41 100644
--- a/schema/spacewalk/common/views/rhnChannelFamilyServerVirtual.sql
+++ b/schema/spacewalk/common/views/rhnChannelFamilyServerVirtual.sql
@@ -30,6 +30,7 @@ create or replace view rhnChannelFamilyServerVirtual as
rcfm.channel_id = rsc.channel_id
and rcfm.channel_family_id = rcf.id
and rsc.server_id = rs.id
+ and rsc.is_fve = 'N'
and exists (
select 1
from
diff --git a/schema/spacewalk/common/views/rhnOrgChannelFamilyPermissions.sql
b/schema/spacewalk/common/views/rhnOrgChannelFamilyPermissions.sql
new file mode 100644
index 0000000..5abf81a
--- /dev/null
+++ b/schema/spacewalk/common/views/rhnOrgChannelFamilyPermissions.sql
@@ -0,0 +1,40 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace view rhnOrgChannelFamilyPermissions as
+ select pcf.channel_family_id,
+ u.org_id as org_id,
+ to_number(null, null) as max_members,
+ 0 as current_members,
+ to_number(null, null) as fve_max_members,
+ 0 as fve_current_members,
+ pcf.created,
+ pcf.modified
+ from rhnPublicChannelFamily pcf,
+ web_contact u
+ union
+ select channel_family_id,
+ org_id,
+ max_members,
+ current_members,
+ fve_max_members,
+ fve_current_members,
+ created,
+ modified
+ from rhnPrivateChannelFamily;
+
diff --git a/schema/spacewalk/oracle/views/rhnOrgChannelFamilyPermissions.sql
b/schema/spacewalk/oracle/views/rhnOrgChannelFamilyPermissions.sql
deleted file mode 100644
index 696bca9..0000000
--- a/schema/spacewalk/oracle/views/rhnOrgChannelFamilyPermissions.sql
+++ /dev/null
@@ -1,46 +0,0 @@
---
--- Copyright (c) 2008 Red Hat, Inc.
---
--- This software is licensed to you under the GNU General Public License,
--- version 2 (GPLv2). There is NO WARRANTY for this software, express or
--- implied, including the implied warranties of MERCHANTABILITY or FITNESS
--- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
--- along with this software; if not, see
---
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
---
--- Red Hat trademarks are not licensed under GPLv2. No permission is
--- granted to use or replicate Red Hat trademarks that are incorporated
--- in this software or its documentation.
---
---
---
---
-
-create or replace view rhnOrgChannelFamilyPermissions as
- select pcf.channel_family_id,
- u.org_id org_id,
- to_number(null) max_members,
- 0 current_members,
- pcf.created,
- pcf.modified
- from rhnPublicChannelFamily pcf,
- web_contact u
- union
- select channel_family_id,
- org_id,
- max_members,
- current_members,
- created,
- modified
- from rhnPrivateChannelFamily;
-
---
---
--- Revision 1.2 2004/04/16 16:07:12 pjones
--- bugzilla: none -- 8.1.7 won't let you use "null foo" as a column in a
view
--- that gets unioned with a typed column. you have to use "to_number(null)
foo". What a load of crap.
---
--- Revision 1.1 2004/04/14 00:09:24 pjones
--- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
--- a frequent full table scan
---
diff --git a/schema/spacewalk/postgres/views/rhnOrgChannelFamilyPermissions.sql
b/schema/spacewalk/postgres/views/rhnOrgChannelFamilyPermissions.sql
deleted file mode 100644
index 0fdf85f..0000000
--- a/schema/spacewalk/postgres/views/rhnOrgChannelFamilyPermissions.sql
+++ /dev/null
@@ -1,36 +0,0 @@
---
--- Copyright (c) 2008 Red Hat, Inc.
---
--- This software is licensed to you under the GNU General Public License,
--- version 2 (GPLv2). There is NO WARRANTY for this software, express or
--- implied, including the implied warranties of MERCHANTABILITY or FITNESS
--- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
--- along with this software; if not, see
---
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
---
--- Red Hat trademarks are not licensed under GPLv2. No permission is
--- granted to use or replicate Red Hat trademarks that are incorporated
--- in this software or its documentation.
---
---
---
---
-
-create or replace view rhnOrgChannelFamilyPermissions as
- select pcf.channel_family_id,
- u.org_id as org_id,
- to_number(null, null) as max_members,
- 0 as current_members,
- pcf.created,
- pcf.modified
- from rhnPublicChannelFamily pcf,
- web_contact u
- union
- select channel_family_id,
- org_id,
- max_members,
- current_members,
- created,
- modified
- from rhnPrivateChannelFamily;
-
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/005-rhnVirtualInstanceType.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/005-rhnVirtualInstanceType.sql
new file mode 100644
index 0000000..196a990
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/005-rhnVirtualInstanceType.sql
@@ -0,0 +1,2 @@
+
+INSERT INTO rhnVirtualInstanceType (ID, NAME, LABEL) values (rhn_vit_id_seq.nextval,
'KVM/QEMU', 'qemu');
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/006-rhnChannelFamilyOverview.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/006-rhnChannelFamilyOverview.sql
new file mode 100644
index 0000000..6ef6d64
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/006-rhnChannelFamilyOverview.sql
@@ -0,0 +1,40 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+-- semantics of this view are much different from what the old
+-- documentation said, and were before I rewrote it. The critical
+-- change was the "where exists" clause, which means we can never
+-- not have any permissions if we show up here.
+
+-- That makes it not so special any more.
+
+create or replace view rhnChannelFamilyOverview as
+select pcf.org_id as org_id,
+ f.id as id,
+ f.name as name,
+ f.product_url as url,
+ f.label as label,
+ coalesce(pcf.current_members,0) as current_members,
+ pcf.max_members as max_members,
+ coalesce(pcf.fve_current_members,0) as fve_current_members,
+ pcf.fve_max_members as fve_max_members,
+ 1 as has_subscription
+from rhnChannelFamily f,
+ rhnPrivateChannelFamily pcf
+where pcf.channel_family_id = f.id;
+
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/007-rhnOrgChannelFamilyPermissions.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/007-rhnOrgChannelFamilyPermissions.sql
new file mode 100644
index 0000000..467ec34
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/007-rhnOrgChannelFamilyPermissions.sql
@@ -0,0 +1,50 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace view rhnOrgChannelFamilyPermissions as
+ select pcf.channel_family_id,
+ u.org_id org_id,
+ to_number(null) max_members,
+ 0 current_members,
+ to_number(null) fve_max_members,
+ 0 fve_current_members,
+ pcf.created,
+ pcf.modified
+ from rhnPublicChannelFamily pcf,
+ web_contact u
+ union
+ select channel_family_id,
+ org_id,
+ max_members,
+ current_members,
+ fve_max_members,
+ fve_current_members,
+ created,
+ modified
+ from rhnPrivateChannelFamily;
+
+--
+--
+-- Revision 1.2 2004/04/16 16:07:12 pjones
+-- bugzilla: none -- 8.1.7 won't let you use "null foo" as a column in a
view
+-- that gets unioned with a typed column. you have to use "to_number(null)
foo". What a load of crap.
+--
+-- Revision 1.1 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/008-rhnChannelFamilyServerPhysical.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/008-rhnChannelFamilyServerPhysical.sql
new file mode 100644
index 0000000..780333d
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/008-rhnChannelFamilyServerPhysical.sql
@@ -0,0 +1,52 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+-- $Id: rhnChannelFamilyServers.sql 43207 2003-04-11 20:46:21Z cturner $
+--
+
+create or replace view rhnChannelFamilyServerPhysical as
+ select rs.org_id as customer_id,
+ rcfm.channel_family_id as channel_family_id,
+ rsc.server_id as server_id,
+ rsc.created as created,
+ rsc.modified as modified
+ from rhnChannelFamilyMembers rcfm,
+ rhnServerChannel rsc,
+ rhnServer rs
+ where
+ rcfm.channel_id = rsc.channel_id
+ and rsc.server_id = rs.id
+ and rsc.is_fve = 'N'
+ and not exists (
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnServerEntitlementView sev,
+ rhnVirtualInstance vi
+ where
+ -- system is a virtual instance
+ vi.virtual_system_id = rs.id
+ and vi.host_system_id = sev.server_id
+ -- system's host has a virt ent
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform')
+ and sev.server_group_type_id = sgtvsl.server_group_type_id
+ -- the host's virt ent grants a cf virt sub level
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ -- the cf is in that virt sub level
+ and cfvsl.channel_family_id = rcfm.channel_family_id
+ );
+
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/009-rhnChannelFamilyServerVirtual.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/009-rhnChannelFamilyServerVirtual.sql
new file mode 100644
index 0000000..d62fc41
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/009-rhnChannelFamilyServerVirtual.sql
@@ -0,0 +1,54 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+--
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+-- $Id: rhnChannelFamilyServers.sql 43207 2003-04-11 20:46:21Z cturner $
+--
+
+create or replace view rhnChannelFamilyServerVirtual as
+ select rs.org_id as customer_id,
+ rcfm.channel_family_id as channel_family_id,
+ rsc.server_id as server_id,
+ rsc.created as created,
+ rsc.modified as modified
+ from rhnChannelFamilyMembers rcfm,
+ rhnChannelFamily rcf,
+ rhnServerChannel rsc,
+ rhnServer rs
+ where
+ rcfm.channel_id = rsc.channel_id
+ and rcfm.channel_family_id = rcf.id
+ and rsc.server_id = rs.id
+ and rsc.is_fve = 'N'
+ and exists (
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnServerEntitlementView sev,
+ rhnVirtualInstance vi
+ where
+ -- system is a virtual instance
+ vi.virtual_system_id = rs.id
+ and vi.host_system_id = sev.server_id
+ -- system's host has a virt ent
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform')
+ and sev.server_group_type_id = sgtvsl.server_group_type_id
+ -- the host's virt ent grants a cf virt sub level
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ -- the cf is in that virt sub level
+ and cfvsl.channel_family_id = rcf.id
+ );
+
commit fb62a753c0b4aaf3376f11bdc071ff138b18a317
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 19:29:16 2010 -0400
few fixes for rhn cert activation, cert activation now works and populates max_members
correctly, but not populating fve_max_members yet
diff --git a/backend/satellite_tools/sync_handlers.py
b/backend/satellite_tools/sync_handlers.py
index 468f35a..aafb6af 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -603,9 +603,17 @@ def populate_channel_family_permissions(cert):
if quant is not None:
quant = int(quant)
flex = cf.flex
+ if flex == '':
+ flex = 0
if flex is not None:
flex = int(flex)
- cert_chfam_hash[cf.name] = (quant, flex)
+
+ if quant is not None:
+ quant = int(quant)
+
+ #we subtract flex from quantity since flex count is included
+ # in the full quantity for backwards compatibility
+ cert_chfam_hash[cf.name] = [quant - flex, flex]
# Generate the channel family permissions data structure
cfps = {}
@@ -617,16 +625,16 @@ def populate_channel_family_permissions(cert):
org_id = cfp['org_id']
# Initially populate cf info with old limits from db
- cfps[(cf_name, org_id)] = (cfp['max_members'], cfp['max_flex'])
- curr_cfps[(cf_name, org_id)] = (cfp['current_members'],
cfp['current_flex'])
+ cfps[(cf_name, org_id)] = [cfp['max_members'], cfp['max_flex']]
+ curr_cfps[(cf_name, org_id)] = [cfp['current_members'],
cfp['current_flex']]
# Now set max_members based on the cert's max_members
for cf_name, max_tuple in cert_chfam_hash.items():
# Make the channel families with null max_members public
- max_members, max_flex = max_tuple
- if max_members is None:
+ if max_tuple is None:
org_id = None
else:
+ max_members, max_flex = max_tuple
# default the org to 1 for channel families from cert
org_id = 1
@@ -639,7 +647,7 @@ def populate_channel_family_permissions(cert):
old_max_tuple = None
- if old_max_tuple and (max_members < old_max_tuple[0] or
+ if old_max_tuple and max_tuple and (max_members < old_max_tuple[0] or
max_flex < old_max_tuple[1]):
# The cert count is low, set the db with new values
cfps[(cf_name, org_id)] = max_tuple
@@ -674,12 +682,16 @@ def populate_channel_family_permissions(cert):
cfps[(cf_name, 1)][1] = max_flex - flex_purge_count
# Cleanup left out suborgs
- for (cf_name, org_id), (max_members, max_flex) in cfps.items():
+ for (cf_name, org_id), max_list in cfps.items():
if cfps.has_key((cf_name, 1)) and cfps[(cf_name, 1)] == None: #is None:
cfps[(cf_name, org_id)] = None
+
batch = []
- for (cf_name, org_id), (max_members, max_flex) in cfps.items():
+ for (cf_name, org_id), max_list in cfps.items():
+ if max_list is None:
+ continue
+ (max_members, max_flex) = max_list
cfperm = importLib.ChannelFamilyPermissions()
batch.append(cfperm.populate({
'channel_family' : cf_name,
@@ -729,7 +741,8 @@ def _fetch_existing_channel_families():
_query_fetch_channel_family_permissions = rhnSQL.Statement("""
select cf.label as channel_family, cfp.org_id,
- cfp.max_members, cfp.current_members, cfp.max_flex, cfp.current_flex,
+ cfp.max_members, cfp.current_members, cfp.fve_max_members as max_flex,
+ cfp.fve_current_members as current_flex,
cf.org_id as owner_org_id
from rhnChannelFamilyPermissions cfp, rhnChannelFamily cf
where cfp.channel_family_id = cf.id
diff --git a/backend/server/importlib/importLib.py
b/backend/server/importlib/importLib.py
index b439c06..2c188ff 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -156,6 +156,7 @@ class ChannelFamilyPermissions(Information):
'channel_family' : StringType,
'org_id' : IntType,
'max_members' : IntType,
+ 'max_flex' : IntType,
}
class DistChannelMap(Information):
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index 433072e..78d385e 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -1324,7 +1324,7 @@ is
end;
begin
- select pcf.current_flex
+ select pcf.fve_current_members
into prev_flex_count
from rhnChannelFamily cf,
rhnPrivateChannelFamily pcf
commit e257b4b9894079e2385f03bd6e0ac6f213969e84
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 19:27:45 2010 -0400
matching hosteds column names for flex guests
diff --git a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
index f4cf362..dea4c97 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
@@ -15,8 +15,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="maxMembers" column="MAX_MEMBERS"
type="long" />
<property name="currentMembers" column="CURRENT_MEMBERS"
not-null="true" type="long" />
- <property name="maxFlex" column="MAX_FLEX" type="long"
/>
- <property name="currentFlex" column="CURRENT_FLEX"
+ <property name="maxFlex" column="fve_max_members"
type="long" />
+ <property name="currentFlex" column="fve_current_members"
not-null="true" type="long" />
<property name="created" column="CREATED"
not-null="true"
type="timestamp" insert="false" update="false" />
diff --git a/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
b/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
index 8964b48..6ee3516 100644
--- a/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
+++ b/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
@@ -26,8 +26,9 @@ CREATE TABLE rhnPrivateChannelFamily
max_members NUMBER,
current_members NUMBER
DEFAULT (0) NOT NULL,
- max_flex NUMBER,
- current_flex NUMBER
+ fve_max_members NUMBER
+ DEFAULT (0),
+ fve_current_members NUMBER
DEFAULT (0) NOT NULL,
created DATE
DEFAULT (sysdate) NOT NULL,
diff --git a/schema/spacewalk/common/views/rhnChannelFamilyPermissions.sql
b/schema/spacewalk/common/views/rhnChannelFamilyPermissions.sql
index 3649289..071e0f0 100644
--- a/schema/spacewalk/common/views/rhnChannelFamilyPermissions.sql
+++ b/schema/spacewalk/common/views/rhnChannelFamilyPermissions.sql
@@ -21,6 +21,8 @@ create or replace view rhnChannelFamilyPermissions as
to_number(null, null) as org_id,
to_number(null, null) as max_members,
0 as current_members,
+ 0 as fve_max_members,
+ 0 as fve_current_members,
created,
modified
from rhnPublicChannelFamily
@@ -29,6 +31,8 @@ create or replace view rhnChannelFamilyPermissions as
org_id,
max_members,
current_members,
+ fve_max_members,
+ fve_current_members,
created,
modified
from rhnPrivateChannelFamily;
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
index fce208b..ab23540 100644
---
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
@@ -1,3 +1,3 @@
-alter table rhnPrivateChannelFamily add max_flex NUMBER;
-alter table rhnPrivateChannelFamily add current_flex NUMBER
+alter table rhnPrivateChannelFamily add FVE_MAX_MEMBERS NUMBER default (0);
+alter table rhnPrivateChannelFamily add FVE_CURRENT_MEMBERS NUMBER
DEFAULT (0) NOT NULL;
commit 000ebe9b3f89b3b13e849339c03fc2245447dd7d
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 17:30:51 2010 -0400
a few fixse for sat cert handling
diff --git a/backend/satellite_tools/satCerts.py b/backend/satellite_tools/satCerts.py
index 732ade8..5632f33 100644
--- a/backend/satellite_tools/satCerts.py
+++ b/backend/satellite_tools/satCerts.py
@@ -164,16 +164,12 @@ def set_slots_from_cert(cert):
db_label = slots.get_db_label()
quantity = slots.get_quantity()
- flex = slots.get_flex()
# Do not pass along a NULL quantity - NULL for
# rhnServerGroup.max_members means 'no maximum' BZ #160046
if not quantity:
quantity = 0
- if not flex:
- flex = 0
-
slot_type_id = None
if slot_table.has_key(db_label):
slot_type_id = slot_table[db_label]['id']
@@ -197,7 +193,7 @@ def set_slots_from_cert(cert):
try:
# Set the counts now
- activate_system_entitlement(org_id, db_label, quantity, flex)
+ activate_system_entitlement(org_id, db_label, quantity)
except rhnSQL.sql_base.SQLSchemaError, e:
if e[0] == 20290:
free_count = sys_ent_counts[(db_label, 1)] - quantity
@@ -216,7 +212,7 @@ def set_slots_from_cert(cert):
# For any other type of slot, set quantity to zero
for slot_type_id, db_label in extra_slots.items():
slot_name = cert.lookup_slot_by_db_label(db_label)
- activate_system_entitlement(org_id, db_label, 0, 0)
+ activate_system_entitlement(org_id, db_label, 0)
org_service_proc(org_id, slot_name, 'N')
# NOTE: must rhnSQL.commit() in calling function.
diff --git a/backend/satellite_tools/sync_handlers.py
b/backend/satellite_tools/sync_handlers.py
index 1d280d5..468f35a 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -617,7 +617,7 @@ def populate_channel_family_permissions(cert):
org_id = cfp['org_id']
# Initially populate cf info with old limits from db
- cfps[(cf_name, org_id)] = (cfp['max_members'], cfg['max_flex'])
+ cfps[(cf_name, org_id)] = (cfp['max_members'], cfp['max_flex'])
curr_cfps[(cf_name, org_id)] = (cfp['current_members'],
cfp['current_flex'])
# Now set max_members based on the cert's max_members
@@ -729,7 +729,8 @@ def _fetch_existing_channel_families():
_query_fetch_channel_family_permissions = rhnSQL.Statement("""
select cf.label as channel_family, cfp.org_id,
- cfp.max_members, cfp.current_members, cf.org_id as owner_org_id
+ cfp.max_members, cfp.current_members, cfp.max_flex, cfp.current_flex,
+ cf.org_id as owner_org_id
from rhnChannelFamilyPermissions cfp, rhnChannelFamily cf
where cfp.channel_family_id = cf.id
""")
commit 0542ad6399ba1d0e8151601e940a44f38ea7daa8
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 16:19:33 2010 -0400
first attempt at adding flex guest to sat cert processing
diff --git a/backend/satellite_tools/satCerts.py b/backend/satellite_tools/satCerts.py
index 42ae4c0..732ade8 100644
--- a/backend/satellite_tools/satCerts.py
+++ b/backend/satellite_tools/satCerts.py
@@ -164,13 +164,16 @@ def set_slots_from_cert(cert):
db_label = slots.get_db_label()
quantity = slots.get_quantity()
+ flex = slots.get_flex()
# Do not pass along a NULL quantity - NULL for
# rhnServerGroup.max_members means 'no maximum' BZ #160046
-
if not quantity:
quantity = 0
+ if not flex:
+ flex = 0
+
slot_type_id = None
if slot_table.has_key(db_label):
slot_type_id = slot_table[db_label]['id']
@@ -194,7 +197,7 @@ def set_slots_from_cert(cert):
try:
# Set the counts now
- activate_system_entitlement(org_id, db_label, quantity)
+ activate_system_entitlement(org_id, db_label, quantity, flex)
except rhnSQL.sql_base.SQLSchemaError, e:
if e[0] == 20290:
free_count = sys_ent_counts[(db_label, 1)] - quantity
@@ -213,7 +216,7 @@ def set_slots_from_cert(cert):
# For any other type of slot, set quantity to zero
for slot_type_id, db_label in extra_slots.items():
slot_name = cert.lookup_slot_by_db_label(db_label)
- activate_system_entitlement(org_id, db_label, 0)
+ activate_system_entitlement(org_id, db_label, 0, 0)
org_service_proc(org_id, slot_name, 'N')
# NOTE: must rhnSQL.commit() in calling function.
diff --git a/backend/satellite_tools/sync_handlers.py
b/backend/satellite_tools/sync_handlers.py
index 7e79c3c..1d280d5 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -602,7 +602,10 @@ def populate_channel_family_permissions(cert):
quant = cf.quantity
if quant is not None:
quant = int(quant)
- cert_chfam_hash[cf.name] = quant
+ flex = cf.flex
+ if flex is not None:
+ flex = int(flex)
+ cert_chfam_hash[cf.name] = (quant, flex)
# Generate the channel family permissions data structure
cfps = {}
@@ -614,12 +617,13 @@ def populate_channel_family_permissions(cert):
org_id = cfp['org_id']
# Initially populate cf info with old limits from db
- cfps[(cf_name, org_id)] = cfp['max_members']
- curr_cfps[(cf_name, org_id)] = cfp['current_members']
+ cfps[(cf_name, org_id)] = (cfp['max_members'], cfg['max_flex'])
+ curr_cfps[(cf_name, org_id)] = (cfp['current_members'],
cfp['current_flex'])
# Now set max_members based on the cert's max_members
- for cf_name, max_members in cert_chfam_hash.items():
+ for cf_name, max_tuple in cert_chfam_hash.items():
# Make the channel families with null max_members public
+ max_members, max_flex = max_tuple
if max_members is None:
org_id = None
else:
@@ -628,47 +632,60 @@ def populate_channel_family_permissions(cert):
cf_name = cf_name.encode('utf-8')
try:
- old_max_members = cfps[(cf_name, org_id)]
+ old_max_tuple = cfps[(cf_name, org_id)]
except KeyError:
# New channel family, populate the db from cert
- cfps[(cf_name, org_id)] = max_members
- old_max_members = None
-
- if old_max_members and max_members < old_max_members:
+ cfps[(cf_name, org_id)] = max_tuple
+ old_max_tuple = None
+
+
+ if old_max_tuple and (max_members < old_max_tuple[0] or
+ max_flex < old_max_tuple[1]):
# The cert count is low, set the db with new values
- cfps[(cf_name, org_id)] = max_members
+ cfps[(cf_name, org_id)] = max_tuple
sum_max_values = compute_sum_max_members(cfps)
- for (cf_name, org_id), max_members in cfps.items():
+ for (cf_name, org_id), (max_members, max_flex) in cfps.items():
if org_id == 1:
if cert_chfam_hash.has_key(cf_name):
- cert_max_value = cert_chfam_hash[cf_name] or 0
+ cert_max_value = cert_chfam_hash[cf_name][0] or 0
+ cert_max_flex = cert_chfam_hash[cf_name][1] or 0
else:
# remove entitlements on extra slots
cfps[(cf_name, org_id)] = None
continue
if not max_members:
max_members = 0
- if cert_max_value >= sum_max_values[cf_name]:
- cfps[(cf_name, 1)] = max_members + \
- (cert_max_value - sum_max_values[cf_name])
+ if not max_flex:
+ max_flex = 0
+
+ (sum_max_mem, sum_max_flex) = sum_max_values[cf_name]
+ if cert_max_value >= sum_max_mem:
+ cfps[(cf_name, 1)][0] = max_members + \
+ (cert_max_value - sum_max_mem)
+ if cert_max_flex >= sum_max_flex:
+ cfps[(cf_name, 1)][1] = max_flex +\
+ (cert_max_flex - sum_max_flex)
else:
# lowering entitlements
- purge_count = sum_max_values[cf_name] - cert_max_value
- cfps[(cf_name, 1)] = max_members - purge_count
+ purge_count = sum_max_mem, - cert_max_value
+ cfps[(cf_name, 1)][0] = max_members - purge_count
+ flex_purge_count = sum_max_flex - cert_max_flex
+ cfps[(cf_name, 1)][1] = max_flex - flex_purge_count
# Cleanup left out suborgs
- for (cf_name, org_id), max_members in cfps.items():
+ for (cf_name, org_id), (max_members, max_flex) in cfps.items():
if cfps.has_key((cf_name, 1)) and cfps[(cf_name, 1)] == None: #is None:
cfps[(cf_name, org_id)] = None
batch = []
- for (cf_name, org_id), max_members in cfps.items():
+ for (cf_name, org_id), (max_members, max_flex) in cfps.items():
cfperm = importLib.ChannelFamilyPermissions()
batch.append(cfperm.populate({
'channel_family' : cf_name,
'org_id' : org_id,
'max_members' : max_members,
+ 'max_flex' : max_flex,
}))
importer = channelImport.ChannelFamilyPermissionsImport(batch,
@@ -677,15 +694,19 @@ def populate_channel_family_permissions(cert):
importer.run()
def compute_sum_max_members(cfps):
- cf_max_members = {}
- for (cf_name, org_id), max_members in cfps.items():
+ """If a channel family appears multiple times for each org, comgine
them"""
+ cf_max_tuples = {}
+ for (cf_name, org_id), (max_members, max_flex) in cfps.items():
if not max_members:
max_members = 0
- if cf_max_members.has_key(cf_name):
- cf_max_members[cf_name] = cf_max_members[cf_name] + max_members
+ if not max_flex:
+ max_flex = 0
+ if cf_max_tuples.has_key(cf_name):
+ cf_max_members, cf_max_flex = cf_max_tuples[cf_name]
+ cf_max_tuples[cf_name] = (cf_max_members + max_members, cf_max_flex +
max_flex)
else:
- cf_max_members[cf_name] = max_members
- return cf_max_members
+ cf_max_tuples[cf_name] = (max_members, max_flex)
+ return cf_max_tuples
_query_fetch_existing_channel_families = rhnSQL.Statement("""
select label
diff --git a/backend/server/importlib/backend.py b/backend/server/importlib/backend.py
index 68b213d..3e68e2c 100644
--- a/backend/server/importlib/backend.py
+++ b/backend/server/importlib/backend.py
@@ -1091,7 +1091,7 @@ class Backend:
continue
try:
activate_channel_entitlements(cfp['org_id'],
- cfp['channel_family'], cfp['max_members'])
+ cfp['channel_family'], cfp['max_members'],
cfp['max_flex'])
except rhnSQL.SQLError, e:
raise rhnFault(23, str(e[1]) + ": org_id [%s] family [%s] max [%s]" % \
(cfp['org_id'], cfp['channel_family'], cfp['max_members']),
explain=0)
diff --git a/backend/server/rhnServer/satellite_cert.py
b/backend/server/rhnServer/satellite_cert.py
index 24bd752..121959a 100644
--- a/backend/server/rhnServer/satellite_cert.py
+++ b/backend/server/rhnServer/satellite_cert.py
@@ -54,7 +54,7 @@ class Item:
class ChannelFamily(Item):
pretty_name = "channel family"
attribute_name = 'channel_families'
- attributes = {'family' : 'name', 'quantity' :
'quantity'}
+ attributes = {'family' : 'name', 'quantity' :
'quantity', 'flex' : 'flex' }
class Slots:
_db_label = None
diff --git a/schema/spacewalk/common/data/rhnException.sql
b/schema/spacewalk/common/data/rhnException.sql
index 69b12d9..8112644 100644
--- a/schema/spacewalk/common/data/rhnException.sql
+++ b/schema/spacewalk/common/data/rhnException.sql
@@ -112,6 +112,7 @@ values (-20291,
insert into rhnException values (-20292, 'package_provider_not_found', 'The
specified package provider could not be found.');
insert into rhnException values (-20293, 'package_key_type_not_found', 'The
specified package key type could not be found.');
+insert into rhnException values (-20294,
'not_enough_flex_entitlements_in_base_org', 'You do not have enough
entitlements in the base org.');
commit;
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index f29cebe..433072e 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -1298,10 +1298,12 @@ is
procedure activate_channel_entitlement(
org_id_in in number,
channel_family_label_in in varchar2,
- quantity_in in number
+ quantity_in in number,
+ flex_in in number
)
is
prev_ent_count number;
+ prev_flex_count number;
prev_ent_count_sum number;
cfam_id number;
begin
@@ -1322,6 +1324,20 @@ is
end;
begin
+ select pcf.current_flex
+ into prev_flex_count
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ prev_flex_count := 0;
+ end;
+
+
+ begin
select id
into cfam_id
from rhnChannelFamily
@@ -1332,6 +1348,11 @@ is
'invalid_channel_family');
end;
+ if flex_in < prev_flex_count then
+ rhn_exception.raise_exception(
+ 'not_enough_flex_entitlements_in_base_org');
+ end if;
+
-- If we're setting the total entitlemnt count to a lower value,
-- and that value is less than the count in that one org,
-- we need to raise an exception.
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pks
b/schema/spacewalk/oracle/packages/rhn_entitlements.pks
index 40eafac..b94399d 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pks
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pks
@@ -137,7 +137,8 @@ is
procedure activate_channel_entitlement(
org_id_in in number,
channel_family_label_in in varchar2,
- quantity_in in number
+ quantity_in in number,
+ flex_in in number
);
procedure set_group_count (
commit b45bddc0726b51981a8440e7d07d346e06bb9e80
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 11:11:01 2010 -0400
adding hibernate mapping for flex guests
diff --git a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
index aaeb897..f4cf362 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.hbm.xml
@@ -15,6 +15,9 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="maxMembers" column="MAX_MEMBERS"
type="long" />
<property name="currentMembers" column="CURRENT_MEMBERS"
not-null="true" type="long" />
+ <property name="maxFlex" column="MAX_FLEX" type="long"
/>
+ <property name="currentFlex" column="CURRENT_FLEX"
+ not-null="true" type="long" />
<property name="created" column="CREATED"
not-null="true"
type="timestamp" insert="false" update="false" />
<property name="modified" column="MODIFIED"
not-null="true"
diff --git a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
index 59cd046..c2e9bee 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/PrivateChannelFamily.java
@@ -34,6 +34,41 @@ public class PrivateChannelFamily implements Serializable {
private Long currentMembers;
private Date created;
private Date modified;
+ private Long maxFlex;
+ private Long currentFlex;
+
+
+ /**
+ * Get the max flex count
+ * @return the count
+ */
+ public Long getMaxFlex() {
+ return maxFlex;
+ }
+
+ /**
+ * Set the max flex count
+ * @param maxFlexIn the max flex
+ */
+ public void setMaxFlex(Long maxFlexIn) {
+ this.maxFlex = maxFlex;
+ }
+
+ /**
+ * get the current flex
+ * @return the current flex count
+ */
+ public Long getCurrentFlex() {
+ return currentFlex;
+ }
+
+ /**
+ * set current flex
+ * @param currentFlexIn the current flex to set
+ */
+ public void setCurrentFlex(Long currentFlexIn) {
+ this.currentFlex = currentFlex;
+ }
/**
* @return Returns the channelFamily.
commit 9883a23591d59daa845c55be19bbe39c2b4a9bb4
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Jun 3 11:00:38 2010 -0400
adding flex guest table changes
diff --git a/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
b/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
index 1efbbbf..8964b48 100644
--- a/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
+++ b/schema/spacewalk/common/tables/rhnPrivateChannelFamily.sql
@@ -26,6 +26,9 @@ CREATE TABLE rhnPrivateChannelFamily
max_members NUMBER,
current_members NUMBER
DEFAULT (0) NOT NULL,
+ max_flex NUMBER,
+ current_flex NUMBER
+ DEFAULT (0) NOT NULL,
created DATE
DEFAULT (sysdate) NOT NULL,
modified DATE
diff --git a/schema/spacewalk/common/tables/rhnServerChannel.sql
b/schema/spacewalk/common/tables/rhnServerChannel.sql
index efc48b1..1b6b20b 100644
--- a/schema/spacewalk/common/tables/rhnServerChannel.sql
+++ b/schema/spacewalk/common/tables/rhnServerChannel.sql
@@ -22,6 +22,10 @@ CREATE TABLE rhnServerChannel
channel_id NUMBER NOT NULL
CONSTRAINT rhn_sc_cid_fk
REFERENCES rhnChannel (id),
+ is_fve char
+ default 'N'
+ CONSTRAINT rhn_server_channel_is_fve_nn NOT NULL
+ CONSTRAINT rhn_server_channel_is_fve_ck CHECK (IS_FVE IN ('Y',
'N')),
created DATE
DEFAULT (sysdate) NOT NULL,
modified DATE
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
new file mode 100644
index 0000000..fce208b
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/003-rhnPrivateChannelFamily.sql
@@ -0,0 +1,3 @@
+alter table rhnPrivateChannelFamily add max_flex NUMBER;
+alter table rhnPrivateChannelFamily add current_flex NUMBER
+ DEFAULT (0) NOT NULL;
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/004-rhnServerChannel.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/004-rhnServerChannel.sql
new file mode 100644
index 0000000..3a86e4d
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/004-rhnServerChannel.sql
@@ -0,0 +1,4 @@
+
+alter TABLE rhnServerChannel add is_fve char default 'N'
+ CONSTRAINT rhn_server_channel_is_fve_nn NOT NULL
+ CONSTRAINT rhn_server_channel_is_fve_ck CHECK (IS_FVE IN ('Y', 'N'));