# Copyright ClusterHQ Inc.  See LICENSE file for details.

"""
Utility functions for test cluster lifecycle management.
"""

from uuid import uuid4, UUID

supported_test_types = ['functional', 'acceptance']
supported_platforms = ['centos-7', 'ubuntu-14.04', 'ubuntu-15.04']
supported_providers = ['aws', 'openstack']


def make_cluster_id(test_type, platform, provider):
    """
    """
    test_index = supported_test_types.index(test_type)
    if test_index == -1:
        raise Exception()
    platform_index = supported_platforms.index(platform)
    if platform_index == -1:
        raise Exception()
    provider_index = supported_providers.index(provider)
    if provider_index == -1:
        raise Exception()

    marker_string = str(test_index) + str(platform_index) + str(provider_index)
    marker = int(marker_string)
    c = uuid4()
    tagged_cluster_id = UUID(fields=(
        c.time_low, c.time_mid, c.time_hi_version,
        c.clock_seq_hi_variant, c.clock_seq_low,
        # Instead of node, a hard-coded magic constant.
        marker,
    ))
    return tagged_cluster_id

@@ -82,13 +82,8 @@
 for 
-test 
 clus
@@ -106,16 +106,28 @@
 nagement
+ in test env
 .%0A%22%22%22%0A%0Af
@@ -155,16 +155,215 @@
 , UUID%0A%0A
+# Parameters influencing cluster id generated by tests.%0A# Since cluster id is generated by indexing into the arrays,%0A# please append to the end of the array if supported types%0A# need to be extended.%0A
 supporte
@@ -574,24 +574,94 @@
 r):%0A    %22%22%22%0A
+    Compose cluster %60%60UUID%60%60 using test type, platform, and provider.%0A
     %22%22%22%0A    
@@ -710,16 +710,64 @@
 st_type)
+%0A%0A    # XXX: Please throw appropriate Exception.
 %0A    if 
@@ -867,16 +867,63 @@
 atform)%0A
+    # XXX: Please throw appropriate Exception.%0A
     if p
@@ -1026,16 +1026,63 @@
 ovider)%0A
+    # XXX: Please throw appropriate Exception.%0A
     if p

Add documentation.