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

Can't do a 'put' api call on a host object if the current 'name' is included in json body #564

Open
darksidemilk opened this issue Mar 29, 2023 · 0 comments
Assignees
Labels
Milestone

Comments

@darksidemilk
Copy link
Member

Describe the bug
When you do a PUT api call on a host object (http://fog-server/fog/host/{hostID}/edit) and you inlcude the 'name' in the json body, where that is the current name and is not changing, it fails with an { "error": "Already created" } If you update with a changed name or omit the name it works fine. If you include other fields with their current values, no errors occur and the values stay the same.

To Reproduce
Steps to reproduce the behavior:

There are other ways to use the api, but I found this using the fogApi powershell module.
So in a powershell session

#if you don't already have the fogpai module configured
install-module FogApi;
Set-fogserversettings -interactive; #follow the prompts to connect your server
$myHost = get-foghost;
# just an example of a change on the description field
$myHost.description = "some new description"
# create json of the whole host object
Update-FogObject -type object -coreObject host -jsonData ($myhost | convertto-json -compress) -idofobject $myhost.id -verbose

you'll get an error such as this

 $result = Invoke-WebRequest @apiCall;
     |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | { "error": "Already created" }

If you do this, to omit the name and macs in the json, it will update the description correctly, you could also select only the description/changed fields

Update-FogObject -type object -coreObject host -jsonData ($myhost | Select-Object -excludeproperty name,macs | convertto-json -compress) -idofobject $myhost.id -verbose

The resulting fog host object would then be displayed:

id             : 1847
name           : myComputerName
description    : some new description
...
#full results of host object omitted

Expected behavior

Including the current name shouldn't affect the api call when the name isn't changing. I'm fairly sure (like 80% sure) it didn't previously do this. I believe it used to ignore the macs field too, but I'm less sure about that, setting macs to a host is a separate table/api path. But this bug is about the name field.

Software (please complete the following information):

  • FOG version [e.g. 1.5.10]
  • FOS kernel n/a
  • OS: [e.g. centos 7 (also found on centos 9)]
@Sebastian-Roth Sebastian-Roth self-assigned this May 4, 2023
@Sebastian-Roth Sebastian-Roth added this to the 1.5.11 milestone May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants