PROD-36385 add delete-class method for ReclassManager

Change-Id: I1cbefcd8f912b1315c1bbd9fcd9fa9792d7f6c72
diff --git a/tcp_tests/managers/reclass_manager.py b/tcp_tests/managers/reclass_manager.py
index 7c75086..7e6243a 100644
--- a/tcp_tests/managers/reclass_manager.py
+++ b/tcp_tests/managers/reclass_manager.py
@@ -11,6 +11,7 @@
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 #    License for the specific language governing permissions and limitations
 #    under the License.
+import yaml
 from tcp_tests import logger
 from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
 
@@ -88,31 +89,17 @@
             key=key
             ))
         request_key = self.ssh.check_call(
-            "{reclass_tools} get-key {key} /srv/salt/reclass/*/{file_name}".
+            "{reclass_tools} get-key {key} "
+            "/srv/salt/reclass/classes/{file_name}".
             format(reclass_tools=self.reclass_tools_cmd,
                    key=key,
                    file_name=file_name))['stdout']
 
-        # Reclass-tools returns result to stdout, so we get it as
-        #     ['\n',
-        #      '---\n',
-        #      '# Found parameters._param.jenkins_pipelines_branch in \
-        #          /srv/salt/reclass/classes/cluster/../infra/init.yml\n',
-        #      'release/proposed/2019.2.0\n',
-        #      '...\n',
-        #      '\n']
-        # So we have no chance to get value without dirty code like `stdout[3]`
-
         LOG.info("Raw output from reclass.get_key {}".format(request_key))
-        if len(request_key) < 4:
-            print("Can't find {key} in {file_name}. Got stdout {stdout}".
-                  format(key=key,
-                         file_name=file_name,
-                         stdout=request_key))
-            return None
-        value = request_key[3].strip('\n')
-        LOG.info("From reclass.get_key {}".format(value))
-        return value
+        encoded_request_key = ''.join(request_key).encode(encoding='UTF-8')
+        key = yaml.load(encoded_request_key)
+        LOG.info("From reclass.get_key {}".format(key))
+        return key
 
     def add_bool_key(self, key, value, short_path):
         """
@@ -174,13 +161,18 @@
             May look like cluster/*/cicd/control/leader.yml
         :return: None
         """
-        self.ssh.check_call(
-            "{reclass_tools} del-key classes {value} \
-            /srv/salt/reclass/classes/{path}".format(
-                reclass_tools=self.reclass_tools_cmd,
+        current_content = self.get_key('classes', short_path)
+        if value not in current_content:
+            LOG.info("{value} not found in classes in {path}".format(
                 value=value,
                 path=short_path
             ))
+            return
+
+        new_content = current_content
+        new_content.remove(value)
+
+        self.add_key("classes", new_content, short_path)
 
     def delete_key(self, key, short_path):
         """
diff --git a/tcp_tests/tests/system/test_ceph_operations.py b/tcp_tests/tests/system/test_ceph_operations.py
index 1db4d77..44ae014 100644
--- a/tcp_tests/tests/system/test_ceph_operations.py
+++ b/tcp_tests/tests/system/test_ceph_operations.py
@@ -114,7 +114,7 @@
 @pytest.fixture(scope='session')
 def wa_prod36167(reclass_actions):
     reclass_actions.delete_class("system.salt.control.virt",
-                                 "classes/cluster/*/infra/kvm.yml")
+                                 "cluster/*/infra/kvm.yml")
 
 
 @pytest.mark.usefixtures("add_xtra_node_to_salt",