Linux script: fog inventory updater/editor
-
@mechalas hello, I installed python on a windows 10 and when running it gives me an error,:c: \ temp> python fog-inventory -h
Traceback (most recent call last):
File “C: \ temp \ fog-inventory”, line 42, in <module>
if os.getuid ():
AttributeError: module ‘os’ has no attribute ‘getuid’pd: my knowledge of python is zero
-
@pep Make sure to pull from the master branch, and be sure you are up to date. The Windows porting is not rolled into a tagged version yet.
That error is from the original distribution, and it comes from trying to run a UNIX-specific system call on a Windows system.
-
@mechalas OK,
OK you are right.I have moved on, but now I have this error:
Traceback (most recent call last):
File “C:\temp\fog-inventory”, line 535, in <module>
host, invid= fog.find_host(name=args.hostname)
File “C:\temp\fog-inventory”, line 223, in find_host
invid= int(invidstr)
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’ -
I am guessing it wasn’t able to figure out your hostname.
What happens if you just run:
python fog-inventory -x
Does that dump inventory info?
-
@mechalas the first computer I tried was a w10 with python 3.9.5 and the inventory works with -x but the information does not go up. Now I have tested it with a w7 and python 3.8.10 and it works perfectly.
This weekend I will try to do more testing
-
@mechalas well, I think I limited the topic.
Your script works in some cases and not in others. The error it gives seems to be linked to the machine name. I have tried it on several computers, win10, w7, with different versions of python etc … and the only pattern I have found is that on computers that an image has been dumped via fog it works, if the computer is in fog with the client but an image has not been dumped does not work.
In both win10 and w7 when it doesn’t work it gives the error I told you -
@pep Thank you for this info. The Windows stuff hasn’t really been fully vetted yet, and this helps a lot! I’ll set up a couple of VMs at home this weekend and wire them to FOG and see what needs to be done to get this working.
-
@pep OK, that extra bit of information you provided combined with my testing at home confirms what you are seeing, and I understand what is going on.
If the machine is in FOG but has not been inventoried, then the -c option fails (because there is no inventory record to fetch). It should just error out gracefully so I need to catch that exception.
The script should allow you to post inventory for a system, however. So that is a bug. I specifically gave it the logic to create an inventory record if none exists, and that means it shouldn’t bomb out because it couldn’t find one. I will get this fixed.
-
I just pushed a fix that should solve this.
-
@mechalas yes, now it works perfectly. Cool