-
Notifications
You must be signed in to change notification settings - Fork 71
D-Bus API for storage issues #548
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
Merged
joseivanlopez
merged 7 commits into
agama-project:issues
from
joseivanlopez:storage-issues-dbus
Apr 27, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
78b4ab4
[service] Add Issue class
joseivanlopez 04e87fd
[service] Add issues interface
joseivanlopez f957f2e
[service] Add shared examples for progress
joseivanlopez d57181c
[service] Add issues to storage
joseivanlopez d832985
[service] Adapt storage client
joseivanlopez 3a29e94
[service] Changelog
joseivanlopez d86b948
[service] Improve doc
joseivanlopez 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 hidden or 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 |
|---|---|---|
| @@ -1,11 +1,33 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Copyright (c) [2022-2023] SUSE LLC | ||
| # | ||
| # All Rights Reserved. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify it | ||
| # under the terms of version 2 of the GNU General Public License as published | ||
| # by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| # more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License along | ||
| # with this program; if not, contact SUSE LLC. | ||
| # | ||
| # To contact SUSE LLC about this file by physical or electronic mail, you may | ||
| # find current contact information at www.suse.com. | ||
|
|
||
| module Agama | ||
| # Namespace for DBus API | ||
| # Namespace for D-Bus API | ||
| module DBus | ||
| end | ||
| end | ||
|
|
||
| require "agama/dbus/manager" | ||
| require "agama/dbus/language" | ||
| require "agama/dbus/software" | ||
| require "agama/dbus/storage" | ||
| require "agama/dbus/users" | ||
| require "agama/dbus/questions" |
This file contains hidden or 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 hidden or 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,54 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Copyright (c) [2023] SUSE LLC | ||
| # | ||
| # All Rights Reserved. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify it | ||
| # under the terms of version 2 of the GNU General Public License as published | ||
| # by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| # more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License along | ||
| # with this program; if not, contact SUSE LLC. | ||
| # | ||
| # To contact SUSE LLC about this file by physical or electronic mail, you may | ||
| # find current contact information at www.suse.com. | ||
|
|
||
| require "agama/issue" | ||
|
|
||
| module Agama | ||
| module DBus | ||
| # Mixin to include in the clients of services that implement the Issues interface | ||
| module WithIssues | ||
| ISSUES_IFACE = "org.opensuse.Agama1.Issues" | ||
| private_constant :ISSUES_IFACE | ||
|
|
||
| # Returns the issues | ||
| # | ||
| # @return [Array<Issue>] | ||
| def issues | ||
| sources = [nil, Issue::Source::SYSTEM, Issue::Source::CONFIG] | ||
| severities = [Issue::Severity::WARN, Issue::Severity::ERROR] | ||
|
|
||
| dbus_object[ISSUES_IFACE]["All"].map do |dbus_issue| | ||
| Issue.new(dbus_issue[0], | ||
| details: dbus_issue[1], | ||
| source: sources[dbus_issue[2]], | ||
| severity: severities[dbus_issue[3]]) | ||
| end | ||
| end | ||
|
|
||
| # Determines whether there are errors | ||
| # | ||
| # @return [Boolean] | ||
| def errors? | ||
| issues.any?(&:error?) | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or 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,33 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Copyright (c) [2023] SUSE LLC | ||
| # | ||
| # All Rights Reserved. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify it | ||
| # under the terms of version 2 of the GNU General Public License as published | ||
| # by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| # more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License along | ||
| # with this program; if not, contact SUSE LLC. | ||
| # | ||
| # To contact SUSE LLC about this file by physical or electronic mail, you may | ||
| # find current contact information at www.suse.com. | ||
|
|
||
| module Agama | ||
| module DBus | ||
| # Namespace for generic D-Bus interfaces | ||
| module Interfaces | ||
| end | ||
| end | ||
| end | ||
|
|
||
| require "agama/dbus/interfaces/issues" | ||
| require "agama/dbus/interfaces/progress" | ||
| require "agama/dbus/interfaces/service_status" | ||
| require "agama/dbus/interfaces/validation" |
This file contains hidden or 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,74 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # Copyright (c) [2023] SUSE LLC | ||
| # | ||
| # All Rights Reserved. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify it | ||
| # under the terms of version 2 of the GNU General Public License as published | ||
| # by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| # more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License along | ||
| # with this program; if not, contact SUSE LLC. | ||
| # | ||
| # To contact SUSE LLC about this file by physical or electronic mail, you may | ||
| # find current contact information at www.suse.com. | ||
|
|
||
| require "dbus" | ||
| require "agama/issue" | ||
|
|
||
| module Agama | ||
| module DBus | ||
| module Interfaces | ||
| # Mixin to define the Issues D-Bus interface | ||
| # | ||
| # @note This mixin is expected to be included in a class that inherits from {DBus::BaseObject} | ||
| # and it requires a #issues method that returns an array of {Issue} objects. | ||
| module Issues | ||
| ISSUES_INTERFACE = "org.opensuse.Agama1.Issues" | ||
|
|
||
| # Issues with the D-Bus format | ||
| # | ||
| # @return [Array<Array(String, String, Integer, Integer)>] The description, details, source | ||
| # and severity of each issue. | ||
| # Source: 1 for system, 2 for config and 3 for unknown. | ||
| # Severity: 0 for warn and 1 for error. | ||
| def dbus_issues | ||
| issues.map do |issue| | ||
| source = case issue.source | ||
| when Agama::Issue::Source::SYSTEM | ||
| 1 | ||
| when Agama::Issue::Source::CONFIG | ||
| 2 | ||
| else | ||
| 0 | ||
| end | ||
| severity = issue.severity == Agama::Issue::Severity::WARN ? 0 : 1 | ||
|
|
||
| [issue.description, issue.details.to_s, source, severity] | ||
| end | ||
| end | ||
|
|
||
| # Emits the signal for properties changed | ||
| def issues_properties_changed | ||
| dbus_properties_changed(ISSUES_INTERFACE, | ||
| interfaces_and_properties[ISSUES_INTERFACE], []) | ||
| end | ||
|
|
||
| def self.included(base) | ||
| base.class_eval do | ||
| dbus_interface ISSUES_INTERFACE do | ||
| # @see {#dbus_issues} | ||
| dbus_reader :dbus_issues, "a(ssuu)", dbus_name: "All" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.