From 1523b70ba26c35c587ee5c6c32a52c73142bb3d2 Mon Sep 17 00:00:00 2001
From: Daniel Caires <daniel.caires@encora.com>
Date: Tue, 5 Sep 2023 09:21:32 -0300
Subject: [PATCH] Fix worker VMs configurations

Change throughout the code every mention of
"compute" as a node to "worker".

Test Plan:
PASS: worker nodes are being configurated as expected
PASS: worker nodes are being deleted when portion of
the code is executed

Story: 2005051
Task: 48726

Change-Id: I6dda10c3b188f14e03dba514cb2063c4c7d1dda4
Signed-off-by: Daniel Caires <daniel.caires@encora.com>
---
 virtualbox/pybox/consts/networking.py             | 8 ++++----
 virtualbox/pybox/consts/node.py                   | 6 +++---
 virtualbox/pybox/helper/host_helper.py            | 4 ++--
 virtualbox/pybox/helper/tests/test_host_helper.py | 8 ++++----
 virtualbox/pybox/helper/tests/test_vboxmanage.py  | 4 ++--
 virtualbox/pybox/helper/vboxmanage.py             | 2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/virtualbox/pybox/consts/networking.py b/virtualbox/pybox/consts/networking.py
index e1c6f52..074144c 100644
--- a/virtualbox/pybox/consts/networking.py
+++ b/virtualbox/pybox/consts/networking.py
@@ -12,7 +12,7 @@ to virtual machines in a lab environment.
 Classes:
 - `Subnets`: A class containing dictionaries for IPv4 and IPv6 subnets.
 - `NICs`: A class containing dictionaries for NIC configurations of different types of
-nodes in the virtual environment, such as `CONTROLLER`, `COMPUTE`, and `STORAGE`.
+nodes in the virtual environment, such as `CONTROLLER`, `WORKER`, and `STORAGE`.
 - `OAM`: A class containing an IP address and netmask for the out-of-band management (OAM) network.
 - `Serial`: A class containing configurations for the serial ports.
 
@@ -40,7 +40,7 @@ class Subnets:
 
 class NICs:
     """The `NICs` class contains dictionaries for NIC configurations of different types
-    of nodes in the virtual environment, such as `CONTROLLER`, `COMPUTE`, and `STORAGE`."""
+    of nodes in the virtual environment, such as `CONTROLLER`, `WORKER`, and `STORAGE`."""
 
     if platform in ("win32", "win64"):
         CONTROLLER = {
@@ -107,8 +107,8 @@ class NICs:
             },
         }
 
-    COMPUTE = {
-        "node_type": "compute",
+    WORKER = {
+        "node_type": "worker",
         "1": {
             "nic": "intnet",
             "intnet": "intnet-unused1",
diff --git a/virtualbox/pybox/consts/node.py b/virtualbox/pybox/consts/node.py
index 8e6dea8..cacac3e 100644
--- a/virtualbox/pybox/consts/node.py
+++ b/virtualbox/pybox/consts/node.py
@@ -5,7 +5,7 @@
 
 """
 This module contains dictionaries for different types of nodes in a virtual environment,
-such as CONTROLLER_CEPH, CONTROLLER_LVM, CONTROLLER_AIO, COMPUTE, and STORAGE.
+such as CONTROLLER_CEPH, CONTROLLER_LVM, CONTROLLER_AIO, WORKER, and STORAGE.
 """
 
 class Nodes: #pylint: disable=too-few-public-methods
@@ -57,8 +57,8 @@ class Nodes: #pylint: disable=too-few-public-methods
         }
     }
 
-    COMPUTE = {
-        'node_type': 'compute',
+    WORKER = {
+        'node_type': 'worker',
         'memory': 8192,
         'cpus': 3,
         'disks': {
diff --git a/virtualbox/pybox/helper/host_helper.py b/virtualbox/pybox/helper/host_helper.py
index 0ae0f76..127cfca 100644
--- a/virtualbox/pybox/helper/host_helper.py
+++ b/virtualbox/pybox/helper/host_helper.py
@@ -88,7 +88,7 @@ def install_host(stream, hostname, host_type, host_id):
     Args:
         stream(stream): Stream to cont0
         hostname(str): Name of host
-        host_type(str): Type of host being installed e.g. 'storage' or 'compute'
+        host_type(str): Type of host being installed e.g. 'storage' or 'worker'
         host_id(int): id to identify host
     """
 
@@ -100,7 +100,7 @@ def install_host(stream, hostname, host_type, host_id):
         cmd = f"system host-update {host_id} personality=storage"
         serial.send_bytes(stream, cmd, expect_prompt=False)
     else:
-        cmd = f"system host-update {host_id} personality=compute hostname={hostname}"
+        cmd = f"system host-update {host_id} personality=worker hostname={hostname}"
         serial.send_bytes(stream, cmd, expect_prompt=False)
 
 
diff --git a/virtualbox/pybox/helper/tests/test_host_helper.py b/virtualbox/pybox/helper/tests/test_host_helper.py
index 53d8645..934af86 100644
--- a/virtualbox/pybox/helper/tests/test_host_helper.py
+++ b/virtualbox/pybox/helper/tests/test_host_helper.py
@@ -175,13 +175,13 @@ class InstallHostTestCase(unittest.TestCase):
                                                        expect_prompt=False)
 
     @patch("host_helper.serial")
-    def test_install_host_compute(self, mock_serial):
+    def test_install_host_worker(self, mock_serial):
         """
-        Test install_host for compute type host
+        Test install_host for worker type host
         """
 
         # Setup
-        mock_host_type = "compute"
+        mock_host_type = "worker"
 
         # Run
         host_helper.install_host(self.mock_stream, self.mock_hostname, mock_host_type, self.mock_host_id)
@@ -189,7 +189,7 @@ class InstallHostTestCase(unittest.TestCase):
         # Assert
         mock_serial.send_bytes.assert_called_once_with(
             self.mock_stream,
-            f"system host-update {self.mock_host_id} personality=compute hostname={self.mock_hostname}",
+            f"system host-update {self.mock_host_id} personality=worker hostname={self.mock_hostname}",
             expect_prompt=False)
 
 
diff --git a/virtualbox/pybox/helper/tests/test_vboxmanage.py b/virtualbox/pybox/helper/tests/test_vboxmanage.py
index 9e15d41..4d08d03 100644
--- a/virtualbox/pybox/helper/tests/test_vboxmanage.py
+++ b/virtualbox/pybox/helper/tests/test_vboxmanage.py
@@ -78,7 +78,7 @@ class GetAllVmsTestCase(unittest.TestCase):
         labname = "lab1"
         mock_list.return_value = [
             b'"lab1-controller-0" {2f7f1b1c-40fe-4063-8182-ece45bbe229d}',
-            b'"lab1-compute-0" {1f7a1a1a-30ee-4062-8182-edc45bbe239d}',
+            b'"lab1-worker-0" {1f7a1a1a-30ee-4062-8182-edc45bbe239d}',
             b'"lab1-storage-0" {1f6a1a1b-30ee-4071-8182-edd45bbe239d}',
             b'"not-matching-vm" {2f7f1b1c-40fe-4063-8182-ece45bbe229d}'
         ]
@@ -91,7 +91,7 @@ class GetAllVmsTestCase(unittest.TestCase):
         mock_list.assert_called_once_with("vms")
         expected_vms = [
             '"lab1-controller-0" {2f7f1b1c-40fe-4063-8182-ece45bbe229d}',
-            '"lab1-compute-0" {1f7a1a1a-30ee-4062-8182-edc45bbe239d}',
+            '"lab1-worker-0" {1f7a1a1a-30ee-4062-8182-edc45bbe239d}',
             '"lab1-storage-0" {1f6a1a1b-30ee-4071-8182-edd45bbe239d}',
         ]
         self.assertCountEqual(vms, expected_vms)
diff --git a/virtualbox/pybox/helper/vboxmanage.py b/virtualbox/pybox/helper/vboxmanage.py
index 54e9b74..c6ba75b 100644
--- a/virtualbox/pybox/helper/vboxmanage.py
+++ b/virtualbox/pybox/helper/vboxmanage.py
@@ -73,7 +73,7 @@ def get_all_vms(labname, option="vms"):
     # Reduce the number of VMs we query
     for item in vm_list:
         if labname.encode("utf-8") in item and (
-            b"controller-" in item or b"compute-" in item or b"storage-" in item
+            b"controller-" in item or b"worker-" in item or b"storage-" in item
         ):
             initial_node_list.append(item.decode("utf-8"))