Index: /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py
===================================================================
--- /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py	(revision 2376)
+++ /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py	(working copy)
@@ -19,16 +19,14 @@
     if isinstance(exc, GenericError):
         response_data = {
             'error': exc.status_code,
-            'message': exc.message,
-            'details': str(exc)
+            'message': exc.message
         }
         status_code = exc.status_code
     else:
         # Default behavior for other exceptions
         response_data = {
             'error': exc.status_code,
-            'message': 'An unexpected error occurred',
-            'details': str(exc)
+            'message': 'An unexpected error occurred'
         }
         status_code = 500
 
Index: /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/log_location.py
===================================================================
--- /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/log_location.py	(revision 2376)
+++ /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/log_location.py	(working copy)
@@ -5,15 +5,27 @@
 from cm.lib.libbasic_operation import oper_log
 from services import log_location_service as log_service
 from hive.custom_exceptions import generic_exception as ge
+from hive.util import constants as const
 
 
 def handle_log_location_app(request, app):
     if app == 'location' and request.method == 'GET':
         return get_log_location(request)
-    elif app == 'location' and (request.method == 'POST' or request.method == 'PUT'):
+    elif app == 'location' and request.method == 'POST':
         return change_log_location(request)
     elif app == 'storage' and request.method == 'GET':
         return get_secondary_drive_info(request)
+    elif app == 'archive' and request.method == 'POST':
+        return archive_logs(request)
+    elif app == 'unarchive' and request.method == 'POST':
+        return unarchive_logs(request)
+    elif app == 'archives' and request.method == 'GET':
+        return get_archive_files(request)
+    else:
+        return HttpResponse(json.dumps({
+            'error': 405,
+            'message': "Invalid HTTP method"
+        }), content_type='application/json')
 
 
 def get_secondary_drive_info(request):
@@ -22,6 +34,9 @@
             storage_type = request.GET.get('type')
             if str(storage_type).strip() == 'secondary':
                 response_data = log_service.get_secondary_drive_info()
