rhtconsulting / rhc-ose

OpenShift Automation and Utilities by Red Hat Consulting
42 stars 34 forks source link

initial convertion of provision.sh and helpers to python as per https… #238

Closed stratus-ss closed 3 years ago

stratus-ss commented 7 years ago

What does this PR do?

Converts the shell to python. No new functionality has been added.

How should this be manually tested?

Usage is almost the same as the shell. Argparse in this case is not looking for -argument= but rather just -argument.

usage: provision.py [-h] [--inventory INVENTORY_FILE]
                    [--installer-path INSTALLER_PATH]
                    [--extra-vars EXTRA_VARS [EXTRA_VARS ...]]

 ./provision.py -i /path/to/hostfile -p /path/to/installer

Is there a relevant Issue open for this?

https://trello.com/c/T330UmJG/206-convert-provision-sh-to-python

Who would you like to review this?

/cc @etsauer

…://trello.com/c/T330UmJG/206-convert-provision-sh-to-python

etsauer commented 7 years ago

@stratus-ss tested this out, looks like there are some dependencies missing:

[root@f767439a12f0 ~]# ./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py -i=./repository/rhc-ose-env-configs/inventory/provision-openstack.casl.pr -p=./repository/openshift-ansible/ -e='openstack_key_name=esauer-util3'
Traceback (most recent call last):
  File "./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py", line 62, in <module>
    provision(ansible_opts, script_base_dir, options.installer_path)
  File "./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py", line 26, in provision
    stdout=subprocess.PIPE).communicate().returncode
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
stratus-ss commented 7 years ago

I updated the PR comments to reflect the fact that it functions almost like the shell, but argparse is not looking for the '=' sign. If requested this can be added in

etsauer commented 7 years ago

@stratus-ss no, spaces are fine, but even when I do that, it still bombs at the same place:

[root@f767439a12f0 ~]# ./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py -i ./repository/rhc-ose-env-configs/inventory/provision-openstack.casl.pr -p ./repository/openshift-ansible/ -e 'openstack_key_name=esauer-util3'
Traceback (most recent call last):
  File "./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py", line 62, in <module>
    provision(ansible_opts, script_base_dir, options.installer_path)
  File "./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py", line 26, in provision
    stdout=subprocess.PIPE).communicate().returncode
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
stratus-ss commented 7 years ago

This should be fixed... I had combine the .communicate() and the return code on one line which was causing subprocess to throw a No such file or directory error for some reason.

In my small environment it works, will need to test in an actual environment

etsauer commented 7 years ago

@stratus-ss now when I run it, it hangs with no output...

[root@f767439a12f0 ~]# ./repository/rhc-ose-etsauer/rhc-ose-ansible/provision.py -i ./repository/rhc-ose-env-configs/inventory/provision-openstack.casl.pr -p ./repository/openshift-ansible/ -e 'openstack_key_name=esauer-util3'