Use os-xenapi for neutron when XenServer as hypervisor
We have made os-xenapi repository to deal with XenServer Dom0 specific functions, this patch is to change neutron to use os-xenapi when XenServer is hypervisor and move the building RPM scripts into os-xenapi repo Depends-On: I8a31c81d9475387fe4ed7030b70b26098e588771 Change-Id: Ia958c366189386b1b5abbadbb4d74950aaa23bb2changes/30/402330/14
parent
3d5d9e8957
commit
bc23e29423
@ -1,16 +0,0 @@
|
||||
This directory contains files that are required for the XenAPI support.
|
||||
They should be installed in the XenServer / Xen Cloud Platform dom0.
|
||||
|
||||
If you install them manually, you will need to ensure that the newly
|
||||
added files are executable. You can do this by running the following
|
||||
command (from dom0):
|
||||
|
||||
chmod a+x /etc/xapi.d/plugins/*
|
||||
|
||||
Otherwise, you can build an rpm by running the following command:
|
||||
|
||||
./contrib/build-rpm.sh
|
||||
|
||||
and install the rpm by running the following command (from dom0):
|
||||
|
||||
rpm -i openstack-neutron-xen-plugins.rpm
|
@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
thisdir=$(dirname $(readlink -f "$0"))
|
||||
export NEUTRON_ROOT="$thisdir/../../../../../../"
|
||||
export PYTHONPATH=$NEUTRON_ROOT
|
||||
|
||||
cd $NEUTRON_ROOT
|
||||
VERSION=$(sh -c "(cat $NEUTRON_ROOT/neutron/version.py; \
|
||||
echo 'print version_info.release_string()') | \
|
||||
python")
|
||||
cd -
|
||||
|
||||
PACKAGE=openstack-neutron-xen-plugins
|
||||
RPMBUILD_DIR=$PWD/rpmbuild
|
||||
if [ ! -d $RPMBUILD_DIR ]; then
|
||||
echo $RPMBUILD_DIR is missing
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dir in BUILD BUILDROOT SRPMS RPMS SOURCES; do
|
||||
rm -rf $RPMBUILD_DIR/$dir
|
||||
mkdir -p $RPMBUILD_DIR/$dir
|
||||
done
|
||||
|
||||
rm -rf /tmp/$PACKAGE
|
||||
mkdir /tmp/$PACKAGE
|
||||
cp -r ../etc/xapi.d /tmp/$PACKAGE
|
||||
tar czf $RPMBUILD_DIR/SOURCES/$PACKAGE.tar.gz -C /tmp $PACKAGE
|
||||
|
||||
rpmbuild -ba --nodeps --define "_topdir $RPMBUILD_DIR" \
|
||||
--define "version $VERSION" \
|
||||
$RPMBUILD_DIR/SPECS/$PACKAGE.spec
|
@ -1,30 +0,0 @@
|
||||
Name: openstack-neutron-xen-plugins
|
||||
Version: %{version}
|
||||
Release: 1
|
||||
Summary: Files for XenAPI support.
|
||||
License: ASL 2.0
|
||||
Group: Applications/Utilities
|
||||
Source0: openstack-neutron-xen-plugins.tar.gz
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
%define debug_package %{nil}
|
||||
|
||||
%description
|
||||
This package contains files that are required for XenAPI support for Neutron.
|
||||
|
||||
%prep
|
||||
%setup -q -n openstack-neutron-xen-plugins
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT/etc
|
||||
cp -r xapi.d $RPM_BUILD_ROOT/etc
|
||||
chmod a+x $RPM_BUILD_ROOT/etc/xapi.d/plugins/*
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
/etc/xapi.d/plugins/*
|
@ -1,94 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
# Copyright 2012 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
#
|
||||
# XenAPI plugin for executing network commands (ovs, iptables, etc) on dom0
|
||||
#
|
||||
|
||||
import errno
|
||||
import gettext
|
||||
gettext.install('neutron', unicode=1)
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
import subprocess
|
||||
|
||||
import XenAPIPlugin
|
||||
|
||||
|
||||
MSG_UNAUTHORIZED = "Unauthorized command"
|
||||
MSG_NOT_FOUND = "Executable not found"
|
||||
|
||||
ALLOWED_CMDS = [
|
||||
'ip',
|
||||
'ipset',
|
||||
'iptables-save',
|
||||
'iptables-restore',
|
||||
'ip6tables-save',
|
||||
'ip6tables-restore',
|
||||
'sysctl',
|
||||
# NOTE(yamamoto): of_interface=native doesn't use ovs-ofctl
|
||||
'ovs-ofctl',
|
||||
'ovs-vsctl',
|
||||
'ovsdb-client',
|
||||
'conntrack',
|
||||
]
|
||||
|
||||
|
||||
class PluginError(Exception):
|
||||
"""Base Exception class for all plugin errors."""
|
||||
def __init__(self, *args):
|
||||
Exception.__init__(self, *args)
|
||||
|
||||
def _run_command(cmd, cmd_input):
|
||||
"""Abstracts out the basics of issuing system commands. If the command
|
||||
returns anything in stderr, a PluginError is raised with that information.
|
||||
Otherwise, the output from stdout is returned.
|
||||
"""
|
||||
try:
|
||||
pipe = subprocess.PIPE
|
||||
proc = subprocess.Popen(cmd, shell=False, stdin=pipe, stdout=pipe,
|
||||
stderr=pipe, close_fds=True)
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT:
|
||||
raise PluginError(MSG_NOT_FOUND)
|
||||
(out, err) = proc.communicate(cmd_input)
|
||||
return proc.returncode, out, err
|
||||
|
||||
|
||||
def run_command(session, args):
|
||||
cmd = json.loads(args.get('cmd'))
|
||||
if cmd and cmd[0] not in ALLOWED_CMDS:
|
||||
raise PluginError(MSG_UNAUTHORIZED)
|
||||
returncode, out, err = _run_command(
|
||||
cmd, json.loads(args.get('cmd_input', 'null')))
|
||||
if not err:
|
||||
err = ""
|
||||
if not out:
|
||||
out = ""
|
||||
# This runs in Dom0, will return to neutron-ovs-agent in compute node
|
||||
result = {'returncode': returncode,
|
||||
'out': out,
|
||||
'err': err}
|
||||
return json.dumps(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
XenAPIPlugin.dispatch({"run_command": run_command})
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- Now that rootwrap daemon mode is supported for XenServer, the
|
||||
``neutron-rootwrap-xen-dom0`` script is deprecated and will be removed
|
||||
in a next release.
|
Loading…
Reference in New Issue