Repository: Azure/WALinuxAgent

Issue:
[BUG] 'WARNING Dhcp client is not running' on Ubuntu 19.10
## Description

On Ubuntu 19.10

**WALinuxAgent** keeps reporting that the DHCP client is not running:
```
WARNING ExtHandler Dhcp client is not running.
WARNING ExtHandler Dhcp client is not running.
WARNING ExtHandler Dhcp client is not running.
```

However *systemd-networkd* is handling DHCP:

```
systemd-networkd[652]: eth0: DHCPv4 address 10.0.0.4/24 via 10.0.0.1
```

You probably need to add an exception and check for `systemd-networkd` like you did for Ubuntu 18:

https://github.com/Azure/WALinuxAgent/blob/e3ecde432c0fd6968bdb6d2774e316a61b3289d2/azurelinuxagent/common/osutil/ubuntu.py#L90-L93


## Version

```
# grep VERSION= /etc/os-release
VERSION="19.10 (Eoan Ermine)"

# waagent --version
/usr/sbin/waagent:27: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
WALinuxAgent-2.2.40 running on ubuntu 19.10
Python: 3.7.5
Goal state agent: 2.2.42
```

Note that the `DeprecationWarning` seen above has already been reported (https://github.com/Azure/WALinuxAgent/issues/1473)

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=h1) Report
> Merging [#1865](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=desc) into [develop](https://codecov.io/gh/Azure/WALinuxAgent/commit/92b652e031dd01027113702df7ee93c816bfd1aa&el=desc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865/graphs/tree.svg?width=650&height=150&src=pr&token=ae90E2KYCw)](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=tree)

```diff
@@           Coverage Diff            @@
##           develop    #1865   +/-   ##
========================================
  Coverage    69.45%   69.45%           
========================================
  Files           82       82           
  Lines        11469    11469           
  Branches      1619     1619           
========================================
  Hits          7966     7966           
  Misses        3166     3166           
  Partials       337      337           
```


| [Impacted Files](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [azurelinuxagent/common/osutil/ubuntu.py](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865/diff?src=pr&el=tree#diff-YXp1cmVsaW51eGFnZW50L2NvbW1vbi9vc3V0aWwvdWJ1bnR1LnB5) | `68.42% <ø> (ø)` | |
| [azurelinuxagent/common/osutil/factory.py](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865/diff?src=pr&el=tree#diff-YXp1cmVsaW51eGFnZW50L2NvbW1vbi9vc3V0aWwvZmFjdG9yeS5weQ==) | `97.29% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=footer). Last update [92b652e...8203a16](https://codecov.io/gh/Azure/WALinuxAgent/pull/1865?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/azurelinuxagent/common/osutil/factory.py b/azurelinuxagent/common/osutil/factory.py
index 56515ede..5baa9ebb 100644
--- a/azurelinuxagent/common/osutil/factory.py
+++ b/azurelinuxagent/common/osutil/factory.py
@@ -65,7 +65,9 @@ def _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)
             return Ubuntu14OSUtil()
         elif Version(distro_version) in [Version('16.04'), Version('16.10'), Version('17.04')]:
             return Ubuntu16OSUtil()
-        elif Version(distro_version) in [Version('18.04')]:
+        elif Version(distro_version) in [Version('18.04'), Version('18.10'),
+                                         Version('19.04'), Version('19.10'),
+                                         Version('20.04')]:
             return Ubuntu18OSUtil()
         elif distro_full_name == "Snappy Ubuntu Core":
             return UbuntuSnappyOSUtil()
diff --git a/azurelinuxagent/common/osutil/ubuntu.py b/azurelinuxagent/common/osutil/ubuntu.py
index 9d2dd786..99a8f89d 100644
--- a/azurelinuxagent/common/osutil/ubuntu.py
+++ b/azurelinuxagent/common/osutil/ubuntu.py
@@ -89,7 +89,7 @@ class Ubuntu16OSUtil(Ubuntu14OSUtil):
 
 class Ubuntu18OSUtil(Ubuntu16OSUtil):
     """
-    Ubuntu 18.04
+    Ubuntu 18.04, 18.10, 19.04, 19.10, 20.04
     """
     def __init__(self):
         super(Ubuntu18OSUtil, self).__init__()


Test patch:
diff --git a/tests/common/osutil/test_factory.py b/tests/common/osutil/test_factory.py
index adc099d5..aa7daebc 100644
--- a/tests/common/osutil/test_factory.py
+++ b/tests/common/osutil/test_factory.py
@@ -83,12 +83,19 @@ class TestOsUtilFactory(AgentTestCase):
         self.assertEquals(ret.get_service_name(), "walinuxagent")
 
         ret = _get_osutil(distro_name="ubuntu",
-                          distro_code_name="",
+                          distro_code_name="bionic",
                           distro_version="18.04",
                           distro_full_name="")
         self.assertTrue(type(ret) == Ubuntu18OSUtil)
         self.assertEquals(ret.get_service_name(), "walinuxagent")
 
+        ret = _get_osutil(distro_name="ubuntu",
+                          distro_code_name="focal",
+                          distro_version="20.04",
+                          distro_full_name="")
+        self.assertTrue(type(ret) == Ubuntu18OSUtil)
+        self.assertEquals(ret.get_service_name(), "walinuxagent")
+
         ret = _get_osutil(distro_name="ubuntu",
                           distro_code_name="",
                           distro_version="10.04",