Python Faceplant - Newbie level help requested
Hey Everyone,
Thanks for taking the time to look at what I'm doing here. My disclaimer: I very, very rarely code. I've done a few python and perl scripts in my day but it has never been my strength. I have completed the "learn python the hard way" tutorial so the fundamentals are there just can't seem to put it together. This script uses vCenter API calls to get a list of all the VMs on our vCenter server. I then want to execute a shell subprocess to query against a proprietary database and compare the two to find any that exist in the vCenter API call but not in the database. I am able to successfully execute the subprocess against the database and get the results from the API call but am having trouble getting the two to compare properly, I'm making backwards progress now from attempting multiple different methods found on google so apologize for any sloppiness. Code:
#!/usr/bin/python Any help or suggestions are very much appreciated! This is difficult to test as it uses API calls and proprietary DB but sample data is below: I probably need to split this or something to compare properly(havent really tried that yet) Code:
vCenter API Call results: Code:
mminfo/db results: |
So you want:
Code:
[DATASTORE] VMNAME/VMCONFIGFILE.vmx Code:
VMNAME And in the code, regularVMs is the "[DATASTORE] VMNAME/VMCONFIGFILE.vmx" list and query is the "VMNAME" list, right? In that case, Code:
for vm in sorted(set(regularVMs) - set(query)): Code:
regularVmS = [vm.split()[1].split('/')[0] for vm in regularVMS] |
All times are GMT -5. The time now is 10:47 AM. |