View | Details | Raw Unified | Return to bug 225531
Collapse All | Expand All

(-)b/sysutils/py-salt/files/patch-salt_modules_at.py (-1 / +73 lines)
Added Link Here
0
- 
1
From ef9199cc9bccb77b1a7923c9236d5c384ac9710a Mon Sep 17 00:00:00 2001
2
From: Fabian Keil <fk@fabiankeil.de>
3
Date: Sun, 6 Aug 2017 15:39:00 +0200
4
Subject: [PATCH 1/2] salt/modules/at.py: Add limited support for FreeBSD's at
5
6
---
7
 salt/modules/at.py | 18 ++++++++++++++++++
8
 1 file changed, 18 insertions(+)
9
10
diff --git salt/modules/at.py salt/modules/at.py
11
index 5a27e5b5ee..a2d5961202 100644
12
--- salt/modules/at.py
13
+++ salt/modules/at.py
14
@@ -101,6 +101,24 @@ def atq(tag=None):
15
         if __grains__['os_family'] == 'RedHat':
16
             job, spec = line.split('\t')
17
             specs = spec.split()
18
+        elif __grains__['os_family'] == 'FreeBSD':
19
+            # Expected output:
20
+            # Date				Owner		Queue	Job#
21
+            # Sun Aug  6 16:00:00 CEST 2017	root            c	4
22
+            # Sun Aug  6 16:04:00 CEST 2017	root            c	5
23
+            if line.startswith('Date'):
24
+                continue
25
+            else:
26
+                tmp = line.split()
27
+                timestr = ' '.join(tmp[1:6])
28
+                owner = tmp[6]
29
+                queue = tmp[7]
30
+                job = tmp[8]
31
+                specs = datetime.datetime(*(time.strptime(timestr,
32
+                    '%b %d %H:%M:%S %Z %Y')[0:5])).isoformat().split('T')
33
+                specs.append(queue)
34
+                specs.append(owner)
35
+
36
         elif __grains__['os'] in BSD:
37
             if line.startswith(' Rank'):
38
                 continue
39
-- 
40
2.14.1
41
42
43
From 5555b7e42ca084efb4c61fef9b871de5756fca7f Mon Sep 17 00:00:00 2001
44
From: Fabian Keil <fk@fabiankeil.de>
45
Date: Sun, 6 Aug 2017 14:48:02 +0200
46
Subject: [PATCH 2/2] salt/modules/at.py: Treat every "at" output starting with
47
 "at: " as error message
48
49
This has only been tested with FreeBSD's "at" (on ElectroBSD) but
50
isn't expected to cause problems with any other "at" implementations
51
and therefore isn't protected by a "__grains__['os_family'] == 'FreeBSD'"
52
check for now.
53
---
54
 salt/modules/at.py | 3 +++
55
 1 file changed, 3 insertions(+)
56
57
diff --git salt/modules/at.py salt/modules/at.py
58
index a2d5961202..2534e18a6b 100644
59
--- salt/modules/at.py
60
+++ salt/modules/at.py
61
@@ -250,6 +250,9 @@ def at(*args, **kwargs):  # pylint: disable=C0103
62
     if output.endswith('Garbled time'):
63
         return {'jobs': [], 'error': 'invalid timespec'}
64
 
65
+    if output.startswith('at: '):
66
+        return {'jobs': [], 'error': output[4:]}
67
+
68
     if output.startswith('warning: commands'):
69
         output = output.splitlines()[1]
70
 
71
-- 
72
2.14.1
73

Return to bug 225531