dolphindeploy 0.0.2-universal-dotnet

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. data/README.markdown +9 -0
  2. data/TODO +18 -0
  3. data/external/DolphinDeploy.IIS.IIS6.dll +0 -0
  4. data/external/Microsoft.Web.Administration.dll +0 -0
  5. data/external/TinySharpZip.dll +0 -0
  6. data/external/adsutil.vbs +2938 -0
  7. data/external/xunit/HTML.xslt +117 -0
  8. data/external/xunit/NUnitXml.xslt +121 -0
  9. data/external/xunit/xunit.console.exe +0 -0
  10. data/external/xunit/xunit.console.exe.config +21 -0
  11. data/external/xunit/xunit.console.x86.exe +0 -0
  12. data/external/xunit/xunit.console.x86.exe.config +21 -0
  13. data/external/xunit/xunit.dll +0 -0
  14. data/external/xunit/xunit.dll.tdnet +5 -0
  15. data/external/xunit/xunit.extensions.dll +0 -0
  16. data/external/xunit/xunit.extensions.xml +706 -0
  17. data/external/xunit/xunit.gui.exe +0 -0
  18. data/external/xunit/xunit.gui.x86.exe +0 -0
  19. data/external/xunit/xunit.installer.exe +0 -0
  20. data/external/xunit/xunit.runner.msbuild.dll +0 -0
  21. data/external/xunit/xunit.runner.tdnet.dll +0 -0
  22. data/external/xunit/xunit.runner.utility.dll +0 -0
  23. data/external/xunit/xunit.runner.utility.xml +1048 -0
  24. data/external/xunit/xunit.xml +2306 -0
  25. data/lib/IIS/IIS.rb +23 -0
  26. data/lib/IIS/IIS6.rb +165 -0
  27. data/lib/IIS/IIS7.rb +152 -0
  28. data/lib/IIS/IISVersion.rb +7 -0
  29. data/lib/configured_as/mvc_deployment.rb +174 -0
  30. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.5.1.ReSharper.user +45 -0
  31. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/AppPoolControllerTests.cs +39 -0
  32. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/DolphinDeploy.IIS.IIS6.Tests.csproj +69 -0
  33. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/DolphinDeploy.IIS.IIS6.Tests.csproj.user +6 -0
  34. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/Helper.cs +18 -0
  35. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/Properties/AssemblyInfo.cs +36 -0
  36. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/WebsiteControllerTests.cs +56 -0
  37. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.Tests.dll +0 -0
  38. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.Tests.pdb +0 -0
  39. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  40. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  41. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/test_site/index.htm +9 -0
  42. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/xunit.dll +0 -0
  43. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/xunit.xml +2306 -0
  44. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  45. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.csproj.FileListAbsolute.txt +12 -0
  46. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.dll +0 -0
  47. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.pdb +0 -0
  48. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/ResolveAssemblyReference.cache +0 -0
  49. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/test_site/index.htm +9 -0
  50. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.sln +26 -0
  51. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.suo +0 -0
  52. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/AppPoolController.cs +41 -0
  53. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.csproj +56 -0
  54. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/IIS6Manager.cs +77 -0
  55. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/Properties/AssemblyInfo.cs +36 -0
  56. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/WebsiteController.cs +101 -0
  57. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/bin/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  58. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/bin/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  59. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  60. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.csproj.FileListAbsolute.txt +7 -0
  61. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  62. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  63. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/BuildScriptCache/1/78fc7364.dat +0 -0
  64. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/ModuleIds.xml +4 -0
  65. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/NamedArguments/5/4b9722ad.dat +0 -0
  66. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/PdbInfo/61d4d5326252d9cd7476a391dfbbb2a47481ffa6 +0 -0
  67. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/ProjectModel/ProjectModel.dat +0 -0
  68. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/SymbolCache.bin +0 -0
  69. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/TodoCache/1/78fc7364.dat +0 -0
  70. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/WordIndex/1/72ab4678.dat +0 -0
  71. data/lib/deploycommandcreator.rb +34 -0
  72. data/lib/deploymentconfig.rb +15 -0
  73. data/lib/directory_cleanup.rb +16 -0
  74. data/lib/dolphindeploy.rb +12 -0
  75. data/lib/dolphindeploy_rake.rb +36 -0
  76. data/lib/file_manager.rb +30 -0
  77. data/lib/unzip.rb +11 -0
  78. data/spec/IIS/IIS6_spec.rb +24 -0
  79. data/spec/IIS/IIS_spec.rb +18 -0
  80. data/spec/configured_as/mvc_deployment_spec.rb +108 -0
  81. data/spec/deploycommandcreator_spec.rb +169 -0
  82. data/spec/deploymentconfig_spec.rb +202 -0
  83. data/spec/dolphindeploy_spec.rb +13 -0
  84. data/spec/file_manager_spec.rb +22 -0
  85. data/spec/support/spec_helper.rb +17 -0
  86. metadata +222 -0
