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

D-Bus API for registration #791

Merged
merged 68 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
b48ae86
[service] Some renames in Software D-Bus API
joseivanlopez Oct 4, 2023
8bbd567
[service] WIP Registration D-Bus API
joseivanlopez Oct 4, 2023
c39c376
add registration mock class
jreidinger Oct 4, 2023
e50337b
[service] Replace Validation by Issues interface
joseivanlopez Oct 5, 2023
c5535f7
[service] Fix names
joseivanlopez Oct 5, 2023
851e85f
[service] WIP return error number and message
joseivanlopez Oct 6, 2023
9300a72
initial forst working POC
jreidinger Oct 6, 2023
12102fd
[service] More fixes to adapt to changes in D-Bus API
joseivanlopez Oct 9, 2023
78c4df0
[web] Adapt UI to D-Bus API changes
joseivanlopez Oct 9, 2023
8ac9699
use suse connect directly without yast
jreidinger Oct 9, 2023
cdc9bb4
[service] Work on some tests
joseivanlopez Oct 9, 2023
f16b07e
[service] Small fixes
joseivanlopez Oct 9, 2023
94dd896
[service] Improve generation of connect result
joseivanlopez Oct 9, 2023
b0734a5
fix missing require
jreidinger Oct 9, 2023
551a643
make rubocop happy
jreidinger Oct 9, 2023
4098011
fix typo
jreidinger Oct 9, 2023
834a7dc
drop removed method from y2-registration
jreidinger Oct 9, 2023
d875395
try registation without release type
jreidinger Oct 10, 2023
861c202
[service] Small improvements
joseivanlopez Oct 10, 2023
719d421
[service] Fix tests
joseivanlopez Oct 10, 2023
9881d89
[service] Continue working on the D-Bus API
joseivanlopez Oct 10, 2023
4f90278
support deregister
jreidinger Oct 10, 2023
fe89d84
[service] Add registration issue
joseivanlopez Oct 10, 2023
7ccfa41
add to deregister also code
jreidinger Oct 10, 2023
60ab7ba
fix typo and order
jreidinger Oct 10, 2023
18f5de9
fix base product cannot be deactivated
jreidinger Oct 10, 2023
a4cc72b
remove credentials file
jreidinger Oct 10, 2023
895a092
properly uninitialize internal variables
jreidinger Oct 10, 2023
cd6a22b
[service] Add Product and ProductBuilder
joseivanlopez Oct 11, 2023
b50ac90
[service] Adapt manager to use products
joseivanlopez Oct 11, 2023
66c509a
[service] Register selected product instead of hardcoded
joseivanlopez Oct 11, 2023
b36e988
[service] Add version to config file
joseivanlopez Oct 11, 2023
c3a1422
Merge branch 'master' into registration-dbus-api
joseivanlopez Oct 11, 2023
3632f6a
[web] Fix pattern selector
joseivanlopez Oct 11, 2023
c4dcbb9
add pkg related stuff after registration
jreidinger Oct 12, 2023
61147b7
fix crash for unknown version
jreidinger Oct 12, 2023
72cbf53
fix crash for wrong namespace
jreidinger Oct 12, 2023
9275479
fix typos
jreidinger Oct 12, 2023
bede9c3
add service specific credentials file
jreidinger Oct 13, 2023
a7b856d
[service] Improve documentation
joseivanlopez Oct 16, 2023
db7567a
[service] Rubocop
joseivanlopez Oct 16, 2023
ef1a0f2
[service] Minor fixes and tests
joseivanlopez Oct 17, 2023
dfd547f
[service] Prevent change of product if needed
joseivanlopez Oct 17, 2023
dd866c7
[service] Document Registration D-Bus interface
joseivanlopez Oct 17, 2023
6c4c742
[service] Partially document Software D-Bus interface
joseivanlopez Oct 17, 2023
2bb1a00
[service] Fix D-Bus documentation
joseivanlopez Oct 17, 2023
cc4ba95
[web] Fix tests
joseivanlopez Oct 17, 2023
88141e1
[rust] Adapt to Software D-Bus changes
joseivanlopez Oct 18, 2023
4032595
[rust] Use better error name
joseivanlopez Oct 18, 2023
70b2def
move service operations to software and fix target init
jreidinger Oct 18, 2023
5a38dac
fix namespace
jreidinger Oct 18, 2023
254dfe4
add dependency on suse connect it is used
jreidinger Oct 18, 2023
6c6cba2
[service] Export a separate product object
joseivanlopez Oct 19, 2023
fe0d63b
[web] Adapt software client
joseivanlopez Oct 19, 2023
7b1cd3c
[service] Unit tests and minor fixes
joseivanlopez Oct 20, 2023
5c3809a
copy credentials in installation
jreidinger Oct 20, 2023
0b21ca7
[service] Registration tests and minor fixes
joseivanlopez Oct 20, 2023
0814460
[service] Add missing check
joseivanlopez Oct 20, 2023
691f71c
[service] Use ruby-dbus 0.23.1
joseivanlopez Oct 20, 2023
a2c702b
[service] Update D-Bus documentation
joseivanlopez Oct 20, 2023
7317e61
[web] Fix tests
joseivanlopez Oct 20, 2023
c99a98e
run probe and propose after registration/deregistration
jreidinger Oct 20, 2023
133acc8
fix return statement
jreidinger Oct 20, 2023
aa57609
[rust] Adapt software proxies and client
joseivanlopez Oct 23, 2023
847952e
[service] Rubocop
joseivanlopez Oct 23, 2023
56d8935
Merge branch 'master' into registration-dbus-api
joseivanlopez Oct 23, 2023
a78702b
Add missing package to setup script
joseivanlopez Oct 23, 2023
aa32a97
fix writting credentials to target system
jreidinger Oct 23, 2023
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
1 change: 1 addition & 0 deletions service/etc/agama.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ALP-Dolomite:
archs: ppc64
optional_packages: null
base_product: ALP-Dolomite
version: "1.0"

