Change plugin for adoptation to Fuel 8.0

Initial support of Fuel 8.0. Change metadata and other stuff.
Completed according changes for support new, granularted neutron tasks

Change-Id: Id8580ef4a00cbc1d185bcb3da60c7f54e3bb2c67
This commit is contained in:
Igor Gajsin 2015-10-27 19:47:20 +03:00
parent 92f96754ea
commit 9a1b486555
14 changed files with 1837 additions and 184 deletions

View File

@ -1,15 +0,0 @@
#!/bin/bash
. /root/openrc
router=router04
neutron router-gateway-clear $router
for port in $(neutron router-port-list $router| grep ip_a| cut -f 2 -d\ ); do
neutron router-interface-delete $router port=$port
neutron port-delete $port
done
for net in $(neutron net-list|grep '/'|cut -f 4 -d\ ); do
neutron net-delete $net
done

View File

@ -1,53 +0,0 @@
#!/bin/bash
if [ -f /etc/primary-controller.yaml ]; then
ln -sf /etc/primary-controller.yaml /etc/astute.yaml
elif [ -f /etc/controller.yaml ]; then
ln -sf /etc/controller.yaml /etc/astute.yaml
fi
plugin_name=fuel-plugin-vmware-dvs
plugin_version=1.1
ip=`hiera master_ip`
role=`hiera role`
port=8080
_hostname=$(hostname)
function _restart_crm_resource {
res=$1
_where=$(crm resource show $res| awk '{print $6}')
if [ "$_where" = "$_hostname" ];
then
echo restart $res
crm resource restart $res
else
echo resource $res launched not here
echo does not restart
fi
}
function _nova_patch {
wget -O /usr/lib/python2.7/dist-packages/nova.patch "http://$ip:$port/plugins/$plugin_name-$plugin_version/nova.patch" && cd /usr/lib/python2.7/dist-packages/ ; patch -N -p1 < nova.patch
sed -i s/url_timeout=.*/url_timeout=3600/ /etc/nova/nova.conf
}
function _restart_nova {
for resource in $(crm_mon -1|awk '/nova_compute_vmware/ {print $1}'); do
_restart_crm_resource $resource
done
}
case $role in
controller|primary-controller)
_nova_patch
_restart_nova
;;
compute-vmware)
_nova_patch
service nova-compute restart
;;
*)
echo "Not a vmware compute node"
;;
esac

View File

@ -0,0 +1,3 @@
notice('MODULAR: vmware_dvs overrride hiera task')
$src = '/etc/hiera/override/plugins.yaml'
$res = override_hiera($src)

View File

