Support checking service ports with ssl connection
By default netcat is used to check if a service is
listening on a port. This is generally ok except
for services expecting SSL connections which need
to be properly closed and netcat can't do that. So
here we add support for optionally using the python
ssl library to create an ssl connection to the port
and close it properly once finished.
Related-Bug: #1920770
(cherry picked from commit 0071e273720d65aca00b49fbde99c3b3ed1d0385)
Repeatedly calling service_enable for a service that
is already enabled can lead to unintended consequences.
Some charms frequently call servie_resume which will
call service('enable') and this adds a check to only
do so of the service is not enabled.
Related-Bug: #2058505
(cherry picked from commit a3345005e597f098909b7c12dfee630a366ce0f6)
Co-authored-by: Edward Hope-Morley <email address hidden>
Swift payload upgrades to wallaby or later currently fail because
this code is unable to determine the version for wallaby+. For
example:
FATAL ERROR: Could not derive swift version for codename: wallaby
We stopped maintaining the SWIFT_CODENAMES and PACKAGE_CODENAMES as of
wallaby because the openstack-release package was introduced in wallaby.
We could update the SWIFT_CODENAMES map, but really this map no longer
needs to be used. There was a time when the same swift package version
existed in two different OpenStack releases, but that is no longer the
case [1]. Therefore we can use the same comparison used for OpenStack
packages which essentially checks current release (based on the
openstack-release package) vs the installation source release.
[1] Current swift versions in Ubuntu are:
2.32.0 bobcat
2.31.1 antelope
2.30.1 zed
2.29.2 yoga
2.28.1 xena
2.27.0 wallaby
2.26.0 victoria
2.25.2 ussuri
Closes-Bug: #2040606
(cherry picked from commit b604d56223772c36f934c199abb849d5d020fdc8)
The openstack_release() function is typically called (indirectly)
by os_release() which already does caching. The caching of
openstack_release() was preventing updates to the value during
upgrading to a new release of openstack.