Exemplo n.º 1
0
def networking_stack_factory(request):
    """Define a fixture to manage the creation and destruction of CloudFormation stacks."""
    factory = CfnStacksFactory(request.config.getoption("credential"))

    def _create_network(region, template_path, parameters):
        file_content = extract_template(template_path)
        stack = CfnStack(
            name="integ-tests-networking-{0}{1}{2}".format(
                random_alphanumeric(),
                "-" if request.config.getoption("stackname_suffix") else "",
                request.config.getoption("stackname_suffix"),
            ),
            region=region,
            template=file_content,
            parameters=parameters,
        )
        factory.create_stack(stack)
        return stack

    def extract_template(template_path):
        with open(template_path) as cfn_file:
            file_content = cfn_file.read()
        return file_content

    yield _create_network
    factory.delete_all_stacks()
def api_with_default_settings(api_infrastructure_s3_uri, public_ecr_image_uri,
                              api_definition_s3_uri, request, region):
    factory = CfnStacksFactory(request.config.getoption("credential"))

    params = []
    if api_definition_s3_uri:
        params.append({
            "ParameterKey": "ApiDefinitionS3Uri",
            "ParameterValue": api_definition_s3_uri
        })
    if public_ecr_image_uri:
        params.append({
            "ParameterKey": "PublicEcrImageUri",
            "ParameterValue": public_ecr_image_uri
        })

    template = (
        api_infrastructure_s3_uri or
        f"s3://{region}-aws-parallelcluster/parallelcluster/{get_installed_parallelcluster_version()}"
        "/api/parallelcluster-api.yaml")
    logging.info(
        f"Creating API Server stack in {region} with template {template}")
    stack = CfnStack(
        name=generate_stack_name("integ-tests-api",
                                 request.config.getoption("stackname_suffix")),
        region=region,
        parameters=params,
        capabilities=["CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND"],
        template=template,
    )
    try:
        factory.create_stack(stack)
        yield stack
    finally:
        factory.delete_all_stacks()
Exemplo n.º 3
0
def cfn_stacks_factory():
    """Define a fixture to manage the creation and destruction of CloudFormation stacks."""
    factory = CfnStacksFactory()
    yield factory
    factory.delete_all_stacks()
Exemplo n.º 4
0
def cfn_stacks_factory(request):
    """Define a fixture to manage the creation and destruction of CloudFormation stacks."""
    factory = CfnStacksFactory(request.config.getoption("credential"))
    yield factory
    if not request.config.getoption("no_delete"):
        factory.delete_all_stacks()