Page MenuHomeVyOS Platform

reboot in - Invalid time
Closed, ResolvedPublicBUG

Description

for "reboot in 60" the format is not correct.
it should be reboot in <minutes> and not <HH:MM>

labuser@lab01:~$ reboot in 60
Invalid time "60". The valid format is HH:MM

labuser@lab01:~$ reboot in 
Possible completions:
  <Minutes>     Reboot in X minutes

labuser@lab01:~$ reboot in 1:00
Reboot is scheduled 2020-11-14 01:00:00

Details

Difficulty level
Easy (less than an hour)
Version
1.3-rolling-202011110217
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

tuxnet updated the task description. (Show Details)
Unknown Object (User) changed the task status from Open to Confirmed.Nov 13 2020, 7:21 AM
Unknown Object (User) added a subscriber: Unknown Object (User).

It looks like need to do some calculation

vyos@vyos:~$ show version | match Version
Version:          VyOS 1.3-rolling-202011130217
vyos@vyos:~$ show date 
Fri 13 Nov 2020 07:18:44 AM UTC
vyos@vyos:~$ reboot in 60
Invalid time "60". The valid format is HH:MM
vyos@vyos:~$ reboot in 59
Reboot is scheduled 2020-11-13 08:18:04
vyos@vyos:~$ reboot in 61
Invalid time "61". The valid format is HH:MM
Unknown Object (User) added a comment.Nov 13 2020, 8:00 AM

How about these changes https://github.com/vyos/vyos-1x/blob/current/src/op_mode/powerctrl.py#L37

diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py
index 69af427e..c000d7d0 100755
--- a/src/op_mode/powerctrl.py
+++ b/src/op_mode/powerctrl.py
@@ -34,7 +34,11 @@ def utc2local(datetime):
 def parse_time(s):
     try:
         if re.match(r'^\d{1,2}$', s):
-            return datetime.strptime(s, "%M").time()
+            if (int(s) > 59):
+                s = str(int(s)//60) + ":" + str(int(s)%60)
+                return datetime.strptime(s, "%H:%M").time()
+            else:
+                return datetime.strptime(s, "%M").time()
         else:
             return datetime.strptime(s, "%H:%M").time()
     except ValueError:
c-po changed the task status from Confirmed to Needs testing.Nov 14 2020, 8:54 AM
c-po assigned this task to Unknown Object (User).
c-po added a subscriber: c-po.

Confirmed working

vyos@vyos:~$ show date
Mon 23 Nov 2020 04:22:38 PM CET
vyos@vyos:~$ reboot in 30
Reboot is scheduled 2020-11-23 16:52:42
vyos@vyos:~$ reboot in 60
Reboot is scheduled 2020-11-23 17:22:44
vyos@vyos:~$ reboot in 90
Reboot is scheduled 2020-11-23 17:52:46
vyos@vyos:~$ reboot in 90
Reboot is scheduled 2020-11-23 17:52:52
erkin set Issue type to Bug (incorrect behavior).Aug 29 2021, 12:16 PM
erkin removed a subscriber: Active contributors.