Skip to content

Commit

Permalink
Merge pull request #70 from yast/new-dbus-api
Browse files Browse the repository at this point in the history
New D-Bus API
  • Loading branch information
imobachgs authored Mar 15, 2022
2 parents be299db + e4c5358 commit 99e23fa
Show file tree
Hide file tree
Showing 92 changed files with 3,427 additions and 1,541 deletions.
113 changes: 109 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: CI
on: [push, pull_request]

jobs:
build:

frontend_build:
runs-on: ubuntu-latest

defaults:
Expand Down Expand Up @@ -33,12 +32,118 @@ jobs:
# run: npm run build --if-present

- name: Run the tests and generate coverage report
run: npm test \"src/**/*.test.js\" -- --coverage
run: npm test -- --coverage

- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: ./web
path-to-lcov: ./web/coverage/lcov.info
flag-name: Unit
flag-name: frontend
parallel: true

frontend-linter:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./web

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'web/package-lock.json'

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

backend_tests:
runs-on: ubuntu-latest
env:
COVERAGE: 1

defaults:
run:
working-directory: ./service

strategy:
fail-fast: false
matrix:
distro: [ "tumbleweed" ]

container:
image: registry.opensuse.org/yast/head/containers_${{matrix.distro}}/yast-ruby

steps:

- name: Git Checkout
uses: actions/checkout@v2

- name: Install Ruby development files
run: zypper --non-interactive install gcc gcc-c++ make openssl-devel ruby-devel npm augeas-devel

- name: Install RubyGems dependencies
run: bundle config set --local with 'development' && bundle install

- name: Run the tests and generate coverage report
run: bundle exec rspec test/**/*_test.rb

- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: ./service
path-to-lcov: ./service/coverage/lcov.info
flag-name: backend
parallel: true

backend-linter:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./service

strategy:
fail-fast: false
matrix:
distro: [ "leap_latest" ]

container:
image: registry.opensuse.org/yast/head/containers_${{matrix.distro}}/yast-ruby

steps:

- name: Git Checkout
uses: actions/checkout@v2

- name: Rubocop
run: /usr/bin/rubocop.*-1.24.1

finish:
runs-on: ubuntu-latest

needs: [frontend_build, backend_tests]

steps:

- name: Coveralls Finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

70 changes: 70 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# D-Installer Contribution Guidelines

This is an open source project and as such it welcomes all kinds of
contributions. If you decide to contribute, please follow these guidelines to
ensure the process is effective and pleasant both for you and the main
developers.

There are two main forms of contribution: providing feedback and performing code
changes.

## Feedback

