Create ovs port with other params together
When create ovs port in nova, it will first create ovs port using one commnd and set other parameters using seperated commands, but this isn't the correct way, because once the ovs port is created, neutron ove agent will monitor the chagne immediately and deals with the new added port, however, at this time, the other params are not set in ovs, this patch is to make creating ovs port and setting corresponding params in one operation In this patch, we add new Dom0 plugin functions ovs_create_port() and wrapper file host_network.py for calling Dom0 plugin Change-Id: Ic7bab9fd3eeed8be3f1493716178189bcf048da1 Partial-Bug: #1649747
This commit is contained in:
parent
beb6df6390
commit
5fb4ce9c3e
24
os_xenapi/client/host_network.py
Normal file
24
os_xenapi/client/host_network.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
def ovs_create_port(session, bridge, port, iface_id, mac, status):
|
||||
args = {'cmd': 'ovs_create_port',
|
||||
'args': {'bridge': bridge,
|
||||
'port': port,
|
||||
'iface-id': iface_id,
|
||||
'mac': mac,
|
||||
'status': status}
|
||||
}
|
||||
session.call_plugin_serialized('xenhost.py', 'network_config', args)
|
@ -66,7 +66,7 @@ class XenAPISession(object):
|
||||
# changed in development environments.
|
||||
# MAJOR VERSION: Incompatible changes with the plugins
|
||||
# MINOR VERSION: Compatible changes, new plguins, etc
|
||||
PLUGIN_REQUIRED_VERSION = '2.0'
|
||||
PLUGIN_REQUIRED_VERSION = '2.1'
|
||||
|
||||
def __init__(self, url, user, pw, originator="os-xenapi", timeout=10,
|
||||
concurrent=5):
|
||||
|
@ -37,7 +37,8 @@ import utils
|
||||
# 1.7 - Add Partition utilities plugin
|
||||
# 1.8 - Add support for calling plug-ins with the .py suffix
|
||||
# 2.0 - Remove plugin files which don't have .py suffix
|
||||
PLUGIN_VERSION = "2.0"
|
||||
# 2.1 - Add interface ovs_create_port in xenhost.py
|
||||
PLUGIN_VERSION = "2.1"
|
||||
|
||||
|
||||
def get_version(session):
|
||||
|
@ -260,6 +260,22 @@ def _ovs_add_port(args):
|
||||
return _run_command(cmd_args)
|
||||
|
||||
|
||||
def _ovs_create_port(args):
|
||||
bridge = pluginlib.exists(args, 'bridge')
|
||||
port = pluginlib.exists(args, 'port')
|
||||
iface_id = pluginlib.exists(args, 'iface-id')
|
||||
mac = pluginlib.exists(args, 'mac')
|
||||
status = pluginlib.exists(args, 'status')
|
||||
cmd_args = ['ovs-vsctl', '--', '--if-exists', 'del-port', port,
|
||||
'--', 'add-port', bridge, port,
|
||||
'--', 'set', 'Interface', port,
|
||||
'external_ids:iface-id=%s' % iface_id,
|
||||
'external_ids:iface-status=%s' % status,
|
||||
'external_ids:attached-mac=%s' % mac,
|
||||
'external_ids:xs-vif-uuid=%s' % iface_id]
|
||||
return _run_command(cmd_args)
|
||||
|
||||
|
||||
def _ip_link_get_dev(args):
|
||||
device_name = pluginlib.exists(args, 'device_name')
|
||||
cmd_args = ['ip', 'link', 'show', device_name]
|
||||
@ -338,6 +354,7 @@ ALLOWED_NETWORK_CMDS = {
|
||||
# allowed cmds to config OVS bridge
|
||||
'ovs_add_patch_port': _ovs_add_patch_port,
|
||||
'ovs_add_port': _ovs_add_port,
|
||||
'ovs_create_port': _ovs_create_port,
|
||||
'ovs_del_port': _ovs_del_port,
|
||||
'ovs_del_br': _ovs_del_br,
|
||||
'ovs_set_if_external_id': _ovs_set_if_external_id,
|
||||
|
@ -35,7 +35,7 @@ class SessionTestCase(base.TestCase):
|
||||
mock_verify_plugin_version):
|
||||
concurrent = 2
|
||||
originator = 'os-xenapi-nova'
|
||||
version = '2.0'
|
||||
version = '2.1'
|
||||
timeout = 10
|
||||
sess = mock.Mock()
|
||||
mock_create_session.return_value = sess
|
||||
|
Loading…
x
Reference in New Issue
Block a user