summaryrefslogtreecommitdiff
path: root/azurelinuxagent/metadata.py
diff options
context:
space:
mode:
Diffstat (limited to 'azurelinuxagent/metadata.py')
-rw-r--r--azurelinuxagent/metadata.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/azurelinuxagent/metadata.py b/azurelinuxagent/metadata.py
new file mode 100644
index 0000000..83d4676
--- /dev/null
+++ b/azurelinuxagent/metadata.py
@@ -0,0 +1,93 @@
+# Windows Azure Linux Agent
+#
+# Copyright 2014 Microsoft Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Requires Python 2.4+ and Openssl 1.0+
+#
+
+import os
+import re
+import platform
+import sys
+from azurelinuxagent.future import text
+
+def get_distro():
+ if 'FreeBSD' in platform.system():
+ release = re.sub('\-.*\Z', '', text(platform.release()))
+ osinfo = ['freebsd', release, '', 'freebsd']
+ if 'linux_distribution' in dir(platform):
+ osinfo = list(platform.linux_distribution(full_distribution_name=0))
+ 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.
+ if os.path.exists("/etc/oracle-release"):
+ osinfo[2] = "oracle"
+ osinfo[3] = "Oracle Linux"
+
+ #Remove trailing whitespace and quote in distro name
+ osinfo[0] = osinfo[0].strip('"').strip(' ').lower()
+ return osinfo
+
+AGENT_NAME = "WALinuxAgent"
+AGENT_LONG_NAME = "Azure Linux Agent"
+AGENT_VERSION = '2.1.1'
+AGENT_LONG_VERSION = "{0}-{1}".format(AGENT_NAME, AGENT_VERSION)
+AGENT_DESCRIPTION = """\
+The Azure Linux Agent supports the provisioning and running of Linux
+VMs in the Azure cloud. This package should be installed on Linux disk
+images that are built to run in the Azure environment.
+"""
+
+__distro__ = get_distro()
+DISTRO_NAME = __distro__[0]
+DISTRO_VERSION = __distro__[1]
+DISTRO_CODE_NAME = __distro__[2]
+DISTRO_FULL_NAME = __distro__[3]
+
+PY_VERSION = sys.version_info
+PY_VERSION_MAJOR = sys.version_info[0]
+PY_VERSION_MINOR = sys.version_info[1]
+PY_VERSION_MICRO = sys.version_info[2]
+
+
+"""
+Add this walk arround for detecting Snappy Ubuntu Core temporarily, until ubuntu
+fixed this bug: https://bugs.launchpad.net/snappy/+bug/1481086
+"""
+def which(program):
+ # Return path of program for execution if found in path
+ def is_exe(fpath):
+ return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+ _fpath, _ = os.path.split(program)
+ if _fpath:
+ if is_exe(program):
+ return program
+ else:
+ for path in os.environ.get("PATH", "").split(os.pathsep):
+ path = path.strip('"')
+ exe_file = os.path.join(path, program)
+ if is_exe(exe_file):
+ return exe_file
+ return None
+
+def is_snappy():
+ return which("snappy")
+
+if is_snappy():
+ DISTRO_FULL_NAME = "Snappy Ubuntu Core"