Skip to content

Commit

Permalink
Merge pull request #79 from myakove/master
Browse files Browse the repository at this point in the history
Service: Don't fail when service have @ in the name
  • Loading branch information
nellyc authored Jan 23, 2017
2 parents 250d3a0 + 7526857 commit 246e2e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rrmngmnt/service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from rrmngmnt.resource import Resource
import re


class Service(Resource):
Expand Down Expand Up @@ -169,6 +170,11 @@ class Systemd(SystemService):

def _can_handle(self):
super(Systemd, self)._can_handle()

orig_name = self.name
if "@" in self.name:
self.name = re.match(r'^.*@', self.name).group(0)

cmd = (
'systemctl', 'list-unit-files', '|',
'grep', '-o', '^[^.][^.]*.service', '|',
Expand All @@ -180,8 +186,9 @@ def _can_handle(self):
out = out.strip().splitlines()
if rc or self.name not in out:
raise self.CanNotHandle(
"%s is not listed in %s" % (self.name, out)
"%s is not listed in %s" % (orig_name, out)
)
self.name = orig_name

def _execute(self, action):
cmd = [
Expand Down

0 comments on commit 246e2e3

Please sign in to comment.