class Lita::Handlers::Pulp

Public Instance Methods

check_sync_status(response) click to toggle source

it returns all history with runcible api, which is not an idea behavior though pulp can puerge the task status according to configuration

# File lib/lita/handlers/pulp.rb, line 389
def check_sync_status(response)
  puts "response.matches[0]=#{response.matches[0][0]}"
  repo_id = response.matches[0][0]
  if repo_id
    unless repo_id
      response.reply "Invalid repository id"
    end
    begin
      result = sync_status(repo_id)
      response.reply JSON.pretty_generate(result)
    rescue Exception => e
      response.reply e.message
    end
  else
    response.reply "No repoistory id specified"
  end
end
cmd_create_puppet_repo(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 555
def cmd_create_puppet_repo(response)
  args = response.extensions[:kwargs]
  #puts "args: #{args}"
  repo_id = args[:repo_id]
  name = args[:name] || repo_id
  description = args[:description]
  feed = args[:feed]
  queries = args[:queries]
  remove_missing = args[:remove_missing].nil? ? false : args[:remove_missing] #default false
  serve_http = args[:http].nil? ? true : args[:http] #default true
  serve_https = args[:https].nil? ? false : args[:https]
  auto_publish = args[:auto_publish].nil? ? false : args[:auto_publish]
  begin
    success = create_puppet_repo(repo_id: repo_id, display_name: name , description: description, feed_url: feed, queries: queries, remove_missing: remove_missing, serve_http: serve_http, serve_https: serve_https, auto_publish: auto_publish )
    response.reply "Repo created successfully."
  rescue Exception => e
    response.reply e.message
  end
end
cmd_create_rpm_repo(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 536
def cmd_create_rpm_repo(response)
  args = response.extensions[:kwargs]
  #puts "args: #{args}"
  repo_id = args[:repo_id]
  name = args[:name] || repo_id
  description = args[:description]
  feed = args[:feed]
  relative_url = args[:relative_url]
  serve_http = args[:http].nil? ? true : args[:http]
  serve_https = args[:https].nil? ? false : args[:https]
  auto_publish = args[:auto_publish].nil? ? false : args[:auto_publish]
  begin
    success = create_rpm_repo(repo_id: repo_id, display_name: name , description: description, feed_url: feed, relative_url: relative_url, serve_http: serve_http, serve_https: serve_https, auto_publish: auto_publish )
    response.reply "Repo created successfully."
  rescue Exception => e
    response.reply e.message
  end
end
cmd_delete_repository(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 575
def cmd_delete_repository(response)
  repo_id = response.matches[0][0]
  begin
    success = delete_repository(repo_id)
    response.reply "Repo deleted successfully."
  rescue Exception => e
    response.reply e.message
  end
end
copy_puppet(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 479
def copy_puppet(response)
  args = response.extensions[:kwargs]
  from = args[:from]
  to = args[:to]
  author = args[:author]
  name = args[:name]
  version = args[:version]
  delete_newer=args[:delete_newer]||false
  publish=args[:publish]||false
  begin
    if from.nil? || to.nil? || author.nil? || name.nil? || version.nil?
      raise "Exception: missing required parameters"
    end
    copy_puppet_between_repo!(from, to, author, name, version, delete_newer, publish)
    response.reply "Command executed successfully"
  rescue StandardError => e
    response.reply e.message
  end
end
copy_rpm(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 458
def copy_rpm(response)
   args = response.extensions[:kwargs]
   from = args[:from]
   to = args[:to]
   release = args[:release]
   name = args[:name]
   version = args[:version]
   arch = args[:arch]
   delete_newer=args[:delete_newer]||false
   publish=args[:publish]||false
   begin
     if from.nil? || to.nil? || release.nil? ||name.nil? || version.nil? || arch.nil?
       raise  "Exception: Missing required paramenter"
     end
     copy_rpm_between_repo!(from, to, name, version, release, arch, delete_newer, publish)
     response.reply "Command executed successfully"
   rescue StandardError => e
     response.reply e.message
   end
end
delete_newer_puppet(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 518
def delete_newer_puppet(response)
  args = response.extensions[:kwargs]
  from = args[:from]
  author = args[:author]
  name = args[:name]
  version = args[:version]
  publish=args[:publish]||false
  begin
    if from.nil? || author.nil? || name.nil? || version.nil?
      raise "Exception: missing required parameters"
    end
    delete_puppet_newer!(from, author, name, version, publish)
    response.reply "Command executed successfully"
  rescue StandardError => e
    response.reply e.message
  end
end
delete_newer_rpm(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 499
def delete_newer_rpm(response)
  args = response.extensions[:kwargs]
  from = args[:from]
  release = args[:release]
  name = args[:name]
  version = args[:version]
  arch = args[:arch]
  publish=args[:publish]||false
  begin
    if from.nil? || author.nil? || name.nil? || version.nil?
      raise "Exception: missing required parameters"
    end
    delete_rpm_newer!(from, name, version, relase, arch, publish)
    response.reply "Command executed successfully"
  rescue StandardError => e
    response.reply e.message
  end
end
puppet_repos(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 328
def puppet_repos(response)
    begin
      result=list_repo(REPO_TYPE_PUPPET)
      #response.reply result.to_json
      #puts result
      s = StringIO.new
      result.each do |r|
        s << "["<< r[:id] << "] : " << r[:name] << ", " << r[:description] << "\n"
      end
      response.reply s.string
    rescue Exception => e
      response.reply e.message
    end
end
repo_publish(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 352
def repo_publish(response)
    repo_id = response.matches[0][0]
    if repo_id
      unless repo_id
        response.reply "Invalid repository id"
      end
      begin
        result = publish_repo!(repo_id)
        response.reply JSON.pretty_generate(result)
      rescue Exception => e
        response.reply e.message
      end
    else
      response.reply "No repoistory id specified"
    end
end
repo_sync(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 369
def repo_sync(response)
  #puts "response.matches[0]=#{response.matches[0][0]}"
  repo_id = response.matches[0][0]
  if repo_id
    unless repo_id
      response.reply "Invalid repository id"
    end
    begin
      result=sync_repo!(repo_id)
      response.reply JSON.pretty_generate(result)
    rescue Exception => e
      response.reply e.message
    end
  else
    response.reply "No repoistory id specified"
  end
end
rpm_repos(response) click to toggle source

route(

/^pulp\s+sync_status\s+(\S+)$/,
:check_sync_status,
command: true,
help: {
  t('help.sync_status_key') => t('help.sync_status_value')
}

)

# File lib/lita/handlers/pulp.rb, line 314
def rpm_repos(response)
  begin
    result=list_repo(REPO_TYPE_RPM)
    #puts "********result"
    s = StringIO.new
    result.each do |r|
      s << "["<< r[:id] << "] : " << r[:name] << ", " << r[:description] << "\n"
    end
    response.reply s.string
  rescue Exception => e
    response.reply e.message
  end
end
show_repo(response) click to toggle source
# File lib/lita/handlers/pulp.rb, line 343
def show_repo(response)
  repo_id = response.matches[0][0]
  begin
    repo = get_repo(repo_id)
    response.reply JSON.pretty_generate(repo)
  rescue Exception => e
    response.reply e.message
  end
end