napalm-automation / napalm-ios

Apache License 2.0
31 stars 40 forks source link

Is autodetect dir always needed? #148

Closed itdependsnetworks closed 6 years ago

itdependsnetworks commented 7 years ago

Description of Issue/Question

Using getters, would not seem like you would always need to auto_detect the dir filesytem.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

Setup

napalm-ios version

(Paste verbatim output from pip freeze | grep napalm-ios between quotes below)

napalm-ios==0.5.1

IOS version

(Paste verbatim output from show version between quotes below)

Any

Steps to Reproduce the Issue

Using Napalm-ansible and getters with napalm-ios, seems to require the dir check no matter what. This requires a different level of privileges then show commands. Is there a way to remove this dependency?

Error Traceback

Note: I'll be out for a week, just wanted to put this in before I forgot.

ktbyers commented 7 years ago

Currently, it does it at open() action.

Easiest solution might just be to try/except the error on dir (in open() ) and then if it fails just set it to default value.

In this way it would not fail on getters and would set it to its default value and would only fail latter when you tried to use it for config operations.

It would also not require I figure out all the config methods where you might require knowing the file-system.

dbarrosop commented 7 years ago

You could turn the variable that returns the filesystem into a property that either uses "cached" data or calls a method that caches the data. Something like:

@propery
def file_system(self):
    return self.file_system or self._discover_file_system()
mirceaulinic commented 6 years ago

This issue has been moved to https://github.com/napalm-automation/napalm/issues/458