Added 'k8s_deployed' fixture

Created a separate fixture for Kubernetes deployment.
Modified existing k8s related fixtures / tests so they
use it now and updated templates with k8s environments.

Also this patch includes few minor changes:

 * removed unused fixture 'deploy_openstack' which
   was a full copy of 'openstack_deployed' fixture;
 * removed unused modules imports;
 * fixed typos and docstrings.

Change-Id: Ic35551f3e52913cede753b92e7d5a81f54570b01
Reviewed-on: https://review.gerrithub.io/365234
Reviewed-by: <vrovachev@mirantis.com>
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Tatyanka Leontovich <tleontovich@mirantis.com>
diff --git a/tcp_tests/fixtures/k8s_fixtures.py b/tcp_tests/fixtures/k8s_fixtures.py
new file mode 100644
index 0000000..bec38a5
--- /dev/null
+++ b/tcp_tests/fixtures/k8s_fixtures.py
@@ -0,0 +1,75 @@
+#    Copyright 2017 Mirantis, Inc.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    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 pytest
+
+from tcp_tests.helpers import ext
+from tcp_tests import logger
+from tcp_tests.managers import k8smanager
+
+LOG = logger.logger
+
+
+@pytest.fixture(scope='function')
+def k8s_actions(config, underlay, salt_deployed):
+    """Fixture that provides various actions for K8S
+
+    :param config: fixture provides oslo.config
+    :param underlay: fixture provides underlay manager
+    :param salt_deployed: fixture provides salt manager
+    :rtype: K8SManager
+
+    For use in tests or fixtures to deploy a custom K8S
+    """
+    return k8smanager.K8SManager(config, underlay, salt_deployed)
+
+
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
+@pytest.fixture(scope='function')
+def k8s_deployed(revert_snapshot, request, config, hardware, underlay,
+                 common_services_deployed, k8s_actions):
+    """Fixture to get or install k8s on environment
+
+    :param revert_snapshot: fixture that reverts snapshot that is specified
+                            in test with @pytest.mark.revert_snapshot(<name>)
+    :param request: fixture provides pytest data
+    :param config: fixture provides oslo.config
+    :param hardware: fixture provides enviromnet manager
+    :param underlay: fixture provides underlay manager
+    :param common_services_deployed: fixture provides CommonServicesManager
+    :param k8s_actions: fixture provides K8SManager instance
+    :rtype: K8SManager
+
+    If config.k8s.k8s_installed is not set, this fixture assumes
+    that the k8s services were not installed, and do the following:
+    - install k8s services
+    - make snapshot with name 'k8s_deployed'
+    - return K8SManager instance
+
+    If config.k8s.k8s_installed was set, this fixture assumes that
+    the k8s services were already installed, and do the following:
+    - return K8SManager instance
+
+    If you want to revert 'k8s_deployed' snapshot, please use mark:
+    @pytest.mark.revert_snapshot("k8s_deployed")
+    """
+
+    # Deploy Kubernetes cluster
+    if not config.k8s.k8s_installed:
+        steps_path = config.k8s_deploy.k8s_steps_path
+        commands = underlay.read_template(steps_path)
+        k8s_actions.install(commands)
+        hardware.create_snapshot(ext.SNAPSHOT.k8s_deployed)
+
+    return k8s_actions
\ No newline at end of file
diff --git a/tcp_tests/fixtures/openstack_fixtures.py b/tcp_tests/fixtures/openstack_fixtures.py
index f69c247..ae3b9e8 100644
--- a/tcp_tests/fixtures/openstack_fixtures.py
+++ b/tcp_tests/fixtures/openstack_fixtures.py
@@ -28,13 +28,14 @@
 
 @pytest.fixture(scope='function')
 def openstack_actions(config, underlay, salt_deployed):
-    """Fixture that provides various actions for K8S
+    """Fixture that provides various actions for OpenStack
 
     :param config: fixture provides oslo.config
     :param underlay: fixture provides underlay manager
