Add new method to ReclassManager to easy edit the reclass models. PROD-36050

Change-Id: Iab007f21abbd00cdc085e999dc8e4b035e93d4a7
diff --git a/tcp_tests/managers/reclass_manager.py b/tcp_tests/managers/reclass_manager.py
index ab6bd72..56116fc 100644
--- a/tcp_tests/managers/reclass_manager.py
+++ b/tcp_tests/managers/reclass_manager.py
@@ -182,6 +182,29 @@
                 path=short_path
             ))
 
+    def merge_context(self, yaml_context, short_path):
+        """
+        Merge
+
+        :param yaml_context: string, yaml with extra context
+        :param short_path: string, path to reclass yaml file.
+            It takes into account default path where the reclass locates.
+            May look like cluster/*/cicd/control/leader.yml
+        :return: None
+        """
+        tmp_file = "/tmp/extra_context.yaml"
+        with open(tmp_file, "w") as f:
+            f.write(yaml_context)
+
+        self.ssh.upload(tmp_file, tmp_file)
+        self.ssh.check_call(
+            "{reclass_tools} merge-context {yaml} \
+            /srv/salt/reclass/classes/{path}".format(
+                reclass_tools=self.reclass_tools_cmd,
+                yaml=tmp_file,
+                path=short_path
+            ))
+
     def commit(self, text_commit):
         self.ssh.check_call(
             "cd /srv/salt/reclass; git add -u && git commit --allow-empty "
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 247e7fd..412c7ca 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -645,7 +645,7 @@
     apt-get -y install python-virtualenv python-pip build-essential python-dev libssl-dev;
     [[ -d /root/venv-reclass-tools ]] || virtualenv /root/venv-reclass-tools;
     . /root/venv-reclass-tools/bin/activate;
-    pip install git+https://github.com/dis-xcom/reclass-tools;
+    pip install git+https://gerrit.mcp.mirantis.com/mcp/tcp-qa-reclass-tools;
     reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/cluster/;
     reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/system/;
     reclass-tools del-key parameters.linux.network.interface /usr/share/salt-formulas/reclass/;
diff --git a/tcp_tests/templates/shared-test-tools.yaml b/tcp_tests/templates/shared-test-tools.yaml
index 802c222..150c6a9 100644
--- a/tcp_tests/templates/shared-test-tools.yaml
+++ b/tcp_tests/templates/shared-test-tools.yaml
@@ -8,7 +8,7 @@
     apt-get install -y build-essential python-dev virtualenv python-virtualenv;
     virtualenv venv-reclass-tools;
     . venv-reclass-tools/bin/activate;
-    pip install git+git://github.com/dis-xcom/reclass_tools.git
+    pip install git+https://gerrit.mcp.mirantis.com/mcp/tcp-qa-reclass-tools
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 1}
   skip_fail: false
diff --git a/tcp_tests/tests/system/test_ceph_operations.py b/tcp_tests/tests/system/test_ceph_operations.py
index 30fdd8d..a22f64c 100644
--- a/tcp_tests/tests/system/test_ceph_operations.py
+++ b/tcp_tests/tests/system/test_ceph_operations.py
@@ -4,6 +4,40 @@
 
 LOG = logger.logger
 
+add_osd_ceph_init_yml = """
+parameters:
+  _param:
+    ceph_osd_node04_hostname: xtra
+    ceph_osd_node04_address: 10.6.0.205
+    ceph_mon_node04_ceph_public_address: #10.166.49.205
+    ceph_osd_system_codename: xenial
+  linux:
+    network:
+      host:
+        xtra:
+          address: ${_param:ceph_osd_node04_address}
+          names:
+          - ${_param:ceph_osd_node04_hostname}
+          - ${_param:ceph_osd_node04_hostname}.${_param:cluster_domain}
+        """
+
+add_osd_config_init_yml = """
+parameters:
+  reclass:
+    storage:
+      node:
+        ceph_osd_node04:
+          name: ${_param:ceph_osd_node04_hostname}
+          domain: ${_param:cluster_domain}
+          classes:
+          - cluster.${_param:cluster_name}.ceph.osd
+          params:
+            salt_master_host: ${_param:reclass_config_master}
+            linux_system_codename:  ${_param:ceph_osd_system_codename}
+            single_address: ${_param:ceph_osd_node04_address}
+            ceph_crush_parent: rack02
+"""
+
 
 @pytest.fixture(scope='module')
 def add_xtra_node_to_salt(salt_actions, underlay_actions, config):
@@ -41,54 +75,18 @@
 
     @pytest.fixture
     def describe_node_in_reclass(self,
-                                 reclass_actions, salt_actions):
+                                 reclass_actions,
+                                 salt_actions):
         LOG.info("Executing pytest SETUP "
                  "from describe_node_in_reclass fixture")
         reclass = reclass_actions
         # ---- cluster/*/ceph/init.yml ---------------
-        path = "cluster/*/ceph/init.yml"
-        reclass.add_key("parameters._param.ceph_osd_node04_hostname",
-                        "xtra",
-                        path)
-        reclass.add_key("parameters._param.ceph_osd_node04_address",
-                        "10.6.0.205",
-                        path)
-        reclass.add_key("parameters._param.ceph_osd_system_codename",
-                        "xenial",
-                        path)
-        reclass.add_key("parameters.linux.network.host.xtra.address",
-                        "${_param:ceph_osd_node04_address}",
-                        path)
-        reclass.add_key(
-            key="parameters.linux.network.host.xtra.names",
-            value="['${_param:ceph_osd_node04_hostname}', "
-            "'${_param:ceph_osd_node04_hostname}.${_param:cluster_domain}']",
-            short_path=path)
+        reclass.merge_context(yaml_context=add_osd_ceph_init_yml,
+                              short_path="cluster/*/ceph/init.yml")
 
         # ------- cluster/infra/config/init.yml -----------
-        path = "cluster/*/infra/config/init.yml"
-        parameter = "parameters.reclass.storage.node.ceph_osd_node04"
-        reclass.add_key(parameter + ".name",
-                        "${_param:ceph_osd_node04_hostname}",
-                        path)
-        reclass.add_key(parameter + ".domain",
-                        "${_param:cluster_domain}",
-                        path)
-        reclass.add_key(parameter + ".classes",
-                        "['cluster.${_param:cluster_name}.ceph.osd']",
-                        path)
-        reclass.add_key(parameter + ".params.salt_master_host",
-                        "${_param:reclass_config_master}",
-                        path)
-        reclass.add_key(parameter + ".params.linux_system_codename",
-                        "${_param:ceph_osd_system_codename}",
-                        path)
-        reclass.add_key(parameter + ".params.single_address",
-                        "${_param:ceph_osd_node04_address}",
-                        path)
-        reclass.add_key(parameter + ".params.ceph_crush_parent",
-                        "rack02",
-                        path)
+        reclass.merge_context(yaml_context=add_osd_config_init_yml,
+                              short_path="cluster/*/infra/config/init.yml")
 
     def test_add_node_process(self, describe_node_in_reclass,
                               drivetrain_actions):