From 8a5c0bbda5d2e0074b4c78a18e685f11eeefac06 Mon Sep 17 00:00:00 2001 From: Juliano Martinez Date: Mon, 18 Jun 2012 19:30:36 -0300 Subject: [PATCH] Bug #1012418 - quantum agent for OVS does not install properly on Xen XCP This change added the feature to package and install the ovs-quantum-agent inside XS and XCP, added an option on Makefile to gen and install using python2.6 ( by default it will use 2.4 ) Change-Id: I8860d7dcb7e7b74125784cb0f33c6ca03b37702b --- quantum/plugins/openvswitch/Makefile | 48 +++++++++++++++---- .../agent/ovs-quantum-agent-xs_xcp.spec | 33 +++++++++++++ .../openvswitch/agent/xenserver_install.sh | 27 ++++++----- 3 files changed, 87 insertions(+), 21 deletions(-) create mode 100644 quantum/plugins/openvswitch/agent/ovs-quantum-agent-xs_xcp.spec diff --git a/quantum/plugins/openvswitch/Makefile b/quantum/plugins/openvswitch/Makefile index 3414c7195..7d6c133b6 100644 --- a/quantum/plugins/openvswitch/Makefile +++ b/quantum/plugins/openvswitch/Makefile @@ -1,18 +1,48 @@ -QUANTUM_PATH=../../../ - # TODO(bgh): DIST_DIR and target for plugin +PHONY: help AGENT_DIST_DIR=ovs_quantum_agent AGENT_DIST_TARBALL=ovs_quantum_agent.tgz +VERSION=$(shell python -c "import sys ; sys.path.append('../../../quantum/') ; import version ; print version.canonical_version_string()") +XAPI_PLUGINS_DIR=$(AGENT_DIST_DIR)/build/ovs-quantum-agent-$(VERSION)/etc/xapi.d/plugins +RPM_BUILD_ROOT=$(AGENT_DIST_DIR)/build/rpm + +help: + @echo "make agent-dist-xen - to create the ovs-quantum-agent-${VERSION}-1.noarch.rpm" + @echo "make agent-dist-xen-python26 - to create ovs-quantum-agent-${VERSION}-1.noarch.rpm and use python2.6" -agent-dist: distclean - mkdir $(AGENT_DIST_DIR) - cp agent/*.py $(AGENT_DIST_DIR) +agent-dist-xen:QUANTUM_LIBS=$(AGENT_DIST_DIR)/build/ovs-quantum-agent-$(VERSION)/usr/lib/python2.4/site-packages +agent-dist-xen-python26:QUANTUM_LIBS=$(AGENT_DIST_DIR)/build/ovs-quantum-agent-$(VERSION)/usr/lib/python2.6/site-packages + +agent-dist-xen agent-dist-xen-python26: distclean + yum --enablerepo=base install rpm-build + mkdir -p $(XAPI_PLUGINS_DIR) + mkdir -p $(QUANTUM_LIBS)/{quantum/plugins/openvswitch/common,quantum/openstack/common} + mkdir -p $(QUANTUM_LIBS)/quantum/agent/linux + mkdir -p $(RPM_BUILD_ROOT)/BUILD $(RPM_BUILD_ROOT)/SOURCES + mkdir -p $(RPM_BUILD_ROOT)/SRPMS $(RPM_BUILD_ROOT)/RPMS $(RPM_BUILD_ROOT)/SPECS + cp agent/*.py $(XAPI_PLUGINS_DIR) cp agent/*.sh $(AGENT_DIST_DIR) + cp agent/ovs-quantum-agent-xs_xcp.spec $(AGENT_DIST_DIR) + sed -i "s/VERSION/$(VERSION)/" $(AGENT_DIST_DIR)/ovs-quantum-agent-xs_xcp.spec cp README $(AGENT_DIST_DIR) - cp ../../../etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini $(AGENT_DIST_DIR) - tar -zcvf $(AGENT_DIST_TARBALL) $(AGENT_DIST_DIR)/ - @echo "Agent tarball created: $(AGENT_DIST_TARBALL)" + cp ../../../etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini $(XAPI_PLUGINS_DIR) + cp ../../agent/linux/{ovs_lib.py,utils.py,__init__.py} $(QUANTUM_LIBS)/quantum/agent/linux + test -d $(AGENT_DIST_DIR)/build/ovs-quantum-agent-$(VERSION)/usr/lib/python2.6/site-packages && \ + sed -i 's/Requires:.*/Requires: python26 python26-sqlalchemy python26-mysqldb/' \ + $(AGENT_DIST_DIR)/ovs-quantum-agent-xs_xcp.spec || true + test -d $(AGENT_DIST_DIR)/build/ovs-quantum-agent-$(VERSION)/usr/lib/python2.6/site-packages && \ + sed -i 's/env python/env python2.6/' $(XAPI_PLUGINS_DIR)/ovs_quantum_agent.py || true + cp ../../__init__.py $(QUANTUM_LIBS)/quantum/ + cp ../../agent/__init__.py $(QUANTUM_LIBS)/quantum/agent/ + cp ../__init__.py $(QUANTUM_LIBS)/quantum/plugins/ + cp __init__.py $(QUANTUM_LIBS)/quantum/plugins/openvswitch/ + cp common/{config.py,__init__.py} $(QUANTUM_LIBS)/quantum/plugins/openvswitch/common/ + cp ../../openstack/__init__.py $(QUANTUM_LIBS)/quantum/openstack/ + cp ../../openstack/common/{cfg.py,iniparser.py,__init__.py} $(QUANTUM_LIBS)/quantum/openstack/common/ + tar -czvpf ${RPM_BUILD_ROOT}/SOURCES/ovs-quantum-agent-${VERSION}.tgz -C $(AGENT_DIST_DIR)/build ovs-quantum-agent-${VERSION} + rpmbuild -ba --define "_topdir $(shell pwd)/$(RPM_BUILD_ROOT)" --clean $(AGENT_DIST_DIR)/ovs-quantum-agent-xs_xcp.spec + @echo "Agent package created: ovs_quantum_agent/build/rpm/RPMS/noarch/ovs-quantum-agent-${VERSION}-1.noarch.rpm" @echo "See README for installation details" all: @@ -23,5 +53,3 @@ clean: distclean: -rm -rf $(AGENT_DIST_DIR) -rm -f $(AGENT_DIST_TARBALL) - -PHONY: agent-dist clean distclean diff --git a/quantum/plugins/openvswitch/agent/ovs-quantum-agent-xs_xcp.spec b/quantum/plugins/openvswitch/agent/ovs-quantum-agent-xs_xcp.spec new file mode 100644 index 000000000..707e110ce --- /dev/null +++ b/quantum/plugins/openvswitch/agent/ovs-quantum-agent-xs_xcp.spec @@ -0,0 +1,33 @@ +Name: ovs-quantum-agent +Version: VERSION +Release: 1 +License: Apache2 +Group: System Environment/Base +Summary: Ovs Quantum Agent +Source: %{name}-%{version}.tgz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildArch: noarch +Requires: python python-sqlalchemy + +%description +OVS Quantum Agent + +%prep +%setup + +%install +rm -rf --preserve-root %{buildroot} +install -d -m 755 %{buildroot} +cp -af * %{buildroot} +pushd %{buildroot} +find ./usr ./etc -type f -o -type l | sed "s/\.//" > %{_builddir}/%{name}-%{version}/%{name}-%{version}-%{release}-filelist +popd + +%clean +[ %{buildroot} != / ] && rm -rf %{buildroot} + +%files -f %{_builddir}/%{name}-%{version}/%{name}-%{version}-%{release}-filelist + +%changelog +* Thu Jun 14 2012 Juliano Martinez - VERSION +- Creating quantum ovs agent package diff --git a/quantum/plugins/openvswitch/agent/xenserver_install.sh b/quantum/plugins/openvswitch/agent/xenserver_install.sh index a0a2a6f70..6c1efe945 100755 --- a/quantum/plugins/openvswitch/agent/xenserver_install.sh +++ b/quantum/plugins/openvswitch/agent/xenserver_install.sh @@ -1,33 +1,38 @@ #!/bin/bash CONF_FILE=/etc/xapi.d/plugins/ovs_quantum_plugin.ini +VERSION=$(python -c "import sys ; sys.path.append('../../../../quantum/') ; import version ; print version.canonical_version_string()") if [ ! -d /etc/xapi.d/plugins ]; then - echo "Am I on a xenserver? I can't find the plugins directory!" - exit 1 + echo "Am I on a xenserver? I can't find the plugins directory!" + exit 1 fi rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm -yum --enablerepo=epel -y install python-sqlalchemy0.5 -yum --enablerepo=base -y install MySQL-python +if [ "$1" == "with_python_2.6" ] ; then + yum --enablerepo=base -y install mx + yum --enablerepo=epel -y install python26 python26-sqlalchemy python26-mysqldb +else + yum --enablerepo=epel -y install python-sqlalchemy + yum --enablerepo=base -y install MySQL-python +fi -sed -i 's/enabled=1/enabled=0' /etc/yum.repos.d/epel.repo +sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo -cp ovs_quantum_agent.py /etc/xapi.d/plugins -cp ovs_quantum_plugin.ini /etc/xapi.d/plugins +rpm -Uvh $PWD/build/rpm/RPMS/noarch/ovs-quantum-agent-$VERSION-1.noarch.rpm xe network-list name-label="integration-bridge" | grep xapi >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo "No integration bridge found. Creating." - xe network-create name-label="integration-bridge" + echo "No integration bridge found. Creating." + xe network-create name-label="integration-bridge" fi BR=$(xe network-list name-label="integration-bridge" | grep "bridge.*:" | awk '{print $4}') CONF_BR=$(grep integration-bridge ${CONF_FILE} | cut -d= -f2) if [ "X$BR" != "X$CONF_BR" ]; then - echo "Integration bridge doesn't match configuration file; fixing." - sed -i -e "s/^integration-bridge =.*$/integration-bridge = ${BR}/g" $CONF_FILE + echo "Integration bridge doesn't match configuration file; fixing." + sed -i -e "s/^integration-bridge =.*$/integration-bridge = ${BR}/g" $CONF_FILE fi echo "Using integration bridge: $BR (make sure this is set in the nova configuration)" -- 2.45.2