Signed-off-by: Isaku Yamahata <[email protected]> --- ryu/lib/ovs_bridge.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 ryu/lib/ovs_bridge.py
diff --git a/ryu/lib/ovs_bridge.py b/ryu/lib/ovs_bridge.py new file mode 100644 index 0000000..8dd006e --- /dev/null +++ b/ryu/lib/ovs_bridge.py @@ -0,0 +1,48 @@ +# Copyright (C) 2012 Isaku Yamahata <yamahata at private email ne jp> +# +# 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 under the License. + +""" +slimmed down version of OVSBridge in quantum agent +""" + +import logging +import signal +from subprocess import PIPE, Popen + + +LOG = logging.getLogger(__name__) + + +class OVSBridge(object): + def __init__(self, ovsdb_addr): + super(OVSBridge, self).__init__() + self.ovsdb_addr = ovsdb_addr + + @staticmethod + def run_cmd(args): + pipe = Popen(args, stdout=PIPE) + retval = pipe.communicate()[0] + if pipe.returncode == -(signal.SIGALRM): + LOG.debug('## timeout running command: ' + ' '.join(args)) + return retval + + def run_vsctl(self, args): + full_args = ['ovs-vsctl', '--db=%s' % self.ovsdb_addr, '--timeout=2'] + full_args += args + return self.run_cmd(full_args) + + def set_db_attribute(self, table_name, record, column, value): + args = ['set', table_name, record, '%s=%s' % (column, value)] + self.run_vsctl(args) -- 1.7.1.1 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