data/lib/IIS/IIS.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'IISVersion'
2
+
3
+ class IIS
4
+ def self.server
5
+ if(IISVersion.current_version =~ /^6/)
6
+ require 'IIS6'
7
+ version = IIS6.new
8
+ else
9
+ require 'IIS7'
10
+ version = IIS7.new
11
+ end
12
+
13
+ return version
14
+ end
15
+ ### Will be executed on the local box, might be able to refactor 'server' out.
16
+ def deploy(server, location, deployment)
17
+ IIS.server.deploy(server, location, deployment)
18
+ end
19
+
20
+ def set_extra_header(header, deployment)
21
+ IIS.server.set_extra_header header,deployment
22
+ end
23
+ end
data/lib/IIS/IIS6.rb ADDED
@@ -0,0 +1,165 @@
1
+ $: << 'external'
2
+ load_assembly 'DolphinDeploy.IIS.IIS6'
3
+ load_assembly 'System.DirectoryServices'
4
+ include DolphinDeploy::IIS::IIS6
5
+ include System::DirectoryServices
6
+
7
+ class IIS6
8
+ def deploy(server, location, deployment)
9
+ unless apppool_exists?(server, deployment)
10
+ create_app_pool(server, deployment.site_name) #Server is only so we can pull out correct path to deploy too
11
+ end
12
+
13
+ if(website_exists?(server, deployment))
14
+ update_website_path(server, location, deployment)
15
+ else
16
+ create_website(server, location, deployment)
17
+ end
18
+ end
19
+
20
+ def website_exists?(server, deployment)
21
+ website = WebsiteController.new
22
+ website.server = server
23
+ website.name = deployment.site_name
24
+
25
+ return website.exists
26
+ end
27
+
28
+ def apppool_exists?(server, deployment)
29
+ app_pool = AppPoolController.new
30
+ app_pool.server = server
31
+ app_pool.name = get_app_pool_name(deployment.site_name)
32
+
33
+ return app_pool.exists
34
+ end
35
+
36
+ def set_extra_header(server, header, deployment)
37
+ site = get_website(server, deployment)
38
+
39
+ header.each do |h|
40
+ existing_headers = get_existing_headers(site)
41
+ header_arg = ""
42
+
43
+ existing_headers.each {|e| header_arg << "\"#{e}\" "}
44
+
45
+ ip = deployment.get_deploy_to_location(server)[0].ipaddress
46
+
47
+ cmd = "cscript /nologo external\\adsutil.vbs set w3svc/#{site.name}/ServerBindings \"#{ip}:#{h}\" #{header_arg}"
48
+ `#{cmd}`
49
+ end
50
+ end
51
+
52
+ def create_virtual_directory(name, path, deployment)
53
+ site = get_website('localhost', deployment)
54
+ cmd = "cscript /nologo external\\adsutil.vbs CREATE w3svc/#{site.name}/root/#{name} \"IIsWebVirtualDir\""
55
+ `#{cmd}`
56
+
57
+ root_site = get_root_site(site)
58
+ full_path = File.join(root_site.Properties['Path'][0], path)
59
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/path #{convert_path_to_iis_format(full_path)}"
60
+ `#{cmd}`
61
+
62
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/AppFriendlyName #{name}"
63
+ `#{cmd}`
64
+
65
+
66
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/AppRoot /LM/W3SVC/#{site.name}/root/#{name}"
67
+ `#{cmd}`
68
+
69
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/AppIsolated 2"
70
+ `#{cmd}`
71
+
72
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/DirBrowseFlags 1073741886"
73
+ `#{cmd}`
74
+
75
+ cmd = "cscript /nologo external\\adsutil.vbs SET w3svc/#{site.name}/root/#{name}/AccessFlags 513"
76
+ `#{cmd}`
77
+ # root_site.Properties['AppRoot'][0] = "LM/W3SVC/#{site.name}/root/#{name}"
78
+ # root_site.Properties['AppIsolated'][0] = 2
79
+ # root_site.Properties['DirBrowseFlags'][0] = 1073741886
80
+ # root_site.Properties['AccessFlags'][0] = 513
81
+ end
82
+
83
+ def execute_admin(type, cmd, deployment)
84
+ site = get_website('localhost', deployment)
85
+ cmd = "cscript /nologo external\\adsutil.vbs #{type.to_s} w3svc/#{site.name}/#{cmd}"
86
+ `#{cmd}`
87
+ end
88
+
89
+ private
90
+
91
+ def get_existing_headers(site)
92
+ cmd = "cscript /nologo external\\adsutil.vbs get w3svc/#{site.name}/ServerBindings"
93
+ result = `#{cmd}`
94
+ headers = result.to_a[1..-1].join
95
+
96
+ headers = clean_output(headers)
97
+
98
+ return headers
99
+ end
100
+
101
+ def create_app_pool(server, name)
102
+ app_pool = AppPoolController.new
103
+ app_pool.server = server # Always executed on the local box
104
+ app_pool.name = get_app_pool_name(name)
105
+ app_pool.create
106
+ end
107
+
108
+ def update_website_path(server, location, deployment)
109
+ site = get_website(server, deployment)
110
+
111
+ root_site = get_root_site(site)
112
+ root_site.Properties['Path'][0] = convert_path_to_iis_format(location)
113
+ root_site.commit_changes()
114
+ end
115
+
116
+ def get_website(server, deployment)
117
+ website = WebsiteController.new
118
+ website.name = deployment.site_name
119
+ website.server = server
120
+ website.get_website()
121
+ end
122
+
123
+ def create_website(server, location, deployment)
124
+ website = WebsiteController.new
125
+ website.name = deployment.site_name
126
+ website.app_pool = get_app_pool_name(deployment.site_name)
127
+ website.home_directory = convert_path_to_iis_format(location)
128
+ website.port = deployment.port
129
+ website.IpAddress = deployment.get_deploy_to_location(server)[0].ipaddress
130
+ website.host_header = deployment.host
131
+ website.server = server
132
+
133
+ website.create
134
+ website.start
135
+
136
+ set_isapi_filter(deployment)
137
+ end
138
+
139
+ def set_isapi_filter(deployment)
140
+ execute_admin(:set, "ScriptMaps \"*,C:\\windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_isapi.dll,1\"", deployment)
141
+ end
142
+
143
+ def get_app_pool_name(name)
144
+ "#{name}_AppPool"
145
+ end
146
+
147
+ def convert_path_to_iis_format(path)
148
+ path.gsub('/','\\').to_clr_string
149
+ end
150
+
151
+ def get_root_site(site)
152
+ path = "IIS://localhost/w3svc/#{site.name}/ROOT"
153
+ DirectoryEntry.new(path.to_clr_string)
154
+ end
155
+
156
+ def clean_output(output)
157
+ result = []
158
+
159
+ output.each do |o|
160
+ result << o.strip.gsub("\n", "")
161
+ end
162
+
163
+ return result
164
+ end
165
+ end
data/lib/IIS/IIS7.rb ADDED
@@ -0,0 +1,152 @@
1
+ $: << 'external'
2
+ load_assembly 'Microsoft.Web.Administration'
3
+ include Microsoft::Web::Administration
4
+
5
+ class IIS7
6
+ def deploy(server, location, deployment)
7
+ unless apppool_exists?(server, deployment)
8
+ create_app_pool(server, deployment.site_name) #Server is only so we can pull out correct path to deploy too
9
+ end
10
+
11
+ if(website_exists?(server, deployment))
12
+ update_website_path(server, location, deployment)
13
+ else
14
+ create_website(server, location, deployment)
15
+ end
16
+ end
17
+
18
+ def website_exists?(server, deployment)
19
+ site = get_website(server, deployment)
20
+
21
+ return site.length > 0
22
+ end
23
+
24
+ def apppool_exists?(server, deployment)
25
+ app = get_app_pool(server, deployment)
26
+
27
+ return app.length > 0
28
+ end
29
+
30
+ def set_extra_header(server, header, deployment)
31
+ iis = ServerManager.new
32
+ sites = iis.sites.select {|s| s.name == deployment.site_name }
33
+
34
+ header.each do |h|
35
+ ip = deployment.get_deploy_to_location(server)[0].ipaddress
36
+
37
+ header_broken_down = h.split(":")
38
+ port = header_broken_down[0]
39
+ host = header_broken_down[1]
40
+ add_binding(sites[0], ip, port, host)
41
+ end
42
+
43
+ iis.commit_changes
44
+ end
45
+
46
+ def create_virtual_directory(name, path, deployment)
47
+ iis = ServerManager.new
48
+ sites = iis.sites.select {|s| s.name == deployment.site_name }
49
+ site = sites[0]
50
+ app = site.applications[0]
51
+
52
+ root = app.virtual_directories.select {|v| v.path == "/" }
53
+ vdir_requested_to_create = app.virtual_directories.select {|v| v.path == "/" + name}
54
+
55
+ if vdir_requested_to_create.empty?
56
+ vdir = app.virtual_directories.create_element()
57
+ vdir.path = "/" + name
58
+ vdir.physical_path = File.join(root[0].physical_path, path)
59
+ app.virtual_directories.add(vdir)
60
+ iis.commit_changes
61
+ end
62
+ end
63
+
64
+ def execute_admin(type, cmd, deployment)
65
+ iis = ServerManager.new
66
+ sites = iis.sites.select {|s| s.name == deployment.site_name }
67
+ site = sites[0]
68
+ cmd = "cscript /nologo external\\adsutil.vbs #{type.to_s} w3svc/#{site.name}/#{cmd}"
69
+ `#{cmd}`
70
+ end
71
+
72
+ private
73
+
74
+ def create_app_pool(server, name)
75
+ iis = ServerManager.new
76
+ iis.application_pools.Add(get_app_pool_name(name));
77
+ iis.commit_changes
78
+ end
79
+
80
+ def update_website_path(server, location, deployment)
81
+ iis = ServerManager.new
82
+ sites = iis.sites.select {|s| s.name == deployment.site_name }
83
+ site = sites[0]
84
+ app = site.applications[0]
85
+
86
+ vdir = app.virtual_directories.select {|v| v.Path == "/"}
87
+ vdir[0].physical_path = convert_path_to_iis_format(location)
88
+ iis.commit_changes
89
+ end
90
+
91
+ def get_website(server, deployment)
92
+ iis = ServerManager.new
93
+ iis.sites.select {|s| s.name == deployment.site_name }
94
+ end
95
+
96
+ def get_app_pool(server, deployment)
97
+ iis = ServerManager.new
98
+ app = iis.application_pools.select {|a| a.name == get_app_pool_name(deployment.site_name) }
99
+ end
100
+
101
+ def create_website(server, location, deployment)
102
+ name = deployment.site_name.to_clr_string
103
+ location = convert_path_to_iis_format(location)
104
+ iis = ServerManager.new
105
+
106
+ site = iis.sites.CreateElement();
107
+ site.id = get_highest_id(iis)
108
+ site.SetAttributeValue("name", name);
109
+
110
+ app = site.Applications.CreateElement();
111
+ app.path = "/".to_clr_string
112
+ app.ApplicationPoolName = get_app_pool_name(deployment.site_name)
113
+
114
+ vdir = app.virtual_directories.CreateElement()
115
+ vdir.path = "/"
116
+ vdir.physical_path = location
117
+ app.virtual_directories.add(vdir)
118
+
119
+ site.applications.add(app);
120
+
121
+ ip_address = deployment.get_deploy_to_location(server)[0].ipaddress
122
+ add_binding(site, ip_address, deployment.port, deployment.host)
123
+
124
+ iis.sites.add(site);
125
+
126
+ iis.commit_changes
127
+ end
128
+
129
+ def get_highest_id(iis)
130
+ highestId = 0
131
+ iis.sites.each do |s|
132
+ highestId = s.Id if(s.Id > highestId)
133
+ end
134
+ highestId + 1
135
+ end
136
+
137
+ def add_binding(site, ip_address, port, host)
138
+ binding = site.bindings.create_element();
139
+ binding.SetAttributeValue("protocol", "http".to_clr_string);
140
+ binding.SetAttributeValue("bindingInformation", "#{ip_address}:#{port}:#{host}".to_clr_string);
141
+ site.bindings.add(binding);
142
+ end
143
+
144
+ def get_app_pool_name(name)
145
+ "#{name}_AppPool"
146
+ end
147
+
148
+ def convert_path_to_iis_format(path)
149
+ path.gsub('/','\\').to_clr_string
150
+ end
151
+
152
+ end
@@ -0,0 +1,7 @@
1
+ include System::Diagnostics
2
+
3
+ class IISVersion
4
+ def self.current_version()
5
+ FileVersionInfo.GetVersionInfo(System::Environment.SystemDirectory + "\\inetsrv\\inetinfo.exe").product_version
6
+ end
7
+ end
@@ -0,0 +1,174 @@
1
+ class MvcDeployment
2
+ attr_accessor :environment
3
+ attr_accessor :host
4
+ attr_accessor :to
5
+ attr_accessor :port
6
+ attr_accessor :ipaddress
7
+ attr_accessor :description
8
+ attr_accessor :site_name
9
+ attr_accessor :deploy_zip_path
10
+ attr_accessor :before
11
+ attr_accessor :after
12
+
13
+ def initialize()
14
+ set_defaults
15
+ end
16
+
17
+ def set_defaults()
18
+ self.port = 80
19
+ self.description = "MvcDeployment"
20
+ end
21
+
22
+ def set_name(name)
23
+ self.site_name = name
24
+ end
25
+
26
+ def set_deploy(path)
27
+ self.deploy_zip_path = path
28
+ end
29
+
30
+ def set_description(desc)
31
+ self.description = desc
32
+ end
33
+
34
+ def set_host(header)
35
+ self.host = header
36
+ end
37
+
38
+ def set_ipaddress(address)
39
+ self.ipaddress = address
40
+ end
41
+
42
+ def set_port(num)
43
+ self.port = num
44
+ end
45
+
46
+ def set_environment(env)
47
+ self.environment = env
48
+ end
49
+
50
+ def set_to(locations)
51
+ self.to = []
52
+
53
+ i = 0
54
+ while i < locations.length
55
+ location = DeployTo.new
56
+ location.server = locations[i]
57
+ location.path = locations[i + 1]
58
+ location.ipaddress = locations[i + 2]
59
+
60
+ self.to << location
61
+ i = i + 3
62
+ end
63
+ end
64
+
65
+ def set_before(block)
66
+ self.before = block
67
+ end
68
+
69
+ def set_after(block)
70
+ self.after = block
71
+ end
72
+
73
+ def add_machine_name_host_header(server, header)
74
+ hostname = `hostname`
75
+ updated_header = header.gsub("<machinename>", hostname.gsub("\n", ""))
76
+
77
+ iis = IIS.server
78
+ iis.set_extra_header(server, updated_header, self)
79
+ end
80
+
81
+ def extra_header(server, header) #Header will contain array of all the headers being added
82
+ iis = IIS.server
83
+ iis.set_extra_header(server, header, self)
84
+ end
85
+
86
+ def virtual_directory(server, vDirInfo) #Directories will contain array of all the virtual directories being added
87
+ iis = IIS.server
88
+
89
+ i = 0
90
+ while i < vDirInfo.length
91
+ name = vDirInfo[i]
92
+ path = vDirInfo[i + 1]
93
+
94
+ iis.create_virtual_directory(name, path, self)
95
+ i = i + 2
96
+ end
97
+ end
98
+
99
+ def cmd(server, command)
100
+ `#{command}`
101
+ end
102
+
103
+ def iis(server, command)
104
+ iis = IIS.server
105
+
106
+ i = 0
107
+ while i < command.length
108
+ type = command[i]
109
+ cmd = command[i + 1]
110
+
111
+ iis.execute_admin(type, cmd, self)
112
+ i = i + 2
113
+ end
114
+
115
+ end
116
+
117
+ def get_deploy_to_location(server)
118
+ self.to.select{|t| t.server == server}
119
+ end
120
+
121
+ def get_location(server)
122
+ servers = get_deploy_to_location(server)
123
+ servers[0].path
124
+ end
125
+
126
+ def deploy(server)
127
+ execute_before_methods(server)
128
+
129
+ location = get_location(server)
130
+
131
+ fm = FileManager.new
132
+ latest_version_location = fm.get_latest_version(location, self.site_name)
133
+
134
+ fm.extract(latest_version_location, self.deploy_zip_path, self.environment)
135
+
136
+ iis = IIS.new
137
+ iis.deploy(server, latest_version_location, self)
138
+
139
+ execute_after_methods(server)
140
+ end
141
+
142
+ def execute_before_methods(server)
143
+ unless self.before.nil?
144
+ self.before.each do |k, v|
145
+ call_method(k, server, v)
146
+ end
147
+ end
148
+ end
149
+
150
+ def execute_after_methods(server)
151
+ unless self.after.nil?
152
+ self.after.each do |k, v|
153
+ call_method(k, server, v)
154
+ end
155
+ end
156
+ end
157
+
158
+ def call_method(method_name, server, param)
159
+ if self.respond_to?(method_name)
160
+ if self.method(method_name).arity == 2
161
+ self.send(method_name, server, param)
162
+ else
163
+ self.send(method_name, param)
164
+ end
165
+ end
166
+ end
167
+
168
+ end
169
+
170
+ class DeployTo
171
+ attr_accessor :server
172
+ attr_accessor :path
173
+ attr_accessor :ipaddress
174
+ end