Created
August 31, 2016 23:48
-
-
Save otherwiseguy/e1784525de342edc3e361a33407437b0 to your computer and use it in GitHub Desktop.
test replace_port
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:]) | |
# config.setup_logging() | |
# config.set_config_defaults() | |
BRIDGE = "mytestbr" | |
PORT = "myport" | |
MAC = "fa:16:3e:53:78:2d" | |
ip = ip_lib.IPWrapper() | |
dev = ip.device(PORT) | |
count = 0 | |
with ovs_lib.OVSBridge(BRIDGE) as br: | |
while True: | |
try: | |
count += 1 | |
br.replace_port( | |
PORT, ('type', 'internal'), | |
('external_ids', { | |
'iface-status': 'active', | |
'iface-id': '91ce28ed-5bda-4371-82f9-91ca73d2d4b0', | |
'attached-mac': MAC})) | |
dev.link.set_address(MAC) | |
# assert dev.link.address == MAC | |
# br.delete_port(PORT) | |
except RuntimeError as e: | |
print "set_address failed", e | |
raise | |
except KeyboardInterrupt: | |
print "Exiting with count", count | |
raise | |
except Exception as e: | |
print "Got exception, continuing", e | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment