Sha256: 57f49cf95227bd599ce3b0779b0e55367f61bae48e00a52c7748a8b635bfe27b

Contents?: true

Size: 407 Bytes

Versions: 2

Compression:

Stored size: 407 Bytes

Contents

require 'open3'

module OVSImager
  class Utils
    def self.get_root_helper(root=true)
      return '' if not root or Process::UID.eid == 0
      root ? 'sudo ' : ''
    end

    def self.execute(cmd, root=false)
      root_helper = self.get_root_helper(root)
      out = `#{root_helper}#{cmd}`
      if $? != 0
        raise "command execution failure: #{$?}"
      end
      return out
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ovsimager-0.0.3 lib/ovsimager/utils.rb
ovsimager-0.0.2 lib/ovsimager/utils.rb