elecksee 1.1.2 → 1.1.4

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: 5338c94533fdfa6461fca82ac7ae057eb78156e8
4
- data.tar.gz: 1a456de0c3e90b671e861cb944b4a9573e0b7e80
3
+ metadata.gz: 21ad5852da8a7cc744f2373114236025f96250fd
4
+ data.tar.gz: f66e5479b7ca68ea91e64252fba2dd700c5744c6
5
5
  SHA512:
6
- metadata.gz: d7dd9c7ae904a7c815fbc9fc8c216b64a2daf41c3f7eb651cbe5c3232d3b49ffb9999a3f92997292316f072c6eb077c211361a15b666cddb22ee71af03509126
7
- data.tar.gz: f933cd9cad68730ec0dccb2f53bbe78477837bb087edd9d7c642de8a5106d6843e163ae2cbe606da533d4514a1cb456ae2444617a111d7dd6d5f569528390f66
6
+ metadata.gz: 25db309c2ec9f98d618b374ad4f1025837868f7baf66c3bbe34bfa0c59a939587125929229a3a32317f38e033d994bf848e97e5db3725ba44405e73ba20790d3
7
+ data.tar.gz: 9284d75a3e4fcb38b4e6023084e886eea5a1e9887515025e800c9d97d4ce433883eb093e3e54914bd9ef8d65b0320ffbf3863728f4ab41c1927f0fd7c69d0b4b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.1.4
2
+ * Only stop container on cleanup if container is running
3
+ * Add flag for selection of using ssh or attach to run commands
4
+
1
5
  ## v1.1.2
2
6
  * Provide direct access to `Rye::Box`
3
7
  * Add alternate ephemeral init using bash wrapper for cleanup
@@ -207,7 +207,7 @@ class Lxc
207
207
  #
208
208
  # @return [TrueClass, FalseClass]
209
209
  def cleanup
210
- lxc.stop
210
+ lxc.stop if lxc.running?
211
211
  @ephemeral_overlay.unmount
212
212
  @ephemeral_binds.map(&:destroy)
213
213
  @ephemeral_device.destroy
data/lib/elecksee/lxc.rb CHANGED
@@ -53,6 +53,8 @@ class Lxc
53
53
  attr_accessor :default_ssh_password
54
54
  # @return [String, NilClass] default ssh user
55
55
  attr_accessor :default_ssh_user
56
+ # @return [Symbol] default command method
57
+ attr_accessor :container_command_via
56
58
 
57
59
  # @return [String] sudo command
58
60
  def sudo
@@ -479,18 +481,25 @@ class Lxc
479
481
  # @option args [TrueClass, FalseClass] :raise_on_failure
480
482
  # @return [CommandResult]
481
483
  def direct_container_command(command, args={})
482
- begin
483
- result = connection(args).execute command
484
- CommandResult.new(result)
485
- rescue Rye::Err => e
486
- if(args[:raise_on_failure])
487
- raise CommandFailed.new(
488
- "Command failed: #{command}",
489
- CommandResult.new(e)
490
- )
491
- else
492
- false
484
+ if(args.fetch(:run_as, Lxc.container_command_via).to_sym == :ssh)
485
+ begin
486
+ result = connection(args).execute command
487
+ CommandResult.new(result)
488
+ rescue Rye::Err => e
489
+ if(args[:raise_on_failure])
490
+ raise CommandFailed.new(
491
+ "Command failed: #{command}",
492
+ CommandResult.new(e)
493
+ )
494
+ else
495
+ false
496
+ end
493
497
  end
498
+ else
499
+ command(
500
+ "lxc-attach -n #{name} #{command}",
501
+ args.merge(:sudo => true)
502
+ )
494
503
  end
495
504
  end
496
505
  alias_method :knife_container, :direct_container_command
@@ -576,5 +585,9 @@ EOS
576
585
 
577
586
  end
578
587
 
579
- Lxc.default_ssh_key = '/opt/hw-lxc-config/id_rsa'
588
+ Lxc.default_ssh_key = [
589
+ File.join(Dir.home, '.ssh', 'lxc_container_rsa'),
590
+ '/opt/hw-lxc-config/id_rsa',
591
+ ].detect{|key| File.exists?(key) }
580
592
  Lxc.default_ssh_user = 'root'
593
+ Lxc.container_command_via = :ssh
@@ -1,4 +1,4 @@
1
1
  module Elecksee
2
2
  # Current library version
3
- VERSION = Gem::Version.new('1.1.2')
3
+ VERSION = Gem::Version.new('1.1.4')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elecksee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: childprocess
@@ -88,4 +88,3 @@ signing_key:
88
88
  specification_version: 4
89
89
  summary: LXC helpers
90
90
  test_files: []
91
- has_rdoc: