def test_hold_apt_packages_nofatal_abortonfatal(self, log, mock_call): packages = ['foo', 'bar'] fetch.apt_hold(packages, fatal=True) log.assert_called() mock_call.assert_called_with(['apt-mark', 'hold', 'foo', 'bar'])
def test_hold_apt_packages_as_string_nofatal(self, log, mock_call): packages = 'foo bar' fetch.apt_hold(packages) log.assert_called() mock_call.assert_called_with(['apt-mark', 'hold', 'foo bar'])
def install_puppet(self): '''Install puppet ''' hookenv.status_set('maintenance', 'Installing puppet agent') self.fetch_install_puppet_deb(self) apt_install(self.puppet_pkg_vers) apt_hold(self.puppet_pkgs)
def hold_all(): """ Hold packages. :return: None """ for k in docker_packages.keys(): apt_hold(docker_packages[k])
def upgrade_charm(): """ Triggered when upgrade-charm is called. :return: None """ # Prevent containerd apt pkg from being implicitly updated. apt_hold(CONTAINERD_PACKAGE) # Re-render config in case the template has changed in the new charm. config_changed()
def install_containerd(): """ Install containerd and then create initial configuration. :return: None """ status.maintenance('Installing containerd via apt') apt_update() apt_install(CONTAINERD_PACKAGE, fatal=True) apt_hold(CONTAINERD_PACKAGE) set_state('containerd.installed') config_changed()
def upgrade_charm(): """ Triggered when upgrade-charm is called. :return: None """ # Prevent containerd apt pkg from being implicitly updated. apt_hold(CONTAINERD_PACKAGE) # Re-render config in case the template has changed in the new charm. config_changed() # Clean up old nvidia sources.list.d files old_source_files = [ '/etc/apt/sources.list.d/nvidia-container-runtime.list', '/etc/apt/sources.list.d/cuda.list' ] for source_file in old_source_files: if os.path.exists(source_file): os.remove(source_file) remove_state('containerd.nvidia.ready')
def ensure_package_status(): '''Hold or unhold packages per the package_status configuration option. All packages installed using this module and handlers are affected. An mechanism may be added in the future to override this for a subset of installed packages. ''' packages = installed() if not packages: return config = hookenv.config() package_status = config.get('package_status') or '' changed = reactive.helpers.data_changed('apt.package_status', (package_status, sorted(packages))) if changed: if package_status == 'hold': hookenv.log('Holding packages {}'.format(','.join(packages))) fetch.apt_hold(packages) else: hookenv.log('Unholding packages {}'.format(','.join(packages))) fetch.apt_unhold(packages) reactive.remove_state('apt.needs_hold')
def ensure_package_status(): '''Hold or unhold packages per the package_status configuration option. All packages installed using this module and handlers are affected. An mechanism may be added in the future to override this for a subset of installed packages. ''' packages = installed() if not packages: return config = hookenv.config() package_status = config['package_status'] changed = reactive.helpers.data_changed('apt.package_status', (package_status, sorted(packages))) if changed: if package_status == 'hold': hookenv.log('Holding packages {}'.format(','.join(packages))) fetch.apt_hold(packages) else: hookenv.log('Unholding packages {}'.format(','.join(packages))) fetch.apt_unhold(packages) reactive.remove_state('apt.needs_hold')
def install(self): status_set('maintenance', 'Installing containerd via apt') apt_update() apt_install(CONTAINERD_PACKAGE, fatal=True) apt_hold(CONTAINERD_PACKAGE)
def holdall(): for k in dockerpackages.keys(): apt_hold(dockerpackages[k])