1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2013 Nicira, Inc.
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
18
# @author: Aaron Rosen, Nicira Networks, Inc.
20
from oslo.config import cfg
22
from nova.openstack.common import importutils
24
security_group_opts = [
25
cfg.StrOpt('security_group_api',
27
help='The full class name of the security API class'),
28
cfg.StrOpt('security_group_handler',
29
default='nova.network.sg.NullSecurityGroupHandler',
30
help='The full class name of the security group handler class'),
34
CONF.register_opts(security_group_opts)
36
NOVA_DRIVER = ('nova.api.openstack.compute.contrib.security_groups.'
37
'NativeNovaSecurityGroupAPI')
38
QUANTUM_DRIVER = ('nova.api.openstack.compute.contrib.security_groups.'
39
'NativeQuantumSecurityGroupAPI')
42
def get_openstack_security_group_driver():
43
if CONF.security_group_api.lower() == 'nova':
44
return importutils.import_object(NOVA_DRIVER)
45
elif CONF.security_group_api.lower() == 'quantum':
46
return importutils.import_object(QUANTUM_DRIVER)
48
return importutils.import_object(CONF.security_group_api)
51
def get_security_group_handler():
52
return importutils.import_object(CONF.security_group_handler)
55
def is_quantum_security_groups():
56
if CONF.security_group_api.lower() == "quantum":