Add new files
This commit is contained in:
		
							
								
								
									
										38
									
								
								Services/ad-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								Services/ad-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: Active Directory
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
  <strong> The Active Directory Service </strong> 
 | 
			
		||||
  includes one primary and optionally a few secondary 
 | 
			
		||||
  Domain Controllers, with DNS
 | 
			
		||||
 | 
			
		||||
full_service_name: activeDirectory
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - ActiveDirectory.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - AD.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
    Windows.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - CreatePrimaryDC.template
 | 
			
		||||
  - AskDnsIp.template
 | 
			
		||||
  - LeaveDomain.template
 | 
			
		||||
  - JoinDomain.template
 | 
			
		||||
  - CreateSecondaryDC.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
  - ImportCoreFunctions.ps1
 | 
			
		||||
  - Set-LocalUserPassword.ps1
 | 
			
		||||
  - Get-DnsListeningIpAddress.ps1
 | 
			
		||||
  - Get-DnsListeningIpAddress.ps1
 | 
			
		||||
  - Join-Domain.ps1
 | 
			
		||||
  - Install-RoleSecondaryDomainController.ps1
 | 
			
		||||
							
								
								
									
										34
									
								
								Services/asp-net-farm-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Services/asp-net-farm-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: ASP.NET Application Web Farm
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The ASP.NET Farm Service </strong> installs a custom application
 | 
			
		||||
     on a load-balanced array of IIS servers
 | 
			
		||||
 | 
			
		||||
full_service_name: aspNetAppFarm
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - AspNetAppFarm.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - WebApps.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
  - LoadBalancer.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
 - SetPassword.template
 | 
			
		||||
 - InstallIIS.template
 | 
			
		||||
 - DeployWebApp.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - CopyPrerequisites.ps1
 | 
			
		||||
 - InstallIIS.ps1
 | 
			
		||||
 - DeployWebApp.ps1
 | 
			
		||||
							
								
								
									
										34
									
								
								Services/asp-net-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Services/asp-net-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: ASP.NET Application
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The ASP.NET Application Service </strong> installs
 | 
			
		||||
     custom application onto one IIS Web Server
 | 
			
		||||
 | 
			
		||||
full_service_name: aspNetApp
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - AspNetApp.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - WebApps.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - InstallIIS.template
 | 
			
		||||
  - DeployWebApp.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - CopyPrerequisites.ps1
 | 
			
		||||
 - InstallIIS.ps1
 | 
			
		||||
 - DeployWebApp.ps1
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										34
									
								
								Services/iis-farm-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Services/iis-farm-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: Internet Information Services Web Farm
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The IIS Farm Service </strong> sets up a load-balanced set of IIS servers
 | 
			
		||||
 | 
			
		||||
full_service_name: webServer
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - WebServerFarm.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - WebApps.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
  - LoadBalancer.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - InstallIIS.template
 | 
			
		||||
  - DeployWebApp.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - CopyPrerequisites.ps1
 | 
			
		||||
 - InstallIIS.ps1
 | 
			
		||||
 - DeployWebApp.ps1
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										35
									
								
								Services/iis-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Services/iis-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: Internet Information Services
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The  Internet Information Service </strong>
 | 
			
		||||
     sets up an IIS server and joins it into an existing domain
 | 
			
		||||
 | 
			
		||||
full_service_name: webServerFarm
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - WebServer.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - WebApps.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - InstallIIS.template
 | 
			
		||||
  - DeployWebApp.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - CopyPrerequisites.ps1
 | 
			
		||||
 - InstallIIS.ps1
 | 
			
		||||
 - DeployWebApp.ps1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										46
									
								
								Services/mssql-cluster-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								Services/mssql-cluster-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: MS SQL Server Cluster
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The MS SQL Failover Cluster </strong> installs
 | 
			
		||||
     Microsoft SQL Failover Cluster Server
 | 
			
		||||
 | 
			
		||||
