diff --git a/WindowsAgent/WindowsAgent/Program.cs b/WindowsAgent/WindowsAgent/Program.cs
index d228f92..32041ae 100644
--- a/WindowsAgent/WindowsAgent/Program.cs
+++ b/WindowsAgent/WindowsAgent/Program.cs
@@ -1,6 +1,7 @@
 using System;
 using System.ComponentModel;
 using System.IO;
+using System.Net;
 using System.Threading;
 using NLog;
 
@@ -60,14 +61,13 @@ namespace Mirantis.Keero.WindowsAgent
 			}
 			if (doReboot)
 			{
-				Console.WriteLine("Rebooting...");
 				try
 				{
 					System.Diagnostics.Process.Start("shutdown.exe", "-r -t 0");
 				}
 				catch (Exception ex)
 				{
-					Console.WriteLine(ex);
+					Log.ErrorException("Cannot execute shutdown.exe", ex);
 				}
 			}
 
diff --git a/WindowsAgent/WindowsAgent/RabbitMqClient.cs b/WindowsAgent/WindowsAgent/RabbitMqClient.cs
index 0ce1a77..c927bd8 100644
--- a/WindowsAgent/WindowsAgent/RabbitMqClient.cs
+++ b/WindowsAgent/WindowsAgent/RabbitMqClient.cs
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Configuration;
 using System.Linq;
+using System.Net;
 using System.Text;
 using System.Threading.Tasks;
 using RabbitMQ.Client;
