File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ require_relative '../db_up_check'
2+
13module Checks
24 module Candlepin
3- class DBUp < ForemanMaintain :: Check
5+ class DBUp < DBUpCheck
46 metadata do
57 description 'Make sure Candlepin DB is up'
68 label :candlepin_db_up
79 for_feature :candlepin_database
810 end
911
10- def run
11- status = false
12- if feature ( :candlepin_database ) . psql_cmd_available?
13- with_spinner ( 'Checking connection to the Candlepin DB' ) do
14- status = feature ( :candlepin_database ) . ping
15- end
16- assert ( status , 'Candlepin DB is not responding. ' \
17- 'It needs to be up and running to perform the following steps' ,
18- :next_steps => start_pgsql )
19- else
20- feature ( :candlepin_database ) . raise_psql_missing_error
21- end
12+ def database_feature
13+ :candlepin_database
2214 end
2315
24- def start_pgsql
25- if feature ( :candlepin_database ) . local?
26- [ Procedures ::Service ::Start . new ( :only => 'postgresql' ) ]
27- else
28- [ ] # there is nothing we can do for remote db
29- end
16+ def database_name
17+ 'Candlepin'
3018 end
3119 end
3220 end
3321end
22+
Original file line number Diff line number Diff line change 1+ require_relative '../db_up_check'
2+
13module Checks
24 module ContainerGateway
3- class DBUp < ForemanMaintain :: Check
5+ class DBUp < DBUpCheck
46 metadata do
57 description 'Make sure ContainerGateway DB is up'
68 label :container_gateway_db_up
79 for_feature :container_gateway_database
810 end
911
10- def run
11- status = false
12- with_spinner ( 'Checking connection to the Container Gateway DB' ) do
13- status = feature ( :container_gateway_database ) . ping
14- end
15- assert ( status , 'Container Gateway DB is not responding. ' \
16- 'It needs to be up and running to perform the following steps' ,
17- :next_steps => next_steps )
12+ def database_feature
13+ :container_gateway_database
1814 end
1915
20- def next_steps
21- if feature ( :container_gateway_database ) . local?
22- [ Procedures ::Service ::Start . new ( :only => 'postgresql' ) ]
23- else
24- [ ] # there is nothing we can do for remote db
25- end
16+ def database_name
17+ 'Container Gateway'
2618 end
2719 end
2820 end
Original file line number Diff line number Diff line change 1+ module Checks
2+ class DBUpCheck < ForemanMaintain ::Check
3+ def run
4+ status = false
5+ if feature ( database_feature ) . psql_cmd_available?
6+ with_spinner ( "Checking connection to the #{ database_name } DB" ) do
7+ status = feature ( database_feature ) . ping
8+ end
9+ assert ( status , "#{ database_name } DB is not responding. " \
10+ "It needs to be up and running to perform the following steps" ,
11+ :next_steps => start_pgsql )
12+ else
13+ feature ( database_feature ) . raise_psql_missing_error
14+ end
15+ end
16+
17+ def start_pgsql
18+ if feature ( database_feature ) . local?
19+ [ Procedures ::Service ::Start . new ( :only => 'postgresql' ) ]
20+ else
21+ [ ] # there is nothing we can do for remote db
22+ end
23+ end
24+
25+ def database_feature
26+ raise NotImplementedError , 'Subclasses must define `database_feature`'
27+ end
28+
29+ def database_name
30+ raise NotImplementedError , 'Subclasses must define `database_name`'
31+ end
32+ end
33+ end
34+
Original file line number Diff line number Diff line change 1+ require_relative '../db_up_check'
2+
13module Checks
24 module Foreman
3- class DBUp < ForemanMaintain :: Check
5+ class DBUp < DBUpCheck
46 metadata do
57 description 'Make sure Foreman DB is up'
68 label :foreman_db_up
79 for_feature :foreman_database
810 end
911
10- def run
11- status = false
12- if feature ( :foreman_database ) . psql_cmd_available?
13- with_spinner ( 'Checking connection to the Foreman DB' ) do
14- status = feature ( :foreman_database ) . ping
15- end
16- assert ( status , 'Foreman DB is not responding. ' \
17- 'It needs to be up and running to perform the following steps' ,
18- :next_steps => start_pgsql )
19- else
20- feature ( :foreman_database ) . raise_psql_missing_error
21- end
12+ def database_feature
13+ :foreman_database
2214 end
2315
24- def start_pgsql
25- if feature ( :foreman_database ) . local?
26- [ Procedures ::Service ::Start . new ( :only => 'postgresql' ) ]
27- else
28- [ ] # there is nothing we can do for remote db
29- end
16+ def database_name
17+ 'Foreman'
3018 end
3119 end
3220 end
3321end
22+
Original file line number Diff line number Diff line change 1+ require_relative '../db_up_check'
2+
13module Checks
24 module Pulpcore
3- class DBUp < ForemanMaintain :: Check
5+ class DBUp < DBUpCheck
46 metadata do
57 description 'Make sure Pulpcore DB is up'
68 label :pulpcore_db_up
79 for_feature :pulpcore_database
810 end
911
10- def run
11- status = false
12- with_spinner ( 'Checking connection to the Pulpcore DB' ) do
13- status = feature ( :pulpcore_database ) . ping
14- end
15- assert ( status , 'Pulpcore DB is not responding. ' \
16- 'It needs to be up and running to perform the following steps' ,
17- :next_steps => next_steps )
12+ def database_feature
13+ :pulpcore_database
1814 end
1915
20- def next_steps
21- if feature ( :pulpcore_database ) . local?
22- [ Procedures ::Service ::Start . new ( :only => 'postgresql' ) ]
23- else
24- [ ] # there is nothing we can do for remote db
25- end
16+ def database_name
17+ 'Pulpcore'
2618 end
2719 end
2820 end
2921end
22+
Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ def extract_pulp_data(backup)
4949 end
5050
5151 def any_database
52- feature ( :foreman_database ) || feature ( :candlepin_database ) || feature ( :pulpcore_database ) || feature ( :container_gateway_database )
52+ %i[
53+ foreman_database
54+ candlepin_database
55+ pulpcore_database
56+ container_gateway_database
57+ ] . any? { |db | feature ( db ) }
5358 end
5459
5560 def extract_pgsql_data ( backup )
You can’t perform that action at this time.
0 commit comments