• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Renaming multiple computers on Fog

    Scheduled Pinned Locked Moved
    General Problems
    5
    9
    2.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gabbas
      last edited by

      Hi,
      Recently our head office decided to change the PC naming convention and they have asked us to rename all our lab computers (around 500 computers in different groups). Can you please advise me whats the best way to accomplish this without spending a lot of time. We also need to rename these in AD. I have researched few scripts but is there anything you would advise which we can do to do this change smoothly?
      Many thanks

      1 Reply Last reply Reply Quote 0
      • Q
        Quazz Moderator
        last edited by

        Download host list, bulk edit with new format, upload host list? Seems easiest to me on FOG’s end anyway. I don’t really use AD so can’t help you there, but others here might.

        G 1 Reply Last reply Reply Quote 0
        • G
          gabbas @Quazz
          last edited by

          @Quazz Should I download in excel, just edit the name cell, save it and import it back to fog? Do I need to delete the existing hosts? Sorry I have not done this before…))

          Q 1 Reply Last reply Reply Quote 0
          • Q
            Quazz Moderator @gabbas
            last edited by

            @gabbas I do not recommend editing in excel, it’s notorious for assigning field types incorrectly messing up your data.

            I think you do have to delete the hosts before uploading the file, yes, so best to have a backup of the host list somewhere.

            1 Reply Last reply Reply Quote 0
            • Tom ElliottT
              Tom Elliott
              last edited by

              Or, and I’m just saying cause why not.

              Get a list of the hosts into a CSV based off the “list” element of api, and script the rename by sending and update to each host to be updated.

              Right now the API only supports editing based on the item’s ID, but you CAN script it using FOG’s API system now.

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

              1 Reply Last reply Reply Quote 1
              • george1421G
                george1421 Moderator
                last edited by

                Maybe cause I’m an old dba, or just old. For 500 computers I might look at doing this directly in the database (with SQL). Is the name transition a logical one? Can you explain the name format exchange?

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                1 Reply Last reply Reply Quote 1
                • george1421G
                  george1421 Moderator
                  last edited by george1421

                  Well I just noodled up a possible solution if the name exchange is not a logical one or one that can be calculated.

                  Will it work??
                  Have I tested it, No!

                  First in case something goes really wrong, lets make a backup of the hosts table.
                  mysqldump -u root -p fog hosts > /tmp/host_table_backup.sql

                  If we need it we can restore the db with this command
                  mysql -u root -p fog < /tmp/host_table_backup.sql

                  The following commands are what we should need in mysql.

                  USE fog;
                  
                  CREATE TABLE NameExchange (
                      OldName varchar(16),
                      NewName varchar(16) 
                  );
                  
                  
                  LOAD DATA LOCAL INFILE  
                      '/temp/host-matrix.csv'
                      INTO TABLE NameExchange  
                      FIELDS TERMINATED BY ',' 
                      ENCLOSED BY '"'
                      LINES TERMINATED BY '\n'
                      (OldName,NewName);
                  
                  UPDATE hosts
                  INNER JOIN NameExchange ON hosts.hostName = NameExchange.OldName
                  SET hosts.hostName = NameExchange.NewName;
                  
                  DROP TABLE NameExchange;
                  
                  
                  1. We tell the mysql command processor we are working with the fog database.

                  2. We’ll create a temp table to hold our new/old name matrix.

                  3. Then import your csv file.

                  4. Then update hosts.hostName based on the match between hostName OldName

                  5. Lastly we’ll drop the matrix table since its not needed anymore.

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                  1 Reply Last reply Reply Quote 1
                  • G
                    gabbas
                    last edited by

                    Hi, Thanks for the suggestions. I imported the list of computers as csv, renamed the host names and imported back to the relevant group. This restarted the PCs and renamed them. Run a script to unjoin from the domain, restarted and fog hostname service re-joined the PCs back to the AD. I believe there will be other ways to do this as well (maybe in less steps) but this one worked for me.
                    Thanks Again

                    Wayne WorkmanW 1 Reply Last reply Reply Quote 0
                    • Wayne WorkmanW
                      Wayne Workman @gabbas
                      last edited by Wayne Workman

                      @gabbas If you were using the latest version of the new fog client, it will rename the object for you in active directory.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                      Daily Clean Installation Results:
                      https://fogtesting.fogproject.us/
                      FOG Reporting:
                      https://fog-external-reporting-results.fogproject.us/

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post

                      154

                      Online

                      12.0k

                      Users

                      17.3k

                      Topics

                      155.2k

                      Posts
                      Copyright © 2012-2024 FOG Project