Page MenuHomeVyOS Platform

"/usr/libexec/vyos/conf_mode/syslog.py" "os.path" module contains wrong attribute named as "os.path.exits" instead of "os.path.exists"
Closed, ResolvedPublic

Description

Hello Experts,

This is my first time filing of bug so please pardon me for any errors.

1. Issue occurs on the following rolling version:

$ show version
Version: VyOS 1.2.0-rolling+201904260337
Built by: autobuild@vyos.net
Built on: Fri 26 Apr 2019 03:37 UTC
Build ID: f5be1973-3184-427e-9024-e6972c144512
Architecture: x86_64
Boot via: installed image
System type: bare metal
Hardware vendor: Vyatta, Inc.
Hardware model: Vyatta 600
Hardware S/N: Unknown
Hardware UUID: Unknown
Copyright: VyOS maintainers and contributors

2. The following configuration does not get committed:

vyos# compare
[edit system]
+syslog {
+ global {
+ archive {
+ file 60
+ size 2048
+ }
+ facility all {
+ level debug
+ }
+ facility protocols {
+ level debug
+ }
+ }
+}

3. When trying to commit the above configuration, following error throws up:

vyos# commit
[ system syslog ]
Traceback (most recent call last):

File "/usr/libexec/vyos/conf_mode/syslog.py", line 293, in <module>
  apply(c)
File "/usr/libexec/vyos/conf_mode/syslog.py", line 282, in apply
  if not os.path.exits('/var/run/rsyslogd.pid'):                                              <<<<< error in "os.path.exits" attribute in line 282

AttributeError: 'module' object has no attribute 'exits'

4. The relevant section of code in the python file "/usr/libexec/vyos/conf_mode/syslog.py" is:

def apply(c):

if not os.path.exits('/var/run/rsyslogd.pid'):                                         <<<<< attribute error in "os.path.exits" on line 282
  os.system("sudo systemctl start rsyslog >/dev/null")
else:
  os.system("sudo systemctl restart rsyslog >/dev/null")

5. Referring to module definitions in python at https://docs.python.org/2/library/os.path.html, I observed that "os.path.exists" is the correct module attribute name.

6. I made the following correction in "/usr/libexec/vyos/conf_mode/syslog.py" python file:

def apply(c):

if not os.path.exists('/var/run/rsyslogd.pid'):                                       <<<<< "os.path.exits" changed to "os.path.exists" on line 282
  os.system("sudo systemctl start rsyslog >/dev/null")
else:
  os.system("sudo systemctl restart rsyslog >/dev/null")

7. After the changed, I was able to commit the configuration defined in Step 2:

vyos# compare
[edit system]
+syslog {
+ global {
+ archive {
+ file 60
+ size 2048
+ }
+ facility all {
+ level debug
+ }
+ facility protocols {
+ level debug
+ }
+ }
+}
[edit]
vyos# commit
[edit]
vyos#

I am not a developer (totally new to development) but I would like contribute to the community wherever I can.
If anyone can guide me on how to make these available in the nightly builds, I can start contributing immediately.

Thank You
Ray

Details

Difficulty level
Unknown (require assessment)
Version
1.2.0-rolling+201904260337
Why the issue appeared?
Will be filled on close

Event Timeline

Ray changed the task status from Open to Confirmed.Apr 27 2019, 11:53 PM
Ray triaged this task as Normal priority.
Ray created this task.
Ray created this object in space S1 VyOS Public.

Hi Daniil,

I remember you since Vyatta time.
I am interested in learning development on VyOS provides that great opportunity.
Could you help me with my question in the bug report?

Thank you very much

Regards
Ray

hagbard changed the task status from Confirmed to Needs testing.Apr 28 2019, 1:42 AM
hagbard claimed this task.
hagbard added a subscriber: hagbard.

Thanks much @hagbard . I will test it out and update.

Hello @hagbard,

Fix confirmed in the following version:

vyos# run show version
Version: VyOS 1.2.0-rolling+201905041032
Built by: autobuild@vyos.net
Built on: Sat 04 May 2019 10:32 UTC
Build ID: ffd5fc74-ff8b-43fa-a521-9160ea955785
Architecture: x86_64
Boot via: installed image
System type: bare metal
Hardware vendor: Vyatta, Inc.
Hardware model: Vyatta 600
Hardware S/N: Unknown
Hardware UUID: Unknown
Copyright: VyOS maintainers and contributors

vyos# delete system syslog
[edit]
vyos# commit
[edit]
vyos# compare saved
[edit system]
-syslog {

  • global {
  • archive {
  • file 60
  • size 2048
  • }
  • facility all {
  • level debug
  • }
  • facility protocols {
  • level debug
  • }
  • }

-}
[edit]
vyos# discard;load;commit

No changes have been discarded

Loading configuration from '/config/config.boot'...

Load complete. Use 'commit' to make changes active.
[edit]

vyos# grep -i "os.path.exists\|os.path.exits" /usr/libexec/vyos/conf_mode/syslog.py

if not os.path.exists('/var/run/rsyslogd.pid'):

Thank You

Ray reassigned this task from Ray to hagbard.