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

Registration support #869

Merged
merged 109 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 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
5f6fc37
Merge pull request #791 from openSUSE/registration-dbus-api
joseivanlopez Oct 24, 2023
eb2dca0
Merge branch 'master' into registration
joseivanlopez Oct 27, 2023
48e0644
Merge branch 'master' into registration
joseivanlopez Nov 3, 2023
d14ae23
Merge branch 'master' into registration
joseivanlopez Nov 3, 2023
ba7f482
[service] Adapt to changes in master
joseivanlopez Nov 3, 2023
a6752fc
Merge pull request #847 from joseivanlopez/merge-master-registration
joseivanlopez Nov 3, 2023
03e29fa
Merge branch 'master' into registration
joseivanlopez Nov 14, 2023
6709506
[service] Adapt product translations to changes in registration
joseivanlopez Nov 15, 2023
d9556cb
Merge pull request #867 from openSUSE/product-localized-description
joseivanlopez Nov 15, 2023
1d27be9
[web] Add product manager to software client
joseivanlopez Oct 24, 2023
4038cbe
[web] Add registration to software client
joseivanlopez Oct 24, 2023
911bcdc
[web] Add product provider
joseivanlopez Oct 25, 2023
f88225d
[web] Allow to configure the rows of SectionSkeleton
joseivanlopez Oct 25, 2023
9ca8e76
[web] Add product section to overview
joseivanlopez Oct 25, 2023
4334e9a
[web] Adapt title of overview page
joseivanlopez Oct 25, 2023
b8524bd
[web] Move issues management to client
joseivanlopez Oct 26, 2023
bd54a8d
[web] Show product and software issues
joseivanlopez Oct 26, 2023
59ca28e
[web] Adapt to changes in master
joseivanlopez Oct 27, 2023
7735ace
[web] Extract product selection form to separate component
joseivanlopez Oct 27, 2023
825b5e3
[web] Move product selection to products components
joseivanlopez Oct 27, 2023
e3122a4
[web] Create ProductSelector instead of form
joseivanlopez Oct 30, 2023
a483046
[web] Change icon for summary
joseivanlopez Oct 30, 2023
3bf7a23
[web] Fix method for getting the registration
joseivanlopez Nov 2, 2023
5738769
[web] Add EmailInput component
joseivanlopez Nov 2, 2023
85caaef
[web] Some code improvements
joseivanlopez Nov 3, 2023
403cdde
[web] Add product page
joseivanlopez Nov 3, 2023
33cf3a6
[service] Do not automatically probe software after registration
joseivanlopez Nov 3, 2023
298dd3c
[web] Fix tests
joseivanlopez Nov 3, 2023
310ce71
[web] Remove link for changing the product
joseivanlopez Nov 3, 2023
608cd40
[web] Add registration section to product page
joseivanlopez Nov 14, 2023
354805c
[web] Use password field for registration code
joseivanlopez Nov 14, 2023
fae9410
[web] Improve product section
joseivanlopez Nov 14, 2023
0e6c2fd
[web] Several improvements from review
joseivanlopez Nov 14, 2023
e5e7510
[web] Use early return
joseivanlopez Nov 15, 2023
f6d5bfe
[service] Remove repos from ALP-Dolomite config
joseivanlopez Nov 15, 2023
a165dd3
Merge pull request #814 from openSUSE/registration-ui
joseivanlopez Nov 15, 2023
12d4ba4
[service] Changelog
joseivanlopez Nov 15, 2023
acc1cf2
[web] Changelog
joseivanlopez Nov 15, 2023
29665b1
[rust] Changelog
joseivanlopez Nov 15, 2023
affdacb
Merge branch 'master' into registration
joseivanlopez Nov 15, 2023
4b55006
Merge branch 'master' into registration
joseivanlopez Nov 15, 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
53 changes: 53 additions & 0 deletions doc/dbus/bus/org.opensuse.Agama.Software1.Product.bus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1/Product">
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" direction="out" type="s"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="Set">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="val" direction="in" type="v"/>
</method>
<method name="GetAll">
<arg name="interface_name" direction="in" type="s"/>
<arg name="value" direction="out" type="a{sv}"/>
</method>
<signal name="PropertiesChanged">
<arg name="interface" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.opensuse.Agama.Software1.Product">
<method name="SelectProduct">
<arg name="id" direction="in" type="s"/>
<arg name="result" direction="out" type="(us)"/>
</method>
<property type="a(ssa{sv})" name="AvailableProducts" access="read"/>
<property type="s" name="SelectedProduct" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Issues">
<property type="a(ssuu)" name="All" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Registration">
<method name="Register">
<arg name="reg_code" direction="in" type="s"/>
<arg name="options" direction="in" type="a{sv}"/>
<arg name="result" direction="out" type="(us)"/>
</method>
<method name="Deregister">
<arg name="result" direction="out" type="(us)"/>
</method>
<property type="s" name="RegCode" access="read"/>
<property type="s" name="Email" access="read"/>
<property type="u" name="Requirement" access="read"/>
</interface>
</node>
25 changes: 15 additions & 10 deletions doc/dbus/bus/org.opensuse.Agama.Software1.bus.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1">
<node name="Product"/>
<node name="Proposal"/>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
Expand Down Expand Up @@ -28,12 +29,18 @@
</signal>
</interface>
<interface name="org.opensuse.Agama.Software1">
<method name="SelectProduct">
<arg name="ProductID" direction="in" type="s"/>
</method>
<method name="ListPatterns">
<arg name="Filtered" direction="in" type="b"/>
<arg name="Result" direction="out" type="a{s(ssssi)}"/>
<arg name="Result" direction="out" type="a{s(sssss)}"/>
</method>
<method name="AddPattern">
<arg name="id" direction="in" type="s"/>
</method>
<method name="RemovePattern">
<arg name="id" direction="in" type="s"/>
</method>
<method name="SetUserPatterns">
<arg name="ids" direction="in" type="as"/>
</method>
<method name="ProvisionsSelected">
<arg name="Provisions" direction="in" type="as"/>
Expand All @@ -54,8 +61,10 @@
</method>
<method name="Finish">
</method>
<property type="a(ssa{sv})" name="AvailableBaseProducts" access="read"/>
<property type="s" name="SelectedBaseProduct" access="read"/>
<property type="a{sy}" name="SelectedPatterns" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Issues">
<property type="a(ssuu)" name="All" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Progress">
<property type="u" name="TotalSteps" access="read"/>
Expand All @@ -66,8 +75,4 @@
<property type="aa{sv}" name="All" access="read"/>
<property type="u" name="Current" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Validation">
<property type="as" name="Errors" access="read"/>
<property type="b" name="Valid" access="read"/>
</interface>
</node>
1 change: 1 addition & 0 deletions doc/dbus/bus/org.opensuse.Agama1.Registration.bus.xml
38 changes: 38 additions & 0 deletions doc/dbus/org.opensuse.Agama.Software1.Product.doc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1/Product">
<interface name="org.opensuse.Agama.Software1.Product">
<!--
Selects a product.
-->
<method name="SelectProduct">
<!--
Product ID. See #AvailableProducts.
-->
<arg name="id" direction="in" type="s"/>
<!--
Result code and description.

