コード例 #1
0
ファイル: smu_utils.py プロジェクト: ponnadarahul/csm
def get_platform_and_release(package_list):
    platform = UNKNOWN
    release = UNKNOWN
    
    # Identify the platform and release
    for line in package_list:
        platform = get_platform(line)
        release = get_release(line)
        
        if platform != UNKNOWN and release != UNKNOWN:
            break
        
    return platform, release
コード例 #2
0
ファイル: smu_utils.py プロジェクト: ommaurya/csm
def get_platform_and_release(package_list):
    platform = UNKNOWN
    release = UNKNOWN
    
    # Identify the platform and release
    for line in package_list:
        platform = get_platform(line)
        release = get_release(line)
        
        if platform != UNKNOWN and release != UNKNOWN:
            break
        
    return platform, release
コード例 #3
0
ファイル: smu_utils.py プロジェクト: anushreejangid/csm
def get_platform_and_release(package_list):
    """
    Given a package list (SMU/SP/Pacages), return the platform and release.
    """
    platform = UNKNOWN
    release = UNKNOWN
    
    # Identify the platform and release
    for line in package_list:
        platform = get_platform(line)
        release = get_release(line)
        
        if platform != UNKNOWN and release != UNKNOWN:
            break
        
    return platform, release
コード例 #4
0
ファイル: smu_utils.py プロジェクト: kstaniek/csm
def get_platform_and_release(package_list):
    """
    Given a package list (SMU/SP/Pacages), return the platform and release.
    """
    platform = UNKNOWN
    release = UNKNOWN

    # Identify the platform and release
    for line in package_list:
        platform = get_platform(line)
        release = get_release(line)

        if platform != UNKNOWN and release != UNKNOWN:
            break

    return platform, release
コード例 #5
0
ファイル: common.py プロジェクト: anushreejangid/csm
def create_or_update_install_job(
    db_session, host_id, install_action, scheduled_time, software_packages=None,
    server=-1, server_directory='', custom_command_profile=-1, dependency=0, pending_downloads=None, install_job=None):

    # This is a new install_job
    if install_job is None:
        install_job = InstallJob()
        install_job.host_id = host_id
        db_session.add(install_job)

    install_job.install_action = install_action

    if install_job.install_action == InstallAction.INSTALL_ADD and \
        not is_empty(pending_downloads):
        install_job.pending_downloads = ','.join(pending_downloads.split())
    else:
        install_job.pending_downloads = ''

    install_job.scheduled_time = get_datetime(scheduled_time, "%m/%d/%Y %I:%M %p")

    # Only Install Add should have server_id and server_directory
    if install_action == InstallAction.INSTALL_ADD:
        install_job.server_id = int(server) if int(server) > 0 else None
        install_job.server_directory = server_directory
    else:
        install_job.server_id = None
        install_job.server_directory = ''

    install_job_packages = []

    # Only the following install actions should have software packages
    if install_action == InstallAction.INSTALL_ADD or \
        install_action == InstallAction.INSTALL_ACTIVATE or \
        install_action == InstallAction.INSTALL_REMOVE or \
        install_action == InstallAction.INSTALL_DEACTIVATE:

        software_packages = software_packages.split() if software_packages is not None else []
        for software_package in software_packages:
            if install_action == InstallAction.INSTALL_ADD:
                # Install Add only accepts external package names with the following suffix
                if '.pie' in software_package or \
                    '.tar' in software_package or \
                    '.rpm' in software_package:
                    install_job_packages.append(software_package)
            else:
                # Install Activate can have external or internal package names
                install_job_packages.append(software_package)

    install_job.packages = ','.join(install_job_packages)
    install_job.dependency = dependency if dependency > 0 else None
    install_job.created_by = current_user.username
    install_job.user_id = current_user.id

    if install_action == InstallAction.PRE_UPGRADE or install_action == InstallAction.POST_UPGRADE:
        install_job.custom_command_profile_id = custom_command_profile if custom_command_profile else None

    # Resets the following fields
    install_job.status = None
    install_job.status_time = None
    install_job.session_log = None
    install_job.trace = None

    if install_job.install_action != InstallAction.UNKNOWN:
        db_session.commit()

    # Creates download jobs if needed
    if install_job.install_action == InstallAction.INSTALL_ADD and \
        len(install_job.packages) > 0 and \
        len(install_job.pending_downloads) > 0:

        # Use the SMU name to derive the platform and release strings
        smu_list = install_job.packages.split(',')
        pending_downloads = install_job.pending_downloads.split(',')

        # Derives the platform and release using the first SMU name.
        platform = get_platform(smu_list[0])
        release = get_release(smu_list[0])

        create_download_jobs(db_session, platform, release, pending_downloads,
                             install_job.server_id, install_job.server_directory)

    return install_job
