Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SnapAdmin's extract_data to accept a dict #341

Open
lamoni opened this issue May 23, 2019 · 0 comments
Open

Allow SnapAdmin's extract_data to accept a dict #341

lamoni opened this issue May 23, 2019 · 0 comments

Comments

@lamoni
Copy link

lamoni commented May 23, 2019

Description of Issue/Question

This is an issue I'm opening to remind myself to add this functionality. Using JSnapy as a module is very cumbersome when it comes to dynamically snapshotting/checking a device (your options are either pass a YAML string formatted the same as a config file, which sticks out like a wart in code and suffers from a bunch of weird issues like needing to hard cast the multi-line string from a bytestring to an actual str since extract_data does an isinstance check to see if it's of type str... or write to a .yml file and then pass that as the argument to snap). It'd be much better if we could just pass a dict.

Setup

Code in question


    if os.path.isfile(config_data):
        data = open(config_data, 'r')
        config_data = yaml.load(data)
    elif isinstance(config_data, str):
        config_data = yaml.load(config_data)
    else:
        self.logger.info(
            colorama.Fore.RED +
            "Incorrect config file or data, please chk !!!!", extra=self.log_detail)
        exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants