Example #1
0
def template(args):
    """ Print the template of a given stack or, if no stack is found, print
    the template that would be generated when launching.

    """

    cloud = get_current_cloud()
    stack_name = args.stack_name_or_id

    try:
        template_ = cloud.orchestration_connection.get_template(stack_name)
        template_ = json.dumps(template_, sort_keys=True, indent=4, separators=(",", ": "))
    except BotoServerError:
        # Stack doesn't exist. Generate a new template.
        stack_type = stack_name
        template_ = generate_stack_template(stack_type, stack_name, args.template_uri, args.template_params)

    print template_
Example #2
0
def test_ownership(get_parsed_doc):

    template = """
{
  "Resources" : {
    "existing_resource": {}
  },

  "Outputs" : {
    "existing_output" : {
      "Value": "existing value",
      "Description" : "existing description"
    }
  }
}"""
    get_parsed_doc.return_value = template

    template = generate_stack_template(None, None, "template_uri", None,
                                       owner="test-user")
    template_dict = json.loads(template)

    resources = template_dict.get("Resources", None)
    outputs = template_dict.get("Outputs", None)

    assert resources is not None
    assert outputs is not None

    assert resources.get("existing_resource", None) is not None

    existing_output = outputs.get("existing_output", None)
    assert existing_output is not None
    assert existing_output["Value"] == "existing value"

    owner_output = outputs.get("owner", None)
    assert owner_output is not None
    assert owner_output["Value"] == "test-user"