+                if not response_data['is_disk_available']:
+                    response_data = {'status', 'There is no secondary disk attached to the system.'
+                                               'Please contact Administrator to add additional disk space'}
             else:
                 return HttpResponse(json.dumps({
                     'error': 500,
@@ -62,9 +77,15 @@
 
 def change_log_location(request):
     try:
-        if request.method == 'POST' or request.method == 'PUT':
+        if request.method == 'POST':
             req_json = json.loads(request.body)
-            response_data = log_service.change_log_location(req_json)
+            if 'location' in req_json:
+                log_location = req_json['location']
+            else:
+                oper_log('error', 'system', 'Log Location not specified')
+                raise ge.GenericError(400, "Log Location not specified")
+
+            response_data = log_service.change_log_location(log_location)
             return HttpResponse(json.dumps(response_data), content_type='application/json')
         else:
             return HttpResponse(json.dumps({
@@ -89,5 +110,130 @@
     except Exception as e:
         # Handle unexpected exceptions
         oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e))
+        e.message = 'An unexpected error occurred: {}'.format(e)
+        return ge.handle_exception(e)
+
+
+def archive_logs(request):
+    try:
+        if request.method == 'POST' or request.method == 'PUT':
+            req_json = json.loads(request.body)
+            if 'location' in req_json:
+                location = req_json['location']
+                if location == const.PRIMARY:
+                    archive_location = '/var/log'
+                elif location == const.SECONDARY:
+                    archive_location = '/secondary'
+                else:
+                    oper_log('error', 'system', 'Invalid location specified: {}. '
+                                                'Valid values are primary or secondary.'.format(location),
+                             )
+                    raise ge.GenericError(400, 'Invalid location specified: {}. '
+                                               'Valid values are primary or secondary.'.format(location))
+            else:
+                oper_log('error', 'system', 'Archive Location not specified')
+                raise ge.GenericError(400, "Archive Location not specified")
+            archive_name = log_service.archive_logs(archive_location)
+            return HttpResponse(json.dumps({'status': 'Archive {} was successfully created in {} storage'.format(
+                archive_name.split("/")[-1], location)}), content_type='application/json')
+        else:
+            return HttpResponse(json.dumps({
+                'error': 405,
+                'message': "Invalid HTTP method"
+            }), content_type='application/json')
+    except ValueError as e:
+        oper_log('error', 'system', 'Invalid JSON provided in request:{}'.format(str(e)))
+        return HttpResponse(json.dumps({
+            'error': 400,
+            'message': "Invalid JSON provided in request:{}".format(str(e))
+        }), content_type='application/json')
+    except ge.GenericError as e:
+        # Log the error (optional)
+        oper_log('error', 'system', 'Error while creating partition: {}'.format(e))
+        e.message = "Error while creating partition"
+        return ge.handle_exception(e)
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e))
+        e.message = 'An unexpected error occurred: {}'.format(e)
+        return ge.handle_exception(e)
+
+
+def get_archive_files(request):
+    try:
+        if request.method == 'GET':
+            location = request.GET.get('location')
+            if location == const.PRIMARY:
+                archive_location = '/var/log/'
+            elif location == const.SECONDARY:
+                archive_location = '/secondary/'
+            else:
+                oper_log('error', 'system', 'Invalid location specified: {}. '
+                                            'Valid values are primary or secondary.'.format(location),
+                         )
+                raise ge.GenericError(400, 'Invalid location specified: {}. '
+                                           'Valid values are primary or secondary.'.format(location))
+        else:
+            oper_log('error', 'system', 'Archive Location not specified')
+            raise ge.GenericError(400, "Archive Location not specified")
+        files = log_service.get_archive_files(archive_location)
+        return HttpResponse(json.dumps({'status': 'success',
+                                        'file_list': files}), content_type='application/json')
+
+    except Exception as e:
+        oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e))
+        e.message = 'An unexpected error occurred: {}'.format(e)
+        return ge.handle_exception(e)
+
+
+def unarchive_logs(request):
+    try:
+        if request.method == 'POST' or request.method == 'PUT':
+            req_json = json.loads(request.body)
+            if 'location' in req_json:
+                location = req_json['location']
+                if location == const.PRIMARY:
+                    archive_location = '/var/log/'
+                elif location == const.SECONDARY:
+                    archive_location = '/secondary/'
+                else:
+                    oper_log('error', 'system', 'Invalid location specified: {}. '
+                                                'Valid values are primary or secondary.'.format(location),
+                             )
+                    raise ge.GenericError(400, 'Invalid location specified: {}. '
+                                               'Valid values are primary or secondary.'.format(location))
+            else:
+                oper_log('error', 'system', 'Archive Location not specified')
+                raise ge.GenericError(400, "Archive Location not specified")
+
+            if 'filename' in req_json:
+                filename = req_json['filename']
+            else:
+                oper_log('error', 'system', 'Filename not specified. Please provide a valid filename to unarchive')
+                raise ge.GenericError(400, 'Filename not specified. Please provide a valid filename to unarchive')
+
+            response_data = log_service.unarchive_logs(archive_location, filename)
+            if response_data is True:
+                return HttpResponse(
+                    json.dumps({'status': '{} is extracted successfully in {} storage'.format(filename, location)}),
+                    content_type='application/json')
+            else:
+                return HttpResponse(
+                    json.dumps({'status': '{} is not present in {} storage'.format(filename, location)}),
+                    content_type='application/json')
+        else:
+            return HttpResponse(json.dumps({
+                'error': 405,
+                'message': "Invalid HTTP method"
+            }), content_type='application/json')
+    except ValueError as e:
+        oper_log('error', 'system', 'Invalid JSON provided in request:{}'.format(str(e)))
+        return HttpResponse(json.dumps({
+            'error': 400,
+            'message': "Invalid JSON provided in request:{}".format(str(e))
+        }), content_type='application/json')
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e))
         e.message = 'An unexpected error occurred: {}'.format(e)
         return ge.handle_exception(e)
\ No newline at end of file
Index: /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py
===================================================================
--- /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py	(revision 2376)
+++ /branches/amp_3_7_1/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py	(working copy)
@@ -1,15 +1,13 @@
 import subprocess
 import re
 import os
+import datetime
+import shutil
+import zipfile
 from hive.custom_exceptions import generic_exception as ge
 
 from cm.lib.libbasic_operation import oper_log
