Skip to content

Instantly share code, notes, and snippets.

Chris Dent cdent

Block or report user

Report or block cdent

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View allocation_candidates.json
{
"allocation_requests": [
{
"allocations": {
"e5a3195f-0466-4c88-be32-e8778d445d7c": {
"resources": {
"VCPU": 1
}
}
}
View placement_runme.sh
#!/bin/bash -e
# Either install from pip if no $1, or $1 is a path or URL
# to an installable placement (such as a local copy of the
# repo).
PLACEMENT_LOCATION=${1:-openstack-placement}
# Make the virtualenv
python -m virtualenv -p python3 placetest
View gist:98b2dba62af8b353bdfe089f4606b248
#!/bin/bash -e
# Either install from pip if no $1, or $1 is a path or URL
# to an installable placement (such as a local cop of the
# repo).
PLACEMENT_LOCATION=${1:-openstack-placement}
# Make the virtualenv
python -m virtualenv -p python3 placetest
View test_mig.py
import contextlib
import functools
import testtools
from alembic import script
import fixtures
import mock
from oslo_concurrency.fixture import lockutils as concurrency
from oslo_config import fixture as config_fixture
from oslo_db import exception as db_exc
View placement.sh
#!/bin/bash
set -xe
# Change these as required
CONF_DIR=/etc/placement
DB_DRIVER=mysql+pymysql # we assume mysql throughout, feel free to change
DB_NAME=placement
DB_USER=root
DB_PASS=secret
View README.md

Demo difference in behaviors between pyyaml 3 and 4 when using custom tags and safe loading. Also check against a pending Ingy change.

Run tox to see it in action. The different versions will do different things. Which is right?

The key difference is that in PyYAML 3 we see ConstructorErrors from safe_load and in PyYAML 4 they are from danger mode.

@cdent
cdent / README.md
Created Oct 28, 2017 — forked from FND/README.md
complate-wsgi sandbox
View README.md
$ python3 -m venv venv
$ . venv/bin/activate

$ pip install js2py gunicorn

$ gunicorn app:app

http://localhost:8000

View coerce.yaml
defaults:
request_headers:
content-type: application/json
verbose: True
tests:
- name: post data
POST: /
data:
@cdent
cdent / app.py
Last active Apr 16, 2018 — forked from FND/app.py
custom Python module importer
View app.py
from hook import register_import_hook
print('calling to register')
register_import_hook()
print('registered')
def later():
import test_foo
@cdent
cdent / extractbin.py
Created Nov 15, 2016
a tool to pull the binaries out of a fat json tiddlers collection
View extractbin.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
You can’t perform that action at this time.