Sha256: 056f69a1246b165991a5ff8f1cb1911707532d5afdb285b6db31381b227f1469

Contents?: true

Size: 482 Bytes

Versions: 3

Compression:

Stored size: 482 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

    def self.escape_nodename(name)
      name.to_s.gsub('-', '_')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ovsimager-0.0.6 lib/ovsimager/utils.rb
ovsimager-0.0.5 lib/ovsimager/utils.rb
ovsimager-0.0.4 lib/ovsimager/utils.rb