Skip to content

Instantly share code, notes, and snippets.

View yosshy's full-sized avatar

Akira YOSHIYAMA yosshy

  • NEC Corporation
View GitHub Profile
@yosshy
yosshy / generate_ironic_state_machine_diagram.py
Last active July 26, 2017 00:04
OpenStack Ironic state machine diagram generator
from automaton.converters import pydot
from ironic.common import states
def edge_attrs_cb(start_state, on_event, end_state):
edge_attrs = {}
edge_attrs['label'] = on_event.replace("_", " ").strip()
if 'reverted' in on_event:
edge_attrs['fontcolor'] = 'darkorange'
if 'fail' in on_event:
@yosshy
yosshy / networking-ovn-metadata-proxy.diff
Created August 6, 2017 09:06
Patch for OVN metadata proxy in RDO
# diff -u a/networking_ovn/agent/metadata/agent.py b/networking_ovn/agent/metadata/agent.py
--- a/networking_ovn/agent/metadata/agent.py 2017-07-14 19:58:10.000000000 +0900
+++ b/networking_ovn/agent/metadata/agent.py 2017-08-06 18:41:39.129119566 +0900
@@ -248,8 +248,7 @@
# addresses, then tear the namespace down if needed. This might happen
# when there are no subnets yet created so metadata port doesn't have
# an IP address.
- if not (port and port.mac and
- port.external_ids.get(ovn_const.OVN_CIDRS_EXT_ID_KEY, None)):
+ if not (port and port.mac):
@yosshy
yosshy / get_vars.py
Last active August 10, 2017 01:27
Jinja2 variable collector
#!/usr/bin/python
import pprint
import re
import sys
RE = re.compile(r"{{ *(.*?) *}}")
VARS = {}
@yosshy
yosshy / count_openstack_repos.py
Last active September 6, 2017 09:38
OpenStack Repositories Counter
#!/usr/bin/python
import requests
import yaml
URL = ("https://git.openstack.org/cgit/openstack/"
"governance/plain/reference/projects.yaml")
@yosshy
yosshy / sydney2017.ical
Created October 29, 2017 09:50
iCalendar for OpenStack Summit Sydney 2017
BEGIN:VCALENDAR
DTSTART:20170507T080000
SUMMARY:OpenStack Summit Boston 2017
BEGIN:VEVENT
SUMMARY:Upstream Institute Sponsored by Lenovo - Day 1 (RSVP Required)
DTSTART;VALUE=DATE-TIME:20171104T030000Z
DTEND;VALUE=DATE-TIME:20171104T070000Z
UID:20363@openstacksummitboston2017
DESCRIPTION:OpenStack Upstream Institute is an intensive program designed
to share knowledge about the different ways of contributing to OpenStack l
@yosshy
yosshy / gen-dc-awx-gitea.sh
Last active December 14, 2019 12:51
Script to generate docker-compose.yml for building AWX + Gitea environment
#!/bin/bash
USER=admin
PASSWORD=password
SYSTEM_USER=sysuser
SYSTEM_PASSWORD=nomoresecret
SECRET_KEY=secrete
FQDN="awx.example.com"
AWX_HTTPS_PORT=443
@yosshy
yosshy / Fix IPv6 config in Monasca APIs
Last active July 30, 2019 04:23
Fix IPv6 config in Monasca APIs
diff --git a/monasca_api/conf/types.py b/monasca_api/conf/types.py
index 5edc56b..a5180e4 100644
--- a/monasca_api/conf/types.py
+++ b/monasca_api/conf/types.py
@@ -36,7 +36,7 @@ class HostAddressPortType(types.HostAddress):
super(HostAddressPortType, self).__init__(version, type_name=type_name)
def __call__(self, value):
- addr, port = value.split(':')
+ addr, port = value.rsplit(':', 1)
@yosshy
yosshy / gen_cert
Created September 14, 2019 10:57
gen_cert: Generate X509 Certificate and Private Key
#!/usr/bin/python
# usage: gen_cert [-h] [-C COUNTRY] [-ST STATE] [-L LOCALITY] [-O ORGANIZATION]
# [-OU ORGANIZATION_UNIT] [-CN COMMON_NAME] [-E EMAIL_ADDRESS]
# [-p PERIOD] [-d DNS] [-i IP] [-s SERIAL]
# certfile keyfile
#
# Generate X509 Certificate and Private Key
#
# positional arguments:
# certfile
@yosshy
yosshy / maze.py
Last active August 14, 2021 04:32
海外君の娘さんの朝のドリル solver
#!/usr/bin/env python
import sys
MAZE = [
"--------",
"-○○◎■□□ア",
"-□□×□△◎-",
"-■□□××△-",
@yosshy
yosshy / jtchecker.py
Last active September 26, 2021 13:04
Japanese translation checker for minikube
import codecs
import json
import re
import string
CHO_ON_PATTERN = re.compile(r"[ア-ンー・]+[アカガサザタダナハバパマヤラワァィゥェォ][^ア-ン]")
ILLEGAL_CHARACTERS = re.compile("[ ({【『[)}】』]”’,.・0123456789:/-]")
ILLEGAL_KANJI_PATTERN = re.compile("(下さい|無し|為|する事)")