class OVSImager::Utils
Public Class Methods
escape_nodename(name)
click to toggle source
# File lib/ovsimager/utils.rb, line 19 def self.escape_nodename(name) name.to_s.gsub('-', '_') end
execute(cmd, root=false)
click to toggle source
# File lib/ovsimager/utils.rb, line 10 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
get_root_helper(root=true)
click to toggle source
# File lib/ovsimager/utils.rb, line 5 def self.get_root_helper(root=true) return '' if not root or Process::UID.eid == 0 root ? 'sudo ' : '' end