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 iSCSI #402

Merged
merged 10 commits into from
Feb 17, 2023
Merged

Conversation

joseivanlopez
Copy link
Contributor

@joseivanlopez joseivanlopez commented Jan 20, 2023

Problem

D-Installer does not provide a way of connecting to iSCSI targets yet.

https://trello.com/c/iQ7BCexU/3261-5-d-installer-d-bus-interface-configure-the-iscsi-initiator-and-the-iscsi-targets

Solution

Extend current D-Bus API of the storage service in order to support iSCSI.

/DInstaller/Storage1
  .ObjectManager
  .DInstaller.ServiceStatus1
  .DInstaller.Progress1
  .DInstaller.Validation1
  .DInstaller.Storage1
  .DInstaller.Storage1.Proposal.Calculator
  .DInstaller.Storage1.ISCSI.Initiator
/DInstaller/Storage1/Proposal
  .DInstaller.Storage1.Proposal
/DInstaller/Storage1/iscsi_nodes/[0-9]+
  .DInstaller.Storage1.ISCSI.Node

Now the main object /DInstaller/Storage1 implements a new interface .DInstaller.Storage1.ISCSI.Initiator . That interface offers methods for configuring the iSCSI initiator, performing discovey, and deleting node.

Discovered nodes are dynamically exported in the path /DInstaller/Storage1/iscsi_nodes/[0-9]+, and such nodes implements the interface .DInstaller.Storage1.ISCSI.Node. A node allows to login and logout.

Follow-up:

  • Configure offload card [create issue].
  • Validate proposal after changing iSCSI nodes [create issue].

Examples

Configure iSCSI initiator name:

$ busctl --address unix:path=/run/d-installer/bus set-property org.opensuse.DInstaller.Storage /org/opensuse/DInstaller/Storage1 org.opensuse.DInstaller.Storage1.ISCSI.Initiator InitiatorName s "iqn.1996-04.de.suse:01:351e6d6249"

Perform discovery

$ busctl --address unix:path=/run/d-installer/bus call org.opensuse.DInstaller.Storage /org/opensuse/DInstaller/Storage1 org.opensuse.DInstaller.Storage1.ISCSI.Initiator Discover sua{sv} 192.168.100.215 3260 4 Username s testi Password s testi ReverseUsername s testt ReversePassword s testt

Login

$ busctl --address unix:path=/run/d-installer/bus call org.opensuse.DInstaller.Storage /org/opensuse/DInstaller/Storage1/iscsi_nodes/2 org.opensuse.DInstaller.Storage1.ISCSI.Node Login a{sv} 5 Username s testi Password s testi ReverseUsername s testt ReversePassword s testt Startup s onboot

Logut

$ busctl --address unix:path=/run/d-installer/bus call org.opensuse.DInstaller.Storage /org/opensuse/DInstaller/Storage1/iscsi_nodes/1 org.opensuse.DInstaller.Storage1.ISCSI.Node Logout

Delete

$ busctl --address unix:path=/run/d-installer/bus call org.opensuse.DInstaller.Storage /org/opensuse/DInstaller/Storage1 org.opensuse.DInstaller.Storage1.ISCSI.Initiator Delete o /org/opensuse/DInstaller/Storage1/iscsi_nodes/1

Testing

  • Added unit tests
  • Tested manually

Screenshots

Screenshot from 2023-02-10 16-56-59

@coveralls
Copy link

coveralls commented Jan 20, 2023

Coverage Status

Coverage: 78.429% (+0.7%) from 77.731% when pulling b802a6d on joseivanlopez:iscsi-dbus into a457bfc on yast:master.

@joseivanlopez joseivanlopez force-pushed the iscsi-dbus branch 12 times, most recently from 0912902 to 6dbe4c3 Compare January 27, 2023 14:04
@mvidner
Copy link
Contributor

mvidner commented Jan 27, 2023

Not directly applicable right now, but eventually I hope:
"Document D-Bus API inside introspection XML" #415

@joseivanlopez joseivanlopez force-pushed the iscsi-dbus branch 2 times, most recently from d9b2576 to 7e1739b Compare February 10, 2023 13:12
@mvidner
Copy link
Contributor

