Skip to content

Instantly share code, notes, and snippets.

@antoviaque
antoviaque / gist:443c8a507d52aaccf76b18a46258da56
Last active September 22, 2016 14:34
OpenCraft IM - Terminate VMs on instances linked to a closed/merged PR
# Ensure to disable auto-indent before pasting in ipython: %autoindent
# TODO: Disable monitoring
# TODO: Hide from UX (archive)
from pr_watch import github
for instance in OpenEdXInstance.objects.filter(watchedpullrequest__isnull=False):
pr = github.get_object_from_url('https://api.github.com/repos/{}/pulls/{}'.format(
instance.watchedpullrequest.target_fork_name,
instance.watchedpullrequest.github_pr_number
))
@antoviaque
antoviaque / gist:216046586b051c3ae1265b54f2d02f71
Last active September 22, 2016 05:41
OpenCraft IM - Automatically terminate old & failed VMs
# Ensure to disable auto-indent before pasting in ipython: %autoindent
from instance.models.appserver import Status
for instance in OpenEdXInstance.objects.all():
for appserver in instance.appserver_set.all():
if appserver.status == Status.ConfigurationFailed:
appserver.terminate_vm()
elif instance.active_appserver and appserver.created < instance.active_appserver.created:
appserver.terminate_vm()
@antoviaque
antoviaque / gist:0b6cc931290881de546319cf673186f6
Last active May 8, 2024 09:16
Open edX - SSO Doc - Draft

Third Party Authentication Features in Open edX: Technical Knowledge Transfer

Part 1: Background / Notes

  • Open edX has full, integrated support for three different types of third party auth provider:
    1. OAuth based providers (OAuth2 and the older OAuth v1). Google, Facebook, LinkedIn, and Azure Active Directory are available by default. Any other OAuth backends supported by python-social-auth v0.2.12 can be enabled by changing a configuration setting. Contributed by Google (John Cox).
    2. SAML / Shibboleth. SAML is an SSO standard mostly used by universities and corporations. Shibboleth is the name of a particular implementation of SAML, commonly used by higher ed. institutions.
    3. LTI. Users can use Learning Tools Interoperability® (LTI®) to authenticate. Support for this was contributed by UBC.
  • The Open edX platform also includes limited support for the following SSO providers.
  1. [
@antoviaque
antoviaque / gist:43a3a52fd9e5532615f341537bd40cdb
Last active July 1, 2016 12:25
Terminate all VMs of a given instance
def terminate_all_instance_vms(domain):
inst = OpenEdXInstance.objects.get(internal_lms_domain=domain)
for appserver in inst.appserver_set.all():
appserver.terminate_vm()
@antoviaque
antoviaque / gist:638836754a9819904a1d01e8e9d8344f
Created June 1, 2016 13:31
Terminate all VMs of all instances
def terminate_ALL_instance_vms():
for inst in OpenEdXInstance.objects.all():
for appserver in inst.appserver_set.all():
appserver.terminate_vm()
@antoviaque
antoviaque / gist:cac3a5fc7593134b777a1126fa32c976
Last active July 1, 2016 12:24
Terminate old VMs of an instance, keep the last one
def terminate_old_instance_vms(domain):
inst = OpenEdXInstance.objects.get(internal_lms_domain=domain)
for appserver in inst.appserver_set.all().order_by('-created')[1:]:
appserver.terminate_vm()
antoviaque@antoviaque-laptop:~/prog/opencraft$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'opencraft/xenial64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'opencraft/xenial64'
default: URL: https://atlas.hashicorp.com/opencraft/xenial64
==> default: Adding box 'opencraft/xenial64' (v1.2) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/opencraft/boxes/xenial64/versions/1.2/providers/virtualbox.box
==> default: Successfully added box 'opencraft/xenial64' (v1.2) for 'virtualbox'!
antoviaque@antoviaque-laptop:~/prog/opencraft$ vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
antoviaque@antoviaque-laptop:~/prog/opencraft$ vagrant box remove opencraft/xenial64
Removing box 'opencraft/xenial64' (v0) with provider 'virtualbox'...
antoviaque@antoviaque-laptop:~/prog/opencraft$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'opencraft/xenial64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
antoviaque@antoviaque-laptop:~/prog/edx/devops/deployment-secrets-databases$ ./venv/bin/ansible-playbook deploy/deploy-all.yml --vault-password-file .vault-pass -u ubuntu --extra-vars @private-extra-vars.yml
PLAY [Set up Mysql server] *****************************************************
TASK [setup] *******************************************************************
ok: [167.114.238.51]
TASK [configure-apt : apt-get update && dist-upgrade] **************************
ok: [167.114.238.51]
antoviaque@antoviaque-laptop:~/prog/edx/devops/deployment-secrets-services$ ./venv/bin/pip install -r requirements.txt
Collecting ansible==2.0.1 (from -r requirements.txt (line 1))
Collecting cryptography==1.3.1 (from -r requirements.txt (line 2))
Using cached cryptography-1.3.1.tar.gz
Collecting paramiko (from ansible==2.0.1->-r requirements.txt (line 1))
Using cached paramiko-1.16.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./venv/lib/python2.7/site-packages (from ansible==2.0.1->-r requirements.txt (line 1))
Collecting PyYAML (from ansible==2.0.1->-r requirements.txt (line 1))
Collecting pycrypto>=2.6 (from ansible==2.0.1->-r requirements.txt (line 1))
Using cached pycrypto-2.6.1.tar.gz