1
1
# Copyright 2014-2015 Canonical Limited.
3
# This file is part of charm-helpers.
5
# charm-helpers is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3 as
7
# published by the Free Software Foundation.
9
# charm-helpers is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
17
15
''' Helpers for interacting with OpenvSwitch '''
26
def add_bridge(name, datapath_type=None):
29
27
''' Add the named bridge to openvswitch '''
30
28
log('Creating bridge {}'.format(name))
31
subprocess.check_call(["ovs-vsctl", "--", "--may-exist", "add-br", name])
29
cmd = ["ovs-vsctl", "--", "--may-exist", "add-br", name]
30
if datapath_type is not None:
31
cmd += ['--', 'set', 'bridge', name,
32
'datapath_type={}'.format(datapath_type)]
33
subprocess.check_call(cmd)
34
36
def del_bridge(name):