Skip to content

Commit

Permalink
Issue #414: service disapear after stopping it at opensuse 42.1
Browse files Browse the repository at this point in the history
Dispite the title, ginger was not listing disabled services on systemctl
management. Just add --all parameter to list all of them, also, need to
list service without cgroup, which value is defined when services are
on.

Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
  • Loading branch information
Ramon Medeiros authored and danielhb committed Oct 3, 2016
1 parent 1f8d733 commit 45fa369
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions model/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def parse_systemctlshow_output(output):


def parse_systemctllist_output(output):
"""Parses the output of 'systemctl --type=service --no-pager'.
"""Parses the output of 'systemctl --type=service --no-pager --all'.
Args:
output (str): the output of the command. Example format:
Expand Down Expand Up @@ -186,7 +186,7 @@ def get_services_list():
List[str]: a list of services.
"""
cmd = ['systemctl', '--type=service', '--no-pager']
cmd = ['systemctl', '--type=service', '--no-pager', '--all']
output = run_systemd_command(cmd)
return parse_systemctllist_output(output)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_services_get_list(self, mock_run_cmd):

services_list = ServicesModel().get_list()
mock_run_cmd.assert_called_once_with(
['systemctl', '--type=service', '--no-pager']
['systemctl', '--type=service', '--no-pager', '--all']
)

expected_output = [
Expand Down
48 changes: 23 additions & 25 deletions ui/js/host-system-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ ginger.generateSystemServiceElem = function(value){
var name = ''
if (value.name !== undefined) {
name = value.name.toLowerCase();
} else {
return;
}
var servicename = name.split(".service").join("").replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
var id = 'service-'+servicename;
Expand Down Expand Up @@ -180,32 +182,28 @@ ginger.generateSystemServiceElem = function(value){
description: description,
cgroup: cgroup
}));
if(!value.cgroup){
$('.system-services-cgroup',systemServicesItem).remove();
$('.column-service-details',systemServicesItem).empty().append('--');
if((value.cgroup) && (!jQuery.isEmptyObject(value.cgroup.processes))){
$.each(value.cgroup.processes, function(pid,process){
var processItem = $.parseHTML(wok.substitute($("#systemServiceProcessItem").html(), {
pid: pid,
process: process
}));
$('.system-service-process-body',systemServicesItem).append(processItem);
});
}else {
$('.system-services-process',systemServicesItem).remove();
}
else {
if(!jQuery.isEmptyObject(value.cgroup.processes)){
$.each(value.cgroup.processes, function(pid,process){
var processItem = $.parseHTML(wok.substitute($("#systemServiceProcessItem").html(), {
pid: pid,
process: process
}));
$('.system-service-process-body',systemServicesItem).append(processItem);
});
}else {
$('.system-services-process',systemServicesItem).remove();
}
if(sub === 'running') {
$('.service-start',systemServicesItem).parent().addClass('disabled');
}else {
$('.service-stop',systemServicesItem).parent().addClass('disabled');
}
if($('#system-services-body > li#'+id).length){
$('#system-services-body > li#'+id).replaceWith(systemServicesItem);
}else {
$('#system-services-body').append(systemServicesItem);
}

if(sub === 'running') {
$('.service-start',systemServicesItem).parent().addClass('disabled');
}else {
$('.service-stop',systemServicesItem).parent().addClass('disabled');
}

if($('#system-services-body > li#'+id).length){
$('#system-services-body > li#'+id).replaceWith(systemServicesItem);
}else {
$('#system-services-body').append(systemServicesItem);
}
};

Expand Down

0 comments on commit 45fa369

Please sign in to comment.