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

Nornir state property returning GlobalState class, not object #666

Closed
brandomando opened this issue Mar 31, 2021 · 4 comments
Closed

Nornir state property returning GlobalState class, not object #666

brandomando opened this issue Mar 31, 2021 · 4 comments

Comments

@brandomando
Copy link
Contributor

return GlobalState

I'm not sure if this is intended behavior but it is a bit confusing to me why there would be a need to return the GlobalState class rather than the instantiated object like the data attribute, which is an instance of GlobalState.

@brandomando
Copy link
Contributor Author

This causes issue with the dict method of the GlobalState object when you're trying to return the dict of the data attribute of a Nornir object because it doesn't have a self since the class is returned and not the instance of it.

def dict(self) -> Dict[str, Any]:

def dict(self) -> Dict[str, Any]:
        """ Return a dictionary representing the object. """
        return {item: getattr(self, item) for item in GlobalState.__slots__}

@dbarrosop
Copy link
Contributor

GlobalState used to be a singleton but that's no longer true so I think this is a leftover. As a matter of fact, state is redundant as data is what we care about nowadays.

@brandomando
Copy link
Contributor Author

I thought that might be the case. I will submit a PR to remove it.

@dbarrosop
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants