Repository: Azure/WALinuxAgent
Pull request #2344 (2021-08-30 14:07:00)

added cloudlinux support
<!-- DO NOT DELETE THIS TEMPLATE -->

## Description
https://www.cloudlinux.com/
CloudLinux OS is a Linux distribution marketed to shared hosting providers.

Issue # <!-- if any -->
<!--
Please add an informative description that covers that changes made by the pull request. 
This checklist is used to make sure that common issues in a pull request are addressed.
This will expedite the process of getting your pull request merged and avoid extra work on your part to fix issues discovered during the review process.
-->

---

### PR information
- [x] The title of the PR is clear and informative.
- [x] There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).
- [x] If applicable, the PR references the bug/issue that it fixes in the description.
- [x] New Unit tests were added for the changes made

### Quality of Code and Contribution Guidelines
- [x] I have read the [contribution guidelines](https://github.com/Azure/WALinuxAgent/blob/master/.github/CONTRIBUTING.md).

codecov[bot]: # [Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) Report
> Merging [#2344](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) (c4b0441) into [develop](https://codecov.io/gh/Azure/WALinuxAgent/commit/167e494e607171a69b3a743bd4f0c047bd2d7473?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) (167e494) will **increase** coverage by `0.03%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344/graphs/tree.svg?width=650&height=150&src=pr&token=ae90E2KYCw&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure)](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure)

```diff
@@             Coverage Diff             @@
##           develop    #2344      +/-   ##
===========================================
+ Coverage    70.86%   70.90%   +0.03%     
===========================================
  Files           97       97              
  Lines        14105    14105              
  Branches      2029     2029              
===========================================
+ Hits          9996    10001       +5     
+ Misses        3662     3660       -2     
+ Partials       447      444       -3     
```


| [Impacted Files](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure) | Coverage Δ | |
|---|---|---|
| [azurelinuxagent/pa/rdma/factory.py](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure#diff-YXp1cmVsaW51eGFnZW50L3BhL3JkbWEvZmFjdG9yeS5weQ==) | `56.25% <0.00%> (ø)` | |
| [azurelinuxagent/common/osutil/factory.py](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure#diff-YXp1cmVsaW51eGFnZW50L2NvbW1vbi9vc3V0aWwvZmFjdG9yeS5weQ==) | `94.80% <100.00%> (ø)` | |
| [azurelinuxagent/ga/collect\_telemetry\_events.py](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure#diff-YXp1cmVsaW51eGFnZW50L2dhL2NvbGxlY3RfdGVsZW1ldHJ5X2V2ZW50cy5weQ==) | `91.43% <0.00%> (+1.71%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure). Last update [167e494...c4b0441](https://codecov.io/gh/Azure/WALinuxAgent/pull/2344?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Azure).

JohnKepplers: @larohra 
Please review! This PR is similar to https://github.com/Azure/WALinuxAgent/pull/2219
JohnKepplers: @ZhidongPeng @dhivyaganesan @narrieta @kevinclark19a @nagworld9
Could you please check my PR? It's similar to https://github.com/Azure/WALinuxAgent/pull/2219.
larohra: Automation ok

Patch:
diff --git a/azurelinuxagent/common/osutil/factory.py b/azurelinuxagent/common/osutil/factory.py
index 4a09544c..5918304d 100644
--- a/azurelinuxagent/common/osutil/factory.py
+++ b/azurelinuxagent/common/osutil/factory.py
@@ -98,7 +98,7 @@ def _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)
 
         return DebianOSBaseUtil()
 
-    if distro_name in ("redhat", "rhel", "centos", "oracle", "almalinux"):
+    if distro_name in ("redhat", "rhel", "centos", "oracle", "almalinux", "cloudlinux"):
         if Version(distro_version) < Version("7"):
             return Redhat6xOSUtil()
 
diff --git a/azurelinuxagent/pa/rdma/factory.py b/azurelinuxagent/pa/rdma/factory.py
index c6d80811..8fb50665 100644
--- a/azurelinuxagent/pa/rdma/factory.py
+++ b/azurelinuxagent/pa/rdma/factory.py
@@ -38,7 +38,7 @@ def get_rdma_handler(
     ):
         return SUSERDMAHandler()
 
-    if distro_full_name in ('CentOS Linux', 'CentOS', 'Red Hat Enterprise Linux Server', 'AlmaLinux'):
+    if distro_full_name in ('CentOS Linux', 'CentOS', 'Red Hat Enterprise Linux Server', 'AlmaLinux', 'CloudLinux'):
         return CentOSRDMAHandler(distro_version)
 
     if distro_full_name == 'Ubuntu':
diff --git a/setup.py b/setup.py
index a359b39a..3a9cba3b 100755
--- a/setup.py
+++ b/setup.py
@@ -95,7 +95,7 @@ def get_data_files(name, version, fullname):  # pylint: disable=R0912
     systemd_dir_path = osutil.get_systemd_unit_file_install_path()
     agent_bin_path = osutil.get_agent_bin_path()
 
-    if name == 'redhat' or name == 'centos' or name == 'almalinux':  # pylint: disable=R1714
+    if name in ('redhat', 'centos', 'almalinux', 'cloudlinux'):  # pylint: disable=R1714
         if version.startswith("8.2"):
             # redhat8+ default to py3
             set_bin_files(data_files, dest=agent_bin_path,


Test patch:
diff --git a/tests/common/osutil/test_factory.py b/tests/common/osutil/test_factory.py
index 4ab23413..74cf8363 100644
--- a/tests/common/osutil/test_factory.py
+++ b/tests/common/osutil/test_factory.py
@@ -244,6 +244,13 @@ class TestOsUtilFactory(AgentTestCase):
         self.assertTrue(isinstance(ret, RedhatOSUtil))
         self.assertEqual(ret.get_service_name(), "waagent")
 
+        ret = _get_osutil(distro_name="cloudlinux",
+                          distro_code_name="",
+                          distro_full_name="",
+                          distro_version="8")
+        self.assertTrue(isinstance(ret, RedhatOSUtil))
+        self.assertEqual(ret.get_service_name(), "waagent")
+
     def test_get_osutil_it_should_return_euleros(self):
         ret = _get_osutil(distro_name="euleros",
                           distro_code_name="",