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.



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

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



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

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

#enableObject



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

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

#exist?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 63

def exist?
  true
end

#inspectObject



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

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

#matches?(service) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
61
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 53

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

#restartObject



41
42
43
44
45
46
47
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 41

def restart
  command_name = ForemanMaintain.command_name
  db_status(<<~MSG
    Remote databases are not managed by #{command_name} and therefore was not restarted.
  MSG
           )
end

#running?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/foreman_maintain/utils/service/remote_db.rb', line 49

def running?
  status.first == 0
end

#startObject



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

def start
  db_status
end

#statusObject



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

def status
  db_status
end

#stopObject



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

def stop
  [0, db_status.last]
end

#to_sObject



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

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