コード例 #1
0
ファイル: containerd.py プロジェクト: hemanthnakkina/hotsos
def purge_containerd():
    """
    Purge Containerd from the cluster.

    :return: None
    """
    status.maintenance('Removing containerd from principal')

    host.service_stop('containerd.service')
    apt_unhold(CONTAINERD_PACKAGE)
    apt_purge(CONTAINERD_PACKAGE, fatal=True)

    if is_state('containerd.nvidia.ready'):
        nvidia_packages = config('nvidia_apt_packages').split()
        apt_purge(nvidia_packages, fatal=True)

    sources = ['/etc/apt/sources.list.d/nvidia.list']

    for f in sources:
        if os.path.isfile(f):
            os.remove(f)

    apt_autoremove(purge=True, fatal=True)

    remove_state('containerd.ready')
    remove_state('containerd.installed')
    remove_state('containerd.nvidia.ready')
    remove_state('containerd.nvidia.checked')
    remove_state('containerd.nvidia.available')
    remove_state('containerd.version-published')
コード例 #2
0
def remove_plugin_config():
    """Called when a dashboard plugin is leaving.

    This is necessary so that the packages that the plugin asked to install are
    removed and any conflicting packages are restored and the config updated.
    This ensures that when changing plugins the system isn't left in a broken
    state.
    """
    resolve_CONFIGS()
    rid = juju_relation_id()
    runit = juju_remote_unit()
    pkg_data = get_plugin_packages_from_kv(rid, runit)
    changed = False
    if pkg_data['install_packages']:
        remove_packages = filter_missing_packages(pkg_data['install_packages'])
        if remove_packages:
            status_set('maintenance', 'Removing packages')
            apt_purge(remove_packages, fatal=True)
            apt_autoremove(purge=True, fatal=True)
            changed = True
    if pkg_data['conflicting_packages']:
        install_packages = filter_installed_packages(
            pkg_data['conflicting_packages'])
        if install_packages:
            status_set('maintenance', 'Installing packages')
            apt_install(install_packages, fatal=True)
            changed = True
    if changed:
        log("Package installation/purge detected, restarting services", "INFO")
        for s in services():
            service_restart(s)
    CONFIGS.write(LOCAL_SETTINGS)
コード例 #3
0
def purge_containerd():
    """
    Purge Containerd from the
    cluster.

    :return: None
    """
    status_set('maintenance', 'Removing containerd from principal')

    host.service_stop('containerd.service')
    apt_purge('containerd', fatal=True)

    if is_state('containerd.nvidia.ready'):
        apt_purge(NVIDIA_PACKAGES, fatal=True)

    sources = [
        '/etc/apt/sources.list.d/cuda.list',
        '/etc/apt/sources.list.d/nvidia-container-runtime.list'
    ]

    for f in sources:
        if os.path.isfile(f):
            os.remove(f)

    apt_autoremove(purge=True, fatal=True)

    remove_state('containerd.ready')
    remove_state('containerd.installed')
    remove_state('containerd.nvidia.ready')
    remove_state('containerd.nvidia.checked')
    remove_state('containerd.nvidia.available')
コード例 #4
0
def remove_old_packages():
    '''Purge any packages that need ot be removed.

    :returns: bool Whether packages were removed.
    '''
    installed_packages = filter_missing_packages(determine_purge_packages())
    if installed_packages:
        apt_purge(installed_packages, fatal=True)
        apt_autoremove(purge=True, fatal=True)
    return bool(installed_packages)
コード例 #5
0
ファイル: heat_utils.py プロジェクト: openstack/charm-heat
def remove_old_packages():
    '''Purge any packages that need ot be removed.

    :returns: bool Whether packages were removed.
    '''
    installed_packages = filter_missing_packages(determine_purge_packages())
    if installed_packages:
        apt_purge(installed_packages, fatal=True)
        apt_autoremove(purge=True, fatal=True)
    return bool(installed_packages)
