Open miarmak opened 7 years ago
That's very interesting... I'll have to take a look. Can you share the code where you use it? even if it's 'anonymized'? That will help troubleshooting :)
Unfortunately the code is not published anywhere. But I can show here, how I use that part. Simplistically, it looks like this:
PARAM_NAME = 'param_name'
def _get_host_param(self, host):
for param in host['parameters']:
if param['name'] == self.PARAM_NAME:
return param
def set_param(self, param_state, hosts_list):
for host in hosts_list:
h = self.foreman_client.hosts.show(host)
param = self._get_host_param(h)
if not param:
param = dict()
param['name'] = self.PARAM_NAME
if param.get('value') == param_state:
continue
param['value'] = param_state
host_update = {'host_parameters_attributes': [param]}
self.foreman_client.hosts.update(host=host_update, id=h['id'])
self.foreman_client.hosts.update(host=host_update, id=h['id'])
Thanks!
So here are 2 methods of
foreman.client.Foreman()
, that work incorrect for me:update_hosts
hosts.update
It take 2 arguments:
host
andid
. So I'm trying to invoke any of those methods from my code with these 2 args:self.foreman_client.hosts.update(host=host_update_dict, id=1)
And here is the result from the first call:
(server side log)
The
host
argument was sent empty for some reason.And if I add the same LOC right after the first one, it works:
(my code)
self.foreman_client.hosts.update(host=host_update_dict, id=1)
self.foreman_client.hosts.update(host=host_update_dict, id=1)
(server side log)
And every next the same request will work as well.
Foreman version:
1.14.3
python-foreman:0.4.19
So in this case, am I doing something wrong or is it a bug?