-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add notification for users with disabled SCC data forwarding (jsc#SUMA-431) #9582
Open
wweellddeerr
wants to merge
1
commit into
uyuni-project:master
Choose a base branch
from
wweellddeerr:scc-optout-notification-master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+247
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
java/code/src/com/redhat/rhn/domain/notification/types/SCCOptOutWarning.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* 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.domain.notification.types; | ||
|
||
import com.redhat.rhn.common.localization.LocalizationService; | ||
import com.redhat.rhn.domain.notification.NotificationMessage; | ||
|
||
public class SCCOptOutWarning implements NotificationData { | ||
|
||
private static final LocalizationService LOCALIZATION_SERVICE = LocalizationService.getInstance(); | ||
|
||
@Override | ||
public NotificationMessage.NotificationMessageSeverity getSeverity() { | ||
return NotificationMessage.NotificationMessageSeverity.WARNING; | ||
} | ||
|
||
@Override | ||
public NotificationType getType() { | ||
return NotificationType.SCCOptOutWarning; | ||
} | ||
|
||
@Override | ||
public String getSummary() { | ||
return LOCALIZATION_SERVICE.getMessage("notification.sccoptoutwarning.summary"); | ||
} | ||
|
||
@Override | ||
public String getDetails() { | ||
return LOCALIZATION_SERVICE.getMessage("notification.sccoptoutwarning.detail"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
java/code/src/com/redhat/rhn/frontend/action/satellite/SCCDataForwardingConfigAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* 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.satellite; | ||
|
||
import com.redhat.rhn.common.conf.Config; | ||
import com.redhat.rhn.domain.user.User; | ||
import com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand; | ||
|
||
/** | ||
* This class extends the {@link BaseConfigAction} class to provide specific command configuration for enabling SCC | ||
* data forwarding. | ||
*/ | ||
public class SCCDataForwardingConfigAction extends BaseConfigAction { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected String getCommandClassName() { | ||
return Config.get().getString( | ||
"web.com.redhat.rhn.frontend.action.satellite.GeneralConfigAction.command", | ||
"com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand" | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ConfigureSatelliteCommand getCommand(User user) { | ||
return (ConfigureSatelliteCommand) super.getCommand(user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../code/src/com/suse/manager/webui/controllers/admin/EnableSCCDataForwardingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* 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.suse.manager.webui.controllers.admin; | ||
|
||
import static com.suse.manager.webui.utils.SparkApplicationHelper.withUser; | ||
import static spark.Spark.get; | ||
|
||
import com.redhat.rhn.common.conf.ConfigDefaults; | ||
import com.redhat.rhn.common.localization.LocalizationService; | ||
import com.redhat.rhn.common.security.PermissionException; | ||
import com.redhat.rhn.common.validator.ValidatorError; | ||
import com.redhat.rhn.domain.role.RoleFactory; | ||
import com.redhat.rhn.domain.user.User; | ||
import com.redhat.rhn.frontend.action.satellite.SCCDataForwardingConfigAction; | ||
import com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import spark.ModelAndView; | ||
import spark.Request; | ||
import spark.Response; | ||
import spark.template.jade.JadeTemplateEngine; | ||
|
||
/** | ||
* Controller class providing backend code to enable SCC data forwarding. | ||
*/ | ||
public class EnableSCCDataForwardingController { | ||
|
||
private EnableSCCDataForwardingController() { } | ||
|
||
private static final SCCDataForwardingConfigAction CONFIG_ACTION = new SCCDataForwardingConfigAction(); | ||
|
||
/** | ||
* Initializes the routes. | ||
* | ||
* @param jade the jade engine | ||
*/ | ||
public static void initRoutes(JadeTemplateEngine jade) { | ||
get("/manager/admin/enable-scc-data-forwarding", withUser(EnableSCCDataForwardingController::enable), jade); | ||
} | ||
|
||
/** | ||
* Route to enable data forwarding | ||
* @param request - the request | ||
* @param response - the response | ||
* @param user - the user | ||
* @return - jade template with confirmation message | ||
*/ | ||
public static ModelAndView enable(Request request, Response response, User user) { | ||
String message = LocalizationService.getInstance().getMessage("scc-data-forwarding.enabled"); | ||
|
||
if (!user.hasRole(RoleFactory.ORG_ADMIN)) { | ||
throw new PermissionException("Only Org Admins can change SCC data forwarding property."); | ||
} | ||
|
||
if (ConfigDefaults.get().isForwardRegistrationEnabled()) { | ||
message = LocalizationService.getInstance().getMessage("scc-data-forwarding.not-changed"); | ||
} | ||
else { | ||
ConfigureSatelliteCommand csc = CONFIG_ACTION.getCommand(user); | ||
csc.updateBoolean(ConfigDefaults.FORWARD_REGISTRATION, Boolean.TRUE); | ||
ValidatorError[] verrors = csc.storeConfiguration(); | ||
if (verrors != null && verrors.length > 0) { | ||
StringBuilder errorMsg = new StringBuilder(); | ||
errorMsg.append("The following errors happened when enabling SCC data forwarding:\n"); | ||
for (var error: verrors) { | ||
errorMsg.append(error.getLocalizedMessage()); | ||
} | ||
message = errorMsg.toString(); | ||
} | ||
} | ||
|
||
Map<String, Object> data = new HashMap<>(); | ||
data.put("message", message); | ||
return new ModelAndView(data, "templates/admin/enable-scc-data-forwarding-confirm.jade"); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
java/code/src/com/suse/manager/webui/templates/admin/enable-scc-data-forwarding-confirm.jade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 #{message} | ||
p | ||
a(href="/rhn/manager/notification-messages") Return to notifications |
2 changes: 2 additions & 0 deletions
2
java/spacewalk-java.changes.welder.scc-data-forwarding-warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add notification for users with disabled SCC data forwarding | ||
(jsc#SUMA-431) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add notification for users with disabled SCC data forwarding | ||
(jsc#SUMA-431) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the change also reflected in the file(rhn.conf? )?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question. We are only changing the property here but if some user actually disabled the taskomatic job, we don't take care of enabling that here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does.
If the Taskomatic job is disabled, the user won’t receive the notification because it is created inside the job. We could create a different job specifically for the notification; however, it would still be possible for the user to disable this specific job. So, I don’t think it’s worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the taskomatic job: I think one thing that we could consider doing here is resetting the schedule to the default one (the one you have after installation), just in case someone might have changed it to only run once per month or so? Not a blocker for this PR though, if it turns out to be complex we can skip it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly we have a different problem. You cannot "disable" a job. In fact it is removed and you cannot get it back. I think we have a separate issue or bug report about it. This problem is bigger than just a changed schedule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/SUSE/spacewalk/issues/16996
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the pointer Michael, that one is concerning :(