-    :rtype: K8SManager
+    :param salt_deployed: fixture provides salt manager
+    :rtype: OpenstackManager
 
-    For use in tests or fixtures to deploy a custom K8S
+    For use in tests or fixtures to deploy a custom OpenStack
     """
     return openstack_manager.OpenstackManager(config, underlay, salt_deployed)
 
@@ -52,7 +53,8 @@
     :param config: fixture provides oslo.config
     :param hardware: fixture provides enviromnet manager
     :param underlay: fixture provides underlay manager
-    :param tcp_actions: fixture provides OpenstackManager instance
+    :param common_services_deployed: fixture provides CommonServicesManager
+    :param openstack_actions: fixture provides OpenstackManager instance
     :rtype: OpenstackManager
 
     If config.openstack.openstack_installed is not set, this fixture assumes
@@ -68,54 +70,7 @@
     If you want to revert 'openstack_deployed' snapshot, please use mark:
     @pytest.mark.revert_snapshot("openstack_deployed")
     """
-    # Create Salt cluster
-    if not config.openstack.openstack_installed:
-        steps_path = config.openstack_deploy.openstack_steps_path
-        commands = underlay.read_template(steps_path)
-        openstack_actions.install(commands)
-        hardware.create_snapshot(ext.SNAPSHOT.openstack_deployed)
-
-    else:
-        # 1. hardware environment created and powered on
-        # 2. config.underlay.ssh contains SSH access to provisioned nodes
-        #    (can be passed from external config with TESTS_CONFIGS variable)
-        # 3. config.tcp.* options contain access credentials to the already
-        #    installed TCP API endpoint
-        pass
-
-    return openstack_actions
-
-
-@pytest.mark.revert_snapshot(ext.SNAPSHOT.openstack_deployed)
-@pytest.fixture(scope='function')
-def deploy_openstack(revert_snapshot, request, config,
-                     hardware, underlay, common_services_deployed,
-                     openstack_actions):
-    """Fixture to get or install OpenStack services on environment
-
-    :param revert_snapshot: fixture that reverts snapshot that is specified
-                            in test with @pytest.mark.revert_snapshot(<name>)
-    :param request: fixture provides pytest data
-    :param config: fixture provides oslo.config
-    :param hardware: fixture provides enviromnet manager
-    :param underlay: fixture provides underlay manager
-    :param tcp_actions: fixture provides OpenstackManager instance
-    :rtype: OpenstackManager
-
-    If config.openstack.openstack_installed is not set, this fixture assumes
-    that the openstack services were not installed, and do the following:
-    - install openstack services
-    - make snapshot with name 'openstack_deployed'
-    - return OpenstackManager instance
-
-    If config.openstack.openstack_installed was set, this fixture assumes that
-    the openstack services were already installed, and do the following:
-    - return OpenstackManager instance
-
-    If you want to revert 'openstack_deployed' snapshot, please use mark:
-    @pytest.mark.revert_snapshot("openstack_deployed")
-    """
-    # Create Salt cluster
+    # Deploy Openstack cluster
     if not config.openstack.openstack_installed:
         steps_path = config.openstack_deploy.openstack_steps_path
         commands = underlay.read_template(steps_path)
diff --git a/tcp_tests/fixtures/virtlet_ceph_fixtures.py b/tcp_tests/fixtures/virtlet_ceph_fixtures.py
index 9a13cb4..a9cd3db 100644
--- a/tcp_tests/fixtures/virtlet_ceph_fixtures.py
+++ b/tcp_tests/fixtures/virtlet_ceph_fixtures.py
@@ -12,40 +12,34 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
-
 import pytest
-import yaml
 
 from tcp_tests import logger
 from tcp_tests.helpers import ext
-from tcp_tests import settings
 from tcp_tests.managers import virtlet_ceph_manager
 
 LOG = logger.logger
 
 
 @pytest.fixture(scope='function')
-def virtlet_ceph_actions(config, underlay, salt_actions):
+def virtlet_ceph_actions(config, underlay):
     """Fixture that provides various actions for Virtlet project
 
     :param config: fixture provides oslo.config
     :param underlay: fixture provides underlay manager
     :rtype: VirtletCephManager
     """