full_service_name: msSqlClusterServer
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - MsSqlClusterServer.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - MsSqlCluster.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
  - SQLCluster.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - SqlServerCluster/FailoverClusterPrerequisites.template
 | 
			
		||||
  - SqlServerCluster/FailoverCluster.template
 | 
			
		||||
  - SqlServerCluster/ConfigureEnvironmentForAOAG.template
 | 
			
		||||
  - SqlServerCluster/InstallSqlServerForAOAG.template
 | 
			
		||||
  - SqlServerCluster/InitializeAlwaysOn.template
 | 
			
		||||
  - SqlServerCluster/InitializeAOAGPrimaryReplica.template
 | 
			
		||||
  - SqlServerCluster/InitializeAOAGSecondaryReplica.template
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - Update-ServiceConfig.ps1
 | 
			
		||||
 - SQLServerForAOAG.ps1
 | 
			
		||||
 - Failover-Cluster.ps1
 | 
			
		||||
 - Start-PowerShellProcess.ps1
 | 
			
		||||
 - Failover-Cluster.ps1
 | 
			
		||||
 - OptionParser.ps1
 | 
			
		||||
 - SQLServerOptionParsers.ps1
 | 
			
		||||
 - SQLServerInstaller.ps1
 | 
			
		||||
 - Export-Function.ps1
 | 
			
		||||
							
								
								
									
										35
									
								
								Services/mssql-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Services/mssql-manifest.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
version: 0.1
 | 
			
		||||
service_display_name: MS SQL Server
 | 
			
		||||
 | 
			
		||||
description: >-
 | 
			
		||||
   <strong> The MS SQL Service </strong> installs an instance of
 | 
			
		||||
     Microsoft SQL Server
 | 
			
		||||
 | 
			
		||||
full_service_name: msSqlServer
 | 
			
		||||
author: Mirantis Inc.
 | 
			
		||||
service_version: 1.0
 | 
			
		||||
enabled: True
 | 
			
		||||
 | 
			
		||||
ui_forms:
 | 
			
		||||
  - MsSqlServer.yaml
 | 
			
		||||
 | 
			
		||||
workflows:
 | 
			
		||||
  - MsSqlServer.xml
 | 
			
		||||
  - Common.xml
 | 
			
		||||
 | 
			
		||||
heat_templates:
 | 
			
		||||
  - Windows.template
 | 
			
		||||
  - SQL-security.template
 | 
			
		||||
 | 
			
		||||
agent_templates:
 | 
			
		||||
  - SetPassword.template
 | 
			
		||||
  - InstallMsSqlServer.template
 | 
			
		||||
 | 
			
		||||
scripts:
 | 
			
		||||
 - ImportCoreFunctions.ps1
 | 
			
		||||
 - Set-LocalUserPassword.ps1
 | 
			
		||||
 - OptionParser.ps1
 | 
			
		||||
 - SQLServerOptionParsers.ps1
 | 
			
		||||
 - SQLServerInstaller.ps1
 | 
			
		||||
 - Install-SQLServer.ps1
 | 
			
		||||
 - Alter-FirewallRulesForSQL.ps1
 | 
			
		||||
							
								
								
									
										174
									
								
								Services/workflows/WebApps.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								Services/workflows/WebApps.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,174 @@
 | 
			
		||||
