# SUR 2015/08/20
# Senlin replacing Heat in Magnum
# cluster_function for bay_conductor 

import argparse
import logging
import time

from magnum.common.clients import OpenStackClients as OSC
from magnum.sur.action.clusters import Cluster
from magnum.sur.action.nodes import Node
from magnum.sur.action.profiles import Profile

LOG = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

def create_cluster(OSC, Ctype):
    LOG.info('Creating Request accepted.')

    # Client
    sc = OSC.senlin()

    # Create Profile
    pr_master = Profile.profile_create(sc, 'SUR_HEAT_Master_Profile', 'os.heat.stack',
                '/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/?', '1111')

    pr_minion = Profile.profile_create(sc, 'SUR_HEAT_Minion_Profile', 'os.heat.stack',
                '/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/?', '1111')

    time.sleep(1)
    LOG.info(pr_master)
    LOG.info(pr_minion)
    
    # Create Cluster
    cr_master = Cluster.cluster_create(sc, 'SUR_Master_Cluster', 'SUR_HEAT_Master_Profile')
    time.sleep(1)
    cr_minion = Cluster.cluster_create(sc, 'SUR_Minion_Cluster', 'SUR_HEAT_Minion_Profile')
    time.sleep(1)
    LOG.info(cr_master)
    LOG.info(cr_minion)

    # Create Nodes
    nr_master = Node.node_create(sc, 'SUR_Node_Master', 'SUR_Master_Cluster',
                                 'SUR_Master_Profile')
    time.sleep(1)
    LOG.info(nr_master)

    nr_minion = Node.node_create(sc, 'SUR_Node_Minion', 'SUR_Minion_Cluster',
                                 'SUR_Minion_Profile')
    time.sleep(1)
    LOG.info(nr_minion)

    #LOG.info('Complete')
    

@@ -857,24 +857,193 @@
 ', '1111')%0A%0A
+    pr_cluster = Profile.profile_create(sc, 'SUR_HEAT_Cluster_Profile', 'os.heat.stack',%0A                 '/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/?', '1111')%0A%0A
     time.sle
@@ -1096,16 +1096,41 @@
 minion)%0A
+    LOG.info(pr_cluster)%0A
     %0A   
@@ -1154,18 +1154,19 @@
 %0A    cr_
-ma
+clu
 ster = C
@@ -1192,30 +1192,28 @@
 te(sc, 'SUR_
-Master
+HEAT
 _Cluster', '
@@ -1225,124 +1225,15 @@
 EAT_
-Master_Profile')%0A    time.sleep(1)%0A    cr_minion = Cluster.cluster_create(sc, 'SUR_Minion_Cluster', 'SUR_HEAT_Minion
+Cluster
 _Pro
@@ -1277,39 +1277,16 @@
 (cr_
-ma
+clu
 ster)
-%0A    LOG.info(cr_minion)
 %0A%0A  
@@ -1302,24 +1302,25 @@
 e Nodes%0A    
+#
 nr_master = 
@@ -1377,32 +1377,33 @@
 r_Cluster',%0A    
+#
                 
@@ -1433,32 +1433,33 @@
 r_Profile')%0A    
+#
 time.sleep(1)%0A  
@@ -1452,32 +1452,33 @@
 me.sleep(1)%0A    
+#
 LOG.info(nr_mast
@@ -1486,16 +1486,17 @@
 r)%0A%0A    
+#
 nr_minio
@@ -1561,24 +1561,25 @@
 uster',%0A    
+#
             
@@ -1613,32 +1613,33 @@
 n_Profile')%0A    
+#
 time.sleep(1)%0A  
@@ -1632,32 +1632,33 @@
 me.sleep(1)%0A    
+#
 LOG.info(nr_mini

modify cluster_function