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
    def _prepare_nodes_network(
            cls, prepared_nodes: Nodes,
            controller_configuration: BaseNodeConfig) -> Nodes:
        if global_variables.platform not in (consts.Platforms.BARE_METAL,
                                             consts.Platforms.NONE):
            yield prepared_nodes
            return

        interfaces = cls.nat_interfaces(
            controller_configuration)  # todo need to fix mismatch config types
        nat = NatController(interfaces,
                            NatController.get_namespace_index(interfaces[0]))
        nat.add_nat_rules()
        yield prepared_nodes
        cls.teardown_nat(nat)
Exemple #3
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
        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