Skip to content

Instantly share code, notes, and snippets.

View mhrivnak's full-sized avatar

Michael Hrivnak mhrivnak

View GitHub Profile
@mhrivnak
mhrivnak / catasb-offline.md
Last active April 26, 2018 21:35
Run catasb offline

Run catasb offline

For demo purposes, I find it handy to run openshift with catasb offline, without an internet connection at all.

Gotchas

The cluster will happily start without an internet connection. You can even provision some services successfully. But due to extensive use of nip.io, several things will fail. apb relist will fail. Using an openshift Route

#!/usr/bin/env bash
# This is just where I keep my apb tool installed in a virtualenv
PYTHON=~/pythons/apb/bin/python
PATH=$PATH:~/pythons/apb/bin/
for chart in $(helm search stable | grep -v NAME | awk '{ print $1 }' | sed -e 's/stable\///'); do
echo $chart
mkdir -p $chart
pushd $chart

If you run this:

package main

import (
    "fmt"
    "github.com/pborman/uuid"
)
@mhrivnak
mhrivnak / vrtest.py
Last active December 17, 2017 20:17
Functional tests for RepositoryVersions
import time
import unittest
import requests
from requests.auth import HTTPBasicAuth
# usage: python3 -m unittest vrtest.py
#!/usr/bin/env python | 27 saxutils.XMLGenerator.characters(self, 'foo')
| 28 self._delivered_checksum = True
import gzip | 29 return
from xml import sax | 30 saxutils.XMLGenerator.characters(self, content)
from xml.sax import handler | 31
| 32 def endElement(self, name):
| 33 if name == 'checksum':
c
from collections import namedtuple
from threading import Lock
import time
class Session(object):
"""
This should actually be a Session object from the requests library. I'm
just lazy and made a simple stand-in.
"""
#!/usr/bin/env python
import subprocess
from urlparse import urlparse
repos = [
# Centos
{'name': 'centos-6-x86_64-base', 'feed': 'http://mirror.centos.org/centos/6/os/x86_64/'},
{'name': 'centos-6-x86_64-updates', 'feed': 'http://mirror.centos.org/centos/6/updates/x86_64/'},
{'name': 'centos-6-x86_64-extras', 'feed': 'http://mirror.centos.org/centos/6/extras/x86_64/'},
def get_unit_all_or_nothing(unit):
"""
Tries to download all files associated with a unit. As soon as one fails,
it aborts and abandons what has been downloaded so far.
I believe this is the current aggreed-upon plan.
"""
if unit.downloaded is True:
# nothing to do then!
return
class TestRepoUpdate(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.data = StuntData()
cls.repo_id = cls.data.create_repo(repotype='yum')
# call repo update API here
@classmethod
def tearDownClass(cls):
cls.data.cleanup()
response = None
for x in range(self.retries + 1):
try:
response = session.get(
request.url, headers=headers, timeout=(self.config.connect_timeout,
self.config.read_timeout)
)
except httplib.BadStatusLine:
continue
if response is None: