specinfra 2.0.0.beta23 → 2.0.0.beta24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/backend/base.rb +4 -2
- data/lib/specinfra/backend/cmd.rb +2 -2
- data/lib/specinfra/backend/docker.rb +4 -4
- data/lib/specinfra/backend/dockerfile.rb +1 -1
- data/lib/specinfra/backend/exec.rb +6 -6
- data/lib/specinfra/backend/lxc.rb +2 -3
- data/lib/specinfra/backend/powershell/command.rb +1 -1
- data/lib/specinfra/backend/powershell/script_helper.rb +5 -5
- data/lib/specinfra/backend/powershell/support/find_iis_component.ps1 +69 -8
- data/lib/specinfra/backend/shellscript.rb +1 -1
- data/lib/specinfra/backend/ssh.rb +20 -20
- data/lib/specinfra/backend/winrm.rb +2 -2
- data/lib/specinfra/backend.rb +9 -0
- data/lib/specinfra/command/windows/base/iis_app_pool.rb +10 -0
- data/lib/specinfra/command/windows/base/iis_website.rb +21 -0
- data/lib/specinfra/configuration.rb +8 -0
- data/lib/specinfra/version.rb +1 -1
- data/lib/specinfra.rb +13 -14
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cd4a2f0043137e883ac5bc8d1c39bb16e3befab
|
4
|
+
data.tar.gz: fb184638708430d79e6d315b3ba26cdfbbc7f76c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8570cdc9ab705ebebc81fbd38993cbbe02a9ab4be8cb111e1543deccc8e882b11bf2301352d482a15233a7c074d5bf74f7a76ebe3437eb94af3aaeecff44fd8f
|
7
|
+
data.tar.gz: 45b0adc803fa83452708cb024720adbf58e8f38b350f5caaa1b4d2c3a9b0906ce3fe39ed5a0105ca81c06421b73ebbc298142db9511c397b7defdf838982c94e
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
3
|
module Specinfra
|
4
|
-
|
4
|
+
class Backend
|
5
5
|
class Cmd < Base
|
6
6
|
include PowerShell::ScriptHelper
|
7
7
|
|
@@ -38,7 +38,7 @@ module Specinfra
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def powershell
|
41
|
-
architecture = @example.metadata[:architecture] ||
|
41
|
+
architecture = @example.metadata[:architecture] || @config[:architecture]
|
42
42
|
|
43
43
|
case architecture
|
44
44
|
when :i386 then x86_powershell
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Specinfra
|
2
|
-
|
2
|
+
class Backend
|
3
3
|
class Docker < Exec
|
4
4
|
def initialize
|
5
5
|
@images = []
|
6
|
-
::Docker.url =
|
6
|
+
::Docker.url = @config[:docker_url]
|
7
7
|
end
|
8
8
|
|
9
9
|
def run_command(cmd, opts={})
|
@@ -27,7 +27,7 @@ module Specinfra
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def base_image
|
30
|
-
@base_image ||= ::Docker::Image.get(
|
30
|
+
@base_image ||= ::Docker::Image.get(@config[:docker_image])
|
31
31
|
end
|
32
32
|
|
33
33
|
def current_image
|
@@ -40,7 +40,7 @@ module Specinfra
|
|
40
40
|
'Cmd' => %W{/bin/sh -c #{cmd}},
|
41
41
|
}.merge(opts)
|
42
42
|
|
43
|
-
if path =
|
43
|
+
if path = @config[:path]
|
44
44
|
(opts['Env'] ||= {})['PATH'] = path
|
45
45
|
end
|
46
46
|
|
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
require 'shellwords'
|
4
4
|
|
5
5
|
module Specinfra
|
6
|
-
|
6
|
+
class Backend
|
7
7
|
class Exec < Base
|
8
8
|
|
9
9
|
def run_command(cmd, opts={})
|
@@ -29,7 +29,7 @@ module Specinfra
|
|
29
29
|
|
30
30
|
keys.each { |key| ENV["_SPECINFRA_#{key}"] = ENV[key] ; ENV.delete(key) }
|
31
31
|
|
32
|
-
env =
|
32
|
+
env = @config[:env] || {}
|
33
33
|
env[:LANG] ||= 'C'
|
34
34
|
|
35
35
|
env.each do |key, value|
|
@@ -48,11 +48,11 @@ module Specinfra
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def build_command(cmd)
|
51
|
-
shell =
|
51
|
+
shell = @config[:shell] || '/bin/sh'
|
52
52
|
cmd = cmd.shelljoin if cmd.is_a?(Array)
|
53
53
|
cmd = "#{shell.shellescape} -c #{cmd.shellescape}"
|
54
54
|
|
55
|
-
path =
|
55
|
+
path = @config[:path]
|
56
56
|
if path
|
57
57
|
cmd = %Q{env PATH="#{path}" #{cmd}}
|
58
58
|
end
|
@@ -61,8 +61,8 @@ module Specinfra
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def add_pre_command(cmd)
|
64
|
-
if
|
65
|
-
pre_cmd = build_command(
|
64
|
+
if @config[:pre_command]
|
65
|
+
pre_cmd = build_command(@config[:pre_command])
|
66
66
|
"#{pre_cmd} && #{cmd}"
|
67
67
|
else
|
68
68
|
cmd
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
1
|
module Specinfra
|
3
|
-
|
2
|
+
class Backend
|
4
3
|
class Lxc < Exec
|
5
4
|
def run_command(cmd, opts={})
|
6
5
|
cmd = build_command(cmd)
|
@@ -28,7 +27,7 @@ module Specinfra
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def ct
|
31
|
-
@ct ||= ::LXC::Container.new(
|
30
|
+
@ct ||= ::LXC::Container.new(@config[:lxc])
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'base64'
|
2
2
|
|
3
3
|
module Specinfra
|
4
|
-
|
4
|
+
class Backend
|
5
5
|
module PowerShell
|
6
6
|
module ScriptHelper
|
7
7
|
def build_command(cmd)
|
8
|
-
path =
|
8
|
+
path = @config[:path]
|
9
9
|
if path
|
10
10
|
cmd.strip!
|
11
11
|
cmd =
|
@@ -18,12 +18,12 @@ EOF
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def add_pre_command(cmd)
|
21
|
-
path =
|
22
|
-
if
|
21
|
+
path = @config[:path]
|
22
|
+
if @config[:pre_command]
|
23
23
|
cmd.strip!
|
24
24
|
cmd =
|
25
25
|
<<-EOF
|
26
|
-
if (#{
|
26
|
+
if (#{@config[:pre_command]})
|
27
27
|
{
|
28
28
|
#{cmd}
|
29
29
|
}
|
@@ -1,19 +1,80 @@
|
|
1
1
|
function FindIISWebsite
|
2
2
|
{
|
3
3
|
param($name)
|
4
|
+
|
4
5
|
Import-Module WebAdministration
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Try {
|
8
|
+
Get-Item "IIS:\Sites\$name" -Erroraction silentlycontinue
|
9
|
+
}
|
10
|
+
Catch [System.IO.FileNotFoundException] {
|
11
|
+
Get-Item "IIS:\Sites\$name" -Erroraction silentlycontinue
|
12
|
+
}
|
12
13
|
}
|
13
14
|
|
14
15
|
function FindIISAppPool
|
15
16
|
{
|
16
17
|
param($name)
|
17
|
-
|
18
|
+
|
19
|
+
Import-Module WebAdministration
|
20
|
+
|
18
21
|
Get-Item "IIS:\AppPools\$name" -Erroraction silentlycontinue
|
19
|
-
}
|
22
|
+
}
|
23
|
+
|
24
|
+
function FindSiteBindings
|
25
|
+
{
|
26
|
+
param($name, $protocol, $hostHeader, $port, $ipAddress)
|
27
|
+
|
28
|
+
Import-Module WebAdministration
|
29
|
+
|
30
|
+
Get-WebBinding -Name $name -Protocol $protocol -HostHeader $hostHeader -Port $port -IPAddress $ipAddress
|
31
|
+
}
|
32
|
+
|
33
|
+
function FindSiteVirtualDir
|
34
|
+
{
|
35
|
+
param($name, $vdir, $path)
|
36
|
+
|
37
|
+
Import-Module WebAdministration
|
38
|
+
|
39
|
+
$webVirtDirPath = [string]::Format('IIS:\Sites\{0}\{1}',$name, $vdir);
|
40
|
+
if (Test-Path $webVirtDirPath)
|
41
|
+
{
|
42
|
+
if ([string]::IsNullOrEmpty($path))
|
43
|
+
{
|
44
|
+
$true
|
45
|
+
}
|
46
|
+
else
|
47
|
+
{
|
48
|
+
(Get-Item $webVirtDirPath).physicalPath -eq $path
|
49
|
+
}
|
50
|
+
}
|
51
|
+
else
|
52
|
+
{
|
53
|
+
$false
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
function FindSiteApplication
|
58
|
+
{
|
59
|
+
param($name, $app, $pool, $physicalPath)
|
60
|
+
|
61
|
+
Import-Module WebAdministration
|
62
|
+
|
63
|
+
$path = "IIS:\Sites\${name}\${app}"
|
64
|
+
$result = $false
|
65
|
+
if (Test-Path $path)
|
66
|
+
{
|
67
|
+
$result = $true
|
68
|
+
if ([string]::IsNullOrEmpty($pool) -eq $false)
|
69
|
+
{
|
70
|
+
$result = $result -and (Get-Item $path).applicationPool -eq $pool
|
71
|
+
}
|
72
|
+
|
73
|
+
if ([string]::IsNullOrEmpty($physicalPath) -eq $false)
|
74
|
+
{
|
75
|
+
$result = $result -and (Get-Item $path).physicalPath -eq $physicalPath
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
$result
|
80
|
+
}
|
@@ -2,7 +2,7 @@ require 'specinfra/backend/exec'
|
|
2
2
|
require 'net/ssh'
|
3
3
|
require 'net/scp'
|
4
4
|
module Specinfra
|
5
|
-
|
5
|
+
class Backend
|
6
6
|
class Ssh < Exec
|
7
7
|
def prompt
|
8
8
|
'Password: '
|
@@ -26,10 +26,10 @@ module Specinfra
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def with_env
|
29
|
-
env =
|
29
|
+
env = @config[:env] || {}
|
30
30
|
env[:LANG] ||= 'C'
|
31
31
|
|
32
|
-
ssh_options =
|
32
|
+
ssh_options = @config[:ssh_options] || {}
|
33
33
|
ssh_options[:send_env] ||= []
|
34
34
|
|
35
35
|
env.each do |key, value|
|
@@ -49,8 +49,8 @@ module Specinfra
|
|
49
49
|
|
50
50
|
def build_command(cmd)
|
51
51
|
cmd = super(cmd)
|
52
|
-
user =
|
53
|
-
disable_sudo =
|
52
|
+
user = @config[:ssh_options][:user]
|
53
|
+
disable_sudo = @config[:disable_sudo]
|
54
54
|
if user != 'root' && !disable_sudo
|
55
55
|
cmd = "#{sudo} -p '#{prompt}' #{cmd}"
|
56
56
|
end
|
@@ -58,25 +58,25 @@ module Specinfra
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def copy_file(from, to)
|
61
|
-
if
|
62
|
-
|
61
|
+
if @config[:scp].nil?
|
62
|
+
@config[:scp] = create_scp
|
63
63
|
end
|
64
64
|
|
65
|
-
scp =
|
65
|
+
scp = @config[:scp]
|
66
66
|
scp.upload!(from, to)
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
70
|
def create_ssh
|
71
71
|
Net::SSH.start(
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
@config[:host],
|
73
|
+
@config[:ssh_options][:user],
|
74
|
+
@config[:ssh_options]
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
78
78
|
def create_scp
|
79
|
-
ssh =
|
79
|
+
ssh = @config[:ssh]
|
80
80
|
if ssh.nil?
|
81
81
|
ssh = create_ssh
|
82
82
|
end
|
@@ -89,13 +89,13 @@ module Specinfra
|
|
89
89
|
exit_status = nil
|
90
90
|
exit_signal = nil
|
91
91
|
|
92
|
-
if
|
93
|
-
|
92
|
+
if @config[:ssh].nil?
|
93
|
+
@config[:ssh] = create_ssh
|
94
94
|
end
|
95
95
|
|
96
|
-
ssh =
|
96
|
+
ssh = @config[:ssh]
|
97
97
|
ssh.open_channel do |channel|
|
98
|
-
if
|
98
|
+
if @config[:sudo_password] or @config[:request_pty]
|
99
99
|
channel.request_pty do |ch, success|
|
100
100
|
abort "Could not obtain pty " if !success
|
101
101
|
end
|
@@ -104,7 +104,7 @@ module Specinfra
|
|
104
104
|
abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
|
105
105
|
channel.on_data do |ch, data|
|
106
106
|
if data.match /^#{prompt}/
|
107
|
-
channel.send_data "#{
|
107
|
+
channel.send_data "#{@config[:sudo_password]}\n"
|
108
108
|
else
|
109
109
|
stdout_data += data
|
110
110
|
end
|
@@ -112,7 +112,7 @@ module Specinfra
|
|
112
112
|
|
113
113
|
channel.on_extended_data do |ch, type, data|
|
114
114
|
if data.match /you must have a tty to run sudo/
|
115
|
-
abort 'Please
|
115
|
+
abort 'Please write "set :request_pty, true" in your spec_helper.rb or other appropriate file.'
|
116
116
|
end
|
117
117
|
|
118
118
|
if data.match /^sudo: no tty present and no askpass program specified/
|
@@ -136,13 +136,13 @@ module Specinfra
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def sudo
|
139
|
-
if sudo_path =
|
139
|
+
if sudo_path = @config[:sudo_path]
|
140
140
|
sudo_path += '/sudo'
|
141
141
|
else
|
142
142
|
sudo_path = 'sudo'
|
143
143
|
end
|
144
144
|
|
145
|
-
sudo_options =
|
145
|
+
sudo_options = @config[:sudo_options]
|
146
146
|
if sudo_options
|
147
147
|
sudo_options = sudo_options.shelljoin if sudo_options.is_a?(Array)
|
148
148
|
sudo_options = ' ' + sudo_options
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Specinfra
|
2
|
-
|
2
|
+
class Backend
|
3
3
|
class WinRM < Base
|
4
4
|
include PowerShell::ScriptHelper
|
5
5
|
|
6
6
|
def run_command(cmd, opts={})
|
7
7
|
script = create_script(cmd)
|
8
|
-
winrm =
|
8
|
+
winrm = @config[:winrm]
|
9
9
|
|
10
10
|
result = winrm.powershell(script)
|
11
11
|
stdout, stderr = [:stdout, :stderr].map do |s|
|
data/lib/specinfra/backend.rb
CHANGED
@@ -9,3 +9,12 @@ require 'specinfra/backend/lxc'
|
|
9
9
|
require 'specinfra/backend/winrm'
|
10
10
|
require 'specinfra/backend/shellscript'
|
11
11
|
require 'specinfra/backend/dockerfile'
|
12
|
+
|
13
|
+
module Specinfra
|
14
|
+
class Backend
|
15
|
+
def Backend.new(type, config)
|
16
|
+
eval "Specinfra::Backend::#{type.to_s.to_camel_case}.new(config)"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -55,5 +55,15 @@ class Specinfra::Command::Windows::Base::IisAppPool < Specinfra::Command::Window
|
|
55
55
|
exec "(FindIISAppPool -name '#{name}').recycling.periodicRestart.time.TotalMinutes -eq #{minutes}"
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
def check_has_managed_pipeline_mode(name, mode)
|
60
|
+
Backend::PowerShell::Command.new do
|
61
|
+
using 'find_iis_component.ps1'
|
62
|
+
exec "(FindIISAppPool -name '#{name}').managedPipelineMode -eq '#{mode}'"
|
63
|
+
end
|
64
|
+
end
|
58
65
|
end
|
59
66
|
end
|
67
|
+
|
68
|
+
|
69
|
+
|
@@ -34,5 +34,26 @@ class Specinfra::Command::Windows::Base::IisWebsite < Specinfra::Command::Window
|
|
34
34
|
exec "[System.Environment]::ExpandEnvironmentVariables( ( FindIISWebsite -name '#{name}' ).physicalPath ).replace('\\', '/' ) -eq ('#{path}'.trimEnd('/').replace('\\', '/'))"
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def check_has_site_bindings(name, port, protocol, ipaddress, host_header)
|
39
|
+
Backend::PowerShell::Command.new do
|
40
|
+
using 'find_iis_component.ps1'
|
41
|
+
exec "(FindSiteBindings -name '#{name}' -protocol '#{protocol}' -hostHeader '#{host_header}' -port #{port} -ipAddress '#{ipaddress}').count -gt 0"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def check_has_virtual_dir(name, vdir, path)
|
46
|
+
Backend::PowerShell::Command.new do
|
47
|
+
using 'find_iis_component.ps1'
|
48
|
+
exec "(FindSiteVirtualDir -name '#{name}' -vdir '#{vdir}' -path '#{path}') -eq $true"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_has_site_application(name, app, pool, physical_path)
|
53
|
+
Backend::PowerShell::Command.new do
|
54
|
+
using 'find_iis_component.ps1'
|
55
|
+
exec "(FindSiteApplication -name '#{name}' -app '#{app}' -pool '#{pool}' -physicalPath '#{physical_path}') -eq $true"
|
56
|
+
end
|
57
|
+
end
|
37
58
|
end
|
38
59
|
end
|
data/lib/specinfra/version.rb
CHANGED
data/lib/specinfra.rb
CHANGED
@@ -9,23 +9,22 @@ require 'specinfra/runner'
|
|
9
9
|
include Specinfra
|
10
10
|
|
11
11
|
module Specinfra
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
@@backend = nil
|
13
|
+
def self.configuration
|
14
|
+
Specinfra::Configuration
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def self.command
|
18
|
+
Specinfra::Command::Base
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
eval "Specinfra::Backend::#{type.to_s.to_camel_case}.instance"
|
21
|
+
def self.backend
|
22
|
+
type = Specinfra.configuration.backend
|
23
|
+
if type.nil?
|
24
|
+
warn "No backend type is specified. Fall back to :exec type."
|
25
|
+
type = :exec
|
28
26
|
end
|
27
|
+
@@backend ||= Specinfra::Backend.new(type, Specinfra.configuration)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|