Possible result codes are:
# 0: successfully selected
# 1: given product is already selected
# 2: current product must be deregistered before selecting a new product
# 3: given product is unknown
-->
<arg name="result" direction="out" type="(us)"/>
</method>
<!--
Available products for installation.

For each product, it returns:
s (product ID)
s (product name)
a{sv}
description s
-->
<property type="a(ssa{sv})" name="AvailableProducts" access="read"/>
<!--
ID of the currently selected product.
-->
<property type="s" name="SelectedProduct" access="read"/>
</interface>
</node>
41 changes: 41 additions & 0 deletions doc/dbus/org.opensuse.Agama.Software1.doc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1">
<node name="Product"/>
<node name="Proposal"/>

<interface name="org.opensuse.Agama.Software1">
<method name="ListPatterns">
<arg name="Filtered" direction="in" type="b"/>
<arg name="Result" direction="out" type="a{s(sssss)}"/>
</method>
<method name="AddPattern">
<arg name="id" direction="in" type="s"/>
</method>
<method name="RemovePattern">
<arg name="id" direction="in" type="s"/>
</method>
<method name="SetUserPatterns">
<arg name="ids" direction="in" type="as"/>
</method>
<method name="ProvisionsSelected">
<arg name="Provisions" direction="in" type="as"/>
<arg name="Result" direction="out" type="ab"/>
</method>
<method name="IsPackageInstalled">
<arg name="Name" direction="in" type="s"/>
<arg name="Result" direction="out" type="b"/>
</method>
<method name="UsedDiskSpace">
<arg name="SpaceSize" direction="out" type="s"/>
</method>
<method name="Probe">
</method>
<method name="Propose">
</method>
<method name="Install">
</method>
<method name="Finish">
</method>
<property type="a{sy}" name="SelectedPatterns" access="read"/>
</interface>
</node>
4 changes: 3 additions & 1 deletion doc/dbus/org.opensuse.Agama1.Progress.doc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/opensuse/Agama/Software1">
<node name="Proposal"></node>
<node name="Product"/>
<node name="Proposal"/>

<!--
org.opensuse.Agama1.Progress:
The main object of a service implements the Progress interface
Expand Down
76 changes: 76 additions & 0 deletions doc/dbus/org.opensuse.Agama1.Registration.doc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1/Product">
<!--
Interface for registering a product.
-->
<interface name="org.opensuse.Agama1.Registration">
<!--
Registers the currently selected product.
-->
<method name="Register">
<!--
Registration code.
-->
<arg name="reg_code" direction="in" type="s"/>
<!--
Email s
-->
<arg name="options" direction="in" type="a{sv}"/>
<!--
Result code and description.

