Add support for containerized keystone to VIM

Adding support to the VIM for containerized keystone. The
VIM will now support two keystone instances:
- platform: bare metal keystone used to authenticate with
  platform services (e.g. sysinv, patching)
- openstack: containerized keystone used to authenticate with
  openstack services (e.g. nova, neutron, cinder)

For now, the VIM will use the same baremetal keystone for both
the platform and openstack, because we still only deploy with
the baremetal keystone.

Story: 2002876
Task: 26872

Depends-On: If4bd46a4c14cc65978774001cb2887e5d3e3607b
Change-Id: Id1ec639aa347e0c4e4019576d3c36c8c72aefedf
This commit is contained in:
Bart Wensley 2018-10-02 06:59:36 -05:00
parent 4873ce0772
commit e547b8c136
31 changed files with 768 additions and 424 deletions

View File

@ -3,12 +3,25 @@
#
# SPDX-License-Identifier: Apache-2.0
#
[platform]
username=admin
tenant=admin
authorization_protocol=http
authorization_ip=192.168.204.2
authorization_port=5000
user_domain_name=Default
project_domain_name=Default
keyring_service=CGCS
[openstack]
username=admin
tenant=admin
authorization_protocol=http
authorization_ip=192.168.204.2
authorization_port=5000
user_domain_name=Default
project_domain_name=Default
keyring_service=CGCS
[keystone]
region_name=RegionOne

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -33,7 +33,3 @@ def load(config_file):
config = Config()
config.read(config_file)
CONF = config.as_dict()
password = CONF['openstack'].get('password', None)
if password is None:
CONF['openstack']['password'] = None

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -569,7 +569,8 @@ class NFVIBlockStorageAPI(nfvi.api.v1.NFVIBlockStorageAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
def finalize(self):
"""

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -2902,7 +2902,8 @@ class NFVIComputeAPI(nfvi.api.v1.NFVIComputeAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
self._rpc_listener = rpc_listener.RPCListener(
config.CONF['amqp']['host'], config.CONF['amqp']['port'],

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -850,7 +850,8 @@ class NFVIGuestAPI(nfvi.api.v1.NFVIGuestAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.PLATFORM)
self._rest_api_server = rest_api.rest_api_get_server(
config.CONF['guest-rest-api']['host'],

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -114,7 +114,8 @@ class NFVIIdentityAPI(nfvi.api.v1.NFVIIdentityAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
def finalize(self):
"""

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -591,7 +591,8 @@ class NFVIImageAPI(nfvi.api.v1.NFVIImageAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
def finalize(self):
"""

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -759,7 +759,8 @@ class NFVINetworkAPI(nfvi.api.v1.NFVINetworkAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
def finalize(self):
"""

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2016 Wind River Systems, Inc.
# Copyright (c) 2016-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -268,7 +268,8 @@ class NFVISwMgmtAPI(nfvi.api.v1.NFVISwMgmtAPI):
Initialize the plugin
"""
config.load(config_file)
self._directory = openstack.get_directory(config)
self._directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.PLATFORM)
def finalize(self):
"""

View File

@ -6,7 +6,7 @@
from nfv_common import debug
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.fm')
@ -16,7 +16,7 @@ def get_alarms(token):
"""
Asks Fault Management for customer alarms
"""
url = token.get_service_url(OPENSTACK_SERVICE.FM)
url = token.get_service_url(PLATFORM_SERVICE.FM)
if url is None:
raise ValueError("OpenStack FM URL is invalid")
@ -30,7 +30,7 @@ def get_logs(token, start=None, end=None):
"""
Asks Fault Management for customer logs
"""
url = token.get_service_url(OPENSTACK_SERVICE.FM)
url = token.get_service_url(PLATFORM_SERVICE.FM)
if url is None:
raise ValueError("OpenStack FM URL is invalid")
@ -59,7 +59,7 @@ def get_alarm_history(token, start=None, end=None):
"""
Asks Fault Management for customer alarm history
"""
url = token.get_service_url(OPENSTACK_SERVICE.FM)
url = token.get_service_url(PLATFORM_SERVICE.FM)
if url is None:
raise ValueError("OpenStack FM URL is invalid")

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -11,7 +11,7 @@ from nfv_common.helpers import Constant
from nfv_common.helpers import Constants
from nfv_common.helpers import Singleton
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.guest')
@ -86,7 +86,7 @@ def host_services_create(token, host_uuid, host_name):
"""
Create host services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -109,7 +109,7 @@ def host_services_enable(token, host_uuid, host_name):
"""
Enable host services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -132,7 +132,7 @@ def host_services_disable(token, host_uuid, host_name):
"""
Disable host services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -155,7 +155,7 @@ def host_services_delete(token, host_uuid):
"""
Delete host services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -173,7 +173,7 @@ def host_services_query(token, host_uuid, host_name):
"""
Query host services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -196,7 +196,7 @@ def guest_services_create(token, instance_uuid, host_name, services):
"""
Create guest services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -220,7 +220,7 @@ def guest_services_set(token, instance_uuid, host_name, services):
"""
Set guest services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -244,7 +244,7 @@ def guest_services_delete(token, instance_uuid):
"""
Delete guest services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -262,7 +262,7 @@ def guest_services_query(token, instance_uuid):
"""
Query guest services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -280,7 +280,7 @@ def guest_services_vote(token, instance_uuid, host_name, action):
"""
Ask guest services to vote
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")
@ -304,7 +304,7 @@ def guest_services_notify(token, instance_uuid, host_name, action):
"""
Notify guest services
"""
url = token.get_service_url(OPENSTACK_SERVICE.GUEST)
url = token.get_service_url(PLATFORM_SERVICE.GUEST)
if url is None:
raise ValueError("OpenStack Guest URL is invalid")

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -11,7 +11,7 @@ from nfv_common.helpers import Constant
from nfv_common.helpers import Constants
from nfv_common.helpers import Singleton
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.mtc')
@ -35,7 +35,7 @@ def system_query(token):
"""
Query Maintenance for the system information
"""
url = token.get_service_url(OPENSTACK_SERVICE.MTC)
url = token.get_service_url(PLATFORM_SERVICE.MTC)
if url is None:
raise ValueError("OpenStack Mtc URL is invalid")
@ -53,7 +53,7 @@ def host_query(token, host_uuid, host_name):
"""
Query Maintenance for the host information
"""
url = token.get_service_url(OPENSTACK_SERVICE.MTC)
url = token.get_service_url(PLATFORM_SERVICE.MTC)
if url is None:
raise ValueError("OpenStack Mtc URL is invalid")
@ -76,7 +76,7 @@ def notify_host_severity(token, host_uuid, host_name, host_severity):
"""
Notify Maintenance the severity of a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.MTC)
url = token.get_service_url(PLATFORM_SERVICE.MTC)
if url is None:
raise ValueError("OpenStack Mtc URL is invalid")

View File

@ -16,6 +16,36 @@ from nfv_common.helpers import Singleton
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.objects')
@six.add_metaclass(Singleton)
class ServiceCategory(Constants):
"""
Service Category Constants
"""
PLATFORM = Constant('platform')
OPENSTACK = Constant('openstack')
# Service Category Constant
SERVICE_CATEGORY = ServiceCategory()
@six.add_metaclass(Singleton)
class PlatformServices(Constants):
"""
Platform Services Constants
"""
GUEST = Constant('guest')
KEYSTONE = Constant('keystone')
MTC = Constant('mtc')
SYSINV = Constant('sysinv')
PATCHING = Constant('patching')
FM = Constant('fm')
# Platform Services Constant
PLATFORM_SERVICE = PlatformServices()
@six.add_metaclass(Singleton)
class OpenStackServices(Constants):
"""
@ -24,15 +54,10 @@ class OpenStackServices(Constants):
CEILOMETER = Constant('ceilometer')
CINDER = Constant('cinder')
GLANCE = Constant('glance')
GUEST = Constant('guest')
KEYSTONE = Constant('keystone')
MTC = Constant('mtc')
NEUTRON = Constant('neutron')
NOVA = Constant('nova')
SYSINV = Constant('sysinv')
HEAT = Constant('heat')
PATCHING = Constant('patching')
FM = Constant('fm')
# OpenStack Services Constant
@ -91,9 +116,12 @@ class Directory(object):
"""
Directory
"""
def __init__(self, auth_protocol, auth_host, auth_port, auth_project,
def __init__(self, service_category, keyring_service, auth_protocol,
auth_host, auth_port, auth_project,
auth_username, auth_password, auth_user_domain_name,
auth_project_domain_name, auth_uri=None):
self._service_category = service_category
self._keyring_service = keyring_service
self._auth_protocol = auth_protocol
self._auth_host = auth_host
self._auth_port = auth_port
@ -105,6 +133,20 @@ class Directory(object):
self._auth_project_domain_name = auth_project_domain_name
self._entries = dict()
@property
def service_category(self):
"""
Returns the service category
"""
return self._service_category
@property
def keyring_service(self):
"""
Returns the keyring service
"""
return self._keyring_service
@property
def auth_protocol(self):
"""

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -9,6 +9,8 @@ import urllib2
from nfv_common import debug
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import SERVICE_CATEGORY
from nfv_plugins.nfvi_plugins.openstack.objects import Directory
from nfv_plugins.nfvi_plugins.openstack.objects import Token
@ -33,7 +35,8 @@ def get_token(directory):
if directory.auth_password is None:
import keyring
password = keyring.get_password('CGCS', directory.auth_username)
password = keyring.get_password(directory.keyring_service,
directory.auth_username)
else:
password = directory.auth_password
@ -75,27 +78,38 @@ def get_token(directory):
return None
def get_directory(config):
def get_directory(config, service_category):
"""
Get directory information from the given configuration
Get directory information from the given configuration for the given
service category.
"""
openstack_info = config.CONF.get('openstack', None)
if openstack_info is not None:
auth_uri = openstack_info.get('authorization_uri', None)
if SERVICE_CATEGORY.PLATFORM == service_category:
services = PLATFORM_SERVICE
elif SERVICE_CATEGORY.OPENSTACK == service_category:
services = OPENSTACK_SERVICE
else:
raise ValueError("service_category is invalid: %s" % service_category)
auth_info = config.CONF.get(service_category, None)
if auth_info is not None:
auth_uri = auth_info.get('authorization_uri', None)
else:
auth_uri = None
directory = Directory(config.CONF['openstack']['authorization_protocol'],
config.CONF['openstack']['authorization_ip'],
config.CONF['openstack']['authorization_port'],
config.CONF['openstack']['tenant'],
config.CONF['openstack']['username'],
config.CONF['openstack']['password'],
config.CONF['openstack']['user_domain_name'],
config.CONF['openstack']['project_domain_name'],
auth_uri)
directory = Directory(
service_category,
config.CONF[service_category]['keyring_service'],
config.CONF[service_category]['authorization_protocol'],
config.CONF[service_category]['authorization_ip'],
config.CONF[service_category]['authorization_port'],
config.CONF[service_category]['tenant'],
config.CONF[service_category]['username'],
config.CONF[service_category].get('password', None),
config.CONF[service_category]['user_domain_name'],
config.CONF[service_category]['project_domain_name'],
auth_uri)
for service in OPENSTACK_SERVICE:
for service in services:
service_info = config.CONF.get(service, None)
if service_info is not None:
region_name = service_info.get('region_name', None)

View File

@ -1,11 +1,11 @@
#
# Copyright (c) 2016 Wind River Systems, Inc.
# Copyright (c) 2016-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from nfv_common import debug
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.patching')
@ -15,7 +15,7 @@ def query_patches(token):
"""
Asks Patch Controller for information about the patches in the system
"""
url = token.get_service_url(OPENSTACK_SERVICE.PATCHING, strip_version=True)
url = token.get_service_url(PLATFORM_SERVICE.PATCHING, strip_version=True)
if url is None:
raise ValueError("OpenStack Patching URL is invalid")
@ -29,7 +29,7 @@ def query_hosts(token):
"""
Asks Patch Controller for information about the hosts in the system
"""
url = token.get_service_url(OPENSTACK_SERVICE.PATCHING, strip_version=True)
url = token.get_service_url(PLATFORM_SERVICE.PATCHING, strip_version=True)
if url is None:
raise ValueError("OpenStack Patching URL is invalid")
@ -43,7 +43,7 @@ def host_install_async(token, host_name):
"""
Asks Patch Controller to perform a software upgrade on a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.PATCHING, strip_version=True)
url = token.get_service_url(PLATFORM_SERVICE.PATCHING, strip_version=True)
if url is None:
raise ValueError("OpenStack Patching URL is invalid")

View File

@ -6,7 +6,7 @@
import json
from nfv_common import debug
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.rest_api import rest_api_request
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.sysinv')
@ -17,7 +17,7 @@ def get_system_info(token):
Asks System Inventory for information about the system, such as
the name of the system
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -31,7 +31,7 @@ def get_hosts(token):
"""
Asks System Inventory for a list of hosts
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -45,7 +45,7 @@ def get_host(token, host_uuid):
"""
Asks System Inventory for a host details
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -59,7 +59,7 @@ def get_upgrade(token):
"""
Asks System Inventory for information about the upgrade
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -73,7 +73,7 @@ def upgrade_start(token):
"""
Ask System Inventory to start an upgrade
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -95,7 +95,7 @@ def upgrade_activate(token):
"""
Ask System Inventory to activate an upgrade
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -122,7 +122,7 @@ def upgrade_complete(token):
"""
Ask System Inventory to complete an upgrade
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -140,7 +140,7 @@ def get_host_lvgs(token, host_uuid):
"""
Asks System Inventory for a list logical volume groups for a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -154,7 +154,7 @@ def notify_host_services_enabled(token, host_uuid):
"""
Notify System Inventory that host services are enabled
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -181,7 +181,7 @@ def notify_host_services_disabled(token, host_uuid):
"""
Notify System Inventory that host services are disabled
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -208,7 +208,7 @@ def notify_host_services_disable_extend(token, host_uuid):
"""
Notify System Inventory that host services disable needs to be extended
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -235,7 +235,7 @@ def notify_host_services_disable_failed(token, host_uuid, reason):
"""
Notify System Inventory that host services disable failed
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -268,7 +268,7 @@ def notify_host_services_deleted(token, host_uuid):
"""
Notify System Inventory that host services have been deleted
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -286,7 +286,7 @@ def notify_host_services_delete_failed(token, host_uuid, reason):
"""
Notify System Inventory that host services delete failed
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -319,7 +319,7 @@ def lock_host(token, host_uuid):
"""
Ask System Inventory to lock a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -346,7 +346,7 @@ def unlock_host(token, host_uuid):
"""
Ask System Inventory to unlock a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -373,7 +373,7 @@ def reboot_host(token, host_uuid):
"""
Ask System Inventory to reboot a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -400,7 +400,7 @@ def upgrade_host(token, host_uuid):
"""
Ask System Inventory to upgrade a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")
@ -422,7 +422,7 @@ def swact_from_host(token, host_uuid):
"""
Ask System Inventory to swact from a host
"""
url = token.get_service_url(OPENSTACK_SERVICE.SYSINV)
url = token.get_service_url(PLATFORM_SERVICE.SYSINV)
if url is None:
raise ValueError("OpenStack SysInv URL is invalid")

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -460,8 +460,12 @@ def do_unit_tests(test_set=None, rest_api_debug=False, test_config=None):
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
directory = openstack.get_directory(config)
token = openstack.get_token(directory)
platform_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.PLATFORM)
openstack_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
platform_token = openstack.get_token(platform_directory)
openstack_token = openstack.get_token(openstack_directory)
if test_set is None:
test_set = ['keystone', 'ceilometer', 'sysinv', 'glance', 'cinder',
@ -469,43 +473,43 @@ def do_unit_tests(test_set=None, rest_api_debug=False, test_config=None):
print("-" * 80)
if 'keystone' in test_set:
keystone_unit_tests(token, test_config)
keystone_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'ceilometer' in test_set:
ceilometer_unit_tests(token, test_config)
ceilometer_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'sysinv' in test_set:
sysinv_unit_tests(token, test_config)
sysinv_unit_tests(platform_token, test_config)
print("-" * 80)
if 'glance' in test_set:
glance_unit_tests(token, test_config)
glance_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'cinder' in test_set:
cinder_unit_tests(token, test_config)
cinder_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'neutron' in test_set:
neutron_unit_tests(token, test_config)
neutron_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'nova' in test_set:
nova_unit_tests(token, test_config)
nova_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'heat' in test_set:
heat_unit_tests(token, test_config)
heat_unit_tests(openstack_token, test_config)
print("-" * 80)
if 'guest' in test_set:
guest_unit_tests(token, test_config)
guest_unit_tests(platform_token, test_config)
print("-" * 80)
if 'rest-api' in test_set:
rest_api_unit_tests(token, test_config)
rest_api_unit_tests(platform_token, test_config)
print("-" * 80)

View File

@ -12,6 +12,16 @@ tar_file=/var/log/nfv-vim-test.tar.gz
config_file=debug.ini
handlers=stdout
[platform]
username=admin
tenant=admin
authorization_protocol=http
authorization_ip=192.168.204.2
authorization_port=5000
user_domain_name=Default
project_domain_name=Default
keyring_service=CGCS
[openstack]
username=admin
tenant=admin
@ -20,6 +30,7 @@ authorization_ip=192.168.204.2
authorization_port=5000
user_domain_name=Default
project_domain_name=Default
keyring_service=CGCS
[keystone]
region_name=RegionOne

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -80,7 +80,8 @@ def process_do_setup(loads_dir, setup_data):
from nfv_plugins.nfvi_plugins.openstack import glance
from nfv_plugins.nfvi_plugins.openstack import neutron
directory = openstack.get_directory(config)
directory = openstack.get_directory(config,
openstack.SERVICE_CATEGORY.OPENSTACK)
token = openstack.get_token(directory)
result = nova.get_flavors(token)
@ -491,7 +492,8 @@ def process_do_teardown(setup_data):
from nfv_plugins.nfvi_plugins.openstack import glance
from nfv_plugins.nfvi_plugins.openstack import neutron
directory = openstack.get_directory(config)
directory = openstack.get_directory(config,
openstack.SERVICE_CATEGORY.OPENSTACK)
token = openstack.get_token(directory)
result = nova.get_flavors(token)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -24,7 +24,8 @@ def _get_token():
global _directory, _token
if _directory is None:
_directory = openstack.get_directory(config)
_directory = openstack.get_directory(config,
openstack.SERVICE_CATEGORY.PLATFORM)
if _token is None:
_token = openstack.get_token(_directory)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -26,7 +26,8 @@ def _get_token():
global _directory, _token
if _directory is None:
_directory = openstack.get_directory(config)
_directory = openstack.get_directory(config,
openstack.SERVICE_CATEGORY.OPENSTACK)
if _token is None:
_token = openstack.get_token(_directory)

View File

@ -35,11 +35,15 @@ class TestHost(_test_base.Test):
self._instance_names = instance_names
self._host_data = None
self._instances = dict()
self._token = None
self._platform_token = None
self._openstack_token = None
self._customer_alarms = None
self._customer_logs = None
self._customer_alarm_history = None
self._directory = openstack.get_directory(config)
self._platform_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.PLATFORM)
self._openstack_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
name = name.replace(' ', '_')
self._output_dir = (config.CONF['test-output']['dir'] + '/' +
name.translate(None, ''.join(['(', ')'])) + '_' +
@ -68,17 +72,32 @@ class TestHost(_test_base.Test):
return _hosts.host_get_id(self._host_data)
@property
def token(self):
def platform_token(self):
"""
Returns the token
Returns the platform token
"""
if self._token is None:
self._token = openstack.get_token(self._directory)
if self._platform_token is None:
self._platform_token = openstack.get_token(self._platform_directory)
elif self._token.is_expired():
self._token = openstack.get_token(self._directory)
elif self._platform_token.is_expired():
self._platform_token = openstack.get_token(self._platform_directory)
return self._token
return self._platform_token
@property
def openstack_token(self):
"""
Returns the openstack token
"""
if self._openstack_token is None:
self._openstack_token = openstack.get_token(
self._openstack_directory)
elif self._openstack_token.is_expired():
self._openstack_token = openstack.get_token(
self._openstack_directory)
return self._openstack_token
def _save_debug(self, test_success, test_reason):
"""
@ -176,7 +195,7 @@ class TestHost(_test_base.Test):
"""
Fetch the customer alarms raised
"""
self._customer_alarms = fm.get_alarms(self.token).result_data
self._customer_alarms = fm.get_alarms(self.platform_token).result_data
return
@ -184,15 +203,18 @@ class TestHost(_test_base.Test):
"""
Fetch the customer logs
"""
self._customer_logs = fm.get_logs(self.token, self.start_datetime,
self.end_datetime).result_data
self._customer_logs = fm.get_logs(self.platform_token,
self.start_datetime,
self.end_datetime).result_data
def _refresh_customer_alarm_history(self):
"""
Fetch the customer alarm history
"""
self._customer_alarm_history = fm.get_alarm_history(
self.token, self.start_datetime, self.end_datetime).result_data
self.platform_token,
self.start_datetime,
self.end_datetime).result_data
class TestHostLock(TestHost):
@ -226,7 +248,7 @@ class TestHostLock(TestHost):
success, reason = _instances.instance_on_host(instance_data,
self.host_name)
if not success:
nova.live_migrate_server(self.token, instance_uuid,
nova.live_migrate_server(self.openstack_token, instance_uuid,
to_host_name=self.host_name)
max_end_datetime = (self._start_datetime +
@ -262,7 +284,7 @@ class TestHostLock(TestHost):
"""
Perform the test
"""
sysinv.lock_host(self.token, self.host_id)
sysinv.lock_host(self.platform_token, self.host_id)
return True, "host locking"
def _test_passed(self):
@ -329,7 +351,7 @@ class TestHostUnlock(TestHost):
"""
Perform the test
"""
sysinv.unlock_host(self.token, self.host_id)
sysinv.unlock_host(self.platform_token, self.host_id)
return True, "host unlocking"
def _test_passed(self):

View File

@ -31,11 +31,15 @@ class TestInstance(_test_base.Test):
super(TestInstance, self).__init__(name, timeout_secs)
self._instance_name = instance_name
self._instance_data = None
self._token = None
self._platform_token = None
self._openstack_token = None
self._customer_alarms = None
self._customer_logs = None
self._customer_alarm_history = None
self._directory = openstack.get_directory(config)
self._platform_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.PLATFORM)
self._openstack_directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
name = name.replace(' ', '_')
self._output_dir = (config.CONF['test-output']['dir'] + '/' +
name.translate(None, ''.join(['(', ')'])) + '_' +
@ -66,17 +70,32 @@ class TestInstance(_test_base.Test):
return None
@property
def token(self):
def platform_token(self):
"""
Returns the token
Returns the platform token
"""
if self._token is None:
self._token = openstack.get_token(self._directory)
if self._platform_token is None:
self._platform_token = openstack.get_token(self._platform_directory)
elif self._token.is_expired():
self._token = openstack.get_token(self._directory)
elif self._platform_token.is_expired():
self._platform_token = openstack.get_token(self._platform_directory)
return self._token
return self._platform_token
@property
def openstack_token(self):
"""
Returns the openstack token
"""
if self._openstack_token is None:
self._openstack_token = openstack.get_token(
self._openstack_directory)
elif self._openstack_token.is_expired():
self._openstack_token = openstack.get_token(
self._openstack_directory)
return self._openstack_token
def _save_debug(self, test_success, test_reason):
"""
@ -162,21 +181,24 @@ class TestInstance(_test_base.Test):
"""
Fetch the customer alarms raised
"""
self._customer_alarms = fm.get_alarms(self.token).result_data
self._customer_alarms = fm.get_alarms(self.platform_token).result_data
def _refresh_customer_logs(self):
"""
Fetch the customer logs
"""
self._customer_logs = fm.get_logs(self.token, self.start_datetime,
self.end_datetime).result_data
self._customer_logs = fm.get_logs(self.platform_token,
self.start_datetime,
self.end_datetime).result_data
def _refresh_customer_alarm_history(self):
"""
Fetch the customer alarm history
"""
self._customer_alarm_history = fm.get_alarm_history(
self.token, self.start_datetime, self.end_datetime).result_data
self.platform_token,
self.start_datetime,
self.end_datetime).result_data
class TestInstanceStart(TestInstance):
@ -202,7 +224,7 @@ class TestInstanceStart(TestInstance):
"""
Perform test
"""
nova.start_server(self.token, self.instance_uuid)
nova.start_server(self.openstack_token, self.instance_uuid)
return True, "instance is starting"
def _test_passed(self):
@ -244,7 +266,7 @@ class TestInstanceStop(TestInstance):
"""
Perform test
"""
nova.stop_server(self.token, self.instance_uuid)
nova.stop_server(self.openstack_token, self.instance_uuid)
return True, "instance is stopping"
def _test_passed(self):
@ -295,7 +317,7 @@ class TestInstancePause(TestInstance):
"""
Perform test
"""
nova.pause_server(self.token, self.instance_uuid)
nova.pause_server(self.openstack_token, self.instance_uuid)
return True, "instance is pausing"
def _test_passed(self):
@ -337,7 +359,7 @@ class TestInstanceUnpause(TestInstance):
"""
Perform test
"""
nova.unpause_server(self.token, self.instance_uuid)
nova.unpause_server(self.openstack_token, self.instance_uuid)
return True, "instance is unpausing"
def _test_passed(self):
@ -379,7 +401,7 @@ class TestInstanceSuspend(TestInstance):
"""
Perform test
"""
nova.suspend_server(self.token, self.instance_uuid)
nova.suspend_server(self.openstack_token, self.instance_uuid)
return True, "instance is suspending"
def _test_passed(self):
@ -424,7 +446,7 @@ class TestInstanceResume(TestInstance):
"""
Perform test
"""
nova.resume_server(self.token, self.instance_uuid)
nova.resume_server(self.openstack_token, self.instance_uuid)
return True, "instance is resuming"
def _test_passed(self):
@ -482,10 +504,10 @@ class TestInstanceReboot(TestInstance):
Perform test
"""
if self._hard:
nova.reboot_server(self.token, self.instance_uuid,
nova.reboot_server(self.openstack_token, self.instance_uuid,
nova.VM_REBOOT_TYPE.HARD)
else:
nova.reboot_server(self.token, self.instance_uuid,
nova.reboot_server(self.openstack_token, self.instance_uuid,
nova.VM_REBOOT_TYPE.SOFT)
return True, "instance is rebooting"
@ -542,7 +564,8 @@ class TestInstanceRebuild(TestInstance):
"""
# try block added to work around nova bug for now
try:
nova.rebuild_server(self.token, self.instance_uuid, self.instance_name,
nova.rebuild_server(self.openstack_token, self.instance_uuid,
self.instance_name,
self._instance_data['image']['id'])
except ValueError:
pass
@ -592,7 +615,8 @@ class TestInstanceLiveMigrate(TestInstance):
"""
Perform test
"""
nova.live_migrate_server(self.token, self.instance_uuid, self._to_host)
nova.live_migrate_server(self.openstack_token, self.instance_uuid,
self._to_host)
return True, "instance is live-migrating"
def _test_passed(self):
@ -639,7 +663,8 @@ class TestInstanceColdMigrate(TestInstance):
"""
Perform test
"""
nova.cold_migrate_server(self.token, self.instance_uuid, self._to_host)
nova.cold_migrate_server(self.openstack_token, self.instance_uuid,
self._to_host)
return True, "instance is cold-migrating"
def _test_passed(self):
@ -686,7 +711,7 @@ class TestInstanceColdMigrateConfirm(TestInstance):
return False, ("instance needs to be migrated for test, but is not in "
"the running state")
nova.cold_migrate_server(self.token, self.instance_uuid)
nova.cold_migrate_server(self.openstack_token, self.instance_uuid)
max_end_datetime = (self._start_datetime +
datetime.timedelta(seconds=self.timeout_secs))
@ -711,7 +736,8 @@ class TestInstanceColdMigrateConfirm(TestInstance):
"""
Perform test
"""
nova.cold_migrate_server_confirm(self.token, self.instance_uuid)
nova.cold_migrate_server_confirm(self.openstack_token,
self.instance_uuid)
return True, "confirming instance cold-migrate"
def _test_passed(self):
@ -757,7 +783,7 @@ class TestInstanceColdMigrateRevert(TestInstance):
return False, ("instance needs to be migrated for test, but is not in "
"the running state")
nova.cold_migrate_server(self.token, self.instance_uuid)
nova.cold_migrate_server(self.openstack_token, self.instance_uuid)
max_end_datetime = (self._start_datetime +
datetime.timedelta(seconds=self.timeout_secs))
@ -782,7 +808,8 @@ class TestInstanceColdMigrateRevert(TestInstance):
"""
Perform test
"""
nova.cold_migrate_server_revert(self.token, self.instance_uuid)
nova.cold_migrate_server_revert(self.openstack_token,
self.instance_uuid)
return True, "reverting instance cold-migrate"
def _test_passed(self):
@ -820,7 +847,7 @@ class TestInstanceResize(TestInstance):
Returns the flavor id associated with the given flavor name
"""
flavor_id = None
flavors = nova.get_flavors(self.token).result_data
flavors = nova.get_flavors(self.openstack_token).result_data
for flavor in flavors['flavors']:
if flavor['name'] == flavor_name:
flavor_id = flavor['id']
@ -857,7 +884,8 @@ class TestInstanceResize(TestInstance):
"""
Perform test
"""
nova.resize_server(self.token, self.instance_uuid, self._flavor_id)
nova.resize_server(self.openstack_token, self.instance_uuid,
self._flavor_id)
return True, "instance is resizing"
def _test_passed(self):
@ -894,7 +922,7 @@ class TestInstanceResizeConfirm(TestInstance):
Returns the flavor id associated with the given flavor name
"""
flavor_id = None
flavors = nova.get_flavors(self.token).result_data
flavors = nova.get_flavors(self.openstack_token).result_data
for flavor in flavors['flavors']:
if flavor['name'] == flavor_name:
flavor_id = flavor['id']
@ -928,7 +956,7 @@ class TestInstanceResizeConfirm(TestInstance):
% (self._name, self.instance_name))
return False, "no valid flavors given"
nova.resize_server(self.token, self.instance_uuid, flavor_id)
nova.resize_server(self.openstack_token, self.instance_uuid, flavor_id)
max_end_datetime = (self._start_datetime +
datetime.timedelta(seconds=self.timeout_secs))
@ -953,7 +981,7 @@ class TestInstanceResizeConfirm(TestInstance):
"""
Perform test
"""
nova.resize_server_confirm(self.token, self.instance_uuid)
nova.resize_server_confirm(self.openstack_token, self.instance_uuid)
return True, "confirming instance resize"
def _test_passed(self):
@ -990,7 +1018,7 @@ class TestInstanceResizeRevert(TestInstance):
Returns the flavor id associated with the given flavor name
"""
flavor_id = None
flavors = nova.get_flavors(self.token).result_data
flavors = nova.get_flavors(self.openstack_token).result_data
for flavor in flavors['flavors']:
if flavor['name'] == flavor_name:
flavor_id = flavor['id']
@ -1024,7 +1052,7 @@ class TestInstanceResizeRevert(TestInstance):
% (self._name, self.instance_name))
return False, "no valid flavors given"
nova.resize_server(self.token, self.instance_uuid, flavor_id)
nova.resize_server(self.openstack_token, self.instance_uuid, flavor_id)
max_end_datetime = (self._start_datetime +
datetime.timedelta(seconds=self.timeout_secs))
@ -1049,7 +1077,7 @@ class TestInstanceResizeRevert(TestInstance):
"""
Perform test
"""
nova.resize_server_revert(self.token, self.instance_uuid)
nova.resize_server_revert(self.openstack_token, self.instance_uuid)
return True, "reverting instance resize"
def _test_passed(self):

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2016 Wind River Systems, Inc.
# Copyright (c) 2016-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -17,7 +17,8 @@ class AuthenticationApplication(object):
self._app = app
self._token = None
self._config = openstack.config_load()
self._directory = openstack.get_directory(self._config)
self._directory = openstack.get_directory(
self._config, openstack.SERVICE_CATEGORY.PLATFORM)
@staticmethod
def _get_header_value(env, key, default_value=None):

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -48,7 +48,8 @@ class HeatAPI(object):
OpenStack Heat Proxy
"""
config = openstack.config_load()
directory = openstack.get_directory(config)
directory = openstack.get_directory(
config, openstack.SERVICE_CATEGORY.OPENSTACK)
token = openstack.get_token(directory)
url_target_index = pecan.request.url.find('/api/openstack/heat')

View File

@ -1,11 +1,13 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from nfv_vim.api.openstack._config import CONF # noqa: F401
from nfv_vim.api.openstack._config import config_load # noqa: F401
from nfv_vim.api.openstack._openstack import OPENSTACK_SERVICE # noqa: F401
from nfv_vim.api.openstack._openstack import PLATFORM_SERVICE # noqa: F401
from nfv_vim.api.openstack._openstack import SERVICE_CATEGORY # noqa: F401
from nfv_vim.api.openstack._openstack import get_directory # noqa: F401
from nfv_vim.api.openstack._openstack import get_token # noqa: F401
from nfv_vim.api.openstack._openstack import validate_token # noqa: F401

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -35,10 +35,6 @@ def config_load():
nfvi_config.read(config.CONF['nfvi']['config_file'])
CONF = nfvi_config.as_dict()
password = CONF['openstack'].get('password', None)
if password is None:
CONF['openstack']['password'] = None
region_name = CONF['openstack'].get('region_name', None)
if region_name is None:
CONF['openstack']['region_name'] = "RegionOne"

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -16,6 +16,36 @@ from nfv_common.helpers import Singleton
DLOG = debug.debug_get_logger('nfv_vim.api.openstack')
@six.add_metaclass(Singleton)
class ServiceCategory(Constants):
"""
Service Category Constants
"""
PLATFORM = Constant('platform')
OPENSTACK = Constant('openstack')
# Service Category Constant
SERVICE_CATEGORY = ServiceCategory()
@six.add_metaclass(Singleton)
class PlatformServices(Constants):
"""
Platform Services Constants
"""
GUEST = Constant('guest')
KEYSTONE = Constant('keystone')
MTC = Constant('mtc')
SYSINV = Constant('sysinv')
PATCHING = Constant('patching')
FM = Constant('fm')
# Platform Services Constant
PLATFORM_SERVICE = PlatformServices()
@six.add_metaclass(Singleton)
class OpenStackServices(Constants):
"""
@ -24,14 +54,10 @@ class OpenStackServices(Constants):
CEILOMETER = Constant('ceilometer')
CINDER = Constant('cinder')
GLANCE = Constant('glance')
GUEST = Constant('guest')
KEYSTONE = Constant('keystone')
MTC = Constant('mtc')
NEUTRON = Constant('neutron')
NOVA = Constant('nova')
SYSINV = Constant('sysinv')
HEAT = Constant('heat')
FM = Constant('fm')
# OpenStack Services Constant
@ -90,9 +116,12 @@ class Directory(object):
"""
Directory
"""
def __init__(self, auth_protocol, auth_host, auth_port, auth_project,
def __init__(self, service_category, keyring_service, auth_protocol,
auth_host, auth_port, auth_project,
auth_username, auth_password, auth_user_domain_name,
auth_project_domain_name, auth_uri=None):
self._service_category = service_category
self._keyring_service = keyring_service
self._auth_protocol = auth_protocol
self._auth_host = auth_host
self._auth_port = auth_port
@ -104,6 +133,20 @@ class Directory(object):
self._auth_project_domain_name = auth_project_domain_name
self._entries = dict()
@property
def service_category(self):
"""
Returns the service category
"""
return self._service_category
@property
def keyring_service(self):
"""
Returns the keyring service
"""
return self._keyring_service
@property
def auth_protocol(self):
"""
@ -271,7 +314,6 @@ class Token(object):
for endpoint in catalog['endpoints']:
if (endpoint['region'] == region_name and
endpoint['interface'] == endpoint_type):
print("HERE HERE HERE")
return endpoint['url']
return None

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -9,6 +9,8 @@ import urllib2
from nfv_common import debug
from nfv_vim.api.openstack._objects import OPENSTACK_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
from nfv_plugins.nfvi_plugins.openstack.objects import SERVICE_CATEGORY
from nfv_vim.api.openstack._objects import Directory
from nfv_vim.api.openstack._objects import Token
@ -17,7 +19,7 @@ DLOG = debug.debug_get_logger('nfv_vim.api.openstack')
def validate_token(directory, admin_token, token_id):
"""
Ask OpenStack if a token is valid
Ask Keystone if a token is valid
"""
try:
if directory.auth_uri is None:
@ -89,7 +91,8 @@ def get_token(directory):
if directory.auth_password is None:
import keyring
password = keyring.get_password('CGCS', directory.auth_username)
password = keyring.get_password(directory.keyring_service,
directory.auth_username)
else:
password = directory.auth_password
@ -131,27 +134,38 @@ def get_token(directory):
return None
def get_directory(config):
def get_directory(config, service_category):
"""
Get directory information from the given configuration
Get directory information from the given configuration for the given
service category.
"""
openstack_info = config.get('openstack', None)
if openstack_info is not None:
auth_uri = openstack_info.get('authorization_uri', None)
if SERVICE_CATEGORY.PLATFORM == service_category:
services = PLATFORM_SERVICE
elif SERVICE_CATEGORY.OPENSTACK == service_category:
services = OPENSTACK_SERVICE
else:
raise ValueError("service_category is invalid: %s" % service_category)
auth_info = config.get(service_category, None)
if auth_info is not None:
auth_uri = auth_info.get('authorization_uri', None)
else:
auth_uri = None
directory = Directory(config['openstack']['authorization_protocol'],
config['openstack']['authorization_ip'],
config['openstack']['authorization_port'],
config['openstack']['tenant'],
config['openstack']['username'],
config['openstack']['password'],
config['openstack']['user_domain_name'],
config['openstack']['project_domain_name'],
auth_uri)
directory = Directory(
service_category,
config[service_category]['keyring_service'],
config[service_category]['authorization_protocol'],
config[service_category]['authorization_ip'],
config[service_category]['authorization_port'],
config[service_category]['tenant'],
config[service_category]['username'],
config[service_category].get('password', None),
config[service_category]['user_domain_name'],
config[service_category]['project_domain_name'],
auth_uri)
for service in OPENSTACK_SERVICE:
for service in services:
service_info = config.get(service, None)
if service_info is not None:
region_name = service_info.get('region_name', None)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -597,7 +597,8 @@ class SimpleHttpServer(object):
self.server_thread = None
config.load(nfvi_config['config_file'])
_directory = openstack.get_directory(config)
_directory = openstack.get_directory(config,
openstack.SERVICE_CATEGORY.PLATFORM)
_vim_api_ip = vim_api_config['host']
if ':' in _vim_api_ip:
# Wrap IPv6 address for use in URLs