Alon Bar-Lev has uploaded a new change for review. Change subject: openstack: quantum: initial support ......................................................................
openstack: quantum: initial support based on Moti Asayag <[email protected]> instructions. does not support rollback due to the use of openstack configuration utility. Change-Id: Ib62d079fea94d73d1f80f519298001a89d217575 Signed-off-by: Alon Bar-Lev <[email protected]> --- M README.environment M configure.ac M src/ovirt_host_deploy/constants.py M src/plugins/ovirt-host-deploy/Makefile.am A src/plugins/ovirt-host-deploy/openstack/Makefile.am A src/plugins/ovirt-host-deploy/openstack/__init__.py A src/plugins/ovirt-host-deploy/openstack/quantum.py A src/plugins/ovirt-host-deploy/openstack/quantum_linuxbridge.py A src/plugins/ovirt-host-deploy/openstack/quantum_openvswitch.py 9 files changed, 585 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy refs/changes/86/15986/1 diff --git a/README.environment b/README.environment index 4ba125d..1356cd4 100644 --- a/README.environment +++ b/README.environment @@ -63,3 +63,24 @@ GLUSTER/enable(str) [False] Instal gluster support. + +OPENSTACK/quantumEnable(bool) [False] + Enable quantum configuration. + +OPENSTACK_QUANTUM_CONFIG/section/key(str) + Set quantum configuration option. + +OPENSTACK/quantumLinuxBridgeEnable(bool) [False] + Enable quantum linux bridge plugin configuration. + +OPENSTACK_QUANTUM_LINUXBRIDGE_CONFIG/section/key(str) + Set quantum linux bridge plugin configuration option. + +OPENSTACK/quantumOpenvswitchEnable(bool) [False] + Enable quantum openvswitch plugin configuration. + +OPENSTACK/quantumOpenvswitchIntegrationBridge(str) [br-int] + Name of integration bridge. + +OPENSTACK_QUANTUM_OPENVSWITCH_CONFIG/section/key(str) + Set quantum openvswitch plugin configuration option. diff --git a/configure.ac b/configure.ac index 314b36d..41c36af 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,7 @@ src/plugins/ovirt-host-deploy/tune/Makefile src/plugins/ovirt-host-deploy/node/Makefile src/plugins/ovirt-host-deploy/gluster/Makefile + src/plugins/ovirt-host-deploy/openstack/Makefile src/java/Makefile src/java/pom.xml src/interface-3/Makefile diff --git a/src/ovirt_host_deploy/constants.py b/src/ovirt_host_deploy/constants.py index af91fef..f7097c1 100644 --- a/src/ovirt_host_deploy/constants.py +++ b/src/ovirt_host_deploy/constants.py @@ -54,6 +54,13 @@ HOOKS_PLUGIN_HOOKS_DIR = 'hooks.d' HOOKS_PLUGIN_PACKAGES_DIR = 'packages.d' + OPENSTACK_QUANTUM_CONFIG = '/etc/quantum/quantum.conf' + OPENSTACK_QUANTUM_PLUGIN_CONFIG = '/etc/quantum/plugin.ini' + OPENSTACK_QUANTUM_LINUXBRIDGE_CONFIG = \ + '/etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini' + OPENSTACK_QUANTUM_OPENVSWITCH_CONFIG = \ + '/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini' + @util.export class Defaults(object): @@ -108,6 +115,19 @@ @util.export @util.codegen +class OpenStackEnv(object): + QUANTUM_ENABLE = 'OPENSTACK/quantumEnable' + QUANTUM_CONFIG_PREFIX = 'OPENSTACK_QUANTUM_CONFIG/' + QUANTUM_LINUXBRIDGE_ENABLE = 'OPENSTACK/quantumLinuxBridgeEnable' + QUANTUM_LINUXBRIDGE_CONFIG_PREFIX = 'OPENSTACK_QUANTUM_LINUXBRIDGE_CONFIG/' + QUANTUM_OPENVSWITCH_ENABLE = 'OPENSTACK/quantumOpenvswitchEnable' + QUANTUM_OPENVSWITCH_INTERNAL_BRIDGE = \ + 'OPENSTACK/quantumOpenvswitchIntegrationBridge' + QUANTUM_OPENVSWITCH_CONFIG_PREFIX = 'OPENSTACK_QUANTUM_OPENVSWITCH_CONFIG/' + + [email protected] [email protected] class Queries(object): CERTIFICATE_CHAIN = 'VDSM_CERTIFICATE_CHAIN' diff --git a/src/plugins/ovirt-host-deploy/Makefile.am b/src/plugins/ovirt-host-deploy/Makefile.am index f256898..6287580 100644 --- a/src/plugins/ovirt-host-deploy/Makefile.am +++ b/src/plugins/ovirt-host-deploy/Makefile.am @@ -28,6 +28,7 @@ tune \ node \ gluster \ + openstack \ $(NULL) install-data-local: diff --git a/src/plugins/ovirt-host-deploy/openstack/Makefile.am b/src/plugins/ovirt-host-deploy/openstack/Makefile.am new file mode 100644 index 0000000..1859ccd --- /dev/null +++ b/src/plugins/ovirt-host-deploy/openstack/Makefile.am @@ -0,0 +1,40 @@ +# +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +include $(top_srcdir)/build/python.inc + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in \ + $(NULL) + +mydir=$(ovirthostdeployplugindir)/ovirt-host-deploy/openstack +dist_my_PYTHON = \ + __init__.py \ + quantum.py \ + quantum_linuxbridge.py \ + quantum_openvswitch.py \ + $(NULL) + +clean-local: \ + python-clean \ + $(NULL) + +all-local: \ + python-syntax-check \ + $(NULL) diff --git a/src/plugins/ovirt-host-deploy/openstack/__init__.py b/src/plugins/ovirt-host-deploy/openstack/__init__.py new file mode 100644 index 0000000..1ba58d8 --- /dev/null +++ b/src/plugins/ovirt-host-deploy/openstack/__init__.py @@ -0,0 +1,39 @@ +# +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +"""openstack plugin.""" + + +from otopi import util + + +from . import quantum +from . import quantum_linuxbridge +from . import quantum_openvswitch + + [email protected] +def createPlugins(context): + quantum.Plugin(context=context) + quantum_linuxbridge.Plugin(context=context) + quantum_openvswitch.Plugin(context=context) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/plugins/ovirt-host-deploy/openstack/quantum.py b/src/plugins/ovirt-host-deploy/openstack/quantum.py new file mode 100644 index 0000000..6d169d2 --- /dev/null +++ b/src/plugins/ovirt-host-deploy/openstack/quantum.py @@ -0,0 +1,119 @@ +# +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +"""quantum plugin.""" + + +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-host-deploy') + + +from otopi import util +from otopi import plugin + + +from ovirt_host_deploy import constants as odeploycons + + [email protected] +class Plugin(plugin.PluginBase): + """quantum. + + Environment: + OpenStackEnv.QUANTUM_ENABLE -- perform quantum installation. + OpenStackEnv.QUANTUM_CONFIG_PREFIX -- quantum configuration. + + TODO: + drop the use of openstack-config and update files directly + so we can rollback and backup. + + """ + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._enabled = False + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + odeploycons.OpenStackEnv.QUANTUM_ENABLE, + False + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('openstack-config') + + @plugin.event( + stage=plugin.Stages.STAGE_VALIDATION, + condition=lambda self: self.environment[ + odeploycons.OpenStackEnv.QUANTUM_ENABLE + ], + ) + def _validation(self): + self._enabled = True + + @plugin.event( + stage=plugin.Stages.STAGE_PACKAGES, + condition=lambda self: self._enabled, + ) + def _packages(self): + self.packager.installUpdate(('openstack-quantum',)) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + ) + def _misc(self): + vars = [ + var for var in self.environment + if var.startswith(odeploycons.OpenStackEnv.QUANTUM_CONFIG_PREFIX) + ] + + for var in vars: + try: + section, key = var.replace( + odeploycons.OpenStackEnv.QUANTUM_CONFIG_PREFIX, '' + ).split('/', 1) + except ValueError: + raise RuntimeError( + _('Invalid quantum configuration entry {key}').format( + key=key + ) + ) + + value = self.environment[var] + + self.execute( + ( + self.command.get('openstack-config'), + '--set', + odeploycons.FileLocations.OPENSTACK_QUANTUM_CONFIG, + section, + key, + value, + ), + ) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/plugins/ovirt-host-deploy/openstack/quantum_linuxbridge.py b/src/plugins/ovirt-host-deploy/openstack/quantum_linuxbridge.py new file mode 100644 index 0000000..ccca868 --- /dev/null +++ b/src/plugins/ovirt-host-deploy/openstack/quantum_linuxbridge.py @@ -0,0 +1,152 @@ +# +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +"""quantum linuxbridge plugin.""" + + +import os +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-host-deploy') + + +from otopi import util +from otopi import plugin + + +from ovirt_host_deploy import constants as odeploycons + + [email protected] +class Plugin(plugin.PluginBase): + """quantum linuxbridge. + + Environment: + OpenStackEnv.QUANTUM_LINUXBRIDGE_ENABLE -- + perform quantum linuxbridge plugin installation. + OpenStackEnv.QUANTUM_LINUXBRODGE_CONFIG_PREFIX -- + quantum linuxbridge configuration. + + TODO: + drop the use of openstack-config and update files directly + so we can rollback and backup. + + """ + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._enabled = False + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + odeploycons.OpenStackEnv.QUANTUM_LINUXBRIDGE_ENABLE, + False + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('openstack-config') + + @plugin.event( + stage=plugin.Stages.STAGE_VALIDATION, + condition=lambda self: self.environment[ + odeploycons.OpenStackEnv.QUANTUM_LINUXBRIDGE_ENABLE + ], + ) + def _validation(self): + self._enabled = True + + @plugin.event( + stage=plugin.Stages.STAGE_PACKAGES, + condition=lambda self: self._enabled, + ) + def _packages(self): + self.packager.installUpdate(('openstack-quantum-linuxbridge',)) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + ) + def _misc(self): + vars = [ + var for var in self.environment + if var.startswith( + odeploycons.OpenStackEnv. + QUANTUM_LINUXBRIDGE_CONFIG_PREFIX + ) + ] + + for var in vars: + try: + section, key = var.replace( + odeploycons.OpenStackEnv.QUANTUM_LINUXBRIDGE_CONFIG_PREFIX, + '' + ).split('/', 1) + except ValueError: + raise RuntimeError( + _('Invalid quantum configuration entry {key}').format( + key=key + ) + ) + + value = self.environment[var] + + self.execute( + ( + self.command.get('openstack-config'), + '--set', + ( + odeploycons.FileLocations. + OPENSTACK_QUANTUM_LINUXBRIDGE_CONFIG + ), + section, + key, + value, + ), + ) + if os.path.exists( + odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG + ): + os.unlink(odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG) + os.symlink( + odeploycons.FileLocations.OPENSTACK_QUANTUM_LINUXBRIDGE_CONFIG, + odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CLOSEUP, + condition=lambda self: ( + self._enabled and + not self.environment[ + odeploycons.CoreEnv.FORCE_REBOOT + ] + ), + ) + def _closeup(self): + self.logger.info(_('Starting quantum linuxbridge plugin')) + for state in (False, True): + self.services.state('quantum-linuxbridge-agent', state) + self.services.startup('quantum-linuxbridge-agent', True) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/src/plugins/ovirt-host-deploy/openstack/quantum_openvswitch.py b/src/plugins/ovirt-host-deploy/openstack/quantum_openvswitch.py new file mode 100644 index 0000000..065c0af --- /dev/null +++ b/src/plugins/ovirt-host-deploy/openstack/quantum_openvswitch.py @@ -0,0 +1,192 @@ +# +# ovirt-host-deploy -- ovirt host deployer +# Copyright (C) 2012-2013 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + + +"""quantum openvswitch plugin.""" + + +import os +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-host-deploy') + + +from otopi import util +from otopi import plugin + + +from ovirt_host_deploy import constants as odeploycons + + [email protected] +class Plugin(plugin.PluginBase): + """quantum openvswitch. + + Environment: + OpenStackEnv.QUANTUM_OPENVSWITCH_ENABLE -- + perform quantum openvswitch plugin installation. + OpenStackEnv.QUANTUM_OPENVSWITCH_INTERNAL_BRIDGE -- + internal bridge name. + OpenStackEnv.QUANTUM_LINUXBRODGE_CONFIG_PREFIX -- + quantum openvswitch configuration. + + TODO: + drop the use of openstack-config and update files directly + so we can rollback and backup. + + """ + def __init__(self, context): + super(Plugin, self).__init__(context=context) + self._enabled = False + + @plugin.event( + stage=plugin.Stages.STAGE_INIT, + ) + def _init(self): + self.environment.setdefault( + odeploycons.OpenStackEnv.QUANTUM_OPENVSWITCH_ENABLE, + False + ) + self.environment.setdefault( + odeploycons.OpenStackEnv.QUANTUM_OPENVSWITCH_INTERNAL_BRIDGE, + 'br-int' + ) + + @plugin.event( + stage=plugin.Stages.STAGE_SETUP, + ) + def _setup(self): + self.command.detect('openstack-config') + self.command.detect('ovs-vsctl') + + @plugin.event( + stage=plugin.Stages.STAGE_VALIDATION, + condition=lambda self: self.environment[ + odeploycons.OpenStackEnv.QUANTUM_OPENVSWITCH_ENABLE + ], + ) + def _validation(self): + self._enabled = True + + @plugin.event( + stage=plugin.Stages.STAGE_PACKAGES, + condition=lambda self: self._enabled, + ) + def _packages(self): + self.packager.installUpdate(('openstack-quantum-openvswitch',)) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + ) + def _misc(self): + vars = [ + var for var in self.environment + if var.startswith( + odeploycons.OpenStackEnv. + QUANTUM_OPENVSWITCH_CONFIG_PREFIX + ) + ] + + for var in vars: + try: + section, key = var.replace( + odeploycons.OpenStackEnv.QUANTUM_OPENVSWITCH_CONFIG_PREFIX, + '' + ).split('/', 1) + except ValueError: + raise RuntimeError( + _('Invalid quantum configuration entry {key}').format( + key=key + ) + ) + + value = self.environment[var] + + self.execute( + ( + self.command.get('openstack-config'), + '--set', + ( + odeploycons.FileLocations. + OPENSTACK_QUANTUM_OPENVSWITCH_CONFIG + ), + section, + key, + value, + ), + ) + if os.path.exists( + odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG + ): + os.unlink(odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG) + os.symlink( + odeploycons.FileLocations.OPENSTACK_QUANTUM_OPENVSWITCH_CONFIG, + odeploycons.FileLocations.OPENSTACK_QUANTUM_PLUGIN_CONFIG + ) + + @plugin.event( + stage=plugin.Stages.STAGE_MISC, + condition=lambda self: self._enabled, + ) + def _createBridge(self): + self.services.state('openvswitch', True) + self.execute( + ( + self.command.get('ovs-vsctl'), + 'add-br', + self.environment[ + odeploycons.OpenStackEnv. + QUANTUM_OPENVSWITCH_INTERNAL_BRIDGE + ], + ), + ) + for setting in self.environment.get( + odeploycons.OpenStackEnv.QUANTUM_OPENVSWITCH_CONFIG_PREFIX + + 'OVS/bridge_mappings', + '' + ).split(','): + setting = setting.strip() + bridge = setting.split(':')[1] + self.execute( + ( + self.command.get('ovs-vsctl'), + 'add-br', + bridge, + ), + ) + + @plugin.event( + stage=plugin.Stages.STAGE_CLOSEUP, + condition=lambda self: ( + self._enabled and + not self.environment[ + odeploycons.CoreEnv.FORCE_REBOOT + ] + ), + ) + def _closeup(self): + self.logger.info(_('Starting quantum openvswitch plugin')) + for state in (False, True): + self.services.state('quantum-openvswitch-agent', state) + self.services.startup('quantum-openvswitch-agent', True) + self.services.startup('quantum-ovs-cleanup', True) + self.services.startup('openvswitch', True) + + +# vim: expandtab tabstop=4 shiftwidth=4 -- To view, visit http://gerrit.ovirt.org/15986 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib62d079fea94d73d1f80f519298001a89d217575 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-host-deploy Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