-    return virtlet_ceph_manager.VirtletCephManager(config, underlay, salt_actions)
+    return virtlet_ceph_manager.VirtletCephManager(config, underlay)
 
 
 @pytest.mark.revert_snapshot(ext.SNAPSHOT.virtlet_ceph_deployed)
 @pytest.fixture(scope='function')
-def virtlet_ceph_deployed(revert_snapshot, request, config,
-                          hardware, underlay, common_services_deployed,
+def virtlet_ceph_deployed(revert_snapshot, config, hardware, underlay,
                           virtlet_deployed, virtlet_ceph_actions):
     """Fixture to get or install Virtlet project on the environment
 
     :param revert_snapshot: fixture that reverts snapshot that is specified
                             in test with @pytest.mark.revert_snapshot(<name>)
-    :param request: fixture provides pytest data
     :param config: fixture provides oslo.config
     :param hardware: fixture provides enviromnet manager
     :param underlay: fixture provides underlay manager
@@ -67,7 +61,7 @@
     If you want to revert 'virtlet_ceph_deployed' snapshot, please use mark:
     @pytest.mark.revert_snapshot("virtlet_ceph_deployed")
     """
-    # Create Salt cluster
+    # Deploy Virtlet with Ceph for Kubernetes
     if not config.virtlet.ceph_installed:
         steps_path = config.virtlet_deploy.virtlet_ceph_steps_path
         commands = underlay.read_template(steps_path)
diff --git a/tcp_tests/fixtures/virtlet_fixtures.py b/tcp_tests/fixtures/virtlet_fixtures.py
index f70a201..301800e 100644
--- a/tcp_tests/fixtures/virtlet_fixtures.py
+++ b/tcp_tests/fixtures/virtlet_fixtures.py
@@ -12,43 +12,38 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
-
 import pytest
-import yaml
 
 from tcp_tests import logger
 from tcp_tests.helpers import ext
-from tcp_tests import settings
 from tcp_tests.managers import virtlet_manager
 
 LOG = logger.logger
 
 
 @pytest.fixture(scope='function')
-def virtlet_actions(config, underlay, salt_actions):
+def virtlet_actions(config, underlay):
     """Fixture that provides various actions for Virtlet project
 
     :param config: fixture provides oslo.config
     :param underlay: fixture provides underlay manager
     :rtype: VirtletManager
     """
-    return virtlet_manager.VirtletManager(config, underlay, salt_actions)
+    return virtlet_manager.VirtletManager(config, underlay)
 
 
 @pytest.mark.revert_snapshot(ext.SNAPSHOT.virtlet_deployed)
 @pytest.fixture(scope='function')
-def virtlet_deployed(revert_snapshot, request, config,
-                             hardware, underlay, common_services_deployed,
-                             virtlet_actions):
+def virtlet_deployed(revert_snapshot, config, hardware, underlay,
+                     k8s_deployed, virtlet_actions):
     """Fixture to get or install Virtlet project on the environment
 
     :param revert_snapshot: fixture that reverts snapshot that is specified
                             in test with @pytest.mark.revert_snapshot(<name>)
-    :param request: fixture provides pytest data
     :param config: fixture provides oslo.config
     :param hardware: fixture provides enviromnet manager
     :param underlay: fixture provides underlay manager
+    :param k8s_deployed: fixture provides K8SManager instance
     :param virtlet_actions: fixture provides VirtletManager instance
     :rtype: VirtletManager
 
@@ -66,7 +61,7 @@
     If you want to revert 'virtlet_deployed' snapshot, please use mark:
     @pytest.mark.revert_snapshot("virtlet_deployed")
     """
-    # Create Salt cluster
+    # Deploy Virtlet for Kubernetes
     if not config.virtlet.virtlet_installed:
         steps_path = config.virtlet_deploy.virtlet_steps_path
         commands = underlay.read_template(steps_path)