summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/version.py
diff options
context:
space:
mode:
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"
+