lop-devops / LOPOsinstall

GNU General Public License v2.0
2 stars 5 forks source link

Issue with `setenforce Permissive` command in installvm.py script #9

Open vpuliyal opened 5 months ago

vpuliyal commented 5 months ago

@PraveenPenguin I setup my dhcp and tftp servers on my lpar. I ran installvm.py script with below arguments and within 5 seconds run was completed.

[root@lktul installpowervm]# python3.7 -u installvm.py --host-ip 9.40.200.xxx --host-name linuxci-lpar1.aus.stglabs.ibm.com --host-gw 9.40.200.1 --host-netmask 255.255.255.0 --host-mac 9a:9e:c4:11:ad:02 --lpar-hmc perfpxxxxx.aus.stglabs.ibm.com --lpar-managed-system perfrainxxxxx --lpar-partition-name linuxci-lpar1 --distro rhel_8.6le_ga --host-disk=nvme-eui.36455630528016980025384100000002 --hmc-profile default_profile --hmc-userid hscroot --hmc-password xxxxxxxxxxxxx [root@lktul installpowervm]# ls installvm.conf installvm.py lib LICENSE log README.md [root@lktul installpowervm]# cd log/ [root@lktul log]# ls [root@lktul log]# cd ..

I debug the issue and issue with setenforce Permissive command in installvm.py script.

[root@cihttp rhel]# setenforce Permissive setenforce: SELinux is disabled [root@cihttp rhel]# echo $? 1 [root@cihttp rhel]# setenforce Permissive setenforce: SELinux is disabled [root@cihttp rhel]# echo $? 1

$? gives you the return value from the last run command. In this case, since SELinux is already disabled, running setenforce Permissive wouldn't go through as it's not needed. I think your script should be handling this case gracefully. It should first check the status of SELinux and then only run these commands if needed.

I've commented below lines in installvm.py script and started now it is working fine. But log files are not showing in log dir.

cmd = 'setenforce Permissive'

self.runCommand(self.dhcpSrvCon, cmd)

vpuliyal commented 5 months ago

I don't see any log file under log dir. Because of this reason script is failing.

**[root@lktul installpowervm]# python3.7 -u installvm.py --host-ip 9.40.200.xxx --host-name linuxci-lpar1.aus.stglabs.ibm.com --host-gw 9.40.200.1 --host-netmask 255.255.255.0 --host-mac 9a:9e:c4:11:ad:02 --lpar-hmc perfpxxxxx.aus.stglabs.ibm.com --lpar-managed-system perfrainxxxxx --lpar-partition-name linuxci-lpar1 --distro rhel_8.6le_ga --host-disk=nvme-eui.36455630528016980025384100000002 --hmc-profile default_profile --hmc-userid hscroot --hmc-password xxxxxxxxxxxxx lpar_netboot -x -v -f -i -D -t ent -s auto -d auto -m 9a9ec411ad02 -S 9.3.2.182 -G 9.40.200.1 -C 9.40.200.xxx -K 255.255.255.0 linuxci-lpar1 default_profile perfrain8bmc Traceback (most recent call last): File "installvm.py", line 674, in copylog() File "installvm.py", line 641, in copylog sftp.put(localpath, filepath) File "/usr/local/lib/python3.7/site-packages/paramiko/sftp_client.py", line 757, in put file_size = os.stat(localpath).st_size FileNotFoundError: [Errno 2] No such file or directory: './log/installvm-20240410-043509.log'**

[root@lktul installpowervm]# cd log/ [root@lktul log]# ls [root@lktul log]# pwd /var/lib/jenkins/workspace/PowerVMInstall_New/installpowervm/log [root@lktul log]#

vpuliyal commented 5 months ago

@PraveenPenguin I debug the log file issue. I've done below changes to "lib/configparser.py" python file.

To use the backport instead of the built-in version, simply I import it explicitly as a backport.

This will work for lower version of python also.