security:
tpm_luks_open: true
Expand Down
27 changes: 22 additions & 5 deletions service/lib/agama/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2022] SUSE LLC
# Copyright (c) [2022-2023] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -92,10 +92,7 @@ def products

# cannot use `data` here to avoid endless loop as in data we use
# pick_product that select product from products
@products = @pure_data["products"].select do |_key, value|
value["archs"].nil? ||
Yast2::ArchFilter.from_string(value["archs"]).match?
end
@products = @pure_data["products"].select { |_k, v| arch_match?(v["archs"]) }
end

# Whether there are more than one product
Expand All @@ -120,6 +117,20 @@ def merge(config)
Config.new(simple_merge(data, config.data))
end

def arch_elements_from(*keys, property: nil)
keys.map!(&:to_s)
elements = pure_data.dig(*keys)
return [] unless elements

elements.map do |element|
if !element.is_a?(Hash)
element
elsif arch_match?(element["archs"])
property ? element[property.to_s] : element
end
end.compact
end

private

# Simple deep merge
Expand All @@ -138,5 +149,11 @@ def simple_merge(a_hash, another_hash)
end
end
end

def arch_match?(archs)
return true if archs.nil?

Yast2::ArchFilter.from_string(archs).match?
end
end
end
18 changes: 9 additions & 9 deletions service/lib/agama/dbus/clients/software.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2022] SUSE LLC
# Copyright (c) [2022-2023] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -20,18 +20,18 @@
# find current contact information at www.suse.com.

require "agama/dbus/clients/base"
require "agama/dbus/clients/with_service_status"
require "agama/dbus/clients/with_issues"
require "agama/dbus/clients/with_progress"
require "agama/dbus/clients/with_validation"
require "agama/dbus/clients/with_service_status"

module Agama
module DBus
module Clients
# D-Bus client for software configuration
class Software < Base
include WithServiceStatus
include WithIssues
include WithProgress
include WithValidation
include WithServiceStatus

TYPES = [:package, :pattern].freeze
private_constant :TYPES
Expand All @@ -55,7 +55,7 @@ def service_name
#
# @return [Array<Array<String, String>>] name and display name of each product
def available_products
dbus_object["org.opensuse.Agama.Software1"]["AvailableBaseProducts"].map do |l|
dbus_object["org.opensuse.Agama.Software1"]["AvailableProducts"].map do |l|
l[0..1]
end
end
Expand All @@ -64,7 +64,7 @@ def available_products
#
# @return [String, nil] name of the product
def selected_product
product = dbus_object["org.opensuse.Agama.Software1"]["SelectedBaseProduct"]
product = dbus_object["org.opensuse.Agama.Software1"]["SelectedProduct"]
return nil if product.empty?

product
Expand Down Expand Up @@ -170,8 +170,8 @@ def remove_resolvables(unique_id, type, resolvables, optional: false)
# @param block [Proc] Callback to run when a product is selected
def on_product_selected(&block)
on_properties_change(dbus_object) do |_, changes, _|
base_product = changes["SelectedBaseProduct"]
block.call(base_product) unless base_product.nil?
product = changes["SelectedProduct"]
block.call(product) unless product.nil?
end
end

Expand Down
Loading