コード例 #6
0
def purge_packages(pkg_list):
    purge_pkgs = []
    required_packages = determine_packages()
    for pkg in pkg_list:
        if pkg not in required_packages:
            purge_pkgs.append(pkg)
    purge_pkgs = filter_missing_packages(purge_pkgs)
    if purge_pkgs:
        status_set('maintenance', 'Purging unused packages')
        apt_purge(purge_pkgs, fatal=True)
        apt_autoremove(purge=True, fatal=True)
コード例 #7
0
def purge_packages(pkg_list):
    purge_pkgs = []
    required_packages = determine_packages()
    for pkg in pkg_list:
        if pkg not in required_packages:
            purge_pkgs.append(pkg)
    purge_pkgs = filter_missing_packages(purge_pkgs)
    if purge_pkgs:
        status_set('maintenance', 'Purging unused packages')
        apt_purge(purge_pkgs, fatal=True)
        apt_autoremove(purge=True, fatal=True)
コード例 #8
0
def remove_old_packages():
    '''Purge any packages that need to be removed.

    :returns: bool Whether packages were removed.
    '''
    installed_packages = filter_missing_packages(determine_purge_packages())
    if installed_packages:
        log('Removing apt packages')
        status_set('maintenance', 'Removing apt packages')
        apt_purge(installed_packages, fatal=True)
        apt_autoremove(purge=True, fatal=True)
    return bool(installed_packages)
コード例 #9
0
ファイル: core.py プロジェクト: rgrullon/charms.openstack
    def remove_obsolete_packages(self):
        """Remove any packages that are no longer needed for operation

        :returns: boolean indication where packages where removed.
        """
        if self.purge_packages:
            # NOTE(jamespage):
            # Ensure packages that should be purged are actually installed
            installed_packages = list(
                set(self.purge_packages) -
                set(fetch.filter_installed_packages(self.purge_packages)))
            if installed_packages:
                fetch.apt_purge(packages=installed_packages, fatal=True)
                fetch.apt_autoremove(purge=True, fatal=True)
                return True
        return False
コード例 #10
0
def remove_old_packages():
    '''Purge any packages that need ot be removed.

    :returns: bool Whether packages were removed.
    '''
    installed_packages = filter_missing_packages(get_purge_packages())
    if installed_packages:
        if 'neutron-lbaasv2-agent' in installed_packages:
            # Remove policyrd entry that would stop dpkg from stopping
            # service when package is removed. Bug #1931655
            policy_rcd.remove_policy_block('neutron-lbaasv2-agent',
                                           ['restart', 'stop', 'try-restart'])
            deferred_events.clear_deferred_restarts('neutron-lbaasv2-agent')
        apt_purge(installed_packages, fatal=True)
        apt_autoremove(purge=True, fatal=True)
    return bool(installed_packages)
コード例 #11
0
ファイル: kata.py プロジェクト: n-pochet/charm-kata
def purge_kata():
    """
    Purge Kata containers.

    :return: None
    """
    status_set('maintenance', 'Purging Kata')

    apt_purge(KATA_PACKAGES, fatal=False)

    source = '/etc/apt/sources.list.d/kata-containers.list'
    if os.path.isfile(source):
        os.remove(source)

    apt_autoremove()

    remove_state('kata.installed')
コード例 #12
0
def update_plugin_config():
    resolve_CONFIGS()
    # NOTE(ajkavanagh) - plugins can indicate that they have packages to
    # install and purge.  Grab them from the relation and install/update as
    # needed.
    rid = juju_relation_id()
    runit = juju_remote_unit()
    (add_packages, remove_packages) = update_plugin_packages_in_kv(rid, runit)
    remove_packages = filter_missing_packages(remove_packages)
    if remove_packages:
        status_set('maintenance', 'Removing packages')
        apt_purge(remove_packages, fatal=True)
        apt_autoremove(purge=True, fatal=True)
    add_packages = filter_installed_packages(add_packages)
    if add_packages:
        status_set('maintenance', 'Installing packages')
        apt_install(add_packages, fatal=True)
    if remove_packages or add_packages:
        log("Package installation/purge detected, restarting services", "INFO")
        for s in services():
            service_restart(s)
    CONFIGS.write(LOCAL_SETTINGS)