<workflow>
 | 
			
		||||
	<rule match="$.services[?(@.type in ('webServer', 'aspNetApp', 'webServerFarm', 'aspNetAppFarm') and @.domain)].units[*]"
 | 
			
		||||
          desc='Units of web services with domain'>
 | 
			
		||||
		<set path="domain">
 | 
			
		||||
			<select path="::domain"/>
 | 
			
		||||
		</set>
 | 
			
		||||
        <mute/>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
	<rule match="$.services[?(@.type in ('webServer', 'aspNetApp', 'webServerFarm', 'aspNetAppFarm') and @.osImage.name)].units[?(@.state.hostname and not @.temp.instanceName)]"
 | 
			
		||||
          desc="Units of web services having hostname and image names assigned but without instances">
 | 
			
		||||
		<report entity="unit">
 | 
			
		||||
			<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
			<parameter name="text">Creating instance <select path="state.hostname"/> (<select path="name"/>)</parameter>
 | 
			
		||||
		</report>
 | 
			
		||||
		<update-cf-stack template="Windows" error="exception">
 | 
			
		||||
			<parameter name="mappings">
 | 
			
		||||
				<map>
 | 
			
		||||
					<mapping name="instanceName"><select path="state.hostname"/></mapping>
 | 
			
		||||
                    <mapping name="instancePort">port-<select path="state.hostname"/></mapping>
 | 
			
		||||
					<mapping name="networkName">network-<select path="/id"/></mapping>
 | 
			
		||||
					<mapping name="userData">
 | 
			
		||||
						<prepare-user-data>
 | 
			
		||||
							<parameter name="hostname"><select path="state.hostname"/></parameter>
 | 
			
		||||
							<parameter name="unit"><select path="id"/></parameter>
 | 
			
		||||
							<parameter name="service"><select path="::id"/></parameter>
 | 
			
		||||
						</prepare-user-data>
 | 
			
		||||
					</mapping>
 | 
			
		||||
					<mapping name="instanceType"><select path="::flavor" default="m1.medium"/></mapping>
 | 
			
		||||
					<mapping name="imageName"><select path="::osImage.name"/></mapping>
 | 
			
		||||
					<mapping name="availabilityZone"><select path="::availabilityZone" default="nova"/></mapping>
 | 
			
		||||
				</map>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<success>
 | 
			
		||||
				<set path="temp.instanceName"><select path="name"/></set>
 | 
			
		||||
				<report entity="unit">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Instance <select path="state.hostname"/> (<select path="name"/>) created</parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
			</success>
 | 
			
		||||
            <failure>
 | 
			
		||||
                <report entity="unit" level="error">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Unable to deploy instance <select path="state.hostname"/> (<select path="name"/>) due to <format-error error="exception"/></parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
                <stop/>
 | 
			
		||||
            </failure>
 | 
			
		||||
		</update-cf-stack>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
	<rule match="$.services[?(@.type in ('webServerFarm', 'aspNetAppFarm'))].units[?(@.state.hostname and not @.temp.registeredWithLB)]"
 | 
			
		||||
          desc="Units of web-farms services which have a hostname assigned but are not registered with LB">
 | 
			
		||||
		<update-cf-stack template="LoadBalancer" result="outputs" error="exception">
 | 
			
		||||
			<parameter name="mappings">
 | 
			
		||||
				<map>
 | 
			
		||||
					<mapping name="instanceName"><select path="state.hostname"/></mapping>
 | 
			
		||||
					<mapping name="lbPort"><select path="::loadBalancerPort"/></mapping>
 | 
			
		||||
					<mapping name="lbName"><select path="::name"/></mapping>
 | 
			
		||||
				</map>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<success>
 | 
			
		||||
				<set path="temp.registeredWithLB"><true/></set>
 | 
			
		||||
				<set path="::uri">http://<select source="outputs" path="LoadBalancerIP"/>:<select path="::loadBalancerPort"/></set>
 | 
			
		||||
			</success>
 | 
			
		||||
            <failure>
 | 
			
		||||
               <report entity="unit" level="error">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Unable to create a Server Farm load balancer on unit <select path="state.hostname"/> (<select path="name"/>) due to <format-error error="exception"/></parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
                <stop/>
 | 
			
		||||
            </failure>
 | 
			
		||||
		</update-cf-stack>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
	<rule match="$.services[?(@.type in ('webServer', 'aspNetApp', 'webServerFarm', 'aspNetAppFarm') and @.adminPassword and @.adminPassword != @.state.adminPassword)].units[?(@.temp.instanceName)]"
 | 
			
		||||
            desc="Units of web services which have got an instance deployed but has not got a correct admin password ">
 | 
			
		||||
		<send-command template="SetPassword" error='exception'>
 | 
			
		||||
			<parameter name="unit">
 | 
			
		||||
				<select path="id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<parameter name="service">
 | 
			
		||||
				<select path="::id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<parameter name="mappings">
 | 
			
		||||
				<map>
 | 
			
		||||
					<mapping name="adminPassword">
 | 
			
		||||
						<select path="::adminPassword"/>
 | 
			
		||||
					</mapping>
 | 
			
		||||
				</map>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<success>
 | 
			
		||||
				<set path="::state.adminPassword">
 | 
			
		||||
					<select path="::adminPassword"/>
 | 
			
		||||
				</set>
 | 
			
		||||
			</success>
 | 
			
		||||
            <failure>
 | 
			
		||||
                <report entity="unit" level="warning">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Unable to set admin password on unit <select path="state.hostname"/> (<select path="name"/>) <format-error error="exception"/></parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
                <mute/>
 | 
			
		||||
            </failure>
 | 
			
		||||
		</send-command>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<rule match="$.services[?(@.type in ('webServer', 'aspNetApp', 'webServerFarm', 'aspNetAppFarm'))].units[?(@.temp.instanceName and not @.state.iisInstalled)]"
 | 
			
		||||
            desc="Units of web services which have got an instance deployed but have not got an IIS installed">
 | 
			
		||||
		<report entity="unit">
 | 
			
		||||
			<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
			<parameter name="text">Creating IIS Web Server on unit <select path="state.hostname"/> (<select path="name"/>)</parameter>
 | 
			
		||||
		</report>
 | 
			
		||||
		<send-command template="InstallIIS" error='exception'>
 | 
			
		||||
			<parameter name="unit">
 | 
			
		||||
				<select path="id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<parameter name="service">
 | 
			
		||||
				<select path="::id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<success>
 | 
			
		||||
				<set path="state.iisInstalled"><true/></set>
 | 
			
		||||
				<report entity="unit">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">IIS <select path="state.hostname"/> (<select path="name"/>) has started</parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
			</success>
 | 
			
		||||
            <failure>
 | 
			
		||||
                <report entity="unit" level="error">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Unable to install IIS on <select path="state.hostname"/> (<select path="name"/>) <format-error error="exception"/></parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
                <stop/>
 | 
			
		||||
            </failure>
 | 
			
		||||
		</send-command>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
	<rule match="$.services[?(@.type in ('aspNetApp', 'aspNetAppFarm'))].units[?(@.state.iisInstalled and not @.state.webAppDeployed)]"
 | 
			
		||||
            desc="Units of ASP.NET app services which have got IIS installed but not the WebApplication deployed">
 | 
			
		||||
		<report entity="unit">
 | 
			
		||||
			<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
			<parameter name="text">Deploying WebApp <select path="::name"/> on unit <select path="state.hostname"/> (<select path="name"/>)</parameter>
 | 
			
		||||
		</report>
 | 
			
		||||
		<send-command template="DeployWebApp" error="exception">
 | 
			
		||||
			<parameter name="unit">
 | 
			
		||||
				<select path="id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<parameter name="service">
 | 
			
		||||
				<select path="::id"/>
 | 
			
		||||
			</parameter>
 | 
			
		||||
            <parameter name="mappings">
 | 
			
		||||
				<map>
 | 
			
		||||
					<mapping name="repository">
 | 
			
		||||
						<select path="::repository"/>
 | 
			
		||||
					</mapping>
 | 
			
		||||
				</map>
 | 
			
		||||
			</parameter>
 | 
			
		||||
			<success>
 | 
			
		||||
				<set path="state.webAppDeployed"><true/></set>
 | 
			
		||||
				<report entity="unit">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">WebApp <select path="::name"/> has been deployed on unit <select path="state.hostname"/> (<select path="name"/>)</parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
			</success>
 | 
			
		||||
            <failure>
 | 
			
		||||
                <report entity="unit" level="error">
 | 
			
		||||
					<parameter name="id"><select path="id"/></parameter>
 | 
			
		||||
					<parameter name="text">Unable to deploy WebApp on <select path="state.hostname"/> (<select path="name"/>) <format-error error="exception"/></parameter>
 | 
			
		||||
				</report>
 | 
			
		||||
                <stop/>
 | 
			
		||||
            </failure>
 | 
			
		||||
		</send-command>
 | 
			
		||||
	</rule>
 | 
			
		||||
 | 
			
		||||
