Skip to content

Commit

Permalink
Add SystemdUnit#static?
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs authored and joseivanlopez committed Aug 6, 2018
1 parent 3b4418c commit 47d657d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/system/src/lib/yast2/system_service.rb
Expand Up @@ -57,7 +57,7 @@ class SystemService
attr_reader :errors

def_delegators :@service, :running?, :start, :stop, :restart, :active?,
:active_state, :sub_state, :name, :description
:active_state, :sub_state, :name, :description, :static?

class << self
# Find a service
Expand Down
16 changes: 10 additions & 6 deletions library/systemd/src/lib/yast2/systemd_unit.rb
Expand Up @@ -72,7 +72,6 @@ class PropMap < Hash

# with ruby 2.4 delegating ostruct with Forwardable start to write warning
# so define it manually (bsc#1049433)
<<<<<<< HEAD
FORWARDED_METHODS = [
:id,
:path,
Expand All @@ -88,11 +87,6 @@ class PropMap < Hash
private_constant :FORWARDED_METHODS

FORWARDED_METHODS.each { |m| define_method(m) { properties.public_send(m) } }
=======
[:id, :path, :description, :active?, :enabled?, :loaded?, :active_state, :sub_state].each do |m|
define_method(m) { properties.public_send(m) }
end
>>>>>>> Add methods to read the service state

# @return [String] eg. "apache2"
# (the canonical one, may be different from unit_name)
Expand Down Expand Up @@ -258,6 +252,7 @@ def initialize(systemd_unit, property_text)
end

extract_properties
<<<<<<< HEAD
self[:active?] = ACTIVE_STATES.include?(active_state)
self[:running?] = sub_state == "running"
self[:loaded?] = load_state == "loaded"
Expand All @@ -266,6 +261,15 @@ def initialize(systemd_unit, property_text)
self[:enabled?] = read_enabled_state
self[:supported?] = SUPPORTED_STATES.include?(unit_file_state)
self[:can_reload?] = can_reload == "yes"
=======
self[:active?] = ACTIVE_STATES.include?(active_state)
self[:running?] = sub_state == "running"
self[:loaded?] = load_state == "loaded"
self[:not_found?] = load_state == "not-found"
self[:static?] = load_state == "static"
self[:enabled?] = read_enabled_state
self[:supported?] = SUPPORTED_STATES.include?(unit_file_state)
>>>>>>> Add SystemdUnit#static?
end

private
Expand Down

0 comments on commit 47d657d

Please sign in to comment.