@ -17,15 +17,11 @@ notice('MODULAR: fuel-plugin-vmware-dvs')
$vc_hash = hiera('vcenter', {})
$dvs_hash = hiera('fuel-plugin-vmware-dvs', {})
$neutron_hash = hiera('quantum_settings', {})
$nets = $neutron_hash['predefined_networks']
$vsphere_hostname = inline_template('<%= @vc_hash["computes"][0]["vc_host"] %>')
$vsphere_login = inline_template('<%= @vc_hash["computes"][0]["vc_user"] %>')
$vsphere_password = inline_template('<%= @vc_hash["computes"][0]["vc_password"] %>')
$dvs_network_maps = inline_template('<%= @dvs_hash["vmware_dvs_net_maps"] %>')
$neutron_physnet = inline_template('<%= @neutron_hash["predefined_networks"]["net04"]["L2"]["physnet"] %>')
$access_hash = hiera('access', {})
$keystone_admin_tenant = $access_hash[tenant]
$pnets = $neutron_hash['L2']['phys_nets']
class {'vmware_dvs':
vsphere_hostname => $vsphere_hostname,
@ -33,9 +29,6 @@ class {'vmware_dvs':
vsphere_password => $vsphere_password,
network_maps => $dvs_network_maps,
neutron_physnet => $neutron_physnet,
nets => $nets,
pnets => $pnets,
keystone_admin_tenant => $keystone_admin_tenant,
driver_name => 'vmware_dvs',
neutron_url_timeout => '3600',
}

View File

@ -0,0 +1,199 @@
# Copyright (c) 2011 Citrix Systems, Inc.
# Copyright 2011 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.
"""VIF drivers for VMware."""
from oslo_config import cfg
from oslo_log import log as logging
from oslo_vmware import exceptions as vexc
from oslo_vmware import vim_util as vutil
from nova import exception
from nova.i18n import _LW
from nova.network import model
from nova.virt.vmwareapi import network_util
from nova.virt.vmwareapi import vm_util
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
vmwareapi_vif_opts = [
cfg.StrOpt('vlan_interface',
default='vmnic0',
help='Physical ethernet adapter name for vlan networking'),
cfg.StrOpt('integration_bridge',
default='br-int',
help='Name of Integration Bridge'),
]
CONF.register_opts(vmwareapi_vif_opts, 'vmware')
def _get_associated_vswitch_for_interface(session, interface, cluster=None):
# Check if the physical network adapter exists on the host.
if not network_util.check_if_vlan_interface_exists(session,
interface, cluster):
raise exception.NetworkAdapterNotFound(adapter=interface)
# Get the vSwitch associated with the Physical Adapter
vswitch_associated = network_util.get_vswitch_for_vlan_interface(
session, interface, cluster)
if not vswitch_associated:
raise exception.SwitchNotFoundForNetworkAdapter(adapter=interface)
return vswitch_associated
def ensure_vlan_bridge(session, vif, cluster=None, create_vlan=True):
"""Create a vlan and bridge unless they already exist."""
vlan_num = vif['network'].get_meta('vlan')
bridge = vif['network']['bridge']
vlan_interface = CONF.vmware.vlan_interface
network_ref = network_util.get_network_with_the_name(session, bridge,
cluster)
if network_ref and network_ref['type'] == 'DistributedVirtualPortgroup':
return network_ref
if not network_ref:
# Create a port group on the vSwitch associated with the
# vlan_interface corresponding physical network adapter on the ESX
# host.
vswitch_associated = _get_associated_vswitch_for_interface(session,
vlan_interface, cluster)
network_util.create_port_group(session, bridge,
vswitch_associated,
vlan_num if create_vlan else 0,
cluster)
network_ref = network_util.get_network_with_the_name(session,
bridge,
cluster)
elif create_vlan:
# Get the vSwitch associated with the Physical Adapter
vswitch_associated = _get_associated_vswitch_for_interface(session,
vlan_interface, cluster)
# Get the vlan id and vswitch corresponding to the port group
_get_pg_info = network_util.get_vlanid_and_vswitch_for_portgroup
pg_vlanid, pg_vswitch = _get_pg_info(session, bridge, cluster)
# Check if the vswitch associated is proper
if pg_vswitch != vswitch_associated:
raise exception.InvalidVLANPortGroup(
bridge=bridge, expected=vswitch_associated,
actual=pg_vswitch)
# Check if the vlan id is proper for the port group
if pg_vlanid != vlan_num:
raise exception.InvalidVLANTag(bridge=bridge, tag=vlan_num,
pgroup=pg_vlanid)
return network_ref
def _is_valid_opaque_network_id(opaque_id, bridge_id, integration_bridge,
num_networks):
return (opaque_id == bridge_id or
(num_networks == 1 and
opaque_id == integration_bridge))
def _get_network_ref_from_opaque(opaque_networks, integration_bridge, bridge):
num_networks = len(opaque_networks)
for network in opaque_networks:
if _is_valid_opaque_network_id(network['opaqueNetworkId'], bridge,
integration_bridge, num_networks):
return {'type': 'OpaqueNetwork',
'network-id': network['opaqueNetworkId'],
'network-name': network['opaqueNetworkName'],
'network-type': network['opaqueNetworkType']}
LOG.warning(_LW("No valid network found in %(opaque)s, from %(bridge)s "
"or %(integration_bridge)s"),
{'opaque': opaque_networks, 'bridge': bridge,
'integration_bridge': integration_bridge})
def _get_opaque_network(session, cluster):
host = vm_util.get_host_ref(session, cluster)
try:
opaque = session._call_method(vutil,
"get_object_property",
host,
"config.network.opaqueNetwork")
except vexc.InvalidPropertyException:
opaque = None
return opaque
def get_neutron_network(session, network_name, cluster, vif):
opaque = None
if vif['type'] != model.VIF_TYPE_DVS:
opaque = _get_opaque_network(session, cluster)
if opaque:
bridge = vif['network']['id']
opaque_networks = opaque.HostOpaqueNetworkInfo
network_ref = _get_network_ref_from_opaque(opaque_networks,
CONF.vmware.integration_bridge, bridge)
else:
bridge = network_name
network_ref = network_util.get_network_with_the_name(
session, network_name, cluster)
if not network_ref:
raise exception.NetworkNotFoundForBridge(bridge=bridge)
return network_ref
def get_network_ref(session, cluster, vif, is_neutron):
if is_neutron:
network_name = (vif['network']['bridge'] or
CONF.vmware.integration_bridge)
network_ref = get_neutron_network(session, network_name, cluster, vif)
try:
network_ref['dvs_port_key']=vif['details']['dvs_port_key']
except KeyError:
pass
else:
create_vlan = vif['network'].get_meta('should_create_vlan', False)
network_ref = ensure_vlan_bridge(session, vif, cluster=cluster,
create_vlan=create_vlan)
return network_ref
def get_vif_dict(session, cluster, vif_model, is_neutron, vif):
mac = vif['address']
name = vif['network']['bridge'] or CONF.vmware.integration_bridge
ref = get_network_ref(session, cluster, vif, is_neutron)
return {'network_name': name,
'mac_address': mac,
'network_ref': ref,
'iface_id': vif['id'],
'vif_model': vif_model}
def get_vif_info(session, cluster, is_neutron, vif_model, network_info):
vif_infos = []
if network_info is None:
return vif_infos
for vif in network_info:
vif_infos.append(get_vif_dict(session, cluster, vif_model,
is_neutron, vif))
return vif_infos
def get_network_device(hardware_devices, mac_address):
"""Return the network device with MAC 'mac_address'."""
if hardware_devices.__class__.__name__ == "ArrayOfVirtualDevice":
hardware_devices = hardware_devices.VirtualDevice
for device in hardware_devices:
if device.__class__.__name__ in vm_util.ALL_SUPPORTED_NETWORK_DEVICES:
if hasattr(device, 'macAddress'):
if device.macAddress == mac_address:
return device

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
module Puppet::Parser::Functions
newfunction(:override_hiera, :type => :rvalue,
:doc => <<-EOS
Construct properly network_maps string
EOS
) do |args|
raise(Puppet::ParseError, 'No file name provided!') if args.size < 1 or args[0] == ""
require 'yaml'
require 'fileutils'
file=args[0]
dir=File.dirname(file)
# read data
if File.exists?(file)
old_data = YAML::load_file(file) || {}
new_data = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }.merge(old_data)
else
new_data = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
end
# modify data
md = new_data["neutron_config"]["L2"]["mechanism_drivers"]
if not md or md == {}
md = "openvswitch,l2population,vmware_dvs"
else
if not md.include?('vmware_dvs')
md << ',vmware_dvs'
end
end
new_data["neutron_config"]["L2"]["mechanism_drivers"] = md
# write data
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
File.open(file, 'w') {|f| f.write new_data.to_yaml}
end
end

