fixed Issues with Sanity
Added Sync Keywords Change-Id: Idb6488ab1fb3a98a56bf6b904da42b59675cf886 Signed-off-by: Abhishek jaiswal <abhishek.jaiswal@windriver.com>
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
// used to deploy the lab (and its subclouds, if any)
|
||||
// All the files are assumed to be stored on the Central Cloud in the case of a DC system.
|
||||
|
||||
"controller" : {
|
||||
"deployment_config_file": "/home/sysadmin/deployment-config.yaml",
|
||||
},
|
||||
"controller" : {
|
||||
"controller-0" : {
|
||||
"deployment_config_file": "/home/sysadmin/deployment-config.yaml",
|
||||
"docker_ca_file": "",
|
||||
}
|
||||
},
|
||||
"subclouds" : {
|
||||
"subcloud1": {
|
||||
"bootstrap_file": "/home/sysadmin/subcloud-1/subcloud1-bootstrap-values.yaml",
|
||||
@@ -24,4 +27,6 @@
|
||||
"install_file": "/home/sysadmin/subcloud-3/subcloud3-install-values.yaml"
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -6,13 +6,16 @@ class DeploymentAssets:
|
||||
Class for DeploymentAssets object
|
||||
"""
|
||||
|
||||
def __init__(self, deployment_assets_dict: Dict[str, str]):
|
||||
def __init__(self, controller_name: str, deployment_assets_dict: Dict[str, str]):
|
||||
"""
|
||||
Constructor
|
||||
|
||||
Args:
|
||||
controller_name (str): name of the controller where file is present
|
||||
deployment_assets_dict (Dict[str, str]): Dictionary version of the deployment_assets config for controllers or a given subcloud.
|
||||
"""
|
||||
self.controller_name = controller_name
|
||||
|
||||
self.bootstrap_file = None
|
||||
if "bootstrap_file" in deployment_assets_dict:
|
||||
self.bootstrap_file = deployment_assets_dict["bootstrap_file"]
|
||||
@@ -25,12 +28,15 @@ class DeploymentAssets:
|
||||
if "install_file" in deployment_assets_dict:
|
||||
self.install_file = deployment_assets_dict["install_file"]
|
||||
|
||||
self.docker_ca_file = None
|
||||
if "docker_ca_file" in deployment_assets_dict:
|
||||
self.docker_ca_file = deployment_assets_dict["docker_ca_file"]
|
||||
|
||||
def get_bootstrap_file(self) -> str:
|
||||
"""
|
||||
Getter for the boostrap_file
|
||||
|
||||
Returns (str): boostrap_file
|
||||
|
||||
"""
|
||||
return self.bootstrap_file.strip() if self.bootstrap_file else self.bootstrap_file
|
||||
|
||||
@@ -39,7 +45,6 @@ class DeploymentAssets:
|
||||
Getter for the deployment_config_file
|
||||
|
||||
Returns (str): deployment_config_file
|
||||
|
||||
"""
|
||||
return self.deployment_config_file.strip()
|
||||
|
||||
@@ -48,6 +53,21 @@ class DeploymentAssets:
|
||||
Getter for the install_file
|
||||
|
||||
Returns (str): install_file
|
||||
|
||||
"""
|
||||
return self.install_file.strip()
|
||||
|
||||
def get_docker_ca_file(self) -> str:
|
||||
"""
|
||||
Getter for the docker_ca_file
|
||||
|
||||
Returns (str): docker_ca_file
|
||||
"""
|
||||
return self.docker_ca_file.strip()
|
||||
|
||||
def get_controller_name(self) -> str:
|
||||
"""
|
||||
Getter for the controller_name
|
||||
|
||||
Returns (str): controller_name
|
||||
"""
|
||||
return self.controller_name
|
||||
|
@@ -16,13 +16,14 @@ class DeploymentAssetsConfig:
|
||||
raise
|
||||
|
||||
deployment_assets_dict = json5.load(json_data)
|
||||
self.controller_deployment_assets = DeploymentAssets(deployment_assets_dict["controller"])
|
||||
controller_name, dep_assets_dict = deployment_assets_dict["controller"].popitem()
|
||||
self.controller_deployment_assets = DeploymentAssets(controller_name, dep_assets_dict)
|
||||
|
||||
self.subclouds_deployment_assets = {}
|
||||
if "subclouds" in deployment_assets_dict:
|
||||
subclouds_dict = deployment_assets_dict["subclouds"]
|
||||
for subcloud_name in subclouds_dict.keys():
|
||||
self.subclouds_deployment_assets[subcloud_name] = DeploymentAssets(subclouds_dict[subcloud_name])
|
||||
self.subclouds_deployment_assets[subcloud_name] = DeploymentAssets(None, subclouds_dict[subcloud_name])
|
||||
|
||||
def get_controller_deployment_assets(self) -> DeploymentAssets:
|
||||
"""
|
||||
|
@@ -533,3 +533,21 @@ class LabConfig:
|
||||
if len(controllers) > 0:
|
||||
return controllers[0]
|
||||
return None
|
||||
|
||||
def get_counterpart_controller(self, lab_node_name: str) -> Node:
|
||||
"""Function to get the paired controller
|
||||
|
||||
Finds and returns the counterpart controller name from a list of controllers,
|
||||
given the name of the current controller. Assumes there are exactly two controllers.
|
||||
|
||||
Args:
|
||||
lab_node_name (str): The name of the current controller.
|
||||
|
||||
Returns:
|
||||
Node: The counterpart / paired controller Node.
|
||||
"""
|
||||
counterpart_controllers = [node for node in self.get_controllers() if node.get_name() != lab_node_name]
|
||||
if not counterpart_controllers:
|
||||
raise Exception("Others controller Not Found")
|
||||
else:
|
||||
return counterpart_controllers[0]
|
||||
|
@@ -8,6 +8,7 @@ class DcManagerSubcloudConfigFilesObject:
|
||||
install_file: str = None,
|
||||
bootstrap_file: str = None,
|
||||
deploy_file: str = None,
|
||||
docker_ca_file: str = None,
|
||||
):
|
||||
"""
|
||||
Constructor
|
||||
@@ -16,10 +17,12 @@ class DcManagerSubcloudConfigFilesObject:
|
||||
install_file (str, optional): Path to the install configuration file
|
||||
bootstrap_file (str, optional): Path to the bootstrap configuration file
|
||||
deploy_file (str, optional): Path to the deploy configuration file
|
||||
docker_ca_file (str, optional): Path to the deploy configuration file
|
||||
"""
|
||||
self.install_file = install_file
|
||||
self.bootstrap_file = bootstrap_file
|
||||
self.deploy_file = deploy_file
|
||||
self.docker_ca_file = docker_ca_file
|
||||
|
||||
def get_install_file(self) -> str:
|
||||
"""Get install configuration file path"""
|
||||
@@ -32,3 +35,7 @@ class DcManagerSubcloudConfigFilesObject:
|
||||
def get_deploy_file(self) -> str:
|
||||
"""Get deploy configuration file path"""
|
||||
return self.deploy_file
|
||||
|
||||
def get_docker_ca_file(self) -> str:
|
||||
"""Get docker ca file path"""
|
||||
return self.docker_ca_file
|
||||
|
39
keywords/cloud_platform/sync_files/sync_deployment_assets.py
Normal file
39
keywords/cloud_platform/sync_files/sync_deployment_assets.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
|
||||
from config.configuration_manager import ConfigurationManager
|
||||
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
|
||||
from keywords.files.file_keywords import FileKeywords
|
||||
|
||||
|
||||
class SyncDeploymentAssets:
|
||||
"""
|
||||
A class for sync deployment assets in between controllers.
|
||||
"""
|
||||
|
||||
def __init__(self, ssh_connection: str):
|
||||
"""Initializes AnsiblePlaybookKeywords with an SSH connection.
|
||||
|
||||
Args:
|
||||
ssh_connection (str): SSH connection to the target system.
|
||||
|
||||
"""
|
||||
self.ssh_connection = ssh_connection
|
||||
|
||||
def sync_assets(self):
|
||||
"""Function to Sync assets between active and standby controllers"""
|
||||
# Sync the lab configuration between active and standby controller
|
||||
lab_config = ConfigurationManager.get_lab_config()
|
||||
password = lab_config.get_admin_credentials().get_password()
|
||||
user = lab_config.get_admin_credentials().get_user_name()
|
||||
deployment_assets_config = ConfigurationManager.get_deployment_assets_config()
|
||||
|
||||
# get the source controller from where we have to copy data
|
||||
src_controller = LabConnectionKeywords().get_ssh_for_hostname(deployment_assets_config.get_controller_deployment_assets().get_controller_name())
|
||||
deployment_config_file = deployment_assets_config.get_controller_deployment_assets().get_deployment_config_file()
|
||||
base_file_path = f"{os.path.dirname(deployment_config_file)}/"
|
||||
|
||||
# get other controlller name
|
||||
dest_controller = lab_config.get_counterpart_controller(src_controller.get_name())
|
||||
# rsync files
|
||||
file_kw = FileKeywords(src_controller)
|
||||
file_kw.rsync_to_remote_server(base_file_path, dest_controller.get_name(), user, password, base_file_path, True)
|
@@ -1,8 +1,5 @@
|
||||
import os
|
||||
|
||||
from pytest import mark
|
||||
|
||||
from config.configuration_manager import ConfigurationManager
|
||||
from framework.logging.automation_logger import get_logger
|
||||
from framework.validation.validation import validate_equals
|
||||
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_add_keywords import DcManagerSubcloudAddKeywords
|
||||
@@ -10,38 +7,9 @@ from keywords.cloud_platform.dcmanager.dcmanager_subcloud_delete_keywords import
|
||||
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_list_keywords import DcManagerSubcloudListKeywords
|
||||
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_manager_keywords import DcManagerSubcloudManagerKeywords
|
||||
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
|
||||
from keywords.cloud_platform.sync_files.sync_deployment_assets import SyncDeploymentAssets
|
||||
from keywords.cloud_platform.system.host.system_host_list_keywords import SystemHostListKeywords
|
||||
from keywords.cloud_platform.system.host.system_host_swact_keywords import SystemHostSwactKeywords
|
||||
from keywords.files.file_keywords import FileKeywords
|
||||
|
||||
|
||||
def sanity_pre_requisite():
|
||||
"""
|
||||
Sanity pre-requisite for the test case
|
||||
"""
|
||||
# Sync the lab configuration between active and standby controller
|
||||
lab_config = ConfigurationManager.get_lab_config()
|
||||
active_controller_ssh = LabConnectionKeywords().get_active_controller_ssh()
|
||||
user = lab_config.get_admin_credentials().get_user_name()
|
||||
|
||||
# get the standby controller
|
||||
standby_controller = SystemHostListKeywords(active_controller_ssh).get_standby_controller()
|
||||
if not standby_controller:
|
||||
raise Exception("System does not have a standby controller")
|
||||
standby_host_name = standby_controller.get_host_name()
|
||||
deployment_assets_config = ConfigurationManager.get_deployment_assets_config()
|
||||
file_kw = FileKeywords(active_controller_ssh)
|
||||
# sync all subclouds files
|
||||
for sc_assets in deployment_assets_config.subclouds_deployment_assets.values():
|
||||
# get base path of the file
|
||||
for file in [sc_assets.get_deployment_config_file(), sc_assets.get_install_file(), sc_assets.get_bootstrap_file()]:
|
||||
|
||||
# get the base path of the file
|
||||
base_file_path = f"{os.path.dirname(file)}/"
|
||||
|
||||
# RSync the files over to the standby controller
|
||||
password = ConfigurationManager.get_lab_config().get_admin_credentials().get_password()
|
||||
file_kw.rsync_to_remote_server(file, standby_host_name, user, password, base_file_path)
|
||||
|
||||
|
||||
def subcloud_add(subcloud_name: str):
|
||||
@@ -107,9 +75,9 @@ def test_dc_subcloud_add_simplex():
|
||||
- add The subcloud
|
||||
- validate that the subcloud is added
|
||||
"""
|
||||
sanity_pre_requisite()
|
||||
# fetch not deployed subcloud
|
||||
ssh_connection = LabConnectionKeywords().get_active_controller_ssh()
|
||||
SyncDeploymentAssets(ssh_connection).sync_assets()
|
||||
dcmanager_subcloud_list_keywords = DcManagerSubcloudListKeywords(ssh_connection)
|
||||
subcloud_name = dcmanager_subcloud_list_keywords.get_dcmanager_subcloud_list().get_undeployed_subcloud_name("Simplex")
|
||||
subcloud_add(subcloud_name)
|
||||
@@ -153,9 +121,9 @@ def test_dc_subcloud_add_duplex():
|
||||
- add The subcloud
|
||||
- validate that the subcloud is added
|
||||
"""
|
||||
sanity_pre_requisite()
|
||||
# fetch not deployed subcloud
|
||||
ssh_connection = LabConnectionKeywords().get_active_controller_ssh()
|
||||
SyncDeploymentAssets(ssh_connection).sync_assets()
|
||||
dcmanager_subcloud_list_keywords = DcManagerSubcloudListKeywords(ssh_connection)
|
||||
subcloud_name = dcmanager_subcloud_list_keywords.get_dcmanager_subcloud_list().get_undeployed_subcloud_name("Duplex")
|
||||
subcloud_add(subcloud_name)
|
||||
|
Reference in New Issue
Block a user