Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/djproject/urls.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/djproject/urls.py	(revision 2344)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/djproject/urls.py	(working copy)
@@ -11,6 +11,7 @@
 from hive.session import current_app
 from hive.composer import KibanaProxyView, elastic_proxy, composer_proxy, reporting_downloading_handler, reporting_logo_handler, composer_config, composer_status
 from hive.storage import storage_mangement
+from hive.log_location import handle_log_location_app
 
 js_info_dict = {
     #'packages': ('your.app.package',),
@@ -56,6 +57,7 @@
     url(r'^composer/(?P<path>.*)', composer_proxy),
     url(r'^composer_config/(?P<app>\w+)', composer_config),
     url(r'^composer_status/(?P<app>\w+)', composer_status),
+    url(r'^log/(?P<app>\w+)$', handle_log_location_app),
     url(r'^real_service$', real_service),
     url(r'^rs_block$', rs_block),
     url(r'^rs_block_import$', rs_block_import),
Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/__init__.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/__init__.py	(revision 0)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/__init__.py	(working copy)
@@ -0,0 +1 @@
+__all__ = ['generic_exception']
\ No newline at end of file
Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py	(revision 0)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/custom_exceptions/generic_exception.py	(working copy)
@@ -0,0 +1,13 @@
+import subprocess
+
+
+class GenericError(Exception):
+    """Exception raised for errors related to creating partition for secondary drive."""
+
+    def __init__(self, status_code=500, message="An error occurred while creating partition for the secondary memory"):
+        super(GenericError, self).__init__(message)
+        self.status_code = status_code
+
+
+def __str__(self):
+    return "{}: {}".format(self.message, self.original_exception)
\ No newline at end of file
Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/log_location.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/log_location.py	(revision 0)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/log_location.py	(working copy)
@@ -0,0 +1,112 @@
+import subprocess
+import json
+
+from django.http import HttpResponse
+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
+
+
+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'):
+        return change_log_location(request)
+    elif app == 'storage' and request.method == 'GET':
+        return get_secondary_drive_info(request)
+
+
+def get_secondary_drive_info(request):
+    if request.method == 'GET':
+        try:
+            storage_type = request.GET.get('type')
+            if str(storage_type).strip() == 'secondary':
+                response_data = log_service.get_secondary_drive_info()
+            else:
+                return HttpResponse(json.dumps({
+                    'error': 500,
+                    'message': "Currently the 'type' parameter only supports 'secondary' value"
+                }), content_type='application/json')
+            return HttpResponse(json.dumps(response_data), content_type='application/json')
+
+        except ge.GenericError as e:
+            oper_log('error', 'system', e.message)
+            return HttpResponse(json.dumps({
+                'error': 500,
+                'message': e.message,
+                'data': str(e)
+            }), content_type='application/json')
+        except Exception as e:
+            oper_log('error', 'system', 'An Unexpected error occurred,  details: {}'.format(e))
+            return HttpResponse(json.dumps({
+                'error': 500,
+                'message': "An Unexpected error occurred",
+                'data': str(e)
+            }), content_type='application/json')
+
+    else:
+        return HttpResponse(json.dumps({
+            'error': 405,
+            'message': "Invalid HTTP method"
+        }), content_type='application/json')
+
+
+def get_log_location(request):
+    try:
+        if request.method == 'GET':
+            response_data = log_service.get_log_location()
+            return HttpResponse(json.dumps(response_data), content_type='application/json')
+        else:
+            return HttpResponse(json.dumps({
+                'error': 405,
+                'message': "Invalid HTTP method"
+            }), content_type='application/json')
+    except Exception as e:
+        oper_log('error', 'system', 'An Unexpected error occurred,  details: {}'.format(e))
+        return HttpResponse(json.dumps({
+            'error': 500,
+            'message': "An Unexpected error occurred",
+            'data': str(e)
+        }), content_type='application/json')
+
+
+def change_log_location(request):
+    try:
+        if request.method == 'POST' or request.method == 'PUT':
+            req_json = json.loads(request.body)
+            response_data = log_service.change_log_location(req_json)
+            return HttpResponse(json.dumps(response_data), 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 IOError as e:
+        oper_log('error', 'system', 'Failed to write to config file')
+        return HttpResponse(json.dumps({
+            'error': 500,
+            'message': "Failed to write to config file",
+            'data': 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))
+        return HttpResponse(json.dumps({
+            'error': 500,
+            'message': "Error while creating partition",
+            'data': str(e)
+        }), content_type='application/json')
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e))
+        return HttpResponse(json.dumps({
+            'error': 500,
+            'message': "An unexpected error occurred",
+            'data': str(e)
+        }), content_type='application/json')
Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/__init__.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/__init__.py	(revision 0)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/__init__.py	(working copy)
@@ -0,0 +1 @@
+__all__ = ['log_location_service']
\ No newline at end of file
Index: /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py
===================================================================
--- /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py	(revision 0)
+++ /branches/amp_3_6_0/src/webui/webui/htdocs/new/src/hive/services/log_location_service.py	(working copy)
@@ -0,0 +1,243 @@
+import subprocess
+import re
+import os
+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'
+
+
+def get_secondary_drive_info():
+    """ Fetches the secondary drive details"""
+    try:
+        result = subprocess.check_output(['df', '-h'], universal_newlines=True)
+
+        # Split the output into lines
+        lines = result.splitlines()
+
+        # Extract the 'Mounted on' column values
+        secondary_drive_info = {}
+        for line in lines[1:]:  # Skip the header line
+            parts = line.split()
+            if '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])
+                disk_name = parts[0]
+                secondary_drive_info = {'is_disk_available': True, 'is_mounted': True, 'disk_name': disk_name,
+                                        'total': total_space, 'used': used_space, 'free': available_space}
+
+        if secondary_drive_info.has_key('is_disk_available') and secondary_drive_info.has_key('is_mounted') and \
+                secondary_drive_info['is_disk_available'] and secondary_drive_info['is_mounted']:
+            return secondary_drive_info
+
+        disk_info = get_unmounted_disk_info()
+        if not disk_info:
+            return {'is_disk_available': False}
+
+        disk_name, disk_size = disk_info
+        disk_name = '/dev/' + disk_name
+        disk_size_in_bytes = convert_to_bytes(disk_size)
+        return {'is_disk_available': True,
+                'is_mounted': False,
+                'disk_name': disk_name,
+                'total': disk_size_in_bytes,
+                'used': 0,
+                'free': disk_size_in_bytes}
+
+    except subprocess.CalledProcessError as e:
+        oper_log('error', 'system', 'Error running df -h: {}'.format(e))
+        raise ge.GenericError(
+            "Error while fetching secondary drive information in system. Error: {}".format(e))
+    except ge.GenericError as e:
+        raise e
+
+
+def convert_to_bytes(size):
+    """ Converts the Size in MegaBytes, Gigabytes to Bytes"""
+    size = size.strip()
+    if size[-1] in ['K', 'M', 'G', 'T', 'P']:
+        size_unit = size[-1]
+        size_value = float(size[:-1])
+        size_units = {'K': 1 << 10, 'M': 1 << 20, 'G': 1 << 30, 'T': 1 << 40, 'P': 1 << 50}
+        return int(size_value * size_units[size_unit])
+    return int(size)
+
+
+def get_unmounted_disk_info():
+    """ Gets ths information of the unmounted disks attached to AMP """
+    try:
+        # Run lsblk command and capture the output
+        result = subprocess.check_output(['lsblk', '-all'], universal_newlines=True)
+        # Parse the output to find unmounted disks
+        lines = result.splitlines()
+
+        unmounted_disk_dict = {}
+        unmounted_disks = []
+        for line in lines:
+            parts = line.split()
+            if len(parts) >= 7:
+                disk_name = parts[0]
+                disk_type = parts[-2]
+                mount_point = parts[-1]
+            else:
+                disk_name = parts[0]
+                disk_type = parts[-1]
+                mount_point = ''
+            disk_size = parts[3]
+
+            is_disk_name_present = False
+            if remove_trailing_number(disk_name) in unmounted_disks:
+                is_disk_name_present = True
+            elif mount_point == '' and disk_type.strip() == 'disk':
+                unmounted_disks.append(disk_name)
+                unmounted_disk_dict[disk_name] = disk_size
+
+            if is_disk_name_present:
+                unmounted_disk_dict.pop(remove_trailing_number(disk_name))
+                unmounted_disks.remove(remove_trailing_number(disk_name))
+                is_disk_name_present = False
+
+        # 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")
+
+        disk_info = unmounted_disks[0], unmounted_disk_dict[unmounted_disks[0]]
+        return disk_info
+    except subprocess.CalledProcessError as e:
+        oper_log('error', 'system', 'Error running lsblk: {}'.format(e))
+        raise ge.GenericError("Error running lsblk: {}".format(e))
+
+
+def remove_trailing_number(s):
+    # Use regex to find and remove the trailing number
+    return re.sub(r'\d+$', '', s)
+
+
+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:
+        lines = configfile.readlines()
+
+    log_location = ''
+    for line in lines:
+        if line.startswith('path.logs:'):
+            log_location = line.split('path.logs:')[-1].strip().strip('"').strip("'")
+
+    if len(log_location) != 0:
+        if log_location.startswith('/var/log'):
+            return {'location': 'primary'}
+        elif log_location.startswith('/secondary'):
+            return {'location': '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):
+    """ 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
+            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()
+
+        elif log_location == 'primary':
+            log_location = '/var/log/elasticsearch'
+        else:
+            oper_log('error', 'system', 'Invalid location specified: {}'.format(log_location))
+            raise ge.GenericError(400, "Invalid location specified: {}. "
+                                       "Valid values are 'primary' and 'secondary'".format(log_location))
+
+        # Read existing configuration
+        with open(ELASTIC_SEARCH_CONFIG_FILE, 'r') as configfile:
+            lines = configfile.readlines()
+
+        updated_lines = []
+        for line in lines:
+            if 'path.logs' in line:
+                updated_lines.append("path.logs: {}\n".format(log_location))
+            else:
+                updated_lines.append(line)
+
+        # write the updated configuration back to the file
+        try:
+            with open(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')
+            e.message = "Failed to write to config file"
+            raise e
+
+        # Restart the Elasticsearch service
+        subprocess.check_call('systemctl restart elasticsearch', shell=True)
+        return {'status': 'success'}
+    except subprocess.CalledProcessError as e:
+        # Log the error (optional)
+        oper_log('error', 'system', 'Error in executing system command: {}'.format(e))
+        raise ge.GenericError("Error in executing system command service. Error: {}".format(e))
+    except Exception as e:
+        # Handle unexpected exceptions
+        oper_log('error', 'system', 'An unexpected error occurred: {}'.format(e.output))
+        e.message = "An unexpected error occurred: {}".format(e.output)
+        raise e
+
+
+def create_elastic_search_dir():
+    if not os.path.exists(SECONDARY_ELASTICSEARCH_DIR):
+        commands = [
+            "mkdir -p {}".format(SECONDARY_ELASTICSEARCH_DIR),
+            "chown -R elasticsearch:elasticsearch {}".format(SECONDARY_ELASTICSEARCH_DIR),
+            "chmod 750 {}".format(SECONDARY_ELASTICSEARCH_DIR)
+        ]
+        for command in commands:
+            try:
+                oper_log('info', 'system', 'Executing command :{}'.format(command))
+                subprocess.check_call(command, shell=True)
+            except subprocess.CalledProcessError as e:
+                oper_log('info', 'system', 'Executing command :{} failed with error:{}'.format(command, e.output))
+                e.message = 'Executing command :{} failed with error:{}'.format(command, e.output)
+                raise ge.GenericError("Executing command :{} failed with error:{}".format(command, e.output))
+            except Exception as e:
+                # Handle unexpected exceptions
+                oper_log('info', 'system', 'Executing command :{} failed with error:{}'.format(command, e.output))
+                e.message = 'Executing command :{} failed with error:{}'.format(command, e.output)
+                raise e
+
+
+def create_partition(disk_info):
+    disk_name = disk_info['disk_name']
+    # Use fdisk to create a new partition
+    subprocess.check_call("echo -e 'n\ne\n1\n\n\nw' | fdisk {}".format(disk_name), shell=True)
+
+    # Format the partition
+    subprocess.check_call("echo -e 'y\n' | mkfs.ext4 {}".format(disk_name), shell=True)
+
+    # Create a mount point
+    subprocess.check_call("mkdir -p /secondary", shell=True)
+
+    # Mount the partition
+    subprocess.check_call("mount -t auto {} /secondary".format(disk_name), shell=True)
+
+    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
