service API updated as per common util method for identifying debian
@@ -9,7 +9,6 @@ import asyncio
import os
import datetime
import uuid
-import platform
import json
import multiprocessing
from aiohttp import web
@@ -263,9 +262,7 @@ async def add_service(request):
delimiter = '.'
if str(version).count(delimiter) != 2:
raise ValueError('Service semantic version is incorrect; it should be like X.Y.Z')
-
- _platform = platform.platform()
- pkg_mgt = 'yum' if 'centos' in _platform or 'redhat' in _platform else 'apt'
+ pkg_mgt = 'apt' if utils.is_debian() else 'yum'
# Check Pre-conditions from Packages table
# if status is -1 (Already in progress) then return as rejected request
storage = connect.get_storage_async()
@@ -684,13 +681,11 @@ async def _put_schedule(protocol: str, host: str, port: int, sch_id: uuid, is_en
def do_update(http_enabled: bool, host: str, port: int, storage: connect, pkg_name: str, uid: str,
schedules: list) -> None:
_logger.info("{} service update started...".format(pkg_name))
- _platform = platform.platform()
stdout_file_path = common.create_log_file("update", pkg_name)
- pkg_mgt = 'apt'
+ pkg_mgt = 'apt' if utils.is_debian() else 'yum'
cmd = "sudo {} -y update > {} 2>&1".format(pkg_mgt, stdout_file_path)
protocol = "HTTP" if http_enabled else "HTTPS"
- if 'centos' in _platform or 'redhat' in _platform:
- pkg_mgt = 'yum'
+ if pkg_mgt == 'yum':
cmd = "sudo {} check-update > {} 2>&1".format(pkg_mgt, stdout_file_path)
ret_code = os.system(cmd)
# sudo apt/yum -y install only happens when update is without any error
