Module: TestLab::Container::Support
- Included in:
- TestLab::Container
- Defined in:
- lib/testlab/container/support.rb
Instance Method Summary collapse
-
#clone_args ⇒ Array<String>
Returns arguments for lxc-start-ephemeral.
-
#create_args ⇒ Array<String>
Returns arguments for lxc-create based on our distro.
-
#detect_arch ⇒ String
Attempt to detect the architecture of the node.
-
#start_args ⇒ Array<String>
Returns arguments for lxc-start.
Instance Method Details
#clone_args ⇒ Array<String>
Returns arguments for lxc-start-ephemeral
41 42 43 44 45 46 47 48 |
# File 'lib/testlab/container/support.rb', line 41 def clone_args arguments = Array.new arguments << %W(-o #{self.lxc_clone.name} -n #{self.lxc.name} -d) arguments << %W(--keep-data) if self.persist arguments.flatten.compact end |
#create_args ⇒ Array<String>
Returns arguments for lxc-create based on our distro
9 10 11 12 13 14 15 16 |
# File 'lib/testlab/container/support.rb', line 9 def create_args case self.distro.downcase when "ubuntu" then %W(-f /etc/lxc/#{self.id} -t #{self.distro} -- --release #{self.release} --arch #{self.arch}) when "fedora" then %W(-f /etc/lxc/#{self.id} -t #{self.distro} -- --release #{self.release}) end end |
#detect_arch ⇒ String
Attempt to detect the architecture of the node. The value returned is respective to the container distro.
55 56 57 58 59 60 61 62 |
# File 'lib/testlab/container/support.rb', line 55 def detect_arch case self.distro.downcase when "ubuntu" then ((self.node.arch =~ /x86_64/) ? "amd64" : "i386") when "fedora" then ((self.node.arch =~ /x86_64/) ? "amd64" : "i686") end end |
#start_args ⇒ Array<String>
Returns arguments for lxc-start
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/testlab/container/support.rb', line 21 def start_args arguments = Array.new unless self.aa_profile.nil? arguments << %W(-s lxc.aa_profile="#{self.aa_profile}") end unless self.cap_drop.nil? cap_drop = [self.cap_drop].flatten.compact.map(&:downcase).join(' ') arguments << %W(-s lxc.cap.drop="#{cap_drop}") end arguments << %W(-d -l DEBUG) arguments.flatten.compact end |