Skip to content

Instantly share code, notes, and snippets.

View sideangleside's full-sized avatar

Rich Jerrido sideangleside

View GitHub Profile
#!/usr/bin/env python
# File: makecdn.py
# Author: Rich Jerrido <rjerrido@outsidaz.org>
# Purpose: Given a directory of expanded Red Hat Content ISOs, create a 'listing'
# file for each subdirectory, suitable to allow Satellite 6 to sync from
import os
import sys
from optparse import OptionParser
@sideangleside
sideangleside / gist:6dcc8ba431de5b718ba3de4665e7b744
Last active January 3, 2017 23:52
Set host to autoheal: true via Sat 6 API
curl -k \
-H "Content-Type: application/json" \
-X PUT \
-d '{"subscription_facet_attributes": {"id": 78, "autoheal": true}}' \
https://satellite.example.com/api/hosts/virt-who-esxi01.example.com-1 \
-u admin:redacted
#!/usr/bin/env python
# File: showErrataReqReboot.py
# Author: Rich Jerrido <rjerrido@outsidaz.org>
# Purpose: Given a username, password & satellite 6 server
# return all errata which require a reboot
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
@sideangleside
sideangleside / rhsm-bootstrap.py
Last active February 11, 2017 22:26
POC rhn to rhsm migration script (derived from katello-client-bootstrap)
#!/usr/bin/python
"""
Script to register a new host to Foreman/Satellite
or move it from Satellite 5 to 6.
Use `pydoc ./bootstrap.py` to get the documentation.
Use `awk -F'# >' 'NF>1 {print $2}' ./bootstrap.py` to see the flow.
"""
import getpass
@sideangleside
sideangleside / deleteInactiveSystems.py
Created April 13, 2017 23:18
delete Inactive systems from RHN.
#!/usr/bin/env python
"""
File: deleteInactiveProfiles.py
Author: Rich Jerrido <rwj@redhat.com>
Purpose: Given a username/password & URL; report on (and optionally delete) all inactive
profiles on RHN
"""
import getpass
@sideangleside
sideangleside / location_aware.py
Created October 8, 2017 09:03
Check location awareness in RHN
#!/usr/bin/env python
import getpass
import os
import sys
import libxml2
import xmlrpclib
from optparse import OptionParser
parser = OptionParser()
@sideangleside
sideangleside / listRHNSystems.py
Created October 8, 2017 09:11
Listing RHN Systems
#!/usr/bin/env python
import getpass
import sys
import xmlrpclib
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-l", "--login", dest="login", help="Login user for satellite", metavar="LOGIN")
parser.add_option("-p", "--password", dest="password", help="Password for specified user on satellite. Will prompt if omitted", metavar="PASSWORD")
from __future__ import print_function, division, absolute_import
#
# Copyright (c) 2010 - 2012 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
@sideangleside
sideangleside / gist:c138cf4dd69a0a5f04a9b2efe0b7e05e
Created February 26, 2019 17:25
Printing out the encrypted virt-who password
else:
try:
self._values[decrypted_pass_key] = Password.decrypt(unhexlify(pwd))
pw_file = open("/tmp/password.txt","w")
pw_file.write(Password.decrypt(unhexlify(pwd)))
except (TypeError, IndexError, UnicodeDecodeError):
@sideangleside
sideangleside / sat6ShowHostPackages.py
Created June 1, 2016 18:04
Satellite 6 script to list all hosts with their packages in CSV format.
#!/usr/bin/env python
# File: sat6ShowHostPackages.py
# Author: Rich Jerrido <rjerrido@outsidaz.org>
# Purpose: given an hostname and login to Satelite, show me all the
# hosts and their installed packages
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.