class Object

Constants

KNOWN_MESSAGES
MACHINE_LIST

Public Instance Methods

libvirt_config_file(vm_name) click to toggle source
# File extended/libvirt/helpers/helper.rb, line 1
def libvirt_config_file(vm_name)
  "/etc/libvirt/qemu/#{vm_name}.xml"
end
param_service() click to toggle source
# File standard/systemd/helpers/param_service.rb, line 1
def param_service
  param! "service",
    default_param: true,
    lookup: lambda { |params|
      @op.list_systemd_services("machine" => params["machine"] ).map { |x| x["name"] }
    }
end
regex_hash(line, regex, keys) click to toggle source
# File standard/ssh/helpers/regex.rb, line 1
def regex_hash(line, regex, keys)
  result = nil

  matched = regex.match(line)
  if matched
    result = {}
    keys.each_with_index do |key, index|
      result[key] = matched.captures[index]
    end
  end

  result
end
ssh_regex(machine, command, regex, keys, options = {except: {}}) click to toggle source

calls command on machine and uses regex to parse into keys options support an `:except` key holding a hash of regex => handler for special-casing by regex, e.g. {

except: {
  /total\s+(\d+)/ => lambda { |matched|
    puts "total is #{matched.captures.first}"
  }
}

} also supported is a `:post_process` block for transmogrifying parsed results

# File standard/ssh/helpers/regex.rb, line 26
def ssh_regex(machine, command, regex, keys, options = {except: {}})
  result = []

  machine.ssh(command).lines.map do |line|
    if options.has_key? :except
      options[:except].each do |regex, block|
        if matched = regex.match(line)
          block.call(matched)
          next
        end
      end
    end

    parsed = regex_hash(line, regex, keys)
    if parsed
      if options.has_key? :post_process
        parsed = options[:post_process].call(parsed)
      end

      result << parsed
    end
  end

  result
end