@@ -32,7 +33,7 @@ namespace Mirantis.Keero.WindowsAgent
 
 		public MqMessage GetMessage()
 		{
-			var queueName = ConfigurationManager.AppSettings["rabbitmq.inputQueue"] ?? Environment.MachineName.ToLower();
+			var queueName = ConfigurationManager.AppSettings["rabbitmq.inputQueue"] ?? Dns.GetHostName().ToLower();
 			try
 			{
 				IConnection connection = null;
diff --git a/WindowsAgent/WindowsAgent/WindowsAgent.csproj b/WindowsAgent/WindowsAgent/WindowsAgent.csproj
index 60247a2..f467e1d 100644
--- a/WindowsAgent/WindowsAgent/WindowsAgent.csproj
+++ b/WindowsAgent/WindowsAgent/WindowsAgent.csproj
@@ -30,6 +30,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Newtonsoft.Json">
diff --git a/dashboard/api/windc.py b/dashboard/api/windc.py
index f67713e..3d412e8 100644
--- a/dashboard/api/windc.py
+++ b/dashboard/api/windc.py
@@ -49,7 +49,7 @@ def datacenters_list(request):
     return windcclient(request).datacenters.list()
 
 def services_create(request, datacenter, parameters):
-    name = parameters.get('name', '')
+    name = parameters.get('dc_name', '')
     return windcclient(request).services.create(datacenter, name)
 
 def services_list(request, datacenter):
diff --git a/dashboard/windc/tables.py b/dashboard/windc/tables.py
index 8b24622..0998797 100644
--- a/dashboard/windc/tables.py
+++ b/dashboard/windc/tables.py
@@ -87,7 +87,7 @@ class DeleteDataCenter(tables.BatchAction):
 
 class EditService(tables.LinkAction):
     name = "edit"
-    verbose_name = _("Edit Service")
+    verbose_name = _("Edit")
     url = "horizon:project:windc:update"
     classes = ("ajax-modal", "btn-edit")
 
@@ -95,6 +95,16 @@ class EditService(tables.LinkAction):
         return True
 
 
+class DeleteService(tables.LinkAction):
+    name = "delete"
+    verbose_name = _("Delete")
+    url = "horizon:project:windc:delete"
+    classes = ("ajax-modal", "btn-edit")
+
+    def allowed(self, request, instance):
+        return True
+
+
 class ShowDataCenterServices(tables.LinkAction):
     name = "edit"
     verbose_name = _("Services")
@@ -128,13 +138,17 @@ class WinDCTable(tables.DataTable):
 
 
 class WinServicesTable(tables.DataTable):
-    name = tables.Column("name",
-                         link=("horizon:project:windc"),
-                         verbose_name=_("Name"))
+    name = tables.Column('name',
+                         link=('horizon:project:windc'),
+                         verbose_name=_('Name'))
+    _type = tables.Column('type',
+                          verbose_name=_('Type'))
+    status = tables.Column('status',
+                           verbose_name=_('Status'))
 
     class Meta:
         name = "services"
         verbose_name = _("Services")
         row_class = UpdateRow
         table_actions = (CreateService,)
-        row_actions = (EditService,)
+        row_actions = (EditService, DeleteService)
diff --git a/dashboard/windc/workflows.py b/dashboard/windc/workflows.py
index 9724aa8..e61e81a 100644
--- a/dashboard/windc/workflows.py
+++ b/dashboard/windc/workflows.py
@@ -20,6 +20,7 @@
 
 import json
 import logging
+import re
 
 from django.utils.text import normalize_newlines
 from django.utils.translation import ugettext as _
@@ -71,11 +72,11 @@ class ConfigureDCAction(workflows.Action):
 
 class ConfigureDC(workflows.Step):
     action_class = ConfigureDCAction
-    contibutes = ("name",)
+    contibutes = ('name',)
 
     def contribute(self, data, context):
         if data:
-            context['name'] = data.get("name", "")
+            context['name'] = data.get('name', '')
         return context
 
 
@@ -83,9 +84,9 @@ class ConfigureWinDCAction(workflows.Action):
     dc_name = forms.CharField(label=_("Domain Name"),
                               required=False)
 
-    dc_net_name = forms.CharField(label=_("Domain NetBIOS Name"),
-                                  required=False,
-                                  help_text=_("A NetBIOS name of new domain."))
+    #dc_net_name = forms.CharField(label=_("Domain NetBIOS Name"),
+    #                              required=False,
+    #                              help_text=_("A NetBIOS name of new domain."))
 
     dc_count = forms.IntegerField(label=_("Domain Controllers Count"),
                                   required=True,
@@ -113,6 +114,16 @@ class ConfigureWinDCAction(workflows.Action):
 
 class ConfigureWinDC(workflows.Step):
     action_class = ConfigureWinDCAction
+    contibutes = ('dc_name', 'dc_count', 'adm_password', 'recovery_password')
+
+    def contribute(self, data, context):
+        if data:
+            context['dc_name'] = data.get('dc_name', '')
+            context['dc_count'] = data.get('dc_count', 1)
+            context['adm_password'] = data.get('adm_password', '')
+            context['recovery_password'] = data.get('recovery_password', '')
+            context['type'] = 'active_directory_service'
+        return context
 
 
 class ConfigureWinIISAction(workflows.Action):
@@ -138,6 +149,15 @@ class ConfigureWinIISAction(workflows.Action):
 class ConfigureWinIIS(workflows.Step):
     action_class = ConfigureWinIISAction
 
+    contibutes = ('iis_name', 'iis_count', 'iis_domain')
+
+    def contribute(self, data, context):
+        if data:
+            context['iis_name'] = data.get('iis_name', '')
+            context['iis_count'] = data.get('iis_count', 1)
+            context['iis_domain'] = data.get('iis_domain', '')
+        return context
+
 
 class CreateWinService(workflows.Workflow):
     slug = "create"
@@ -149,15 +169,21 @@ class CreateWinService(workflows.Workflow):
     default_steps = (SelectProjectUser,
                      ConfigureWinDC,
                      ConfigureWinIIS)
-
+    
     def format_status_message(self, message):
-        name = self.context.get('name', 'noname')
+        name = self.context.get('dc_name', 'noname')
         return message % name
 
     def handle(self, request, context):
         try:
-            datacenter = context.get('domain_controller_name', '')
-            service = api.windc.services_create(request, context)
+            ############## FIX ME:
+            link = request.__dict__['META']['HTTP_REFERER']
+            datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]
+            ##############
+
+            service = api.windc.services_create(request,
+                                                datacenter_id,
+                                                context)
             return True
         except:
             exceptions.handle(request)
diff --git a/windc/bin/windc-api b/windc/bin/windc-api
index d3c15ff..6c8adc0 100755
--- a/windc/bin/windc-api
+++ b/windc/bin/windc-api
@@ -38,6 +38,7 @@ from windc.common import cfg
 from windc.common import config
 from windc.common import wsgi
 from windc.db import session
+from windc.core import builder_set
 
 gettext.install('balancer', unicode=1)
 
@@ -50,10 +51,11 @@ if __name__ == '__main__':
         conf.register_cli_opt(dbsync_opt)
         conf()
 
+        config.setup_logging(conf)
         if conf.dbsync:
-            config.setup_logging(conf)
             session.sync(conf)
         else:
+            builder_set.builders.load(conf)
             app = config.load_paste_app(conf)
             server = wsgi.Server()
             server.start(app, conf, default_port=8181)
diff --git a/windc/data/CreatePrimaryDC.json b/windc/data/CreatePrimaryDC.json
new file mode 100644
index 0000000..fb74fbb
--- /dev/null
+++ b/windc/data/CreatePrimaryDC.json
@@ -0,0 +1,29 @@
+{
+  "Scripts": [
+    "RnVuY3Rpb24gU2V0LUxvY2FsVXNlclBhc3N3b3JkIHsNCiAgICBwYXJhbSAoDQogICAgICAgIFtTdHJpbmddICRVc2VyTmFtZSwNCiAgICAgICAgW1N0cmluZ10gJFBhc3N3b3JkLA0KICAgICAgICBbU3dpdGNoXSAkRm9yY2UNCiAgICApDQogICAgDQogICAgdHJhcCB7IFN0b3AtRXhlY3V0aW9uICRfIH0NC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nJvckFjdGlvbiBTdG9wIHwgT3V0LU51bGwNCg0KCVdyaXRlLUhvc3QgIldhaXRpbmcgZm9yIHJlYm9vdCAuLi4iCQkNCiMJU3RvcC1FeGVjdXRpb24gLUV4aXRDb2RlIDMwMTAgLUV4aXRTdHJpbmcgIkNvbXB1dGVyIG11c3QgYmUgcmVzdGFydGVkIHRvIGZpbmlzaCBkb21haW4gY29udHJvbGxlciBwcm9tb3Rpb24uIg0KIwlXcml0ZS1Mb2cgIlJlc3RhcmluZyBjb21wdXRlciAuLi4iDQojCVJlc3RhcnQtQ29tcHV0ZXIgLUZvcmNlDQp9DQo="
+  ],
+  "Commands": [
+    {
+      "Name": "Import-Module",
+      "Arguments": {
+        "Name": "CoreFunctions"
+      }
+    },
+    {
+      "Name": "Set-LocalUserPassword",
+      "Arguments": {
+        "UserName": "Administrator",
+        "Password": "@adm_password",
+        "Force": true
+      }
+    },
+    {
+      "Name": "Install-RolePrimaryDomainController",
+      "Arguments": {
+        "DomainName": "@dc_name",
+        "SafeModePassword": "@recovery_password"
+      }
+    }
+  ],
+  "RebootOnCompletion": 1
+}
\ No newline at end of file
diff --git a/windc/data/Windows.template b/windc/data/Windows.template
new file mode 100644
index 0000000..66d650d
--- /dev/null
+++ b/windc/data/Windows.template
@@ -0,0 +1,61 @@
+{
+  "AWSTemplateFormatVersion" : "2010-09-09",
+ 
+  "Description" : "",
+ 
+  "Parameters" : {
+    "KeyName" : {
+      "Description" : "Name of an existing Amazon EC2 key pair for RDP access",
+      "Type" : "String",
+      "Default" : "keero_key"
+    },
+    "InstanceType" : {
+      "Description" : "Amazon EC2 instance type",
+      "Type" : "String",
+      "Default" : "m1.medium",
+      "AllowedValues" : [ "m1.small", "m1.medium", "m1.large" ]
+    },
+    "ImageName" : {
+      "Description" : "Image name",
+      "Type" : "String",
+      "Default" : "ws-2012-full-agent",
+      "AllowedValues" : [ "ws-2012-full", "ws-2012-core", "ws-2012-full-agent" ]
+    }   
+  },
+ 
+  "Resources" : {
+    "IAMUser" : {
+      "Type" : "AWS::IAM::User",
+      "Properties" : {
+        "Path": "/",
+        "Policies": [{
+          "PolicyName": "root",
+          "PolicyDocument": { "Statement":[{
+            "Effect": "Allow",
+            "Action": "CloudFormation:DescribeStackResource",
+            "Resource": "*"
+          }]}
+        }]
+      }
+    },
+ 
+    "IAMUserAccessKey" : {
+      "Type" : "AWS::IAM::AccessKey",
+      "Properties" : {
+        "UserName" : {"Ref": "IAMUser"}
+      }
+    },
+ 
+    "InstanceTemplate": {
+      "Type" : "AWS::EC2::Instance",
+      "Properties": {
+        "InstanceType" : { "Ref" : "InstanceType" },
+        "ImageId" : { "Ref" : "ImageName" },
+        "KeyName" : { "Ref" : "KeyName" }
+      }
+    }
+   },
+   
+  "Outputs" : {
+  } 
+}
\ No newline at end of file
diff --git a/windc/etc/windc-api-paste.ini b/windc/etc/windc-api-paste.ini
index 7c0deee..8dbdc8c 100644
--- a/windc/etc/windc-api-paste.ini
+++ b/windc/etc/windc-api-paste.ini
@@ -51,3 +51,7 @@ admin_password = 000
 [filter:auth-context]
 paste.filter_factory = windc.common.wsgi:filter_factory
 windc.filter_factory = keystone.middleware.balancer_auth_token:KeystoneContextMiddleware
+
+[rabbitmq]
+host = 10.0.0.1
+vhost = keero
\ No newline at end of file
diff --git a/windc/heat_run b/windc/heat_run
index 69e4182..e2498a8 100755
--- a/windc/heat_run
+++ b/windc/heat_run
@@ -1,5 +1,8 @@
 #!/bin/bash
 
-source openrc.sh
+
+#export OS_USERNAME=admin
+#source ../../devstack/openrc
+#nova keypair-add keero-linux-keys > heat_key.priv
 heat "$@"
 
diff --git a/windc/tools/pip-requires b/windc/tools/pip-requires
index d860a56..20109d9 100644
--- a/windc/tools/pip-requires
+++ b/windc/tools/pip-requires
@@ -20,3 +20,4 @@ PyChef
 Paste
 
 passlib
+puka
diff --git a/windc/windc/api/v1/services.py b/windc/windc/api/v1/services.py
index 6040926..0a05593 100644
--- a/windc/windc/api/v1/services.py
+++ b/windc/windc/api/v1/services.py
@@ -49,6 +49,7 @@ class Services_Controller(object):
         # We need to create Service object and return its id
         params['tenant_id'] = tenant_id
         params['datacenter_id'] = datacenter_id
+        params['type'] = 'active_directory_service'
         service_id = core_api.create_service(self.conf, params)
         return {'service': {'id': service_id}}
 
diff --git a/windc/windc/core/__init__.py b/windc/windc/core/__init__.py
index 1e6d1b8..1d3eb57 100644
--- a/windc/windc/core/__init__.py
+++ b/windc/windc/core/__init__.py
@@ -18,4 +18,4 @@
 import builder_set
 
 builder_set.builders = builder_set.BuilderSet()
-builder_set.builders.load()
\ No newline at end of file
+#builder_set.builders.load()
\ No newline at end of file
diff --git a/windc/windc/core/builder.py b/windc/windc/core/builder.py
index 15a14e6..7708848 100644
--- a/windc/windc/core/builder.py
+++ b/windc/windc/core/builder.py
@@ -20,7 +20,7 @@ class Builder:
 	type = "abstract"
 	version = 0
 
-	def __init__(self):
+	def __init__(self, conf):
 		pass
 
 	def __str__(self):
diff --git a/windc/windc/core/builder_set.py b/windc/windc/core/builder_set.py
index 99d481c..0f36601 100644
--- a/windc/windc/core/builder_set.py
+++ b/windc/windc/core/builder_set.py
@@ -26,7 +26,7 @@ import traceback
 LOG = logging.getLogger(__name__)
 global builders
 
-def load_from_file(filepath):
+def load_from_file(filepath, conf):
     class_inst = None
 
     mod_name,file_ext = os.path.splitext(os.path.split(filepath)[-1])
@@ -39,7 +39,7 @@ def load_from_file(filepath):
 
     if hasattr(py_mod, mod_name):
     	callable = getattr(__import__(mod_name),mod_name)
-        class_inst = callable()
+        class_inst = callable(conf)
 
     return class_inst
 
@@ -50,14 +50,14 @@ class BuilderSet:
 		sys.path.append(self.path)
 		self.set = {}
 
-	def load(self):
+	def load(self, conf):
 
 		files = glob.glob(self.path+'/*.py')
 
 		for file in files:
 			LOG.debug("Trying to load builder from file: %s", file)
 			try:
-				builder = load_from_file(file)
+				builder = load_from_file(file, conf)
 				LOG.info("Buider '%s' loaded.", builder.name)
 				self.set[builder.type] = builder
 			except:
diff --git a/windc/windc/core/builders/ActiveDirectory.py b/windc/windc/core/builders/ActiveDirectory.py
index 703703b..2bae2a0 100644
--- a/windc/windc/core/builders/ActiveDirectory.py
+++ b/windc/windc/core/builders/ActiveDirectory.py
@@ -18,6 +18,9 @@
 
 import logging
 import uuid
+import os
+from sphinx.ext.autosummary import generate
+
 LOG = logging.getLogger(__name__)
 
 from windc.core.builder import Builder
@@ -25,90 +28,183 @@ from windc.core import change_events as events
 from windc.db import api as db_api
 from windc.core.templates import Template
 from windc.core import commands as command_api
+import json
+from windc.common import cfg
+from random import choice
+
+chars = 'abcdefghklmnopqrstvwxyz2345689'
+
 
 class ActiveDirectory(Builder):
-	def __init__(self):
-		self.name = "Active Directory Builder"
-		self.type = "active_directory_service"
-		self.version = 1
+    def __init__(self, conf):
+        self.name = "Active Directory Builder"
+        self.type = "active_directory_service"
+        self.version = 1
+        self.conf = conf
 
-	def build(self, context, event, data):
-		dc = db_api.unpack_extra(data)
-		if event.scope == events.SCOPE_SERVICE_CHANGE:
-			LOG.info ("Got service change event. Analysing..")
-			if self.do_analysis(context, event, dc):
-				self.plan_changes(context, event, dc)
+        conf.register_group(cfg.OptGroup(name="rabbitmq"))
+        conf.register_opts([
+            cfg.StrOpt('host', default='10.0.0.1'),
+            cfg.StrOpt('vhost', default='keero'),
+        ], group="rabbitmq")
 
-				self.submit_commands(context, event, dc)
-		else:
-			LOG.debug("Not in my scope. Skip event.")
-		pass
 
-	def do_analysis(self, context, event, data):
-		LOG.debug("Doing analysis for data: %s", data)
-		zones = data['zones']
-		if data['type'] == self.type and len(zones) == 1:
-			LOG.debug("It is a service which I should build.")
-			datacenter_id = data['datacenter_id']
-			dc = db_api.datacenter_get(context['conf'],data['tenant_id'],
-					data['datacenter_id'])
-			datacenter = db_api.unpack_extra(dc)
-			context['stack_name']=datacenter['name']
-			return True
-		else:
-			return False
+    def build(self, context, event, data, executor):
+        dc = db_api.unpack_extra(data)
+        if event.scope == events.SCOPE_SERVICE_CHANGE:
+            LOG.info ("Got service change event. Analysing..")
+            if self.do_analysis(context, event, dc):
+                self.plan_changes(context, event, dc)
 
-	def plan_changes(self, context, event, data):
-		# Here we can plan multiple command execution.
-		# It might be Heat call command, then chef call command and other
-		#
-		LOG.debug("Plan changes...")
-		self.prepare_template(context, event, data)
-		self.chef_configuration(context, event, data)
-		context['commands'].append(self.deploy_template_command(context, event, data))
-		context['commands'].append(self.chef_configuration_command(context, event, data))
-		pass
+                self.submit_commands(context, event, dc, executor)
+        else:
+            LOG.debug("Not in my scope. Skip event.")
+        pass
 
-	def prepare_template(self, context, event, data):
-		LOG.debug("Prepare CloudFormation Template...")
-		template = Template()
-		template.add_description('Base template for Active Directory deployment')
-		sec_grp = template.create_security_group('Security group for AD')
-		rule = template.create_securitygroup_rule('tcp','3389','3389','0.0.0.0/0')
-		template.add_rule_to_securitygroup(sec_grp, rule)
-		template.add_resource('ADSecurityGroup', sec_grp)
+    def generate(self, length):
+        return ''.join(choice(chars) for _ in range(length))
 
-		instance = template.create_instance()
-		instance_name= 'AD-DC001'
-		template.add_security_group(instance, 'ADSecurityGroup')
-		template.add_resource(instance_name, instance)
+    def do_analysis(self, context, event, data):
+        LOG.debug("Doing analysis for data: %s", data)
+        print data
 
-		template.add_output_value(instance_name+'-IP',{"Fn::GetAtt" : [instance_name,'PublicIp']},
-			'Public IP for the domain controller.')
-		context['template']=template
-		pass
+        context['zones'] = ['a1']
+        if data['type'] == self.type:
+            LOG.debug("It is a service which I should build.")
+            datacenter_id = data['datacenter_id']
+            dc = db_api.datacenter_get(context['conf'],data['tenant_id'],
+                    data['datacenter_id'])
+            datacenter = db_api.unpack_extra(dc)
+            context['stack_name']=datacenter['name']
+            return True
+        else:
+            return False
 
-	def deploy_template_command(self, context, event, data):
-		LOG.debug("Creating CloudFormation Template deployment command...")
-		fname = "templates/"+str(uuid.uuid4())
-		f=open(fname, "w")
-		f.write(context['template'].to_json())
-		f.close()
-		context['template_name']=fname
-		command = command_api.Command(command_api.TEMPLATE_DEPLOYMENT_COMMAND, context)
-		return command
-		pass
+    def plan_changes(self, context, event, data):
+        # Here we can plan multiple command execution.
+        # It might be Heat call command, then chef call command and other
+        #
+        LOG.debug("Plan changes...")
+        self.prepare_template(context, event, data)
+        # self.chef_configuration(context, event, data)
+        # context['commands'].append(self.deploy_template_command(context, event, data))
+        # context['commands'].append(self.chef_configuration_command(context, event, data))
+        pass
 
-	def chef_configuration(self, context, event, data):
-		LOG.debug("Creating Chef configuration...")
-		context['Role'] = 'pdc'
-		pass
+    def prepare_template(self, context, event, data):
+        LOG.debug("Prepare CloudFormation Template...")
+        # template = Template()
+        # template.add_description('Base template for Active Directory deployment')
+        # sec_grp = template.create_security_group('Security group for AD')
+        # rule = template.create_securitygroup_rule('tcp','3389','3389','0.0.0.0/0')
+        # template.add_rule_to_securitygroup(sec_grp, rule)
+        # template.add_resource('ADSecurityGroup', sec_grp)
+        #
+        # instance = template.create_instance()
+        # instance_name= 'AD-DC001'
+        # template.add_security_group(instance, 'ADSecurityGroup')
+        # template.add_resource(instance_name, instance)
+        #
+        # template.add_output_value(instance_name+'-IP',{"Fn::GetAtt" : [instance_name,'PublicIp']},
+        # 	'Public IP for the domain controller.')
 
-	def chef_configuration_command(self, context, event, data):
-		LOG.debug("Creating Chef configuration command...")
-		command = command_api.Command(command_api.CHEF_COMMAND, context)
-		return command
+        print "-------------------"
+        print data
+        print "-------------------"
+        print context
+        print "********"
+        try:
+            print self.conf.rabbitmq.vhost
+        except Exception, ex:
+            print ex
+        print "********"
 
-	def submit_commands(self, context, event, data):
-		LOG.debug("Submit commands for execution...")
-		pass
\ No newline at end of file
+        with open('data/Windows.template', 'r') as f:
+            read_data = f.read()
+
+        template = json.loads(read_data)
+
+        instance_template = template['Resources']['InstanceTemplate']
+
+        del template['Resources']['InstanceTemplate']
+        context['instances'] = []
+        context['template_arguments'] = {
+            "KeyName": "keero-linux-keys",
+            "InstanceType": "m1.medium",
+            "ImageName": "ws-2012-full-agent"
+        }
+
+        for i in range(data['dc_count']):
+            instance_name = 'dc' + str(i) + "x" + self.generate(9)
+            context['instances'].append(instance_name)
+            template['Resources'][instance_name] = instance_template
+
+        context['template']=template
+        pass
+
+    def deploy_template_command(self, context, event, data, executor):
+        LOG.debug("Creating CloudFormation Template deployment command...")
+        #print context['template'].to_json()
+        LOG.debug(context['template'])
+        if not os.path.exists("templates"):
+            os.mkdir("templates")
+        fname = "templates/"+str(uuid.uuid4())
+        print "Saving template to", fname
+        f=open(fname, "w")
+        f.write(json.dumps(context['template']))
+        f.close()
+        context['template_name']=fname
+        command = command_api.Command(command_api.TEMPLATE_DEPLOYMENT_COMMAND, context)
+        executor.execute(command)
+
+    def chef_configuration(self, context, event, data):
+        LOG.debug("Creating Chef configuration...")
+        context['Role'] = 'pdc'
+        pass
+
+    def transform(self, path, map):
+        with open(path, 'r') as f:
+            read_data = f.read()
+
+        template = json.loads(read_data)
+        if 'Commands' in template:
+            for command in template['Commands']:
+                if 'Arguments' in command:
+                    for argument, argument_value in command['Arguments'].items():
+                        if isinstance(argument_value, (str, unicode)) and argument_value.startswith("@"):
+                            command['Arguments'][argument] = map[argument_value[1:]]
+
+        return json.dumps(template)
+
+    def deploy_execution_plan(self, context, event, data, executor):
+        i = 0
+        for instance in context['instances']:
+            i += 1
+            if i == 1:
+                files = ["data/CreatePrimaryDC.json"]
+            else:
+                files = []
+
+            for file in files:
+                queueData = {
+                    "queueName" : str("%s-%s" % (context['stack_name'], instance)),
+                    "resultQueueName": "-execution-results",
+                    "body": self.transform(file, data)
+                }
+                command = command_api.Command(command_api.EXECUTION_PLAN_DEPLOYMENT_COMMAND, context, queueData)
+                executor.execute(command)
+
+
+
+
+    def chef_configuration_command(self, context, event, data):
+        LOG.debug("Creating Chef configuration command...")
+        command = command_api.Command(command_api.CHEF_COMMAND, context)
+        return command
+
+    def submit_commands(self, context, event, data, executor):
+        LOG.debug("Submit commands for execution...")
+        self.deploy_template_command(context, event, data, executor)
+        self.deploy_execution_plan(context, event, data, executor)
+        print "Commands submitted"
+        pass
diff --git a/windc/windc/core/builders/DataCenter.py b/windc/windc/core/builders/DataCenter.py
index 92bc1bf..d425bae 100644
--- a/windc/windc/core/builders/DataCenter.py
+++ b/windc/windc/core/builders/DataCenter.py
@@ -23,12 +23,12 @@ from windc.core.builder import Builder
 from windc.core import change_events as events
 
 class DataCenter(Builder):
-	def __init__(self):
+	def __init__(self, conf):
 		self.name = "Data Center Builder"
 		self.type = "datacenter"
 		self.version = 1
 
-	def build(self, context, event, data):
+	def build(self, context, event, data, executor):
 		if event.scope == events.SCOPE_DATACENTER_CHANGE:
 			LOG.info ("Got Data Center change event. Analysing...")
 		else:
diff --git a/windc/windc/core/change_events.py b/windc/windc/core/change_events.py
index 8955b58..c73ea29 100644
--- a/windc/windc/core/change_events.py
+++ b/windc/windc/core/change_events.py
@@ -33,24 +33,21 @@ ACTION_MODIFY = "Modify"
 ACTION_DELETE = "Delete"
 
 class Event:
-	scope = None
-	action = None
-	previous_state = None
-	def __init__(self, scope, action):
-		self.scope = scope
-		self.action = action
+    scope = None
+    action = None
+    previous_state = None
+    def __init__(self, scope, action):
+        self.scope = scope
+        self.action = action
 
 def change_event(conf, event, data):
-	LOG.info("Change event of type: %s ", event)
-	context = builder.create_context()
-	context['conf'] = conf
-	for builder_type in builder_set.builders.set:
-		builder_instance = builder_set.builders.set[builder_type]
-		builder_instance.build(context, event, data)
-
-	executor = command_executor.Executor()
-	executor.execute(context['commands'])
-	pass
+    LOG.info("Change event of type: %s ", event)
+    context = builder.create_context()
+    context['conf'] = conf
+    executor = command_executor.Executor(conf)
+    for builder_type in builder_set.builders.set:
+        builder_instance = builder_set.builders.set[builder_type]
+        builder_instance.build(context, event, data, executor)
 
 
 
diff --git a/windc/windc/core/commands.py b/windc/windc/core/commands.py
index 86473c1..06af49c 100644
--- a/windc/windc/core/commands.py
+++ b/windc/windc/core/commands.py
@@ -16,26 +16,19 @@
 #    under the License.
 
 TEMPLATE_DEPLOYMENT_COMMAND = "Template"
+EXECUTION_PLAN_DEPLOYMENT_COMMAND = "EPlan"
 CHEF_COMMAND = "Chef"
 CHEF_OP_CREATE_ENV = "Env"
 CHEF_OP_CREATE_ROLE = "Role"
 CHEF_OP_ASSIGN_ROLE = "AssignRole"
 CHEF_OP_CREATE_NODE = "CRNode"
 
-class Command:
+class Command(object):
 	type = "Empty"
 	context = None
 
-	def __init__(self):
-		self.type = "Empty"
-		self.context = None
-		self.data = None
 
-	def __init__(self, type, context):
-		self.type = type
-		self.context = context
-
-	def __init__(self, type, context, data):
+	def __init__(self, type="Empty", context=None, data=None):
 		self.type = type
 		self.context = context
 		self.data = data
diff --git a/windc/windc/drivers/command_executor.py b/windc/windc/drivers/command_executor.py
index c7c0d2f..f675a0a 100644
--- a/windc/windc/drivers/command_executor.py
+++ b/windc/windc/drivers/command_executor.py
@@ -20,18 +20,21 @@
 
 from windc.core import commands as commands_api
 from windc.drivers import openstack_heat
+from windc.drivers import windows_agent
 
 class Executor:
 
-	map = {commands_api.TEMPLATE_DEPLOYMENT_COMMAND : openstack_heat.Heat}
+    map = {commands_api.TEMPLATE_DEPLOYMENT_COMMAND : openstack_heat.Heat}
 
-	def __init__(self):
-		pass
+    def __init__(self, conf):
+        self._conf = conf
 
-	def execute(self, commands):
-		for command in commands:
-			if command.type == commands_api.TEMPLATE_DEPLOYMENT_COMMAND:
-				executor = openstack_heat.Heat()
-				executor.execute(command)
+    def execute(self, command):
+        if command.type == commands_api.TEMPLATE_DEPLOYMENT_COMMAND:
+            executor = openstack_heat.Heat()
+            return executor.execute(command)
+        elif command.type == commands_api.EXECUTION_PLAN_DEPLOYMENT_COMMAND:
+            executor = windows_agent.Agent(self._conf)
+            return executor.execute(command)
 
 
diff --git a/windc/windc/drivers/openstack_heat.py b/windc/windc/drivers/openstack_heat.py
index 7661bb6..dd50fda 100644
--- a/windc/windc/drivers/openstack_heat.py
+++ b/windc/windc/drivers/openstack_heat.py
@@ -32,7 +32,12 @@ class Heat:
 	def execute(self, command):
 #		client = Client('1',OS_IMAGE_ENDPOINT, OS_TENANT_ID)
  		LOG.debug('Calling heat script to execute template')
-		call(["./heat_run","stack-create","-f "+command.context['template_name'],
-			command.context['stack_name']])
+		arguments = ";".join(['%s=%s' % (key, value) for (key, value) in command.context['template_arguments'].items()])
+		call([
+            "./heat_run","stack-create",
+            "-f" + command.context['template_name'],
+            "-P" + arguments,
+			command.context['stack_name']
+        ])
 		pass
 
diff --git a/windc/windc/drivers/windows_agent.py b/windc/windc/drivers/windows_agent.py
new file mode 100644
index 0000000..e446b05
--- /dev/null
+++ b/windc/windc/drivers/windows_agent.py
@@ -0,0 +1,66 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# Copyright 2011 Piston Cloud Computing, Inc.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+import traceback
+
+import puka
+
+import logging
+import sys
+
+LOG = logging.getLogger(__name__)
+
+class Agent(object):
+
+    def __init__(self, conf):
+        self._conf = conf
+
+    def execute(self, command):
+        try:
+            client = puka.Client("amqp://keero:keero@%s/%s" % (
+                self._conf.rabbitmq.host, self._conf.rabbitmq.vhost))
+            promise = client.connect()
+            client.wait(promise)
+
+
+            promise = client.queue_declare(queue=command.data['queueName'], durable=True)
+            client.wait(promise)
+
+            promise = client.queue_declare(queue=command.data['resultQueueName'], durable=True)
+            client.wait(promise)
+
+            promise = client.basic_publish(exchange='', routing_key=command.data['queueName'],
+                                           body=command.data['body'])
+            client.wait(promise)
+
+            consume_promise = client.basic_consume(queue=command.data['resultQueueName'])
+            result = client.wait(consume_promise)
+
+            result_msg = result['body']
+            client.basic_ack(result)
+            client.basic_cancel(consume_promise)
+
+            promise = client.close()
+            client.wait(promise)
+
+            return result_msg
+        except Exception:
+            exc_type, exc_value, exc_traceback = sys.exc_info()
+            print exc_type, exc_value, exc_traceback
+            print traceback.format_exc()