Hi Mike,

classmethod's first argument is always its class as it is always bound to
the class, which is not the case with normal methods. Thus, both of the
above methods can in essence still co-exist in base.py as they serve
different purposes.

In the latter classmethod, you need to pass your host object ID as one of
the argument while calling it with its class name as its first argument.

e.g. Host.enableMaintenance(self.apiclient, host_1.id)

Note: "Host" is the class name of the above methods in base.py. "host_1" is
your host object.

In the former method, you just need to call it with your host object as its
first argument, it takes the host ID from the passed host object.

e.g. host_1.enableMaintenance(self.apiclient)


On Sat, Apr 30, 2016 at 7:08 AM, Tutkowski, Mike <mike.tutkow...@netapp.com>
wrote:

> Hi everyone,
>
>
> I received an error when trying to invoke the instance version of
> enableMaintenance (below).
>
>
> 'TypeError: enableMaintenance() takes exactly 3 arguments (2 given)\n']
>
>
> I looked at base.py and it has the following with regards to maintenance
> mode for hosts:
>
>
>     def enableMaintenance(self, apiclient):
>
>         """enables maintenance mode Host"""
>
>
>         cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
>
>         cmd.id = self.id
>
>         return apiclient.prepareHostForMaintenance(cmd)
>
>
>     @classmethod
>
>     def enableMaintenance(cls, apiclient, id):
>
>         """enables maintenance mode Host"""
>
>
>         cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
>
>         cmd.id = id
>
>         return apiclient.prepareHostForMaintenance(cmd)
>
>
> Now, I definitely have a lot more Java experience than Python, but - as
> far as I know - having two methods with the same name such as this (even if
> one is an instance method and the other is a class method) is not really
> "permitted" in Python.
>
>
> I mean, technically it's permitted, but the second one will override the
> first one.
>
>
> Can any of our Python people comment on this?
>
>
> I was thinking I'd remove the class method (assuming my knowledge here
> regarding this topic is correct).
>
>
> Thanks!
>
> Mike
>
>
>
>

Reply via email to