Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 1 addition & 59 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*

# Web interface logs directory
.log
.yardoc/
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ service. At first sight, we have identified these components:
* A user interface. For this experiment, we have decided to use a
[Cockpit](https://cockpit-project.org/) module.

## Requirements

To build and run this software you need a few tools. To install them on openSUSE
Tumbleweed just type:

$ sudo zypper in gcc gcc-c++ make openssl-devel ruby-devel npm
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 to document it


## yastd

`yastd` is a YaST-based service that is able to install a system. You can interact with such a
Expand All @@ -23,7 +30,8 @@ installs the software and so on. So you need to tell dbus about the service by c
To run the service, type:

$ cd yastd
$ sudo ruby bin/yastd
$ bundle install
$ sudo bunle exec bin/yastd

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:
Expand All @@ -46,26 +54,25 @@ JavaScript, etc.). In the future, we could replace it with anything even smaller

To start the proxy, just type:

$ cd yastd-proxy
$ bundle install
$ rails s -e production
$ cd yastd-proxy
$ bundle install
$ bundle exec bin/yastd-proxy

Now you can try to access the D-Bus service using cURL:

$ curl http://localhost:3000/properties
[{"Disk":"/dev/sda","Product":"openSUSE-Addon-NonOss","Language":"en_US","Status":0}]
$ curl -X PUT -d value=/dev/sda http://localhost:3000/properties/Disk
$ curl -X POST -d meth=GetStorage http://localhost:3000/calls
[{"mount":"/boot/efi","device":"/dev/sda1","type":"vfat","size":"536870912"},...

$ curl http://localhost:3000/properties
[{"Disk":"/dev/sda","Product":"openSUSE-Addon-NonOss","Language":"en_US","Status":0}]
$ curl -X PUT -d value=/dev/sda http://localhost:3000/properties/Disk
$ curl -X POST -d meth=GetStorage http://localhost:3000/calls
[{"mount":"/boot/efi","device":"/dev/sda1","type":"vfat","size":"536870912"},...

## Web UI

The current UI is a small web application built with [React](https://reactjs.org/). It allows to set a few installation parameters and start the installation (not implemented yet).

$ cd we
$ npm install
$ npm start
$ cd web
$ npm install
$ npm start

Point your browser to http://localhost:3000 and enjoy!

Expand Down
3 changes: 3 additions & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Web interface logs directory
.log
1 change: 1 addition & 0 deletions web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function App() {
loadOptions(dispatch);
loadInstallation(dispatch);
registerWebSocketHandler(event => {
// TODO: handle other events
console.log("WebSocket Event", event);
const { data } = event;
const changedKeys = Object.keys(JSON.parse(data));
Expand Down
4 changes: 3 additions & 1 deletion web/src/lib/InstallerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default class InstallerClient {
}

async startInstallation() {
return await axios.put(`${this.url}/installation.json`, { action: 'start' });
return await axios.post(
`${this.url}/calls`, { meth: "Start" }
);
}
}
4 changes: 4 additions & 0 deletions yastd-proxy/bin/yastd-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ EM.run do
ws.send changes.to_json
end

client.on_status_change do |status_id|
ws.send({ event: "StatusChanged", status: status_id }.to_json)
end

EventMachine::PeriodicTimer.new(0.5) { client.dispatch }
end
end
Expand Down
10 changes: 10 additions & 0 deletions yastd-proxy/lib/yastd-proxy/dbus_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,22 @@ def on_property_change(&block)
end
end

# Runs a block when the status changes
#
# @param block [Proc] Block to run
def on_status_change(&block)
installer_obj[IFACE].on_signal("StatusChanged") do |status|
block.call(status)
end
end

# Dispatch the message queue in a non-blocking fashion
#
# This method runs any callback defined using the #on_property_change for
# each change.
#
# @see #on_property_change
# @see #on_status_change
def dispatch
bus.dispatch_message_queue
end
Expand Down
56 changes: 56 additions & 0 deletions yastd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
2 changes: 2 additions & 0 deletions yastd/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ source "https://rubygems.org"

gem "rake"
gem "ruby-dbus"
gem "eventmachine"
gem "nokogiri"

# Required by YaST
gem "cheetah"
Expand Down
27 changes: 27 additions & 0 deletions yastd/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
abstract_method (1.2.1)
cheetah (1.0.0)
abstract_method (~> 1.2)
eventmachine (1.2.7)
fast_gettext (2.1.0)
nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4)
racc (1.6.0)
rake (13.0.6)
ruby-dbus (0.16.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
cheetah
eventmachine
fast_gettext
nokogiri
rake
ruby-dbus

BUNDLED WITH
2.2.27
11 changes: 10 additions & 1 deletion yastd/bin/yastd
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)

require "rubygems"
require "bundler/setup"

require "eventmachine"
require "yast2/dbus/service"
Yast2::DBus::Service.new.run

EM.run do
service = Yast2::DBus::Service.new
service.export
EventMachine::PeriodicTimer.new(0.1) { service.dispatch }
end
16 changes: 11 additions & 5 deletions yastd/lib/yast2/dbus/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Installer < ::DBus::Object
def initialize(installer, logger, *args)
@installer = installer
@logger = logger

installer.on_status_change do |status|
self.StatusChanged(status.id)
end

super(*args)
end

Expand Down Expand Up @@ -87,17 +92,17 @@ def initialize(installer, logger, *args)

dbus_method :Probe, "out result:b" do
logger.info "Probe"

installer.probe
Thread.new { installer.probe }
true
end

dbus_method :Start, "out result:b" do
logger.info "Start"

installer.install
Thread.new { installer.install }
true
end

dbus_signal :StatusChanged, "status:n"
end

dbus_interface PROPERTY_INTERFACE do
Expand All @@ -110,7 +115,8 @@ def initialize(installer, logger, *args)
end

begin
installer.send(propname.downcase.to_s).to_s
value = installer.send(propname.downcase.to_s)
value.respond_to?(:id) ? value.id : value.to_s
rescue NoMethodError
raise ::DBus.error("org.freedesktop.DBus.Error.InvalidArgs"),
"Property '#{interface}.#{propname}' not found on object '#{@path}'"
Expand Down
Loading