Class: ForemanMaintain::Utils::Service::RemoteDB

Inherits:
Abstract
  • Object
show all
Defined in:
lib/foreman_maintain/utils/service/remote_db.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#name, #priority

Instance Method Summary collapse

Methods inherited from Abstract

#<=>, #socket

Constructor Details

#initialize(name, priority, options = {}) ⇒ RemoteDB

Returns a new instance of RemoteDB.



5
6
7
8
9
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 5

def initialize(name, priority, options = {})
  super
  @db_feature = options.fetch(:db_feature)
  @component = options.fetch(:component, nil)
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



4
5
6
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 4

def component
  @component
end

#db_featureObject (readonly)

Returns the value of attribute db_feature.



4
5
6
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 4

def db_feature
  @db_feature
end

Instance Method Details

#disableObject



24
25
26
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 24

def disable
  [0, db_status("It can't be disabled.").last]
end

#enableObject



28
29
30
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 28

def enable
  [0, db_status("It can't be enabled.").last]
end

#exist?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 54

def exist?
  true
end

#inspectObject



15
16
17
18
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 15

def inspect
  component = @component ? ':' + @component : ''
  "#{self.class.name.split('::').last}(#{@name}#{component} [#{@priority}])"
end

#matches?(service) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 44

def matches?(service)
  if service.instance_of?(self.class)
    service.name == @name && service.component == @component
  elsif service.is_a? String
    service == @name
  else
    false
  end
end

#running?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 40

def running?
  status.first == 0
end

#startObject



32
33
34
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 32

def start
  db_status
end

#statusObject



20
21
22
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 20

def status
  db_status
end

#stopObject



36
37
38
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 36

def stop
  [0, db_status.last]
end

#to_sObject



11
12
13
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 11

def to_s
  @name + (@component ? " (#{@component})" : '')
end