Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master show client payg UI api #7697

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions java/code/src/com/redhat/rhn/common/security/acl/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,21 @@ public boolean aclSystemSupportsPtfRemoval(Map<String, Object> ctx, String[] par
ServerFactory.isPtfUninstallationSupported(server);
}

/**
* Checks if a system is Pay-as-you-go
* @param ctx acl context
* @param params parameters for acl
* @return true if the system is Pay-as-you-go
*/
public boolean aclSystemIsPayg(Map<String, Object> ctx, String[] params) {
Long sid = getAsLong(ctx.get("sid"));
User user = (User) ctx.get("user");

Server server = SystemManager.lookupByIdAndUser(sid, user);
if (server == null) {
return false;
}

return server.isPayg();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20787,6 +20787,18 @@ The Tree Path, Base Channel, and Installer Generation should always match. This
<context context-type="sourcefile">/systems/details/Overview.do</context>
</context-group>
</trans-unit>
<trans-unit id="sdc.details.overview.payg" xml:space="preserve">
<source>Pay-as-you-go:</source>
<context-group name="ctx">
<context context-type="sourcefile">/systems/details/Overview.do</context>
</context-group>
</trans-unit>
<trans-unit id="sdc.details.overview.payg_msg" xml:space="preserve">
<source>This is a Pay-as-you-go server</source>
<context-group name="ctx">
<context context-type="sourcefile">/systems/details/Overview.do</context>
</context-group>
</trans-unit>
<trans-unit id="sdc.details.overview.activationkey" xml:space="preserve">
<source>Activation Key:</source>
<context-group name="ctx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* #prop_desc("int", "id", "system ID")
* #prop("string", "profile_name")
* #prop("string", "machine_id")
* #prop_desc("boolean", "payg", "Whether the server instance is payg or not")
* #prop("string", "minion_id")
* #prop_desc("string", "base_entitlement", "system's base entitlement label")
*
Expand Down Expand Up @@ -86,7 +87,8 @@ public SerializedApiResponse serialize(Server src) {
.add("profile_name", src.getName())
.add("machine_id", src.getMachineId())
.add("hostname", src.getHostname())
.add("minion_id", src.getMinionId());
.add("minion_id", src.getMinionId())
.add("payg", src.isPayg());

// Find this server's base entitlement:
String baseEntitlement = EntitlementManager.UNENTITLED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ private Date convertLocalToUtc(Date in) {
* #struct_begin("server details")
* #prop_desc("int", "id", "The server's id")
* #prop_desc("string", "name", "The server's name")
* #prop_desc("boolean", "payg", "Whether the server instance is payg or not")
* #prop_desc("string", "minion_id", "The server's minion id, in case it is a salt minion client")
* #prop_desc("$date", "last_checkin",
* "Last time server successfully checked in (in UTC)")
Expand Down Expand Up @@ -885,6 +886,8 @@ public List<Map<String, Object>> listActiveSystemsDetails(
}
m.put("subscribed_channels", channels);

m.put("payg", server.isPayg());

Collection<VirtualInstance> guests = server.getGuests();
List<Long> guestList = new ArrayList<>();
for (VirtualInstance guest : guests) {
Expand Down
11 changes: 11 additions & 0 deletions java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@
</td>
</tr>
</rhn:require>
<!-- PAYG info -->
<rhn:require acl="system_is_payg()">
<tr>
<td>
<bean:message key="sdc.details.overview.payg"/>
</td>
<td>
<rhn:icon type="system-ok" title="sdc.details.overview.payg_msg"/>
</td>
</tr>
</rhn:require>
<tr>
<td><bean:message key="sdc.details.overview.sysid"/></td>
<td><c:out value="${system.id}" /></td>
Expand Down
1 change: 1 addition & 0 deletions java/spacewalk-java.changes.mikeletux.22205
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add payg info to UI and rest API
Loading