</workflow>
 | 
			
		||||
							
								
								
									
										81
									
								
								parser.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								parser.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
import os
 | 
			
		||||
import yaml
 | 
			
		||||
import logging as log
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManifestParser(object):
 | 
			
		||||
    def __init__(self,
 | 
			
		||||
                 manifest_directory,
 | 
			
		||||
                 ui_forms_directory=None,
 | 
			
		||||
                 workflows_directory=None,
 | 
			
		||||
                 heat_templates_directory=None,
 | 
			
		||||
                 agent_templates_directory=None,
 | 
			
		||||
                 scripts_directory=None
 | 
			
		||||
                 ):
 | 
			
		||||
 | 
			
		||||
        if ui_forms_directory is None:
 | 
			
		||||
            ui_forms_directory = os.path.join(manifest_directory, "ui_forms")
 | 
			
		||||
        if workflows_directory is None:
 | 
			
		||||
            workflows_directory = os.path.join(manifest_directory, "workflows")
 | 
			
		||||
        if heat_templates_directory is None:
 | 
			
		||||
            heat_templates_directory = os.path.join(manifest_directory,
 | 
			
		||||
                                                    "heat_templates")
 | 
			
		||||
        if agent_templates_directory is None:
 | 
			
		||||
            agent_templates_directory = os.path.join(manifest_directory,
 | 
			
		||||
                                                     "agent_templates")
 | 
			
		||||
        if scripts_directory is None:
 | 
			
		||||
            scripts_directory = os.path.join(manifest_directory, "scripts")
 | 
			
		||||
 | 
			
		||||
        self.manifest_directory = manifest_directory
 | 
			
		||||
        self.directory_mapping = {"ui_forms": ui_forms_directory,
 | 
			
		||||
                                  "workflows": workflows_directory,
 | 
			
		||||
                                  "heat_templates_directory":
 | 
			
		||||
                                  heat_templates_directory,
 | 
			
		||||
                                  "agent_templates": agent_templates_directory,
 | 
			
		||||
                                  "scripts": scripts_directory
 | 
			
		||||
                                  }
 | 
			
		||||
 | 
			
		||||
    def parse(self):
 | 
			
		||||
        manifests = []
 | 
			
		||||
        for file in os.listdir(self.manifest_directory):
 | 
			
		||||
            if os.path.isfile(file):
 | 
			
		||||
                if not file.endswith(".yaml"):
 | 
			
		||||
                    log.warning("Extention of {0} file is not yaml. "
 | 
			
		||||
                                "Only yaml file supported for "
 | 
			
		||||
                                "service manifest files.".format(file))
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
                service_file = os.path.join(self.manifest_directory, file)
 | 
			
		||||
                try:
 | 
			
		||||
                    with open(service_file) as stream:
 | 
			
		||||
                        service_manifest = yaml.load(stream)
 | 
			
		||||
                except yaml.YAMLError, exc:
 | 
			
		||||
                        log.warn("Failed to load manifest file. {0}. "
 | 
			
		||||
                                 "The reason: {1!s}".format(service_file,
 | 
			
		||||
                                                            exc))
 | 
			
		||||
                        continue
 | 
			
		||||
                for key, value in service_manifest.iteritems():
 | 
			
		||||
                    directory_location = self.directory_mapping.get(key)
 | 
			
		||||
                    if directory_location:
 | 
			
		||||
                        for i, filename in enumerate(value):
 | 
			
		||||
                            absolute_path = os.path.join(directory_location,
 | 
			
		||||
                                                         filename)
 | 
			
		||||
                            service_manifest[key][i] = absolute_path
 | 
			
		||||
                            if not os.path.exists(absolute_path):
 | 
			
		||||
                                log.warning(
 | 
			
		||||
                                    "File {0} specified in manifest {1} "
 | 
			
		||||
                                    "doesn't exist at {2}".format(filename,
 | 
			
		||||
                                                                  file,
 | 
			
		||||
                                                                  absolute_path
 | 
			
		||||
                                                                  ))
 | 
			
		||||
 | 
			
		||||
                manifests.append(service_manifest)
 | 
			
		||||
        return manifests
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    ManifestParser(os.path.join(os.path.dirname(__file__), 'Services')).parse()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
   main()
 | 
			
		||||
		Reference in New Issue
	
	Block a user