コード例 #6
0
ファイル: common.py プロジェクト: kstaniek/csm
def create_or_update_install_job(
    db_session, host_id, install_action, scheduled_time, software_packages=None,
    server=-1, server_directory='', custom_command_profile=-1, dependency=0, pending_downloads=None, install_job=None):

    # This is a new install_job
    if install_job is None:
        install_job = InstallJob()
        install_job.host_id = host_id
        db_session.add(install_job)

    install_job.install_action = install_action

    if install_job.install_action == InstallAction.INSTALL_ADD and \
        not is_empty(pending_downloads):
        install_job.pending_downloads = ','.join(pending_downloads.split())
    else:
        install_job.pending_downloads = ''

    install_job.scheduled_time = get_datetime(scheduled_time, "%m/%d/%Y %I:%M %p")

    # Only Install Add should have server_id and server_directory
    if install_action == InstallAction.INSTALL_ADD:
        install_job.server_id = int(server) if int(server) > 0 else None
        install_job.server_directory = server_directory
    else:
        install_job.server_id = None
        install_job.server_directory = ''

    install_job_packages = []

    # Only the following install actions should have software packages
    if install_action == InstallAction.INSTALL_ADD or \
        install_action == InstallAction.INSTALL_ACTIVATE or \
        install_action == InstallAction.INSTALL_REMOVE or \
        install_action == InstallAction.INSTALL_DEACTIVATE:

        software_packages = software_packages.split() if software_packages is not None else []
        for software_package in software_packages:
            if install_action == InstallAction.INSTALL_ADD:
                # Install Add only accepts external package names with the following suffix
                if '.pie' in software_package or \
                    '.tar' in software_package or \
                    '.rpm' in software_package:
                    install_job_packages.append(software_package)
            else:
                # Install Activate can have external or internal package names
                install_job_packages.append(software_package)

    install_job.packages = ','.join(install_job_packages)
    install_job.dependency = dependency if dependency > 0 else None
    install_job.created_by = current_user.username
    install_job.user_id = current_user.id

    if install_action == InstallAction.PRE_UPGRADE or install_action == InstallAction.POST_UPGRADE:
        install_job.custom_command_profile_id = custom_command_profile if custom_command_profile else None

    # Resets the following fields
    install_job.status = None
    install_job.status_time = None
    install_job.session_log = None
    install_job.trace = None

    if install_job.install_action != InstallAction.UNKNOWN:
        db_session.commit()

    # Creates download jobs if needed
    if install_job.install_action == InstallAction.INSTALL_ADD and \
        len(install_job.packages) > 0 and \
        len(install_job.pending_downloads) > 0:

        # Use the SMU name to derive the platform and release strings
        smu_list = install_job.packages.split(',')
        pending_downloads = install_job.pending_downloads.split(',')

        # Derives the platform and release using the first SMU name.
        platform = get_platform(smu_list[0])
        release = get_release(smu_list[0])

        create_download_jobs(db_session, platform, release, pending_downloads,
                             install_job.server_id, install_job.server_directory)

    return install_job