5 Replies Latest reply on Feb 1, 2012 2:21 AM by prinand

    system.importSystem filename, branchNodeID - filename does not work....

    prinand

      Hi, maybe someone can help me ?

       

      in Python I am trying to execute the command:

      >>>mc.system.importSystem('file:///d:/tools/tree.txt','2')

      true  (this is the response that I get)

       

       

      I can manually import this flat file when logged into the "regular" ePO console, via the system tree actions, new systems, I provide this tree.txt file and it will create the entire tree as expected.

      (no computers are actually in this tree.txt)

       

       

      if I run the above command I get the response true  and if I refresh the tree, it only shows that one computer "com" was added to the root of the tree (nodeID 2 is the root)

       

      what I am doing wrong, why is this file not imported ???

       

       

       

      does someone know what flattenTreeStructure means and how I would have to use this optional parameter ?

       

       

      regards,

      Andre

        • 1. Re: system.importSystem filename, branchNodeID - filename does not work....

          Hi

           

          I have the exact same problem too. Importing the text file with multiple computer names (one per line) produces the same result, a single computer-generated named com within the group indicated.

          Instead, if explicitly names on the command line (mc.system.importSystem ('test1, test2, test3', '15 '), it is operating correctly.

           

          Strangely, trough the API Explorer Web tools ePO, import command works correctly and pass the file name.

           

          I think McAfee needs to fix something.

           

          regards

           

          barena

          • 2. Re: system.importSystem filename, branchNodeID - filename does not work....
            tkincher

            This is a bit confusing. By default, it's expecting this parameter to be the list of file names. To get the desired behavior, we have to do this instead:

             

            >>> mc.system.importSystem(uploadFile="file:///d:\tools\tree.txt", branchNodeID=2);

             

            The "flattenTreeStructure" parameter is either "true" or "false" and is analogous to the radio button you see when you are in the ePO console and you go to System Tree > New Systems and select "Import systems from a text file". Here you will see an option to import either "Systems and System Tree structure" (the default) or "Systems only (as a flat list)". Setting "flattenTreeStructure" to "true" is equivalent to choosing this second option: it will not build a tree structure even if one is indicated in your text file.

            • 3. Re: system.importSystem filename, branchNodeID - filename does not work....

              Very well, a warm thanks for the help!


              In fact I made several tests, including using the parameter UploadFile, but I was not able to peck the correct syntax.

              In fact, using the python remote client the correct syntax is:

               

              barena

                >>> mc.system.importSystem (UploadFile = "file: / / / d: \ tools \ tree.txt" branchNodeID = '2');

               

              Where the entire branchNodeID it should be placed in quotation marks.

               

              Fully confirm the proper execution of the command to the remote client python.

               

              thanks again

               

              best regard

              • 4. Re: system.importSystem filename, branchNodeID - filename does not work....
                prinand

                Thanks,

                this is working like a charm now !

                 

                Barena, thanks too but there are 2 errors : UploadFile should be uploadFile  (lowercase u) and you missed the comma after the first argument

                 

                 

                >>> mc.system.importSystem(uploadFile="file:///d:\Tools\Andre\TreeStructure.txt",branchNodeID = '2');

                 

                python seems very sensitive to the case of the letters....

                • 5. Re: system.importSystem filename, branchNodeID - filename does not work....
                  prinand

                  I have been playing with Python a bit more, I am now doing the following call :

                   

                  python.exe import.py username password d:\Tools\Andre\TreeStructure.txt 2

                   

                  and import.py contains:

                   

                  import mcafee
                  import sys
                  import string

                   

                  usrname=sys.argv[1]
                  pwd=sys.argv[2]
                  tr="file:///"
                  tr+=sys.argv[3]
                  br=sys.argv[4]

                  mc = mcafee.client('localhost','38443',usrname,pwd)
                  mc.system.importSystem(uploadFile=tr,branchNodeID=br)

                  exit()

                   

                  and this worked like a charm now

                   

                  I am running most of my script in powershell, but I did not manage yet to run this import in powershell, so now I can just call this routine out of powershell and pass on the variables out of powershell to the python script this way.