How to change hostname on an existing instance?

Hi,

We had an Infoblox issue, and the hostname in Morpheus is incorrect. Is there a way to change the hostname, either through an API or from the UI?

Thanks!

This should be possible if you use the Update Host API with a JSON payload that looks like this:

{
	"server": {
		"hostname": "<new-hostname-here>"
	}
}

Note: this only changes the hostname in the UI so I would recommend using something like hostnamectl (set-hostname) first to update the hostname on the server → Then use the API above to update it in the UI.

The hostnamectl equivalent for Windows appears to be ‘Rename-Computer’.

Thanks for responding to my post.

I would need to change the hostname in instance.

https://morpheus.com/api/instances/id

{
	"instance": {
		"hostname": "-test-hostname"
	}
}

Applying the API call to server didn’t triggered the change.

https://morpheus.com/api/servers/id

{
	"server": {
		"hostname": "test-hostname.com"
	}
}

As you can see, the issue is it contains the hyphen. We already made the necessary changes in other services but wasn’t able to make the same change in ServiceNow, Morpheus is keep overriding the values with “-test-hostname”. I’m assuming if I can change the hostname, it will prevent from overriding the ServiceNow.

Thanks!

Thanks for the feedback :slight_smile:

I’m seeing the same behaviour as you for VMware but I think it might be expected. Doesn’t look like it’s related to hyphenation. If you don’t update the hostname on the guest OS - for example, by using hostnamectl if it’s a Linux server - prior to making the API call, Morpheus won’t make it persist on cloud syncs.

I think the hostname on the server/container is syncing up with what’s set on the guest OS so it’s worth checking that this is set/changed correctly on the host.

For the server you are working on, what’s the hostname at the OS level? You can run hostname at the command prompt / terminal to quickly find this out. Is it “-test-hostname”?

Final note - the instance hostname is referenced by “hostName” instead of “hostname” so you’ll need to update that first JSON payload

Hello and Happy New Year!

This is Windows machine, and we did run rename-computer to fix the hostname on the guest OS. Running hostname at the command prompt shows the right hostname without the hyphen.

All other attributes has the correct hostname in Morpheus, except the one I mentioned.

{
	"instance": {
		"hostname": "-test-hostname"
	}
}

Should we reinstall Morpheus agent and see if that picks up the change? Thanks again!

Dong