summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/version.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-01-16 10:10:41 +0100
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-01-17 17:53:13 +0000
commitdd73af563850762aad64e7ed2a9897377830af10 (patch)
tree33f34ccce29a5a11227741dbe6a8fce20deeeaba /azurelinuxagent/common/version.py
parenta05019d9343d0fde153d75a8e61fb6f99d1d3ff3 (diff)
parent558111e33720eb8f1eaacf571cf4fadae2430286 (diff)
downloadvyos-walinuxagent-dd73af563850762aad64e7ed2a9897377830af10.tar.gz
vyos-walinuxagent-dd73af563850762aad64e7ed2a9897377830af10.zip
Import patches-applied version 2.2.2-0ubuntu1 to applied/ubuntu/zesty-proposed
Imported using git-ubuntu import. Changelog parent: a05019d9343d0fde153d75a8e61fb6f99d1d3ff3 Unapplied parent: 558111e33720eb8f1eaacf571cf4fadae2430286 New changelog entries: * New upstream release (LP: #1651128) - d/patches/fix-auto-update.patch, d/patches/lp1623570-adjust-walinuxagent-service-after-and-wants.patch: - Dropped as changes have been applied upstream - Refreshed debian/patches/disable_import_test.patch
Diffstat (limited to 'azurelinuxagent/common/version.py')
-rw-r--r--azurelinuxagent/common/version.py62
1 files changed, 59 insertions, 3 deletions
diff --git a/azurelinuxagent/common/version.py b/azurelinuxagent/common/version.py
index 6c4b475..1099e25 100644
--- a/azurelinuxagent/common/version.py
+++ b/azurelinuxagent/common/version.py
@@ -26,23 +26,59 @@ from azurelinuxagent.common.utils.flexible_version import FlexibleVersion
from azurelinuxagent.common.future import ustr
+"""
+Add this workaround for detecting F5 products because BIG-IP/IQ/etc do not show
+their version info in the /etc/product-version location. Instead, the version
+and product information is contained in the /VERSION file.
+"""
+def get_f5_platform():
+ result = [None,None,None,None]
+ f5_version = re.compile("^Version: (\d+\.\d+\.\d+)")
+ f5_product = re.compile("^Product: ([\w-]+)")
+
+ with open('/VERSION', 'r') as fh:
+ content = fh.readlines()
+ for line in content:
+ version_matches = f5_version.match(line)
+ product_matches = f5_product.match(line)
+ if version_matches:
+ result[1] = version_matches.group(1)
+ elif product_matches:
+ result[3] = product_matches.group(1)
+ if result[3] == "BIG-IP":
+ result[0] = "bigip"
+ result[2] = "bigip"
+ elif result[3] == "BIG-IQ":
+ result[0] = "bigiq"
+ result[2] = "bigiq"
+ elif result[3] == "iWorkflow":
+ result[0] = "iworkflow"
+ result[2] = "iworkflow"
+ return result
+
def get_distro():
if 'FreeBSD' in platform.system():
release = re.sub('\-.*\Z', '', ustr(platform.release()))
osinfo = ['freebsd', release, '', 'freebsd']
elif 'linux_distribution' in dir(platform):
- osinfo = list(platform.linux_distribution(full_distribution_name=0))
+ osinfo = list(platform.linux_distribution(full_distribution_name=0,
+ supported_dists=platform._supported_dists+('alpine',)))
full_name = platform.linux_distribution()[0].strip()
osinfo.append(full_name)
else:
osinfo = platform.dist()
# The platform.py lib has issue with detecting oracle linux distribution.
- # Merge the following patch provided by oracle as a temparory fix.
+ # Merge the following patch provided by oracle as a temporary fix.
if os.path.exists("/etc/oracle-release"):
osinfo[2] = "oracle"
osinfo[3] = "Oracle Linux"
+ # The platform.py lib has issue with detecting BIG-IP linux distribution.
+ # Merge the following patch provided by F5.
+ if os.path.exists("/shared/vadc"):
+ osinfo = get_f5_platform()
+
# Remove trailing whitespace and quote in distro name
osinfo[0] = osinfo[0].strip('"').strip(' ').lower()
return osinfo
@@ -50,7 +86,7 @@ def get_distro():
AGENT_NAME = "WALinuxAgent"
AGENT_LONG_NAME = "Azure Linux Agent"
-AGENT_VERSION = '2.1.5'
+AGENT_VERSION = '2.2.2'
AGENT_LONG_VERSION = "{0}-{1}".format(AGENT_NAME, AGENT_VERSION)
AGENT_DESCRIPTION = """\
The Azure Linux Agent supports the provisioning and running of Linux
@@ -65,6 +101,8 @@ AGENT_PATTERN = "{0}-(.*)".format(AGENT_NAME)
AGENT_NAME_PATTERN = re.compile(AGENT_PATTERN)
AGENT_DIR_PATTERN = re.compile(".*/{0}".format(AGENT_PATTERN))
+EXT_HANDLER_PATTERN = b".*/WALinuxAgent-(\w.\w.\w[.\w]*)-.*-run-exthandlers"
+EXT_HANDLER_REGEX = re.compile(EXT_HANDLER_PATTERN)
# Set the CURRENT_AGENT and CURRENT_VERSION to match the agent directory name
# - This ensures the agent will "see itself" using the same name and version
@@ -83,6 +121,23 @@ def set_current_agent():
return agent, FlexibleVersion(version)
CURRENT_AGENT, CURRENT_VERSION = set_current_agent()
+def set_goal_state_agent():
+ agent = None
+ pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
+ for pid in pids:
+ try:
+ pname = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
+ match = EXT_HANDLER_REGEX.match(pname)
+ if match:
+ agent = match.group(1)
+ break
+ except IOError:
+ continue
+ if agent is None:
+ agent = CURRENT_VERSION
+ return agent
+GOAL_STATE_AGENT_VERSION = set_goal_state_agent()
+
def is_current_agent_installed():
return CURRENT_AGENT == AGENT_LONG_VERSION
@@ -114,3 +169,4 @@ def is_snappy():
if is_snappy():
DISTRO_FULL_NAME = "Snappy Ubuntu Core"
+