Repository: Azure/WALinuxAgent
Pull request #1554 (2019-06-13 18:33:19)

Revert "Rhel8 changes"
Reverts Azure/WALinuxAgent#1547

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/azure/walinuxagent/1554)
<!-- Reviewable:end -->



Patch:
diff --git a/azurelinuxagent/ga/update.py b/azurelinuxagent/ga/update.py
index 90801e2d..bb66614c 100644
--- a/azurelinuxagent/ga/update.py
+++ b/azurelinuxagent/ga/update.py
@@ -92,11 +92,8 @@ def get_update_handler():
 
 
 def get_python_cmd():
-    if sys.executable:
-        return sys.executable
-    else:
-        major_version = platform.python_version_tuple()[0]
-        return "python" if int(major_version) <= 2 else "python{0}".format(major_version)
+    major_version = platform.python_version_tuple()[0]
+    return "python" if int(major_version) <= 2 else "python{0}".format(major_version)
 
 
 class UpdateHandler(object):
diff --git a/init/rhel/8.0/waagent b/init/rhel/8.0/waagent
deleted file mode 100755
index 81c287c0..00000000
--- a/init/rhel/8.0/waagent
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/libexec/platform-python
-#
-# Azure Linux Agent
-#
-# Copyright 2015 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.6 and Openssl 1.0+
-#
-# Implements parts of RFC 2131, 1541, 1497 and
-# http://msdn.microsoft.com/en-us/library/cc227282%28PROT.10%29.aspx
-# http://msdn.microsoft.com/en-us/library/cc227259%28PROT.13%29.aspx
-#
-
-import os
-import imp
-import sys
-
-if __name__ == '__main__' :
-    import azurelinuxagent.agent as agent
-    """
-    Invoke main method of agent
-    """
-    agent.main()
-
-if __name__ == 'waagent':
-    """
-    Load waagent2.0 to support old version of extensions
-    """
-    if sys.version_info[0] == 3:
-        raise ImportError("waagent2.0 doesn't support python3")
-    bin_path = os.path.dirname(os.path.abspath(__file__))
-    agent20_path = os.path.join(bin_path, "waagent2.0")
-    if not os.path.isfile(agent20_path):
-        raise ImportError("Can't load waagent")
-    agent20 = imp.load_source('waagent', agent20_path)
-    __all__ = dir(agent20)
-
diff --git a/init/rhel/8.0/waagent.service b/init/rhel/8.0/waagent.service
deleted file mode 100644
index 50f70521..00000000
--- a/init/rhel/8.0/waagent.service
+++ /dev/null
@@ -1,16 +0,0 @@
-[Unit]
-Description=Azure Linux Agent
-Wants=network-online.target sshd.service sshd-keygen.service
-After=network-online.target
-
-ConditionFileIsExecutable=/usr/sbin/waagent
-ConditionPathExists=/etc/waagent.conf
-
-[Service]
-Type=simple
-ExecStart=/usr/libexec/platform-python -u /usr/sbin/waagent -daemon
-Restart=always
-RestartSec=5
-
-[Install]
-WantedBy=multi-user.target
\ No newline at end of file
diff --git a/setup.py b/setup.py
index e47a94f0..ee0d8392 100755
--- a/setup.py
+++ b/setup.py
@@ -83,18 +83,14 @@ def get_data_files(name, version, fullname):
     data_files = []
 
     if name == 'redhat' or name == 'centos':
+        set_bin_files(data_files)
         set_conf_files(data_files)
         set_logrotate_files(data_files)
         set_udev_files(data_files)
         if version.startswith("6"):
-            set_bin_files(data_files)
             set_sysv_files(data_files)
-        elif version.startswith("8"):
-            set_bin_files(data_files, src=["init/rhel/8.0/waagent", "bin/waagent2.0"])
-            set_systemd_files(data_files, dest="/usr/lib/systemd/system", src=["init/rhel/8.0/waagent.service"])
         else:
             # redhat7.0+ use systemd
-            set_bin_files(data_files)
             set_systemd_files(data_files, dest="/usr/lib/systemd/system")
             if version.startswith("7.1"):
                 # TODO this is a mitigation to systemctl bug on 7.1


Test patch:
diff --git a/tests/ga/test_update.py b/tests/ga/test_update.py
index 8ce20f55..24430055 100644
--- a/tests/ga/test_update.py
+++ b/tests/ga/test_update.py
@@ -288,9 +288,6 @@ class TestGuestAgentError(UpdateTestCase):
         self.assertEqual(s, str(err))
         return
 
-    def test_get_python_cmd(self):
-        self.assertIn("python", get_python_cmd())
-
 
 class TestGuestAgent(UpdateTestCase):
     def setUp(self):
@@ -1063,7 +1060,7 @@ class TestUpdate(UpdateTestCase):
 
         self.assertEqual(args, cmds)
         self.assertTrue(len(args) > 1)
-        self.assertTrue("python" in args[0])
+        self.assertTrue(args[0].startswith("python"))
         self.assertEqual("-run-exthandlers", args[len(args)-1])
         self.assertEqual(True, 'cwd' in kwargs)
         self.assertEqual(agent.get_agent_dir(), kwargs['cwd'])
@@ -1077,7 +1074,7 @@ class TestUpdate(UpdateTestCase):
         args = args[0]
 
         self.assertTrue(len(args) > 1)
-        self.assertTrue("python" in args[0])
+        self.assertTrue(args[0].startswith("python"))
         self.assertEqual("AnArgument", args[len(args)-1])
 
     def test_run_latest_polls_and_waits_for_success(self):