Exemplo n.º 1
0
        def get_nodes_func(tf_config: BaseTerraformConfig,
                           infraenv_config: InfraEnvConfig):
            if "nodes" in nodes_data:
                return nodes_data["nodes"]

            nodes_data["configs"] = infraenv_config, tf_config

            net_asset = LibvirtNetworkAssets()
            tf_config.net_asset = net_asset.get()
            nodes_data["net_asset"] = net_asset

            controller = TerraformController(tf_config,
                                             entity_config=infraenv_config)
            nodes = Nodes(controller)
            nodes_data["nodes"] = nodes

            nodes.prepare_nodes()

            interfaces = BaseTest.nat_interfaces(tf_config)
            nat = NatController(
                interfaces, NatController.get_namespace_index(interfaces[0]))
            nat.add_nat_rules()

            nodes_data["nat"] = nat

            return nodes
Exemplo n.º 2
0
 def nodes(self, setup_node_controller, request):
     if hasattr(request, 'param'):
         node_vars = self.override_node_parameters(**request.param)
     else:
         node_vars = env_variables
     net_asset = None
     needs_nat = node_vars.get("platform") == consts.Platforms.NONE
     try:
         if not qe_env:
             net_asset = NetworkAssets()
             node_vars["net_asset"] = net_asset.get()
         controller = setup_node_controller(**node_vars)
         nodes = Nodes(controller, node_vars["private_ssh_key_path"])
         nodes.prepare_nodes()
         if needs_nat:
             nodes.configure_nat()
         yield nodes
         if env_variables['test_teardown']:
             logging.info('--- TEARDOWN --- node controller\n')
             nodes.destroy_all_nodes()
         if needs_nat:
             nodes.unconfigure_nat()
     finally:
         if not qe_env:
             net_asset.release_all()
Exemplo n.º 3
0
        def get_nodes_func(config: TerraformConfig = TerraformConfig()):
            if "nodes" in nodes_data:
                return nodes_data["nodes"]

            nodes_data["needs_nat"] = config.platform == consts.Platforms.NONE
            nodes_data["net_asset"] = NetworkAssets()
            config.net_asset = nodes_data["net_asset"].get()

            nodes = Nodes(TerraformController(config), config.private_ssh_key_path)
            nodes.prepare_nodes()
            if nodes_data["needs_nat"]:
                nodes.configure_nat()

            nodes_data["nodes"] = nodes
            return nodes
Exemplo n.º 4
0
 def nodes(self, setup_node_controller):
     net_asset = None
     try:
         if not qe_env:
             net_asset = NetworkAssets()
             env_variables["net_asset"] = net_asset.get()
         controller = setup_node_controller(**env_variables)
         nodes = Nodes(controller, env_variables["private_ssh_key_path"])
         nodes.prepare_nodes()
         yield nodes
         logging.info(f'--- TEARDOWN --- node controller\n')
         nodes.destroy_all_nodes()
     finally:
         if not qe_env:
             net_asset.release_all()
Exemplo n.º 5
0
 def prepare_nodes(self, nodes: Nodes,
                   cluster_configuration: ClusterConfig) -> Nodes:
     try:
         nodes.prepare_nodes()
         yield nodes
     finally:
         if global_variables.test_teardown:
             logging.info('--- TEARDOWN --- node controller\n')
             nodes.destroy_all_nodes()
             logging.info(
                 f'--- TEARDOWN --- deleting iso file from: {cluster_configuration.iso_download_path}\n'
             )
             infra_utils.run_command(
                 f"rm -f {cluster_configuration.iso_download_path}",
                 shell=True)
Exemplo n.º 6
0
        def get_nodes_func(config: TerraformConfig = TerraformConfig()):
            if "nodes" in nodes_data:
                return nodes_data["nodes"]

            net_asset = NetworkAssets()
            config.net_asset = net_asset.get()

            nodes = Nodes(TerraformController(config),
                          config.private_ssh_key_path,
                          net_asset,
                          config.platform == consts.Platforms.NONE)

            nodes.prepare_nodes()
            nodes_data["nodes"] = nodes
            return nodes
Exemplo n.º 7
0
 def prepare_infraenv_nodes(
         self, infraenv_nodes: Nodes,
         infra_env_configuration: InfraEnvConfig) -> Nodes:
     try:
         infraenv_nodes.prepare_nodes()
         yield infraenv_nodes
     finally:
         if global_variables.test_teardown:
             logging.info("--- TEARDOWN --- node controller\n")
             infraenv_nodes.destroy_all_nodes()
             logging.info(
                 f"--- TEARDOWN --- deleting iso file from: {infra_env_configuration.iso_download_path}\n"
             )
             infra_utils.run_command(
                 f"rm -f {infra_env_configuration.iso_download_path}",
                 shell=True)
Exemplo n.º 8
0
 def nodes(self, setup_node_controller, request):
     if hasattr(request, 'param'):
         node_vars = self.override_node_parameters(**request.param)
     else:
         node_vars = env_variables
     net_asset = None
     try:
         if not qe_env:
             net_asset = NetworkAssets()
             node_vars["net_asset"] = net_asset.get()
         controller = setup_node_controller(**node_vars)
         nodes = Nodes(controller, node_vars["private_ssh_key_path"])
         nodes.prepare_nodes()
         yield nodes
         logging.info('--- TEARDOWN --- node controller\n')
         nodes.destroy_all_nodes()
     finally:
         if not qe_env:
             net_asset.release_all()
Exemplo n.º 9
0
        def get_nodes_func(tf_config: TerraformConfig, cluster_config: ClusterConfig):
            if "nodes" in nodes_data:
                return nodes_data["nodes"]

            nodes_data["configs"] = cluster_config, tf_config
            net_asset = LibvirtNetworkAssets()
            tf_config.net_asset = net_asset.get()
            nodes_data["net_asset"] = net_asset

            controller = TerraformController(tf_config, cluster_config=cluster_config)
            nodes = Nodes(controller, tf_config.private_ssh_key_path)
            nodes_data["nodes"] = nodes

            nodes.prepare_nodes()
            interfaces = BaseTest.nat_interfaces(tf_config)
            nat = NatController(interfaces, NatController.get_namespace_index(interfaces[0]))
            nat.add_nat_rules()
            nodes_data["nat"] = nat

            return nodes
Exemplo n.º 10
0
        def get_nodes_func(config: Optional[TerraformConfig] = None):
            if not config:
                config = TerraformConfig()

            if "nodes" in nodes_data:
                return nodes_data["nodes"]

            net_asset = LibvirtNetworkAssets()
            config.net_asset = net_asset.get()
            controller = TerraformController(config)
            nodes = Nodes(controller, config.private_ssh_key_path)

            nodes.prepare_nodes()
            interfaces = BaseTest.nat_interfaces(config)
            nat = NatController(
                interfaces, NatController.get_namespace_index(interfaces[0]))
            nat.add_nat_rules()

            nodes_data["nodes"] = nodes
            nodes_data["config"] = config
            nodes_data["net_asset"] = net_asset
            nodes_data["nat"] = nat
            return nodes