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 / 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 / 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 / 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 / bmc_sol.diff
Last active July 10, 2017 07:41
SOL capability for IPMI server in pyghmi
commit 529fa89de14a4e2027dbfad79d7412b57b91f88a
Author: Akira Yoshiyama <[email protected]>
Date: Sun Jul 9 01:14:20 2017 +0900
Added SOL capability to BMC
diff --git a/bin/fakebmc b/bin/fakebmc
index 318970e..2647f11 100755
--- a/bin/fakebmc
+++ b/bin/fakebmc
@yosshy
yosshy / console.log
Created May 6, 2017 05:30
State machine of a node in OpenStack Baremetal (Ironic)
[root@ocata ~]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ironic.common import states
>>> states.machine
<ironic.common.fsm.FSM object at 0x2764f50>
>>> print(states.machine.pformat())
+----------------+---------+----------------+-------------------------------+------------------------------+
| Start | Event | End | On Enter | On Exit |
@yosshy
yosshy / boston2017.ical
Last active April 23, 2017 00:33
iCal for OpenStack Summit Boston 2017
BEGIN:VCALENDAR
DTSTART:20170507T080000
SUMMARY:OpenStack Summit Boston 2017
BEGIN:VEVENT
SUMMARY:OpenStack Upstream Institute\, Sponsored by Lenovo (Day 1)
DTSTART;VALUE=DATE-TIME:20170506T170000Z
DTEND;VALUE=DATE-TIME:20170506T220000Z
UID:18639@openstacksummitboston2017
DESCRIPTION:OpenStack Upstream Institute is an intensive program designed
to share knowledge about the different ways of contributing to OpenStack l
@yosshy
yosshy / split_log.py
Last active April 14, 2017 04:13
Split an OpenStack logfile into ones per request
#!/usr/bin/env python
import argparse
import re
import sys
# Log format:
# 2017-01-04 12:00:04.103 25416 DEBUG oslo_service.periodic_task
# [req-c28f86bb-9a6c-4c17-bbfc-8e00824fcff9 - - - - -]
@yosshy
yosshy / ironic.patch
Last active January 4, 2017 13:49
Ironic patch to support setting/getting boot devices of VMs on VMware ESXi with pxe_ssh driver
$ diff -u /tmp/ssh.py ironic/drivers/modules/ssh.py
--- /tmp/ssh.py 2017-01-02 07:06:46.896349353 -0500
+++ ironic/drivers/modules/ssh.py 2017-01-04 03:44:48.278981212 -0500
@@ -184,6 +184,10 @@
'get_node_macs': (
"vmsvc/device.getdevices {_NodeName_} | "
"grep macAddress | awk -F '\"' '{print $2}' || true"),
+ 'set_boot_device': (
+ 'vmbootdev {_NodeName_} {_BootDevice_}'),
+ 'get_boot_device': (
@yosshy
yosshy / command-line-example
Last active April 4, 2016 13:59
Console service daemon with logging output for ironic-conductor
# ./ironic-console-server.py -f /tmp/log -p 5555 -c "ipmitool -H 192.168.2.236 -U root -P opctest -I lanplus sol activate"
@yosshy
yosshy / case 1
Created December 8, 2015 14:14
some additional tests for oslo.policy with keystone
+----------------------------------+----------+---------+--------+
| ID | Name | Project | User |
+----------------------------------+----------+---------+--------+
| 9fe2ff9ee4384b1894a90878d3e92bab | _member_ | sample | sample |
| dbc42f57cb9645d8ba2e7cb24210a2ca | s4 | sample | sample |
| b907d1e97a544d608246e10fe1b608b0 | s3 | sample | sample |
| 932bf48856f345be81af257c3616b9e9 | s1 | sample | sample |
| bd9c438aa1fa4c398b2ae1fbe4defc78 | s2 | sample | sample |
+----------------------------------+----------+---------+--------+
( role:s1 or role:s2 or role:s3 ) or role:s4 (should be True): True