Hide Forgot
Description of problem: When trying to update puppet class for smart variable 404 error is raised, though variable exists. Other fields can be updated. # Update puppet class > Making HTTP PUT request to https://example.com/api/v2/smart_variables/231 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"puppetclass_id": 1}. > Received HTTP 404 response: {"message":"Smart variable not found by id '231'"} # Perform GET request to the same variable > Making HTTP GET request to https://example.com/api/v2/smart_variables/231 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and no data. > Received HTTP 200 response: {...,"id":231,"override_values":[]} # Update description > Making HTTP PUT request to https://example.com/api/v2/smart_variables/231 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"description": "test"}. > Received HTTP 200 response: Version-Release number of selected component (if applicable): 6.2.2 (build 09/12/2016) How reproducible: Always Steps to Reproduce: 1. Create smart variable 2. Perform PUT request to update puppet class 3. Actual results: 404 error is raised, puppet class wasn't updated Expected results: Puppet class should be updated Additional info: Environment info: > OS: redhat > RELEASE: Red Hat Enterprise Linux Server release 7.2 (Maipo) > FOREMAN: 1.11.0.53 > RUBY: ruby 2.0.0p598 (2014-11-13) [x86_64-linux] > PUPPET: 3.8.6 > DENIALS: 0 Installed packages: * candlepin-0.9.54.7-1.el7.noarch * candlepin-selinux-0.9.54.7-1.el7.noarch * foreman-1.11.0.53-1.el7sat.noarch * foreman-compute-1.11.0.53-1.el7sat.noarch * foreman-debug-1.11.0.53-1.el7sat.noarch * foreman-discovery-image-3.1.1-17.el7sat.noarch * foreman-ec2-1.11.0.53-1.el7sat.noarch * foreman-gce-1.11.0.53-1.el7sat.noarch * foreman-installer-1.11.0.10-1.el7sat.noarch * foreman-installer-katello-3.0.0.57-1.el7sat.noarch * foreman-libvirt-1.11.0.53-1.el7sat.noarch * foreman-openstack-1.11.0.53-1.el7sat.noarch * foreman-ovirt-1.11.0.53-1.el7sat.noarch * foreman-postgresql-1.11.0.53-1.el7sat.noarch * foreman-proxy-1.11.0.6-1.el7sat.noarch * foreman-rackspace-1.11.0.53-1.el7sat.noarch * foreman-selinux-1.11.0.2-1.el7sat.noarch * foreman-vmware-1.11.0.53-1.el7sat.noarch * katello-3.0.0-12.el7sat.noarch * katello-certs-tools-2.4.0-1.el7sat.noarch * katello-client-bootstrap-1.1.0-2.el7sat.noarch * katello-common-3.0.0-12.el7sat.noarch * katello-debug-3.0.0-12.el7sat.noarch * katello-default-ca-1.0-1.noarch * katello-installer-base-3.0.0.57-1.el7sat.noarch * katello-selinux-3.0.1.2-1.el7sat.noarch * katello-server-ca-1.0-1.noarch * katello-service-3.0.0-12.el7sat.noarch * openldap-2.4.40-9.el7_2.x86_64 * pulp-client-1.0-1.noarch * pulp-docker-plugins-2.0.1.1-1.el7sat.noarch * pulp-katello-1.0.1-1.el7sat.noarch * pulp-ostree-plugins-1.1.1-2.el7sat.noarch * pulp-puppet-plugins-2.8.3.3-1.el7sat.noarch * pulp-puppet-tools-2.8.3.3-1.el7sat.noarch * pulp-rpm-plugins-2.8.3.5-1.el7sat.noarch * pulp-selinux-2.8.3.4-1.el7sat.noarch * pulp-server-2.8.3.4-1.el7sat.noarch * python-ldap-2.4.15-2.el7.x86_64 * tfm-rubygem-ldap_fluff-0.4.3-1.el7sat.noarch * tfm-rubygem-net-ldap-0.13.0-1.el7sat.noarch
The update request should send all data nested under smart_variable. To change the puppet class the data sent should be: { "smart_variable": { "puppetclass_id": 1 } } Does that work for you?
Well, it works but looks like update and create methods are not unified. For example, create sends parameters directly: > Making HTTP POST request to https://sat6.com/api/v2/smart_variables with ... data {"description": "test1", "variable": "abc", "puppetclass_id": 7}. > Received HTTP 201 response: {"description":"test1", ..., "puppetclass_id":7, ..., "variable":"abc","id":447,"override_values_count":0,"override_values":[]} Also other parameters except 'puppet_class_id' can be updated sending directly, e.g. 'description': > Making HTTP PUT request to https://sat6.com/api/v2/smart_variables/447 with ... and data {"description": "test2"}. > Received HTTP 200 response: {"description":"test2", ..., "puppetclass_id":7, ...,"variable":"abc","id":447,"override_values_count":0,"override_values":[]} Though it is also possible to send them nested under smart_variable: > Making HTTP PUT request to https://sat6.com/api/v2/smart_variables/448 with ... and data {"smart_variable": {"description": "test2"}}. > Received HTTP 200 response: {"description":"test2", ...} As for me, either both variants should work correctly (i.e. sending directly and nested) or only one should be available (e.g. sending nested).
Everything should work as nested for smart variables, that is also what is documented. Some things might be working directly but that is not supported and should not be used.