Renaming Host with Web UI
-
Hello,
Recently I’ve been playing with my host naming convention for manageability on my Ubuntu 20.04 based FOG server.
One of the actions I did is to rename the host (e.g. from name1 to name2) using the Web UI. Then I want to revert to name1; and the Web UI popped up with a message saying that the host with name1 already exists. However, looking at the Web UI’s list of host, name1 is not there. I also tried removing name2 from host list followed by re-adding that same host with name1. Unfortunately this leads to the same error message.
I suspect that there’s something in Ubuntu terminal that needs to be manually removed to allow renaming the host (i.e. similar to removing OS images - removing both in Web UI and in Linux directory).
Would anyone know which file to edit? Also, what’s the BKM for renaming host to avoid this problem in the future?
Thanks,
-M -
@mgoh Off the top of my head I think that maybe fog is marking the host as deleted in the database (and not showing it in the web ui). This is only a guess since I don’t have immediate access to a fog server to verify.
If you know sql query syntax, through the FOG server’s linux console you can connect to the mysql database as root then access the fog database. The command you would do to login to the cli version of the mysql query tool is
mysql -u root
The password is a bit tricky, because if it was originally blank when fog was installed the installer will ask you to set root’s password. This value is only used to initially setup fog and is not recorded anywhere. This password is not ever used in FOG except for the initial setup of FOG. If you don’t know what you set it to there are instructions on the internet that show you how to reset the password. Then the login command would bemysql -u root -p
and then it will prompt you for root’s password.Once you get logged into mysql then issue.
use fog; select * from hosts;
That will list all of the hosts in the FOG hosts table. As I said above I don’t have immediate access to a fog server to verify it so this next query is a guess because I might not have the field name correct.
to limit the response to only the host in question use this query.
select * from hosts where name = 'name1';
See if name1 (understand that name1 represents the original name of a specific host) is still listed in the database even though you changed its name.
-
@george1421 Thanks. The column name is very close (hostName). The output is below, and the offending name is there (A40C6604DBF9).
I assume the command to delete is:
DELETE FROM
hosts
WHEREhostName
= ‘A40C6604DBF9’;Let me know if this is correct.
-
@mgoh Well the short answer is if you run that command it will delete the host from the database. But I’m not seeing a field that would say delete the host or not make it show up in the web ui.
I think before I would do anything I would run this command from the FOG server linux console.
mysqldump -B fog -u root -p > /new/fogdb.sql
ref: https://wiki.fogproject.org/wiki/index.php?title=Migrate_FOGThat way if something goes horribly wrong you can fix it.
If you remove the host from the host table it will be gone from the web ui (note because of database caching you might need to restart apache to flush the web server cache). The risk is potentially leaving records in other tables that reference host ID 12 that is no longer there. It shouldn’t hurt anything to leave these referenced table since hots ID 12 will never be used a second time.
I think if it was me and I was in a hackie mindset (with a proper backup) I would delete the record as you have it defined and see if it gives you the results you need. If not restore the database and we can think about another approach.
-
@george1421 This works. I did a backup as you suggested, and I did the command: DELETE FROM
hosts
WHEREhostName
= ‘name1’;Thank you. I noticed I didn’t put the title of this thread correctly (I hit “send” too early). I’ll create another thread so it’s searchable, if I can’t figure out how to rename the post.
Thanks,
-M -
@mgoh I think I can fix the thread for you. Glad you found a solution.