Possible result codes are:
0: success
1: missing product
2: already registered
3: registration not required
4: network error
5: timeout error
6: api error
7: missing credentials
8: incorrect credentials
8: invalid certificate
10: internal error (e.g., parsing json data)
-->
<arg name="result" direction="out" type="(us)"/>
</method>
<!--
Deregisters the currently selected product.
-->
<method name="Deregister">
<!--
Result code and description.

Possible result codes are:
0: success
1: missing product
2: not registered yet
3: network error
4: timeout error
5: api error
6: missing credentials
7: incorrect credentials
8: invalid certificate
9: internal error (e.g., parsing json data)
-->
<arg name="result" direction="out" type="(us)"/>
</method>
<!--
Registration code. Empty if the current product is not registered yet.
-->
<property type="s" name="RegCode" access="read"/>
<!--
Email used for the registration. Empty if the current product is not registered yet.
-->
<property type="s" name="Email" access="read"/>
<!--
Indicates the registration requirement of the currently selected product.

Possible values:
0: registration is not required.
1: registration is optional.
2: registration is mandatory.
-->
<property type="u" name="Requirement" access="read"/>
</interface>
</node>
10 changes: 0 additions & 10 deletions products.d/ALP-Dolomite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ translations:
bezpečnost pro poskytování úplného minima ke spuštění úloh a služeb v
kontejnerech nebo virtuálních strojích.
software:
installation_repositories:
- url: https://updates.suse.com/SUSE/Products/ALP-Dolomite/1.0/x86_64/product/
archs: x86_64
- url: https://updates.suse.com/SUSE/Products/ALP-Dolomite/1.0/aarch64/product/
archs: aarch64
- url: https://updates.suse.com/SUSE/Products/ALP-Dolomite/1.0/s390x/product/
archs: s390
- url: https://updates.suse.com/SUSE/Products/ALP-Dolomite/1.0/ppc64le/product/
archs: ppc

mandatory_patterns:
- alp_base_zypper
- alp_cockpit
Expand Down
4 changes: 2 additions & 2 deletions rust/agama-lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ pub enum ServiceError {
DBus(#[from] zbus::Error),
#[error("Could not connect to Agama bus at '{0}'")]
DBusConnectionError(String, #[source] zbus::Error),
#[error("Unknown product '{0}'. Available products: '{1:?}'")]
UnknownProduct(String, Vec<String>),
// it's fine to say only "Error" because the original
// specific error will be printed too
#[error("Error: {0}")]
Anyhow(#[from] anyhow::Error),
#[error("Wrong user parameters: '{0:?}'")]
WrongUser(Vec<String>),
#[error("Error: {0}")]
UnsuccessfulAction(String),
}

#[derive(Error, Debug)]
Expand Down
25 changes: 18 additions & 7 deletions rust/agama-lib/src/software/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::proxies::Software1Proxy;
use super::proxies::SoftwareProductProxy;
use crate::error::ServiceError;
use serde::Serialize;
use zbus::Connection;
Expand All @@ -16,21 +16,21 @@ pub struct Product {

/// D-Bus client for the software service
pub struct SoftwareClient<'a> {
software_proxy: Software1Proxy<'a>,
product_proxy: SoftwareProductProxy<'a>,
}

impl<'a> SoftwareClient<'a> {
pub async fn new(connection: Connection) -> Result<SoftwareClient<'a>, ServiceError> {
Ok(Self {
software_proxy: Software1Proxy::new(&connection).await?,
product_proxy: SoftwareProductProxy::new(&connection).await?,
})
}

/// Returns the available products
pub async fn products(&self) -> Result<Vec<Product>, ServiceError> {
let products: Vec<Product> = self
.software_proxy
.available_base_products()
.product_proxy
.available_products()
.await?
.into_iter()
.map(|(id, name, data)| {
Expand All @@ -50,11 +50,22 @@ impl<'a> SoftwareClient<'a> {

/// Returns the selected product to install
pub async fn product(&self) -> Result<String, ServiceError> {
Ok(self.software_proxy.selected_base_product().await?)
Ok(self.product_proxy.selected_product().await?)
}

/// Selects the product to install
pub async fn select_product(&self, product_id: &str) -> Result<(), ServiceError> {
Ok(self.software_proxy.select_product(product_id).await?)
let result = self.product_proxy.select_product(product_id).await?;

match result {
(0, _) => Ok(()),
(3, description) => {
let products = self.products().await?;
let ids: Vec<String> = products.into_iter().map(|p| p.id).collect();
let error = format!("{0}. Available products: '{1:?}'", description, ids);
Err(ServiceError::UnsuccessfulAction(error))
}
(_, description) => Err(ServiceError::UnsuccessfulAction(description)),
}
}
}
Loading
Loading