ethernet: Change the behavior of setting VLANEnable

In current implementation, setting VLANEnable to true does nothing
while setting to false will essentially delete the VLAN from system,
which is not a reasonable behavior for Redfish. PATCH requests should
never delete a resource. This patch changes the behavior to changing
the NICEnabled property of VLAN interface, which essentially enables/
disables the VLAN interface.

Tested:
Verified PATCH {"VLANEnable": false} no longer deletes the interface
and the NICEnabled property on DBus is successfully changed.

Change-Id: I8c47f6f2987fed576ba36c215f29bc03c6e9182b
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 00f9930..804d8aa 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -2009,7 +2009,7 @@
                     "/redfish/v1/Managers/bmc/EthernetInterfaces/" +
                     parentIfaceId + "/VLANs/" + ifaceId;
 
-                asyncResp->res.jsonValue["VLANEnable"] = true;
+                asyncResp->res.jsonValue["VLANEnable"] = ethData.nicEnabled;
                 asyncResp->res.jsonValue["VLANId"] = *ethData.vlanId;
             }
             else
@@ -2067,23 +2067,22 @@
                 const boost::container::flat_set<IPv6AddressData>&) {
             if (success && ethData.vlanId)
             {
-                auto callback =
-                    [asyncResp](const boost::system::error_code ec) {
-                    if (ec)
-                    {
-                        messages::internalError(asyncResp->res);
-                        return;
-                    }
-                };
-
-                if (vlanEnable && !(*vlanEnable))
+                if (vlanEnable)
                 {
-                    BMCWEB_LOG_DEBUG << "vlanEnable is false. Deleting the "
-                                        "vlan interface";
                     crow::connections::systemBus->async_method_call(
-                        std::move(callback), "xyz.openbmc_project.Network",
-                        std::string("/xyz/openbmc_project/network/") + ifaceId,
-                        "xyz.openbmc_project.Object.Delete", "Delete");
+                        [asyncResp](const boost::system::error_code ec) {
+                        if (ec)
+                        {
+                            messages::internalError(asyncResp->res);
+                            return;
+                        }
+                        },
+                        "xyz.openbmc_project.Network",
+                        "/xyz/openbmc_project/network/" + ifaceId,
+                        "org.freedesktop.DBus.Properties", "Set",
+                        "xyz.openbmc_project.Network.EthernetInterface",
+                        "NICEnabled",
+                        dbus::utility::DbusVariantType(*vlanEnable));
                 }
             }
             else