specinfra 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 435ccd7d6235168493d866a544d63080463997a5
4
- data.tar.gz: fff80d5a375cf3a240ec3546d58d1a16eaf60c86
3
+ metadata.gz: 3b7d709f36935542a65418e095c59c7603e50fc6
4
+ data.tar.gz: 52eca55054a808e6b247a26662e29e54b3970bd4
5
5
  SHA512:
6
- metadata.gz: 3770696459535aafb583a378d178fe4e2277b7962befa71b8efd9c9035156199a3c37c39f36e5f5aa0b9310335e9ae5e67fc2411786df9af58d7baefc82abcd1
7
- data.tar.gz: 7e092224e1cb4c85e80398344a7bd508d6515266b769b4ca37c84d278b11552b939526606d1c56217242411e7032aa2bc78c6630ad976c02773f1605049acd00
6
+ metadata.gz: 60739fc1cfb20beec8059cdc67114f6f2085f850776c53253e81a270316c5e3c8769a79ab8f7b8669ef9b0f664016aa2b62a71e6fee552ff80696aeeb09a020a
7
+ data.tar.gz: 3d71fc8140b48089ca4c4f25329c1a9835fcd5b137d881768e98552191465306a1587553a139a465e0be2e3ea8b3a677054b421cfe3537217572d44a1def2d23
@@ -5,6 +5,7 @@ require 'specinfra/backend/powershell/script_helper'
5
5
  require 'specinfra/backend/powershell/command'
6
6
  require 'specinfra/backend/cmd'
7
7
  require 'specinfra/backend/docker'
8
+ require 'specinfra/backend/lxc'
8
9
  require 'specinfra/backend/winrm'
9
10
  require 'specinfra/backend/shellscript'
10
11
  require 'specinfra/backend/dockerfile'
@@ -17,7 +17,7 @@ module SpecInfra
17
17
  def commands
18
18
  @commands
19
19
  end
20
-
20
+
21
21
  def check_zero(cmd, *args)
22
22
  run_command(commands.send(cmd, *args)).success?
23
23
  end
@@ -0,0 +1,40 @@
1
+
2
+ module SpecInfra
3
+ module Backend
4
+ class Lxc < Exec
5
+ def run_command(cmd, opts={})
6
+ cmd = build_command(cmd)
7
+ cmd = add_pre_command(cmd)
8
+ out, ret = ct.execute do
9
+ out = `#{cmd}`
10
+ [out, $?.dup]
11
+ end
12
+ if @example
13
+ @example.metadata[:command] = cmd
14
+ @example.metadata[:stdout] = out
15
+ end
16
+ CommandResult.new :stdout => out, :exit_status => ret.exitstatus
17
+ end
18
+ def build_command(cmd)
19
+ cmd
20
+ end
21
+
22
+ def add_pre_command(cmd)
23
+ cmd
24
+ end
25
+
26
+ def copy_file(from, to)
27
+ begin
28
+ FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to))
29
+ rescue => e
30
+ return false
31
+ end
32
+ true
33
+ end
34
+
35
+ def ct
36
+ @ct ||= ::LXC::Container.new(RSpec.configuration.lxc)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -44,7 +44,7 @@ module SpecInfra
44
44
  ip_address.gsub!(".", "\\.")
45
45
  "ip addr show #{interface} | grep 'inet #{ip_address}'"
46
46
  end
47
-
47
+
48
48
  def check_zfs(zfs, property=nil)
49
49
  if property.nil?
50
50
  "zfs list -H #{escape(zfs)}"
@@ -43,7 +43,7 @@ module SpecInfra
43
43
  exec cmd
44
44
  end
45
45
  end
46
-
46
+
47
47
  def check_directory(dir)
48
48
  cmd = item_has_attribute dir, 'Directory'
49
49
  Backend::PowerShell::Command.new do
@@ -195,7 +195,7 @@ module SpecInfra
195
195
  Backend::PowerShell::Command.new do
196
196
  exec "(New-Object System.Net.NetworkInformation.Ping).send('#{host}').Status -eq 'Success'"
197
197
  end
198
- else
198
+ else
199
199
  Backend::PowerShell::Command.new do
200
200
  using 'is_remote_port_listening.ps1'
201
201
  exec"(IsRemotePortListening -hostname #{host} -port #{port} -timeout #{timeout} -proto #{proto}) -eq $true"
@@ -204,7 +204,7 @@ module SpecInfra
204
204
  end
205
205
 
206
206
  def check_windows_feature_enabled(name,provider)
207
-
207
+
208
208
  if provider.nil?
209
209
  cmd = "@(ListWindowsFeatures -feature #{name}).count -gt 0"
210
210
  else
@@ -10,7 +10,8 @@ module SpecInfra
10
10
  :disable_sudo,
11
11
  :pass_prompt,
12
12
  :sudo_options,
13
- :docker_image
13
+ :docker_image,
14
+ :lxc
14
15
  ].freeze
15
16
 
16
17
  def defaults
@@ -5,6 +5,7 @@ require 'specinfra/helper/backend'
5
5
  include SpecInfra::Helper::Backend
6
6
 
7
7
  require 'specinfra/helper/docker'
8
+ require 'specinfra/helper/lxc'
8
9
 
9
10
  require 'specinfra/helper/configuration'
10
11
 
@@ -1,6 +1,6 @@
1
1
  module SpecInfra
2
2
  module Helper
3
- ['Exec', 'Ssh', 'Cmd', 'Docker', 'WinRM', 'ShellScript', 'Dockerfile'].each do |type|
3
+ ['Exec', 'Ssh', 'Cmd', 'Docker', 'WinRM', 'ShellScript', 'Dockerfile', 'Lxc'].each do |type|
4
4
  eval <<-EOF
5
5
  module #{type}
6
6
  def backend(commands_object=nil)
@@ -0,0 +1,11 @@
1
+ module SpecInfra
2
+ module Helper
3
+ module Lxc
4
+ def self.included(klass)
5
+ require 'lxc/extra' unless defined?(::LXC::Extra)
6
+ rescue LoadError
7
+ fail "LXC client library is not available. Try installing `ruby-lxc' gem."
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "0.5.9"
2
+ VERSION = "0.6.0"
3
3
  end
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: 0.5.9
4
+ version: 0.6.0
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-02-17 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - lib/specinfra/backend/docker.rb
87
87
  - lib/specinfra/backend/dockerfile.rb
88
88
  - lib/specinfra/backend/exec.rb
89
+ - lib/specinfra/backend/lxc.rb
89
90
  - lib/specinfra/backend/powershell/command.rb
90
91
  - lib/specinfra/backend/powershell/script_helper.rb
91
92
  - lib/specinfra/backend/powershell/support/check_file_access_rules.ps1
@@ -125,6 +126,7 @@ files:
125
126
  - lib/specinfra/helper/configuration.rb
126
127
  - lib/specinfra/helper/detect_os.rb
127
128
  - lib/specinfra/helper/docker.rb
129
+ - lib/specinfra/helper/lxc.rb
128
130
  - lib/specinfra/helper/os.rb
129
131
  - lib/specinfra/helper/properties.rb
130
132
  - lib/specinfra/properties.rb