This proof of concept is currently driven by the YaST development team. The
best way to reach us is at the [#yast](https://web.libera.chat/#yast) IRC
channel on libera.chat or using the [YaST development mailing
list](http://lists.opensuse.org/yast-devel/).

## Code Changes

We welcome all kinds of code contributions. However, before making any
non-trivial contribution, get in touch with us first — this can prevent wasted
effort on both sides. Also, have a look at the Code Structure section below.

To send us your code change, use GitHub pull requests. The workflow is as
follows:

1. Fork the project.

2. Create a topic branch based on `master`.

3. Implement your change, including tests if possible.

4. Publish the branch and create a pull request.

5. YaST developers will review your change and possibly point out issues.
Adapt the code under their guidance until they are all resolved.

6. Finally, the pull request will get merged or rejected.

See also [GitHub's guide on
contributing](https://help.github.com/articles/fork-a-repo).

If you want to do multiple unrelated changes, use separate branches and pull
requests.

## Code Structure

This section contains a small unsorted list of the principles and guidelines we
are trying to observe while developing D-Installer.

The project is divided in two big parts that communicate with each other - the
installer service written in Ruby (code located at the `service` directory) and
the web interface written in Javascript that currently relies on the Cockpit
infrastructure for some operations (code at the `web` directory).

### Service Structure

The service part written in Ruby is separated into two layers, a backend (in the
Ruby namespace `DInstaller`) and the D-Bus interface on top (namespace
`DInstaller::DBus`).

Although there can be only one installation in progress, the service is
structured to avoid the abuse of the Singleton programming pattern as mechanism
to share the state information. The classes containing the business logic (eg.
`DInstaller::Manager`, `DInstaller::Software`) are completely independent and
decoupled from the ones providing the D-Bus layer. When an object of the
`DInstaller::DBus` namespace is initialized, it receives the corresponding
business logic object as argument. That's more robust than making those business
logic objects singleton and allowing the D-Bus related ones to simply access
those singletons.
2 changes: 1 addition & 1 deletion PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The process to release a new version can be summarized in these steps:
5. Commit the changes.

If you need to modify the `spec` file, please, use the `gem2rpm` tool. The configuration is [included
in the repository](./yastd/package/gem2rpm.yml). To regenerate the spec, just type:
in the repository](./service/package/gem2rpm.yml). To regenerate the spec, just type:

gem2rpm --config gem2rpm.yml d-installer-0.1.gem > rubygem-d-installer.spec

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service. At first sight, we have identified these components:

## Quickstart

:warning: :warning: **This is a proof-of-concept so use a virtual machine to give it a try.** :warning: :warning:
:warning: :warning: **This is a proof-of-concept so use a virtual machine to give it a try.** :warning: :warning:

The easiest way to give D-Installer a try is to install the
[rubygem-d-installer](https://build.opensuse.org/package/show/YaST:Head:D-Installer/rubygem-d-installer)
Expand Down Expand Up @@ -63,25 +63,25 @@ service using the D-Bus interface it provides.

Beware that `d-installer` must run as root (like YaST does) to do hardware probing, partition the
disks, install the software and so on. So you need to tell dbus about the service by copying
`yastd/share/dbus.conf` to `/etc/dbus-1/system.d/d-installer.conf`.
`service/share/dbus.conf` to `/usr/share/dbus-1/system.d/org.opensuse.DInstaller.conf`.

To run the service, type:

cd yastd
cd service
bundle install
sudo bundle exec bin/d-installer

To check that `d-installer` is working, you can use a tool like
[busctl](https://www.freedesktop.org/wiki/Software/dbus/) (or
[D-Feet](https://wiki.gnome.org/Apps/DFeet)) if you prefer a graphical one:

busctl call org.opensuse.YaST /org/opensuse/YaST/Installer \
org.opensuse.YaST.Installer GetDisks
busctl call org.opensuse.DInstaller /org/opensuse/DInstaller/Language1 \
org.opensuse.DInstaller.Language1 AvailableLanguages

If you want to get the properties, just type:

busctl call org.opensuse.YaST /org/opensuse/YaST/Installer \
org.freedesktop.DBus.Properties GetAll s org.opensuse.YaST.Installer
busctl call org.opensuse.DInstaller /org/opensuse/DInstaller/Language1 \
org.freedesktop.DBus.Properties GetAll s org.opensuse.DInstaller.Language1

### Starting the web-based user interface

Expand Down
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ sudo systemctl start d-installer
# set 'linux' as password
echo "linux:Nk1RhI1GqlxdA" | sudo chpasswd -e linux

xdg-open http://localhost:9090/cockpit/static/installer/index.html
xdg-open http://localhost:9090/cockpit/static/installer/index.html
44 changes: 41 additions & 3 deletions yastd/dbus_api.md → doc/dbus_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ We use these resources to get more familiar with D-Bus API designing.
- network manager design https://people.freedesktop.org/~lkundrak/nm-docs/spec.html
- anakonda D-Bus API ( spread in `*_interface.py` files https://github.com/rhinstaller/anaconda/tree/master/pyanaconda/modules

## get the list of available languages
## Language

Iface: o.o.YaST.Installer1.Language

Expand Down Expand Up @@ -78,7 +78,7 @@ identifiers: maybe LanguageTag https://www.rubydoc.info/github/yast/yast-package
- see https://tools.ietf.org/html/rfc4647 Matching of Language Tags
- see https://lists.opensuse.org/archives/list/[email protected]/message/D52PSZ7TRID2RVM6CE6K2C2RUNNGOS6Z/

## get the list of base products
## Base Product

Iface: o.o.YaST.Installer1.Software

Expand Down Expand Up @@ -111,7 +111,7 @@ Iface: o.o.YaST.Installer1.Software
- PropertiesChanged ( only standard one from org.freedesktop.DBus.Properties interface )


## interact with the storage proposal
## Storage

### Iface: o.o.YaST.Installer1.Storage

Expand Down Expand Up @@ -200,3 +200,41 @@ Inspired by Udisks2.Partition

- Drive -> o.o.YaST.Installer1.Storage.Drive
where partitions live

## Users

### iface o.o.Installer1.Users

#### methods:

- SetRootPassword(string value, boolean encrypted) -> void
sets root password. If encrypted is set to true, it means that already encrypted password
is send.
example:

SetRootPassword("test", false) -> ()

- SetRootSSHKey(string value) -> void
set root ssh public keys. Use empty string to unset it.
example:

SetRootSSHKey("idrsa long key") -> ()

- SetFirstUser(string FullName, string UserName, string Password, boolean AutoLogin, map AdditionalData) -> void
sets one non root user after installation. FullName and UserName has to follow restrictions
for respective passwd entry. To unset it use empty UserName.
example:

SetRootSSHKey("idrsa long key") -> ()

#### Properties (all read only):

- RootPasswordSet -> boolean
whenever root password will be set by installer

- RootSSHKey -> string
root public ssh key that can be used to login to machine
Can be empty which means not set

- FirstUser -> struct( string FullName, string UserName, boolean AutoLogin, map AdditionalData)
info about first user to set. if Username is empty, it means not set and other values can be ignored
File renamed without changes.
7 changes: 3 additions & 4 deletions yastd/.rubocop.yml → service/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ AllCops:
Exclude:
- vendor/**/*

Metrics/BlockLength:
# ruby-dbus DSL can have long blocks
Exclude:
- lib/yast2/dbus/installer.rb
# assignment in method calls is used to document some params
Lint/UselessAssignment:
Enabled: false
4 changes: 4 additions & 0 deletions yastd/Gemfile → service/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
source "https://rubygems.org"

gemspec

group :development do
gem "byebug"
end
Loading

0 comments on commit 99e23fa

Please sign in to comment.