Skip to content

Instantly share code, notes, and snippets.

View jlsherrill's full-sized avatar

Justin Sherrill jlsherrill

View GitHub Profile
diff --git a/app/views/katello/api/v2/systems/show.json.rabl b/app/views/katello/api/v2/systems/show.json.rabl
index 8f2710d..1646caf 100644
--- a/app/views/katello/api/v2/systems/show.json.rabl
+++ b/app/views/katello/api/v2/systems/show.json.rabl
@@ -63,7 +63,7 @@ end
# Requires another API call to fetch from Candlepin
if params[:fields] == "full"
- attributes :type
+ attributes :system_type => :type
@jlsherrill
jlsherrill / factsd.rb
Created November 13, 2014 17:22
Fact exchange
#!/usr/bin/ruby
if File.exists?("/etc/facts.d")
entries = Dir.entries("/etc/facts.d/")
name_map = {}
entries.each do |entry|
if File.file?("/etc/facts.d/#{entry}")
ext = entry.split('.')[1]
@jlsherrill
jlsherrill / generate_puppet_repo.py
Last active August 29, 2015 14:11
Script to generate repos syncable by katello/pulp for built puppet modules.
#!/usr/bin/env python
import sys
import os
from hashlib import sha256
ARCHIVE_SUFFIX = '.tar.gz'
def digest(path):
h = sha256()
def Print print
return print.size
end
def _Print print
return print.chr
end
def _print *print
return Print([print]) << Print(print)
@jlsherrill
jlsherrill / gist:26eeca53f66879a3dc66
Created January 7, 2015 18:46
Removing a distribution for a repo
yum install pulp-admin-client pulp-rpm-admin-extensions
# edit /etc/pulp/admin/admin.conf and change:
host = localhost.localdomain
# to
host = myhost.domain.com
# and change
@jlsherrill
jlsherrill / gist:66842924e4248900ef77
Last active August 29, 2015 14:13
Fixing clean_backend_objects

find the file:

/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.0.0/lib/katello/tasks/clean_backend_objects.rake

###1. on line 13 change:

system.facts to

@jlsherrill
jlsherrill / export_tasks.rake
Last active August 29, 2015 14:13
export tasks
# Drop this file in /usr/share/foreman/lib/tasks
# and then run "foreman-rake export_tasks"
# To export all tasks "foreman-rake export_tasks tasks=all"
desc 'Export Dynflow Tasks'
task :export_tasks => :environment do
class TaskRender
def initialize
@cache = {}
diff --git a/app/models/host/managed.rb b/app/models/host/managed.rb
index b2a718b..117c306 100644
--- a/app/models/host/managed.rb
+++ b/app/models/host/managed.rb
@@ -121,7 +121,7 @@ class Host::Managed < Host::Base
scope :for_vm, lambda { |cr,vm| where(:compute_resource_id => cr.id, :uuid => Array.wrap(vm).compact.map(&:ide
# audit the changes to this model
- audited :except => [:last_report, :puppet_status, :last_compile], :allow_mass_assignment => true
+ audited :except => [:last_report, :puppet_status, :last_compile, :primary_interface], :allow_mass_assignment =
@jlsherrill
jlsherrill / removeing_repo_manually.md
Last active September 28, 2018 14:01
Removing missing Red Hat Repositories

It is recommend you have a backup before proceeding with these steps. There is no need to shut down any part of the application while performing these steps.

  1. Ensure that the repositories being deleted are not published in any content views. If there are any, please delete the Content View Versions including the affected repos.

  2. For each repository, find its id. This should be located by going to the Content > Products page, clicking on the product the repository is in, and then repository name itself. Notice the URL in the browser, it will look something like:

https://abed.example.com/products/91/repositories/29

Go into the rails console:

# foreman-rake console

Then run the following:

 Katello::Distribution.search{ filter :terms, :repoids => Katello::ContentView.find(5).repositories_to_publish.pluck(:pulp_id); size 100 }.as_json