View File

@ -15,29 +15,43 @@
# == Class: ::vmware_dvs
#
# edit /etc/neutron/neturon.conf and /etc/neutron/plugin.ini
# recreate net04 and net04_ext on primary-controller
# restart the neutron-server
#
# === Parameters
#
# [*vsphere_hostname*]
# (required) String. This is a name or ip of VMware vSphere server
# (required) String. This is the name or ip of VMware vSphere server
#
# [*vsphere_login*]
# (required) String. This is the name of VMware vSphere user
#
# [*vsphere_password*]
# (required) String. This is the password of VMware vSphere user
#
# [*network_maps*]
# (required) String. This is a name of distributed vSwitch
#
# [*neutron_physnet*]
# (required) String. This is a name of physnet of neutron.
#
# [*driver_name*]
# (optional) String. This is the name of installed driver.
#
# [*neutron_url_timeout*]
# (optional) String. This is the timeout for neutron
class vmware_dvs(
$vsphere_hostname,
$vsphere_login,
$vsphere_password,
$network_maps,
$neutron_physnet,
$nets,
$pnets,
$keystone_admin_tenant,
$driver_name = 'vmware_dvs',
$neutron_url_timeout = '3600',
)
{
$true_network_maps = get_network_maps($network_maps, $neutron_physnet)
$primary_controller = inline_template("<% if File.exist?('/etc/primary-controller.yaml') -%>true<% end -%>")
Exec { path => '/usr/bin:/usr/sbin:/bin:/sbin' }
@ -57,14 +71,6 @@ class vmware_dvs(
'ml2_vmware/network_maps': value => $true_network_maps;
} ->
ini_subsetting {'vmware_dvs_driver':
path => '/etc/neutron/plugin.ini',
section => 'ml2',
setting => 'mechanism_drivers',
subsetting => $driver_name,
subsetting_separator => ','
}
file_line { 'neutron_timeout':
path => '/etc/haproxy/conf.d/085-neutron.cfg',
line => ' timeout server 1h',
@ -72,9 +78,9 @@ class vmware_dvs(
}
service { 'neutron-server':
ensure => running,
enable => true,
subscribe => [[Package['python-suds','python-mech-vmware-dvs']],Ini_Subsetting['vmware_dvs_driver']],
ensure => running,
enable => true,
subscribe => [[Package['python-suds','python-mech-vmware-dvs']]],
}
service {'haproxy':
@ -84,32 +90,22 @@ class vmware_dvs(
subscribe => File_Line['neutron_timeout'],
}
if $pnets['physnet2'] {
if $pnets['physnet2']['vlan_range'] {
$fallback = split($pnets['physnet2']['vlan_range'], ':')
Openstack::Network::Create_network {
tenant_name => $keystone_admin_tenant,
fallback_segment_id => $fallback[1]
}
}
# some changes for nova
nova_config {'neutron/url_timeout': value => $neutron_url_timeout}
file {'/usr/lib/python2.7/dist-packages/nova/virt/vmwareapi/vif.py':
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/vmware_dvs/vif.py'
}
if $primary_controller and $nets and !empty($nets) {
openstack::network::create_network{'net04':
netdata => $nets['net04'],
segmentation_type => 'vlan',
require => Service['neutron-server'],
} ->
openstack::network::create_network{'net04_ext':
netdata => $nets['net04_ext'],
segmentation_type => 'local',
} ->
openstack::network::create_router{'router04':
internal_network => 'net04',
external_network => 'net04_ext',
tenant_name => $keystone_admin_tenant
}
file {'/usr/lib/python2.7/dist-packages/nova/virt/vmwareapi/vm_util.py':
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/vmware_dvs/vm_util.py'
}
}

View File

@ -1,41 +1,27 @@
- id: delete-predefined-networks
- id: vmware-dvs-property-hypervisor_type
role: ['primary-controller']
required_for: [post_deployment_end]
requires: [post_deployment_start]
type: shell
parameters:
cmd: ./del_predefined_networks.sh 2>&1 | tee -a /tmp/dep_pre_nets.log
timeout: 120
- id: property-hypervisor_type
role: ['primary-controller']
required_for: [post_deployment_end]
requires: [upload_cirros]
requires: [disable_keystone_service_token]
type: shell
parameters:
cmd: ./add_hyperv_type.sh 2>&1 | tee -a /tmp/add_hyper_type.log
timeout: 120
- id: install-the-driver
role: ['primary-controller','controller']
required_for: [post_deployment_end]
requires: ['delete-predefined-networks']
type: shell
parameters:
cmd: ./install_the_driver.sh 2>&1 | tee -a /tmp/ins_the_drivers.log
timeout: 720
- id: install-the-driver-compute
type: shell
role: [compute-vmware]
required_for: [post_deployment_end]
requires: ['openstack-network-vmware-compute']
condition: "settings:common.use_vcenter.value == true"
parameters:
cmd: ./install_the_driver.sh 2>&1 | tee -a /tmp/ins_the_drivers.log
timeout: 720
- id: openstack-network-vmware-compute
- id: vmware-dvs-override-hiera
groups: ['primary-controller','controller', 'compute-vmware']
required_for: [openstack-network-plugins-l2]
requires: [openstack-network-server-config]
type: puppet
role: [compute-vmware]
required_for: ['install-the-driver-compute']
requires: ['delete-predefined-networks']
parameters:
puppet_manifest: puppet/manifests/override_hiera.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: vmware-dvs-openstack-network-vmware-compute
type: puppet
groups: ['compute-vmware']
required_for: [post_deployment_end]
requires: [vmware-dvs-override-hiera]
condition: "settings:common.use_vcenter.value == true"
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/openstack-network/openstack-network-compute.pp
@ -45,10 +31,11 @@
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/openstack-network/openstack-network-compute_pre.rb
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/openstack-network/openstack-network-compute_post.rb
- id: setup-neutron-plugin
role: ['primary-controller','controller']
required_for: [post_deployment_end]
requires: ['install-the-driver']
- id: vmware-dvs-setup-neutron-plugin
groups: ['primary-controller','controller']
required_for: [openstack-network-plugins-l2]
requires: [vmware-dvs-override-hiera]
type: puppet
parameters:
puppet_manifest: puppet/manifests/site.pp

View File

@ -1,30 +0,0 @@
diff --git a/nova/virt/vmwareapi/vif.py b/nova/virt/vmwareapi/vif.py
index 3d228d7..d513a74 100644
--- a/nova/virt/vmwareapi/vif.py
+++ b/nova/virt/vmwareapi/vif.py
@@ -155,6 +155,10 @@ def get_network_ref(session, cluster, vif, is_neutron):
network_name = (vif['network']['bridge'] or
CONF.vmware.integration_bridge)
network_ref = get_neutron_network(session, network_name, cluster, vif)
+ try:
+ network_ref['dvs_port_key']=vif['details']['dvs_port_key']
+ except KeyError:
+ pass
else:
create_vlan = vif['network'].get_meta('should_create_vlan', False)
network_ref = ensure_vlan_bridge(session, vif, cluster=cluster,
diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py
index bbf2835..be68010 100644
--- a/nova/virt/vmwareapi/vm_util.py
+++ b/nova/virt/vmwareapi/vm_util.py
@@ -339,6 +339,10 @@ def _create_vif_spec(client_factory, vif_info):
'ns0:DistributedVirtualSwitchPortConnection')
portgroup.switchUuid = network_ref['dvsw']
portgroup.portgroupKey = network_ref['dvpg']
+ try:
+ portgroup.portKey = network_ref['dvs_port_key']
+ except KeyError:
+ pass
backing.port = portgroup
else:
backing = client_factory.create(

View File

@ -118,7 +118,7 @@ Limitations:
#. Only VLANs are supported for tenant network separation (VxLAN support can
be added later, if project will be continued).
#. Only vSphere 5.5 is supported
#. Only vSphere 5.5 or 6.0 is supported
Alternatives
------------