-
-SECONDARY_ELASTICSEARCH_DIR = '/secondary/elasticsearch'
-
-SECONDARY_LOG_LOCATION = '/secondary/elasticsearch'
-
-ELASTIC_SEARCH_CONFIG_FILE = '/etc/elasticsearch/elasticsearch.yml'
+from hive.util import constants as const
 
 
 def get_secondary_drive_info():
@@ -24,7 +22,7 @@
         secondary_drive_info = {}
         for line in lines[1:]:  # Skip the header line
             parts = line.split()
-            if 'secondary' in parts[-1]:
+            if const.SECONDARY in parts[-1]:
                 total_space = convert_to_bytes(parts[1])
                 used_space = convert_to_bytes(parts[2])
                 available_space = convert_to_bytes(parts[3])
@@ -105,8 +103,7 @@
 
         # Display unmounted disks
         if len(unmounted_disk_dict) == 0 and len(unmounted_disks) == 0:
-            raise ge.GenericError(500, "There is no secondary disk attached to the system. "
-                                       "Please contact Administrator to add additional disk space")
+            return None
 
         disk_info = unmounted_disks[0], unmounted_disk_dict[unmounted_disks[0]]
         return disk_info
@@ -123,7 +120,7 @@
 def get_log_location():
     """ Fetches the current log location in AMP Eg: 'primary' or 'secondary' """
     # Read existing configuration
-    with open(ELASTIC_SEARCH_CONFIG_FILE, 'r') as configfile:
+    with open(const.ELASTIC_SEARCH_CONFIG_FILE, 'r') as configfile:
         lines = configfile.readlines()
 
     log_location = ''
@@ -133,42 +130,40 @@
 
     if len(log_location) != 0:
         if log_location.startswith('/var/log'):
-            return {'location': 'primary'}
+            return {'location': const.PRIMARY}
         elif log_location.startswith('/secondary'):
-            return {'location': 'secondary'}
+            return {'location': const.SECONDARY}
     else:
         oper_log('error', 'system', 'Log location is not specified')
         raise ge.GenericError(500, "Log location is not specified")
 
 
-def change_log_location(req_json):
+def change_log_location(log_location):
     """ Changes the log location from For Eg from 'primary' to 'secondary' or vice versa """
 
     try:
-        if 'location' in req_json:
-            log_location = req_json['location']
-        else:
-            oper_log('error', 'system', 'Log Location not specified')
-            raise ge.GenericError(400, "Log Location not specified")
-
-        if log_location == 'secondary':
-            log_location = SECONDARY_LOG_LOCATION
+        if log_location == const.SECONDARY:
+            log_location = const.SECONDARY_LOG_LOCATION
             secondary_drive_info = get_secondary_drive_info()
 
             if secondary_drive_info.get('is_disk_available'):
                 if not secondary_drive_info.get('is_mounted'):
                     create_partition(secondary_drive_info)
                 create_elastic_search_dir()
+            else:
+                return {'status', 'There is no secondary disk attached to the system.'
+                                  'Please contact Administrator to add additional disk space'}
 
-        elif log_location == 'primary':
-            log_location = '/var/log/elasticsearch'
+        elif log_location == const.PRIMARY:
+            log_location = const.PRIMARY_LOG_LOCATION
         else:
             oper_log('error', 'system', 'Invalid location specified: {}'.format(log_location))
             raise ge.GenericError(400, "Invalid location specified: {}. "
-                                       "Valid values are {} and {}".format(log_location, 'primary', 'secondary'))
+                                       "Valid values are {} and {}".format(log_location, const.PRIMARY,
+                                                                           const.SECONDARY))
 
         # Read existing configuration
-        with open(ELASTIC_SEARCH_CONFIG_FILE, 'r') as configfile:
+        with open(const.ELASTIC_SEARCH_CONFIG_FILE, 'r') as configfile:
             lines = configfile.readlines()
 
         updated_lines = []
@@ -180,7 +175,7 @@
 
         # write the updated configuration back to the file
         try:
