Openvswitch component implemented

* Openvswitch installer and uninstaller components added.
* Openvswitch component configuration added.
* RHEL distro updated with openvswitch commands.
* Components order corrected in personas files.
* Openvswitch configuring script removed.

Change-Id: I418f5b783da4db7c63c03c8bd3db21fbddbd8cd7
This commit is contained in:
Stanislav Kudriashev 2013-11-20 13:29:19 +02:00
parent d270e9f3ba
commit 0b84a8b8d4
11 changed files with 111 additions and 26 deletions

View File

@ -25,7 +25,8 @@ class L3Configurator(base.AgentConfigurator):
def _adjust_plugin_config(self, plugin_conf):
super(L3Configurator, self)._adjust_plugin_config(plugin_conf)
plugin_conf.add("external_network_bridge", "br-ex")
plugin_conf.add("external_network_bridge",
self.installer.get_option("external_bridge"))
plugin_conf.add("root_helper", "sudo neutron-rootwrap /etc/neutron/rootwrap.conf")
plugin_conf.add("use_namespaces", self.installer.get_option("use_namespaces",
default_value=True))

View File

@ -24,3 +24,9 @@ class OpenvswitchConfigurator(base.CorePluginConfigurator):
def __init__(self, installer):
super(OpenvswitchConfigurator, self).__init__(installer)
def _adjust_plugin_config(self, plugin_conf):
super(OpenvswitchConfigurator, self)._adjust_plugin_config(plugin_conf)
plugin_conf.add("integration_bridge",
self.installer.get_option("integration_bridge"))

View File

@ -14,16 +14,92 @@
# License for the specific language governing permissions and limitations
# under the License.
from anvil import colorizer
from anvil import exceptions as excp
from anvil import log as logging
from anvil import shell as sh
from anvil import utils
from anvil.components import base_install as binstall
from anvil.components import base_runtime as bruntime
LOG = logging.getLogger(__name__)
class OpenvswitchUninstaller(binstall.PkgUninstallComponent):
def __init__(self, *args, **kwargs):
binstall.PkgUninstallComponent.__init__(self, *args, **kwargs)
self.runtime = self.siblings.get('running')
def _del_bridge(self, name):
cmd_template = self.distro.get_command('openvswitch', 'del_bridge')
cmd = utils.expand_template_deep(cmd_template, {'NAME': name})
try:
sh.execute(cmd)
except excp.ProcessExecutionError:
LOG.warn("Failed to delete '%s' openvswitch bridge." % name)
def pre_uninstall(self):
bridges = self.get_option('bridges', default_value=[])
if bridges:
LOG.info("Attempting to delete %s bridges: %s."
% (colorizer.quote(self.name), ", ".join(bridges)))
LOG.info("Ensuring %s service is started before we use it."
% colorizer.quote(self.name))
self.runtime.start()
self.runtime.wait_active()
for bridge in bridges:
self._del_bridge(bridge)
class OpenvswitchInstaller(binstall.PkgInstallComponent):
def __init__(self, *args, **kwargs):
binstall.PkgInstallComponent.__init__(self, *args, **kwargs)
self.runtime = self.siblings.get('running')
def _add_bridge(self, name):
cmd_template = self.distro.get_command('openvswitch', 'add_bridge')
cmd = utils.expand_template_deep(cmd_template, {'NAME': name})
try:
sh.execute(cmd)
except excp.ProcessExecutionError:
LOG.warn("Failed to create '%s' openvswitch bridge." % name)
def post_install(self):
binstall.PkgInstallComponent.post_install(self)
bridges = self.get_option('bridges', default_value=[])
if bridges:
LOG.info("Attempting to create %s bridges: %s."
% (colorizer.quote(self.name), ", ".join(bridges)))
LOG.info("Ensuring %s service is started before we use it."
% colorizer.quote(self.name))
self.runtime.start()
self.runtime.wait_active()
for bridge in bridges:
self._add_bridge(bridge)
def configure(self):
# NOTE(skudriashev): configuration is not required for this component
pass
class OpenvswitchRuntime(bruntime.ServiceRuntime):
@property
def applications(self):
return ["openvswitch"]
def status_app(self, program):
status_cmd = self.get_command("status", program)
try:
output = sh.execute(status_cmd, shell=True)[0]
except excp.ProcessExecutionError:
return False
if utils.has_any(output, "is not running"):
return False
return True

View File

@ -12,6 +12,9 @@ use_namespaces: True
network_vlan_ranges: physnet1:100:299
physical_interface_mappings: physnet1:100:299
external_bridge: br-ex
integration_bridge: br-int
# When building a package for the neutron the arguments to the individual daemons
# will be expanded to include the following runtime arguments.
daemon_args:

View File

@ -0,0 +1,9 @@
# Settings for component openvswitch
---
# List of bridges to manage
bridges:
- $(neutron:external_bridge)
- $(neutron:integration_bridge)
...

View File

@ -51,6 +51,9 @@ commands:
set_pwd: mysql --user=$USER --password=$OLD_PASSWORD -e
"USE mysql; UPDATE user SET password=PASSWORD('$NEW_PASSWORD') WHERE User='$USER'; FLUSH PRIVILEGES;"
daemon: mysqld
openvswitch:
add_bridge: ovs-vsctl --may-exist add-br $NAME
del_bridge: ovs-vsctl --if-exists del-br $NAME
# Where component symlinks will go, the component name will become a directory
# under this directory where its configuration files will be connected to there
# actual location.
@ -277,6 +280,14 @@ components:
test: anvil.components.openstack_client:OpenStackClientTester
coverage: anvil.components.openstack_client:OpenStackClientTester
uninstall: anvil.components.base_install:PkgUninstallComponent
openvswitch:
action_classes:
install: anvil.components.openvswitch:OpenvswitchInstaller
running: anvil.components.openvswitch:OpenvswitchRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.openvswitch:OpenvswitchUninstaller
packages:
- name: openvswitch
oslo-config:
action_classes:
install: anvil.components.base_install:PythonInstallComponent
@ -373,10 +384,4 @@ components:
test: anvil.components.base_testing:PythonTestingComponent
coverage: anvil.components.base_testing:PythonTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
openvswitch:
action_classes:
install: anvil.components.base_install:PkgInstallComponent
running: anvil.components.openvswitch:OpenvswitchRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
...

View File

@ -15,6 +15,7 @@ components:
- heat-client
- neutron-client
- swift-client
- openvswitch
- neutron
- cinder
- nova

View File

@ -14,6 +14,7 @@ components:
- cinder-client
- neutron-client
- swift-client
- openvswitch
- neutron
- cinder
- nova

View File

@ -16,8 +16,8 @@ components:
- heat-client
- neutron-client
- swift-client
- neutron
- openvswitch
- neutron
- cinder
- nova
- nova-client

View File

@ -22,10 +22,10 @@ options:
nova:
db-sync: true
do-network-init: true
mq-type: "rabbit"
enable-cells: false
enable-spice: false
local-conductor: false
mq-type: rabbit
glance:
db-sync: true
load-images: true

View File

@ -1,17 +0,0 @@
#!/bin/bash
# This is a sample script to configure OpenVSwitch for
# development needs.
echo 'Startig openvswitch service'
sudo /etc/init.d/openvswitch start
echo "Creating internal bridge 'br-int'"
sudo ovs-vsctl add-br br-int
echo "Creating external bridge 'br-ex'"
sudo ovs-vsctl add-br br-ex
echo "Adding a network interface 'eth1'"
sudo ovs-vsctl add-port br-ex eth1