diff --git a/.gitignore b/.gitignore index e3200e0f81..6b9434514a 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* + +# Web interface logs directory +.log diff --git a/README.md b/README.md index a02d95e62c..d115627ae6 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ The current UI is a small web application built with [React](https://reactjs.org $ npm install $ npm start -Point your browser to http://localhost:3001 and enjoy! +Point your browser to http://localhost:3000 and enjoy! # References diff --git a/web/package.json b/web/package.json index aadd7290b8..7512fdadd9 100644 --- a/web/package.json +++ b/web/package.json @@ -21,7 +21,7 @@ "web-vitals": "^0.2.2" }, "scripts": { - "start": "HOST=localhost PORT=3001 react-scripts start", + "start": "HOST=localhost PORT=3000 react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" diff --git a/web/src/App.js b/web/src/App.js index 3a47ac77f1..d5f8651d5b 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -51,11 +51,11 @@ function App() { console.log("WebSocket Event", event); const { data } = event; const changedKeys = Object.keys(JSON.parse(data)); - if (changedKeys.includes("disk")) { + if (changedKeys.includes("Disk")) { loadStorage(dispatch); } - if (changedKeys.includes("status")) { + if (changedKeys.includes("Status")) { loadInstallation(dispatch); } }); diff --git a/web/src/context/installer.js b/web/src/context/installer.js index ad740869af..765467ec89 100644 --- a/web/src/context/installer.js +++ b/web/src/context/installer.js @@ -121,7 +121,9 @@ let _installerClient; const installerClient = () => { if (_installerClient) return _installerClient; - _installerClient = new InstallerClient('http://localhost:3000'); + _installerClient = new InstallerClient({ + url: 'http://localhost:3001', ws: 'ws://localhost:3002' + }); return _installerClient; }; diff --git a/web/src/lib/InstallerClient.js b/web/src/lib/InstallerClient.js index e5865bbf07..fe5f8cbc51 100644 --- a/web/src/lib/InstallerClient.js +++ b/web/src/lib/InstallerClient.js @@ -22,15 +22,14 @@ import axios from 'axios'; export default class InstallerClient { - constructor(url) { + constructor({ url, ws }) { this.url = url; - // const wsUrl = url.replace("http", "ws") + "/ws"; - // this.socket = new WebSocket(`${wsUrl}`); - // this.socket.onclose = () => console.log("The socket was closed"); + this.socket = new WebSocket(`${ws}`); + this.socket.onclose = () => console.log("The socket was closed"); } onMessage(handler) { - // this.socket.addEventListener("message", handler); + this.socket.addEventListener("message", handler); } async getInstallation() { @@ -39,14 +38,14 @@ export default class InstallerClient { async getProducts() { const { data } = await axios.post( - `${this.url}/calls.json`, { meth: "GetProducts" } + `${this.url}/calls`, { meth: "GetProducts" } ); return data; } async getLanguages() { const { data } = await axios.post( - `${this.url}/calls.json`, { meth: "GetLanguages" } + `${this.url}/calls`, { meth: "GetLanguages" } ); return Object.keys(data).map(key => { return { id: key, name: data[key][1] } @@ -55,20 +54,20 @@ export default class InstallerClient { async getStorage() { const { data } = await axios.post( - `${this.url}/calls.json`, { meth: "GetStorage" } + `${this.url}/calls`, { meth: "GetStorage" } ); return data; } async getDisks() { const { data } = await axios.post( - `${this.url}/calls.json`, { meth: "GetDisks" } + `${this.url}/calls`, { meth: "GetDisks" } ); return data; } async getOptions() { - const { data } = await axios.get(`${this.url}/properties.json`); + const { data } = await axios.get(`${this.url}/properties`); return Object.fromEntries( Object.entries(data[0]).map(([k, v]) => [k.toLowerCase(), v]) ) diff --git a/yastd-proxy/.gitattributes b/yastd-proxy/.gitattributes deleted file mode 100644 index 285e9e9653..0000000000 --- a/yastd-proxy/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -# See https://git-scm.com/docs/gitattributes for more about git attribute files. - - -# Mark any vendored files as having been vendored. -vendor/* linguist-vendored diff --git a/yastd-proxy/.gitignore b/yastd-proxy/.gitignore index 38838156cd..e3200e0f81 100644 --- a/yastd-proxy/.gitignore +++ b/yastd-proxy/.gitignore @@ -1,26 +1,56 @@ -# See https://help.github.com/articles/ignoring-files for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile '~/.gitignore_global' +*.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 -# Ignore bundler config. -/.bundle +## 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/ -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/ -!/tmp/pids/.keep +## 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 -# Ignore master key for decrypting credentials and more. -/config/master.key +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc -# Ignore vendor/bundle, where gems are installed -vendor/bundle +# Used by RuboCop. Remote config files pulled in from inherit_from directive. +# .rubocop-https?--* diff --git a/yastd-proxy/.ruby-version b/yastd-proxy/.ruby-version deleted file mode 100644 index 849c0c47ff..0000000000 --- a/yastd-proxy/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.7.5 diff --git a/yastd-proxy/Gemfile b/yastd-proxy/Gemfile index 0f07828199..f2b2fb6552 100644 --- a/yastd-proxy/Gemfile +++ b/yastd-proxy/Gemfile @@ -1,47 +1,12 @@ -source "https://rubygems.org" -git_source(:github) { |repo| "https://github.com/#{repo}.git" } - -ruby "2.7.5" - -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.0.0" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" - -# Build JSON APIs with ease [https://github.com/rails/jbuilder] -# gem "jbuilder" - -# Use Redis adapter to run Action Cable in production -# gem "redis", "~> 4.0" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" +# frozen_string_literal: true -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] - -# Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false - -# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible -# gem "rack-cors" - -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri mingw x64_mingw ] -end - -group :development do - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" -end - -# Add CORS support -gem "rack-cors" +source "https://rubygems.org" -# Run commands -gem "cheetah" +gem "eventmachine" +gem "em-websocket" +gem "rack-contrib", require: "rack/contrib" +gem "rake" +gem "sinatra" +gem "sinatra-cors" +gem "ruby-dbus", require: "dbus" +gem "thin" diff --git a/yastd-proxy/Gemfile.lock b/yastd-proxy/Gemfile.lock index f4f3e93670..f8bce4574d 100644 --- a/yastd-proxy/Gemfile.lock +++ b/yastd-proxy/Gemfile.lock @@ -2,155 +2,51 @@ GEM remote: https://rubygems.org/ specs: abstract_method (1.2.1) - actioncable (7.0.0) - actionpack (= 7.0.0) - activesupport (= 7.0.0) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (7.0.0) - actionpack (= 7.0.0) - activejob (= 7.0.0) - activerecord (= 7.0.0) - activestorage (= 7.0.0) - activesupport (= 7.0.0) - mail (>= 2.7.1) - actionmailer (7.0.0) - actionpack (= 7.0.0) - actionview (= 7.0.0) - activejob (= 7.0.0) - activesupport (= 7.0.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (7.0.0) - actionview (= 7.0.0) - activesupport (= 7.0.0) - rack (~> 2.0, >= 2.2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.0) - actionpack (= 7.0.0) - activerecord (= 7.0.0) - activestorage (= 7.0.0) - activesupport (= 7.0.0) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.0.0) - activesupport (= 7.0.0) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.0) - activesupport (= 7.0.0) - globalid (>= 0.3.6) - activemodel (7.0.0) - activesupport (= 7.0.0) - activerecord (7.0.0) - activemodel (= 7.0.0) - activesupport (= 7.0.0) - activestorage (7.0.0) - actionpack (= 7.0.0) - activejob (= 7.0.0) - activerecord (= 7.0.0) - activesupport (= 7.0.0) - marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - bootsnap (1.9.3) - msgpack (~> 1.0) - builder (3.2.4) + byebug (11.1.3) cheetah (1.0.0) abstract_method (~> 1.2) - concurrent-ruby (1.1.9) - crass (1.0.6) - debug (1.4.0) - irb (>= 1.3.6) - reline (>= 0.2.7) - erubi (1.10.0) - globalid (1.0.0) - activesupport (>= 5.0) - i18n (1.8.11) - concurrent-ruby (~> 1.0) - io-console (0.5.9) - irb (1.3.7) - reline (>= 0.2.7) - loofah (2.13.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) - mini_mime (>= 0.1.1) - marcel (1.0.2) - method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.15.0) - msgpack (1.4.2) - nio4r (2.5.8) - nokogiri (1.12.5-x86_64-linux) - racc (~> 1.4) - puma (5.5.2) - nio4r (~> 2.0) - racc (1.6.0) + daemons (1.4.1) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + http_parser.rb (0.8.0) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) rack (2.2.3) - rack-cors (1.1.1) - rack (>= 2.0.0) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (7.0.0) - actioncable (= 7.0.0) - actionmailbox (= 7.0.0) - actionmailer (= 7.0.0) - actionpack (= 7.0.0) - actiontext (= 7.0.0) - actionview (= 7.0.0) - activejob (= 7.0.0) - activemodel (= 7.0.0) - activerecord (= 7.0.0) - activestorage (= 7.0.0) - activesupport (= 7.0.0) - bundler (>= 1.15.0) - railties (= 7.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (7.0.0) - actionpack (= 7.0.0) - activesupport (= 7.0.0) - method_source - rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + rack-contrib (2.3.0) + rack (~> 2.0) + rack-protection (2.1.0) + rack rake (13.0.6) - reline (0.2.7) - io-console (~> 0.5) - thor (1.1.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.5.1) + ruby-dbus (0.16.0) + ruby2_keywords (0.0.5) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + sinatra-cors (1.2.0) + thin (1.8.1) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) + tilt (2.0.10) PLATFORMS x86_64-linux DEPENDENCIES - bootsnap + byebug cheetah - debug - puma (~> 5.0) - rack-cors - rails (~> 7.0.0) - tzinfo-data - -RUBY VERSION - ruby 2.7.5p203 + em-websocket + eventmachine + rack-contrib + rake + ruby-dbus + sinatra + sinatra-cors + thin BUNDLED WITH 2.2.27 diff --git a/yastd-proxy/README.md b/yastd-proxy/README.md deleted file mode 100644 index 7db80e4ca1..0000000000 --- a/yastd-proxy/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... diff --git a/yastd-proxy/Rakefile b/yastd-proxy/Rakefile deleted file mode 100644 index 9a5ea7383a..0000000000 --- a/yastd-proxy/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require_relative "config/application" - -Rails.application.load_tasks diff --git a/yastd-proxy/app/channels/application_cable/channel.rb b/yastd-proxy/app/channels/application_cable/channel.rb deleted file mode 100644 index d672697283..0000000000 --- a/yastd-proxy/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/yastd-proxy/app/channels/application_cable/connection.rb b/yastd-proxy/app/channels/application_cable/connection.rb deleted file mode 100644 index 0ff5442f47..0000000000 --- a/yastd-proxy/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/yastd-proxy/app/controllers/application_controller.rb b/yastd-proxy/app/controllers/application_controller.rb deleted file mode 100644 index fbbaafb048..0000000000 --- a/yastd-proxy/app/controllers/application_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "yast2/dbus_client" - -class ApplicationController < ActionController::API - - private - - def client - @client ||= Yast2::DBusClient.new - end -end diff --git a/yastd-proxy/app/controllers/calls_controller.rb b/yastd-proxy/app/controllers/calls_controller.rb deleted file mode 100644 index 0d70ccf56f..0000000000 --- a/yastd-proxy/app/controllers/calls_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class CallsController < ApplicationController - def create - ret = client.call(params[:meth]) - render json: ret[0] - end -end diff --git a/yastd-proxy/app/controllers/concerns/.keep b/yastd-proxy/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/yastd-proxy/app/controllers/properties_controller.rb b/yastd-proxy/app/controllers/properties_controller.rb deleted file mode 100644 index 56a09b02f4..0000000000 --- a/yastd-proxy/app/controllers/properties_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class PropertiesController < ApplicationController - def index - render json: client.get_properties - end - - def show - render json: client.get_property(params[:name]) - end - - def update - client.set_property(params[:name], params[:value]) - render :ok - rescue ::DBus::Error => e - render json: { status: "error", message: e.message } - end -end diff --git a/yastd-proxy/app/jobs/application_job.rb b/yastd-proxy/app/jobs/application_job.rb deleted file mode 100644 index d394c3d106..0000000000 --- a/yastd-proxy/app/jobs/application_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ApplicationJob < ActiveJob::Base - # Automatically retry jobs that encountered a deadlock - # retry_on ActiveRecord::Deadlocked - - # Most jobs are safe to ignore if the underlying records are no longer available - # discard_on ActiveJob::DeserializationError -end diff --git a/yastd-proxy/app/mailers/application_mailer.rb b/yastd-proxy/app/mailers/application_mailer.rb deleted file mode 100644 index 3c34c8148f..0000000000 --- a/yastd-proxy/app/mailers/application_mailer.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" - layout "mailer" -end diff --git a/yastd-proxy/app/models/concerns/.keep b/yastd-proxy/app/models/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/yastd-proxy/app/views/layouts/mailer.html.erb b/yastd-proxy/app/views/layouts/mailer.html.erb deleted file mode 100644 index cbd34d2e9d..0000000000 --- a/yastd-proxy/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - -
- - - - - - <%= yield %> - - diff --git a/yastd-proxy/app/views/layouts/mailer.text.erb b/yastd-proxy/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bddbd7..0000000000 --- a/yastd-proxy/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/yastd-proxy/bin/rails b/yastd-proxy/bin/rails deleted file mode 100755 index f5c296e0db..0000000000 --- a/yastd-proxy/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby.ruby2.7 -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/yastd-proxy/bin/rake b/yastd-proxy/bin/rake deleted file mode 100755 index 8fce4a6fc1..0000000000 --- a/yastd-proxy/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby.ruby2.7 -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/yastd-proxy/bin/setup b/yastd-proxy/bin/setup deleted file mode 100755 index d45c253aff..0000000000 --- a/yastd-proxy/bin/setup +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env ruby.ruby2.7 -require "fileutils" - -# path to your application root. -APP_ROOT = File.expand_path("..", __dir__) - -def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") -end - -FileUtils.chdir APP_ROOT do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - puts "\n== Restarting application server ==" - system! "bin/rails restart" -end diff --git a/yastd-proxy/bin/yastd-proxy b/yastd-proxy/bin/yastd-proxy new file mode 100755 index 0000000000..592aa3b11b --- /dev/null +++ b/yastd-proxy/bin/yastd-proxy @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true +# +# Copyright (c) [2021] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) + +require "rubygems" +require "bundler/setup" + +require "thin" +require "eventmachine" +require "em-websocket" +require "json" + +require "yastd-proxy/webservice" +require "yastd-proxy/dbus_client" + +HTTP_PORT = 3001 +WS_PORT = 3002 + +def shutdown + puts "Shutting down..." + EventMachine.stop +end + +EM.run do + Signal.trap("INT") { shutdown } + Signal.trap("TERM") { shutdown } + + Thin::Server.start(WebService, '0.0.0.0', HTTP_PORT, signals: false) + + EM::WebSocket.run(host: '0.0.0.0', port: WS_PORT) do |ws| + client = Yast2::DBusClient.new + + ws.onopen do |handsake| + client.on_property_change do |changes| + ws.send changes.to_json + end + + EventMachine::PeriodicTimer.new(0.5) { client.dispatch } + end + end +end diff --git a/yastd-proxy/config.ru b/yastd-proxy/config.ru deleted file mode 100644 index 4a3c09a688..0000000000 --- a/yastd-proxy/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require_relative "config/environment" - -run Rails.application -Rails.application.load_server diff --git a/yastd-proxy/config/application.rb b/yastd-proxy/config/application.rb deleted file mode 100644 index 3dfdafe06f..0000000000 --- a/yastd-proxy/config/application.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -require_relative "boot" - -require "rails" -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -# require "active_record/railtie" -# require "active_storage/engine" -require "action_controller/railtie" -require "action_mailer/railtie" -# require "action_mailbox/engine" -# require "action_text/engine" -require "action_view/railtie" -require "action_cable/engine" -require "rails/test_unit/railtie" - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module YastdProxy - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 - - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - - # Only loads a smaller set of middleware suitable for API only apps. - # Middleware like session, flash, cookies can be added back manually. - # Skip views, helpers and assets when generating a new resource. - config.api_only = true - end -end diff --git a/yastd-proxy/config/boot.rb b/yastd-proxy/config/boot.rb deleted file mode 100644 index aef6d031ee..0000000000 --- a/yastd-proxy/config/boot.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/yastd-proxy/config/cable.yml b/yastd-proxy/config/cable.yml deleted file mode 100644 index ce052383de..0000000000 --- a/yastd-proxy/config/cable.yml +++ /dev/null @@ -1,10 +0,0 @@ -development: - adapter: async - -test: - adapter: test - -production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: yastd_proxy_production diff --git a/yastd-proxy/config/credentials.yml.enc b/yastd-proxy/config/credentials.yml.enc deleted file mode 100644 index 944a173332..0000000000 --- a/yastd-proxy/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -3i+M16JkndPIHcHfz1E1TYpihQZWHi4JDdfrRCbSnLrhx1gNXEjTH0ep3OkzhCfPuERyrTRx+pKRz3NiWueEtmIKjktnQES7srsqPXzNvVDB49ewgWSQ2nchJO06oYhbnyITYbFiNX+xiaM2p6KD2vYEWwRMQ8lCK4zjmU6sVGttHPMipdKPcA5N8BBWkrlTRRhlp1thFbi0p15GStldWnz0eR29Niwe1Xm7AZj0C1zpy2ZJe7rxtpKEbfFx3RJnxsgBBr9vU142b+EHQuCALfR5msMQTMkxlUcdXn2WlXgjwfXVt06D7YqmP7MKN6E8hPvEdx+AJjuan03Z+nHY9Buwahar4/fYWHWBXVPen8ZkG5N4y97v9QXnCW8aXVCHIGwXaij4WoMgfQEdttj+9GnPF1zYYEBR/Dah--3ldUutAdnBkig25Q--gGKwcFLH3FuA9oqTovb6pg== \ No newline at end of file diff --git a/yastd-proxy/config/environment.rb b/yastd-proxy/config/environment.rb deleted file mode 100644 index 7df99e89c6..0000000000 --- a/yastd-proxy/config/environment.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Load the Rails application. -require_relative "application" - -# Initialize the Rails application. -Rails.application.initialize! diff --git a/yastd-proxy/config/environments/development.rb b/yastd-proxy/config/environments/development.rb deleted file mode 100644 index 83df801bce..0000000000 --- a/yastd-proxy/config/environments/development.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end - - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - config.action_mailer.perform_caching = false - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true -end diff --git a/yastd-proxy/config/environments/production.rb b/yastd-proxy/config/environments/production.rb deleted file mode 100644 index 0ebd727399..0000000000 --- a/yastd-proxy/config/environments/production.rb +++ /dev/null @@ -1,80 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.cache_classes = true - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "yastd_proxy_production" - - config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end -end diff --git a/yastd-proxy/config/environments/test.rb b/yastd-proxy/config/environments/test.rb deleted file mode 100644 index 0a8eb25318..0000000000 --- a/yastd-proxy/config/environments/test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require "active_support/core_ext/integer/time" - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Turn false under Spring and add config.action_view.cache_template_loading = true - config.cache_classes = true - - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? - - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store - - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false - - config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true -end diff --git a/yastd-proxy/config/initializers/cors.rb b/yastd-proxy/config/initializers/cors.rb deleted file mode 100644 index c546e69c51..0000000000 --- a/yastd-proxy/config/initializers/cors.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Avoid CORS issues when API is called from the frontend app. -# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. - -# Read more: https://github.com/cyu/rack-cors - -# Rails.application.config.middleware.insert_before 0, Rack::Cors do -# allow do -# origins 'example.com' -# -# resource '*', -# headers: :any, -# methods: [:get, :post, :put, :patch, :delete, :options, :head] -# end -# end - -Rails.application.config.middleware.insert_before 0, Rack::Cors do - allow do - origins 'localhost:3001' - - resource '*', - headers: :any, - methods: [:get, :post, :put, :patch, :delete, :options, :head] - end -end diff --git a/yastd-proxy/config/initializers/filter_parameter_logging.rb b/yastd-proxy/config/initializers/filter_parameter_logging.rb deleted file mode 100644 index 4b34a03668..0000000000 --- a/yastd-proxy/config/initializers/filter_parameter_logging.rb +++ /dev/null @@ -1,6 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn -] diff --git a/yastd-proxy/config/initializers/inflections.rb b/yastd-proxy/config/initializers/inflections.rb deleted file mode 100644 index 3860f659ea..0000000000 --- a/yastd-proxy/config/initializers/inflections.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end diff --git a/yastd-proxy/config/locales/en.yml b/yastd-proxy/config/locales/en.yml deleted file mode 100644 index 8ca56fc74f..0000000000 --- a/yastd-proxy/config/locales/en.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: -# -# true, false, on, off, yes, no -# -# Instead, surround them with single quotes. -# -# en: -# "true": "foo" -# -# To learn more, please read the Rails Internationalization guide -# available at https://guides.rubyonrails.org/i18n.html. - -en: - hello: "Hello world" diff --git a/yastd-proxy/config/puma.rb b/yastd-proxy/config/puma.rb deleted file mode 100644 index ea3b550207..0000000000 --- a/yastd-proxy/config/puma.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -# -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -# -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. -# -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. -# -# preload_app! - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart diff --git a/yastd-proxy/config/routes.rb b/yastd-proxy/config/routes.rb deleted file mode 100644 index 2800f42b3e..0000000000 --- a/yastd-proxy/config/routes.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -Rails.application.routes.draw do - get "properties/:name", to: "properties#show" - put "properties/:name", to: "properties#update" - get "properties", to: "properties#index" - - post "calls", to: "calls#create" - - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - - # Defines the root path route ("/") - # root "articles#index" -end diff --git a/yastd-proxy/lib/tasks/.keep b/yastd-proxy/lib/tasks/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/yastd-proxy/lib/yast2/dbus_client.rb b/yastd-proxy/lib/yastd-proxy/dbus_client.rb similarity index 54% rename from yastd-proxy/lib/yast2/dbus_client.rb rename to yastd-proxy/lib/yastd-proxy/dbus_client.rb index fe6ab68c13..ae8a71f5fa 100644 --- a/yastd-proxy/lib/yast2/dbus_client.rb +++ b/yastd-proxy/lib/yastd-proxy/dbus_client.rb @@ -17,7 +17,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require "cheetah" +require "dbus" module Yast2 class DBusClient @@ -28,15 +28,18 @@ class DBusClient class CouldNotSetProperty < StandardError; end + attr_reader :bus + + # Constructor + def initialize + @bus = DBus::SystemBus.instance + end + # Returns the installer properties # # @return [Array