-            with open(ELASTIC_SEARCH_CONFIG_FILE, 'w') as configfile:
+            with open(const.ELASTIC_SEARCH_CONFIG_FILE, 'w') as configfile:
                 configfile.writelines(updated_lines)
         except IOError as e:
             oper_log('error', 'system', 'Failed to write to config file')
@@ -202,11 +197,11 @@
 
 
 def create_elastic_search_dir():
-    if not os.path.exists(SECONDARY_ELASTICSEARCH_DIR):
+    if not os.path.exists(const.SECONDARY_LOG_LOCATION):
         commands = [
-            "mkdir -p {}".format(SECONDARY_ELASTICSEARCH_DIR),
-            "chown -R elasticsearch:elasticsearch {}".format(SECONDARY_ELASTICSEARCH_DIR),
-            "chmod 750 {}".format(SECONDARY_ELASTICSEARCH_DIR)
+            "mkdir -p {}".format(const.SECONDARY_LOG_LOCATION),
+            "chown -R elasticsearch:elasticsearch {}".format(const.SECONDARY_LOG_LOCATION),
+            "chmod 750 {}".format(const.SECONDARY_LOG_LOCATION)
         ]
         for command in commands:
             try:
@@ -240,4 +235,76 @@
     secondary_drive_info = get_secondary_drive_info()
     if len(secondary_drive_info) == 0 and not secondary_drive_info['is_mounted']:
         oper_log('error', 'system', 'Error in mounting disk {}'.format(disk_name))
-        raise ge.GenericError(400, "Error in mounting disk {}".format(disk_name))
\ No newline at end of file
+        raise ge.GenericError(400, "Error in mounting disk {}".format(disk_name))
+
+
+def archive_logs(archive_location):
+    """ archive_location is location where we wish to store the archive file
+        current_log_location is the location from which we need to create the archive file"""
+    try:
+        current_log_location = get_log_location()
+
+        # List all files in the directory
+        location = current_log_location['location']
+        if location == const.PRIMARY:
+            location = const.PRIMARY_LOG_LOCATION
+            all_files = os.listdir(location)
+        elif location == const.SECONDARY:
+            location = const.SECONDARY_LOG_LOCATION
+            all_files = os.listdir(location)
+        else:
+            oper_log('error', 'system', 'Invalid location specified: {}'.format(location))
+            raise ge.GenericError(400, "Invalid location specified: {}. "
+                                       "Valid values are {} and {}".format(location, 'primary', 'secondary'))
+
+            # Filter out ZIP files
+        files_to_archive = [f for f in all_files if not f.startswith('log_') and not f.endswith('.zip')]
+
+        timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
+        archive_name = os.path.join(archive_location, 'logs_{}'.format(timestamp) + '.zip')
+
+        with zipfile.ZipFile(archive_name, 'w') as archive:
+            for file in files_to_archive:
+                file_path = os.path.join(location, file)
+                archive.write(file_path, os.path.relpath(file_path, location))
+        return archive_name
+
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('info', 'system', 'An error occurred while archiving logs: {}'.format(e))
+        e.message = 'An error occurred while archiving logs: {}'.format(e)
+        raise e
+
+
+def get_archive_files(archive_location):
+    try:
+        all_files = os.listdir(archive_location)
+        files = [f for f in all_files if f.startswith('logs_') and f.endswith('.zip')]
+        return files
+
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('info', 'system', 'An error occurred while fetching archive logs: {}'.format(e))
+        e.message = 'An error occurred while fetching archive logs: {}'.format(e)
+        raise e
+
+
+def unarchive_logs(extract_location, filename):
+    try:
+        file_path = os.path.join(extract_location, filename)
+        # Check if the file exists and is a file
+        is_file_exists = os.path.isfile(file_path)
+        if is_file_exists:
+            with zipfile.ZipFile(os.path.join(extract_location, filename), 'r') as zip_ref:
+                location = extract_location + filename.split(".")[0].strip()
+                if not os.path.exists(location):
+                    os.makedirs(location)
+                zip_ref.extractall(location)
+                return True
+        return False
+
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('info', 'system', 'An error occurred while archiving logs: {}'.format(e))
+        e.message = 'An error occurred while archiving logs: {}'.format(e)
+        raise e
\ No newline at end of file
