From: Joe VLcek jvlcek@redhat.com
Signed-off-by: Joe VLcek jvlcek@redhat.com --- agent/Makefile | 6 ++++-- agent/aeolus-audrey-agent.spec.in | 4 +++- agent/audrey_agent.in.py | 31 +++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/agent/Makefile b/agent/Makefile index 537ab20..6f60023 100644 --- a/agent/Makefile +++ b/agent/Makefile @@ -62,9 +62,11 @@ audrey_agent.py: audrey_agent.in.py audrey: audrey_agent.py cp $< $@
-# Generate the man page using help2man from the --help text output from the Audrey agent. -# Run the audrey target before geneeerating the man page. +# Generate the man page using help2man from the --help text output +# from the Audrey agent. +# Run the audrey target before generating the man page. audrey.$(man_section): audrey + ./$< --help help2man --name='Aeolus agent' --section $(man_section) \ --no-info ./$< > $@-t mv $@-t $@ diff --git a/agent/aeolus-audrey-agent.spec.in b/agent/aeolus-audrey-agent.spec.in index c6dc369..444f761 100644 --- a/agent/aeolus-audrey-agent.spec.in +++ b/agent/aeolus-audrey-agent.spec.in @@ -15,7 +15,7 @@ # Name: aeolus-audrey-agent Version: @VERSION@ -Release: 12%{?dist} +Release: 13%{?dist} Summary: The Aeolus Audrey Startup Agent
Group: Applications/System @@ -65,6 +65,8 @@ cp audrey.8 %{buildroot}%{_mandir}/man8 %doc COPYING
%changelog +* Tue Dec 06 2011 Joe VLcek jvlcek@redhat.com 0.4.0-13 +- Made run with Python2.4 for RHEL5 compatibility * Thu Nov 18 2011 Joe VLcek jvlcek@redhat.com 0.4.0-12 - Fixed Auto help file generation induced build failure * Thu Nov 17 2011 Joe VLcek jvlcek@redhat.com 0.4.0-11 diff --git a/agent/audrey_agent.in.py b/agent/audrey_agent.in.py index f59ba1e..9ef7826 100755 --- a/agent/audrey_agent.in.py +++ b/agent/audrey_agent.in.py @@ -20,8 +20,8 @@ ''' Audrey Startup (AS)
-Note: The source file is named audrey_agent.in.py The make process generates - audrey_agent.py. audrey_agent.py should not be manually modified. +Note: The source file is named audrey_start.in.py The make process generates + audrey_start.py. audrey_start.py should not be manually modified.
Invoked at instance launch to interface with the Config Server (CS)
@@ -93,7 +93,7 @@ def _raise_ASError(err_msg): LOGGER.error(err_msg) raise ASError(err_msg)
-class _run_cmd_return_subproc(): +class _run_cmd_return_subproc(object): ''' Used to pass return code to caller if no subprocess object is generated by Popen() due to an error. @@ -1007,9 +1007,14 @@ def discover_config_server(cloud_info_file=CLOUD_INFO_FILE, else: _raise_ASError('Could not get user data version, parse failed')
+ # This could be done using "with open()" but that's not available + # in Python 2.4 as used on RHEL5 try: - with open(cloud_info_file, 'r') as fp: + fp = open(cloud_info_file, 'r') + try: read_data = fp.read() + finally: + fp.close() except IOError: _raise_ASError(('Failed accessing file %s') % \ (cloud_info_file)) @@ -1097,13 +1102,18 @@ def discover_config_server(cloud_info_file=CLOUD_INFO_FILE, _raise_ASError(('Failed command: \n%s \nError: \n%s') % \ (' '.join(cmd), str(ret['err'])))
+ # Condfig Server (CS) address:port. + # This could be done using "with open()" but that's not available + # in Python 2.4 as used on RHEL5 try: - # Condfig Server (CS) address:port. - with open('/media/deltacloud-user-data.txt', 'r') as fp: + fp = open('/media/deltacloud-user-data.txt', 'r') + try: line = fp.read().strip() if '|' not in line: line = base64.b64decode(line) return _parse_user_data(line) + finally: + fp.close() except: _raise_ASError('Failed accessing RHEVm user data.')
@@ -1142,13 +1152,18 @@ def discover_config_server(cloud_info_file=CLOUD_INFO_FILE, _raise_ASError(('Failed command: \n%s \nError: \n%s') % \ (' '.join(cmd), str(ret['err'])))
+ # Condfig Server (CS) address:port. + # This could be done using "with open()" but that's not available + # in Python 2.4 as used on RHEL5 try: - # Condfig Server (CS) address:port. - with open('/media/deltacloud-user-data.txt', 'r') as fp: + fp = open('/media/deltacloud-user-data.txt', 'r') + try: line = fp.read().strip() if '|' not in line: line = base64.b64decode(line) return _parse_user_data(line) + finally: + fp.close() except: _raise_ASError('Failed accessing vSphere user data.')