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

[featurerequest] Ability to query power information #81

Closed
seanhoughton opened this issue Mar 13, 2017 · 3 comments
Closed

[featurerequest] Ability to query power information #81

seanhoughton opened this issue Mar 13, 2017 · 3 comments

Comments

@seanhoughton
Copy link

It would be really useful to be able to use the "op=power_parameters" machine query to get IPMI information. Something like...

c.machines.get('machineid').power_parameters

I looked through the code to see if I could add it myself but used up my self-imposed timebox :) The code uses some abstractions that make it pretty difficult to follow for someone new to the project.

@seanhoughton
Copy link
Author

I see that there's a test case for this, so it appears that it's possible, but I can't figure out the syntax to use in real code.

def test__Machines_power_parameters(self):
        session = bones.SessionAPI(self.description, ("a", "b", "c"))
        action = session.Machines.power_parameters
        self.assertThat(action, MatchesStructure.byEquality(
            name="power_parameters", fullname="Machines.power_parameters",
            method="GET", handler=session.Machines, is_restful=False,
            op="power_parameters",
        ))

@seanhoughton
Copy link
Author

Ok, after a more hours than I would like to admit, I've figured out the required incantation, thanks to the unit tests:

    for machine in await origin.Machines.read():
        if machine.status_name == 'New':
            get_power = origin.session.Machine.power_parameters.bind(system_id=machine.system_id)
            power = await get_power.call()
            logging.info('%s - %s %s', machine.hostname, machine.ip_addresses, power.data)

It would really be nice if this was part of the simple api.

@brendan-donegan
Copy link
Contributor

Hi Sean,

Actually the Machines endpoint has a 'power_parameters' method - the branch I attached exposes this as a method on the Machines class

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