4 Replies Latest reply on Jul 3, 2017 6:38 PM by TrentHuhn

    How to automate renaming of AF Server

    TrentHuhn

      Currently, we have a test environment consisting of a PI data archive and PI AF server. Currently, when we want to refresh the test environment, the underlying SQL database (PIFD) is copied down on-demand from our production environment. Following this copy down, there are a number of manual steps that I have to take in order to prep the environment for use (such as renaming the AF server, assigning a new ID, and updating all AF attribute PI point data references). I am currently in the process of trying to automate these steps so that we can refresh the environment on a more regular basis. I am attempting to do this via a batch file, since most steps involve running command-line utilities. The one step I'm having trouble with is updating the actual AF server name (i.e. 'AFSVRPROD01' -> 'AFSVRTEST01') following the copy-down. Currently, I accomplish this via the Connections dialogue in PI System Explorer.

       

      Does anyone know if there is a command-line utility that would allow me to accomplish this? If not, would it be possible to update the 'Name' column of the AFSystemID SQL table directly with the new database name? I know directly modifying settings in the PIFD database is generally frowned upon, but this seems like a fairly straight-forward change.

       

      Thanks,

      Trent

        • Re: How to automate renaming of AF Server
          Lal_Babu_Shaik

          Hi Trent, PI Builder can be used for renaming the AF Server name. Though direct update on PIFD database is feasible it is not recommended. If you are using templates in AF then you it facilitate server name change using PI server attribute else you need to use PI builder to download the configuration and change the name.

            • Re: How to automate renaming of AF Server
              TrentHuhn

              Thanks for the response. Can you explain a little more about what you mean about using PI server attributes to update the AF server name? We are using various types of templates in our AF database, although I don't see why that would matter for the purposes of changing the database name. Also, I played around a bit in PI Builder, but was not able to figure out how to change the server name through here - is this stored in an attribute in the Configuration database that I can access?

            • Re: How to automate renaming of AF Server
              Eugene Lee

              Hi Trent,

               

              You can use PISystem.Name property to do that. Make sure that you are connected to the AF Server when you perform the change.

                • Re: How to automate renaming of AF Server
                  TrentHuhn

                  Thanks, this seemed to work. I ended up creating a small console application using the AF SDK that can be run from the command line to rename the AF server.

                   

                  static void Main(string[] args)

                  {

                       string afServerName = "", runType = "", oldAFserverName = "";

                       if (args.Length > 0)

                       {

                            runType = args[0].ToString();

                            afServerName = args[1].ToString();

                            oldAFserverName = args[2].ToString();

                       }

                   

                       PISystems piSystems = new PISystems();

                       PISystem piSystem = piSystems.FirstOrDefault(s => s.Name.ToLower() == oldAFserverName.ToLower());

                       if (piSystem != null)

                       {

                            piSystem.Name = afServerName;

                            piSystem.CheckIn();

                       }         

                  }

                  1 of 1 people found this helpful