This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(x, y): | |
val = 0 | |
for i in range(x + y): | |
val += 1 | |
return val | |
import mock | |
import unittest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py | |
index f96e31c..aee88d6 100644 | |
--- a/neutron/agent/common/ovs_lib.py | |
+++ b/neutron/agent/common/ovs_lib.py | |
@@ -87,12 +87,13 @@ def _ovsdb_retry(fn): | |
class VifPort(object): | |
- def __init__(self, port_name, ofport, vif_id, vif_mac, switch): | |
+ def __init__(self, port_name, ofport, vif_id, vif_mac, switch, other=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{!?upstream_version: %global upstream_version %{version}%{?milestone}} | |
# Python3 support in OpenStack starts with version 3.5, | |
# which is only in Fedora 24+ | |
%if 0%{?fedora} >= 24 | |
%global with_python3 1 | |
%endif | |
%global library ovsdbapp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from neutron.agent.common import ovs_lib | |
from neutron.agent.linux import ip_lib | |
# import sys | |
# from oslo_config import cfg | |
# from neutron.common import config | |
# | |
# config.init(sys.argv[1:]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FakeSchemaHelper(object): | |
def register_table(self, table): | |
print "register_table(%s)" % table | |
def register_columns(self, table, columns, read_only=None): | |
print "register_column(%s, %s, %s)" % (table, str(columns), | |
str(read_only)) | |
def register_all(self): | |
print "register_all" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
set -e | |
IMAGE=rhel | |
# Create private network | |
neutron net-create privateA | |
neutron subnet-create --ip_version 4 --gateway 10.1.0.1 --name privateA privateA 10.1.0.0/24 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
eventlet.monkey_patch() | |
import os | |
import time | |
def fun(): | |
num = 0 | |
while True: | |
print num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddLogicalPortCommand(BaseCommand): | |
# required values or values that need processing enumerated, optional | |
# columns as kwargs | |
def __init__(self, api, lswitch_name, lport_name, may_exist, **columns): | |
super(AddLogicalPortCommand, self).__init__(api) | |
self.lswitch_name = lswitch_name | |
self.lport_name = lport_name | |
self.may_exist = may_exist | |
self.columns == columns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import six | |
@six.add_metaclass(abc.ABCMeta) | |
class NotifyDict(dict): | |
NOT_FOUND = object() | |
@abc.abstractmethod | |
def on_create(self, key, val): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def autocommit(fn): | |
def wrapper(*args, **kwargs): | |
self = args[0] | |
cmd = fn(*args, **kwargs) | |
if isinstance(self, Transaction): | |
self.commands.append(cmd) | |
return cmd | |
else: | |
return cmd.execute() | |
return wrapper |