Class: OVSImager::Utils
- Inherits:
-
Object
- Object
- OVSImager::Utils
- Defined in:
- lib/ovsimager/utils.rb
Class Method Summary collapse
- .escape_nodename(name) ⇒ Object
- .execute(cmd, root = false) ⇒ Object
- .get_root_helper(root = true) ⇒ Object
Class Method Details
.escape_nodename(name) ⇒ Object
19 20 21 |
# File 'lib/ovsimager/utils.rb', line 19 def self.escape_nodename(name) name.to_s.gsub('-', '_') end |
.execute(cmd, root = false) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
5 6 7 8 |
# 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 |