jimbobhickville / python-ambariclient

Python client bindings for the Apache Ambari REST API
44 stars 31 forks source link

HostComponent stop doesn't work #38

Open jdonnelly-apixio opened 5 years ago

jdonnelly-apixio commented 5 years ago

Trying to stop a specific component for a host doesn't work currently. The request is made, but the operation_level is not set correctly, so nothing happens in ambari.

I don't do this much, so not quite sure how to push this fix from my fork. But in models.py, HostComponent stop should be changed to:

    def stop(self, context=None):
        if not context:
            context = "Stop %s" % normalize_underscore_case(self.component_name)

        """Starts this component on its host, if already installed and started."""
        self.load(self.client.put(self.url, data={
            "RequestInfo": {
                "context": context,
                "operation_level": {
                        "level": "HOST_COMPONENT",
                        "cluster_name": self.cluster_name,
                        "host_name": self.host_name,
                    }
            },
            "HostRoles": {
                "state": "INSTALLED",
            },
        }))
        return self

I will try to push the fix upstream at some point when I get some time (unless anyone is monitoring these issues and wants to do it before then).

jdonnelly-apixio commented 5 years ago

think i did this right.. i sent in this PR: https://github.com/jimbobhickville/python-ambariclient/pull/39

Can someone let me know if I did this wrong?

Thanks!