Пример #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 = self.nat_interfaces(tf_config)
            nat = NatController(
                interfaces, NatController.get_namespace_index(interfaces[0]))
            nat.add_nat_rules()

            nodes_data["nat"] = nat

            return nodes
Пример #2
0
    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)
Пример #3
0
 def teardown_nat(nat: NatController) -> None:
     if global_variables.test_teardown and nat:
         nat.remove_nat_rules()