mvidner commented Feb 13, 2023

In the review somebody mentioned that service/lib/dinstaller/dbus/storage/manager.rb was getting quite big, with all the interfaces it needs to have.

One way to address it would be to put each of the interfaces in its own Module... and we're already doing it with DInstaller::DBus::Interfaces::Progress, ServiceStatus an Validation.

Perhaps doing the same for all the remaining interfaces would solve the problem? Or split the manager object up according to the responsibilities?

If ruby-dbus can get an improvement to help with it, I'd happily add it, but so far I don't see one.

@joseivanlopez
Copy link
Contributor Author

joseivanlopez commented Feb 13, 2023

In the review somebody mentioned that service/lib/dinstaller/dbus/storage/manager.rb was getting quite big, with all the interfaces it needs to have.

One way to address it would be to put each of the interfaces in its own Module... and we're already doing it with DInstaller::DBus::Interfaces::Progress, ServiceStatus an Validation.

Perhaps doing the same for all the remaining interfaces would solve the problem? Or split the manager object up according to the responsibilities?

If ruby-dbus can get an improvement to help with it, I'd happily add it, but so far I don't see one.

The problem I see is that the interface properties and methods are defined by the dbus object. If a dbus object implements quite some ifaces, then it has to define all the methods for each intereface, which implies to have a dbus object with a lot of possibly unrelated logic. Moreover, we need to pay special attention to property/method name collition, specially when importing interfaces from a module (e.g., Progress iface).

I would like to have some kind of composition or similar approach for aisolating the interface logic and definition. An idea could be to do something similar to what a service does with exporting D-Bus objects. For example, interfces are defined in its own class, and then the D-Bus object add them:

class MyObject < DBus::Object
  def initialize
    foo_iface = DBus::Interface.new
    bar_iface = DBus::Interface.new

    add_interfaces foo_iface, bar_iface
  end
end

We could workaround it by implementing some kind of Interface and Object wrappers around DBus::Object in D-Installer, but maybe it would be better to do it directly in ruby-dbus.

And maybe, it would also open the door to dynamically removing interfaces in the future: remove_interface foo_iface.

@mvidner
Copy link
Contributor

mvidner commented Feb 13, 2023

If a dbus object implements quite some ifaces, then it has to define all the methods for each intereface, which implies to have a dbus object with a lot of possibly unrelated logic.

But that problem is also true if we leave out D-Bus out of the picture, and then it looks to me like an ordinary OOP design problem: mixing too many responsibilities in a single class.

I would solve that by using different classes/objects. Here, the ISCSI.Initiator interface is IMHO a natural case for one.

Even if the objects lifetimes are tightly coupled (so you could take that a reason to combine them in a single class) I'd split them up for clarity and ease of maintenance.

doc/dbus_api.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ancorgs ancorgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just releasing some comments (I did hit the wrong button when adding them).

service/lib/dinstaller/storage/iscsi/initiator.rb Outdated Show resolved Hide resolved
service/lib/dinstaller/storage/iscsi/manager.rb Outdated Show resolved Hide resolved
@joseivanlopez joseivanlopez marked this pull request as ready for review February 15, 2023 16:19
Copy link
Contributor

@ancorgs ancorgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it looks pretty nice. Great work. But I added a couple of comments.

Copy link
Contributor

@ancorgs ancorgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great work!

@joseivanlopez joseivanlopez merged commit ee368a0 into agama-project:master Feb 17, 2023
@joseivanlopez joseivanlopez mentioned this pull request Mar 16, 2023
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Mar 21, 2023
https://build.opensuse.org/request/show/1073333
by user IGonzalezSosa + dimstar_suse
- Version 0.8
  * Adapted the service configuration for the s390x architecture
    (gh#agama-project/agama#469).
  * Fix gem2rpm configuration requiring the dbus-1-common package
    (gh#agama-project/agama#470).
  * Fix gem2rpm configuration to include YaST2 dependencies
    (gh#agama-project/agama#459).
  * Write /iguana/mountlist if running on Iguana
    (gh#agama-project/agama#445).
  * Add D-Bus API for iSCSI (gh#agama-project/agama#402).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants