Refactor NOVA_BAREMETAL_CREDS

Change-Id: If1939a930ad47e6d08947d6e676756e3855d3857
Implements: blueprint fixme-local-settings
This commit is contained in:
Imre Farkas
2013-08-15 11:33:23 +02:00
parent 631e4b41e0
commit 8172c733c9
4 changed files with 38 additions and 28 deletions

View File

@@ -112,10 +112,10 @@ editor. You will want to customize several settings:
OpenStack server to change them.)
- ``TUSKAR_ENDPOINT_URL`` should point to the Tuskar server you
configured. It normally runs on port 6385.
- ``NOVA_BAREMETAL_CREDS`` is a dictionary of settings for connecting
to Nova Baremetal. This information is normally gathered from
Keystone's service catalog, but a common configuration with Tuskar
and friends is to have Nova Baremetal reachable only from certain
- ``REMOTE_NOVA_BAREMETAL_CREDS`` is optional. It's a dictionary of settings
for connecting to a remote Nova Baremetal. If not set, this information is
gathered from Keystone's service catalog, but a common configuration with
Tuskar and friends is to have Nova Baremetal reachable only from certain
machines, so the credentials are held separately right now. The
``user``, ``password``, and ``tenant`` settings will very likely
match those of Keystone, and ``auth_url`` may also be the same.
@@ -134,9 +134,6 @@ and selecting the id column that matches your tenant name.
(Of course, substituting the appropriate values in for ``USERNAME``,
``PASSWORD``, ``TENANTNAME`` and ``AUTHURL``)
Long-term, this ``NOVA_BAREMETAL_CREDS`` block will likely not be
necessary.
Final setup
-----------

View File

@@ -379,9 +379,12 @@ SECURITY_GROUP_RULES = {
},
}
TUSKAR_ENDPOINT_URL = "http://127.0.0.1:6385"
NOVA_BAREMETAL_CREDS = {
# The REMOTE_NOVA_BAREMETAL_CREDS settings can be used to connect to a remote
# Nova Baremetal instance instead of the one defined in the Keystone service
# catalog.
REMOTE_NOVA_BAREMETAL_CREDS = {
'user': 'admin',
'password': 'password',
'tenant': 'admin',
@@ -390,7 +393,6 @@ NOVA_BAREMETAL_CREDS = {
}
OVERCLOUD_CREDS = {
'enabled': False,
'user': 'admin',
'password': 'password',
'tenant': 'admin',

View File

@@ -30,13 +30,15 @@ from tuskarclient.v1 import client as tuskar_client
from openstack_dashboard.api import base
from openstack_dashboard.api import nova
import tuskar_ui.infrastructure.models as dummymodels
LOG = logging.getLogger(__name__)
TUSKAR_ENDPOINT_URL = getattr(settings, 'TUSKAR_ENDPOINT_URL')
NOVA_BAREMETAL_CREDS = getattr(settings, 'NOVA_BAREMETAL_CREDS')
OVERCLOUD_CREDS = getattr(settings, 'OVERCLOUD_CREDS')
REMOTE_NOVA_BAREMETAL_CREDS = getattr(settings, 'REMOTE_NOVA_BAREMETAL_CREDS',
False)
OVERCLOUD_CREDS = getattr(settings, 'OVERCLOUD_CREDS', False)
# FIXME: request isn't used right in the tuskar client right now, but looking
@@ -47,11 +49,27 @@ def tuskarclient(request):
def baremetalclient(request):
nc = nova.nova_client.Client(NOVA_BAREMETAL_CREDS['user'],
NOVA_BAREMETAL_CREDS['password'],
NOVA_BAREMETAL_CREDS['tenant'],
auth_url=NOVA_BAREMETAL_CREDS['auth_url'],
bypass_url=NOVA_BAREMETAL_CREDS['bypass_url'])
if REMOTE_NOVA_BAREMETAL_CREDS:
LOG.debug('remote nova baremetal client connection created')
nc = nova.nova_client.Client(REMOTE_NOVA_BAREMETAL_CREDS['user'],
REMOTE_NOVA_BAREMETAL_CREDS['password'],
REMOTE_NOVA_BAREMETAL_CREDS['tenant'],
auth_url=REMOTE_NOVA_BAREMETAL_CREDS['auth_url'],
bypass_url=REMOTE_NOVA_BAREMETAL_CREDS['bypass_url'])
else:
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
LOG.debug('nova baremetal client connection created using token "%s" '
'and url "%s"' %
(request.user.token.id, base.url_for(request, 'compute')))
nc = nova.nova_client.Client(request.user.username,
request.user.token.id,
project_id=request.user.tenant_id,
auth_url=base.url_for(request, 'compute'),
insecure=insecure,
http_log_debug=settings.DEBUG)
nc.client.auth_token = request.user.token.id
nc.client.management_url = base.url_for(request, 'compute')
return baremetal.BareMetalNodeManager(nc)
@@ -313,7 +331,7 @@ class Node(StringIdAPIResourceWrapper):
@property
def running_virtual_machines(self):
if not hasattr(self, '_running_virtual_machines'):
if OVERCLOUD_CREDS['enabled']:
if OVERCLOUD_CREDS:
search_opts = {}
search_opts['all_tenants'] = True
self._running_virtual_machines = [s for s in
@@ -321,6 +339,8 @@ class Node(StringIdAPIResourceWrapper):
.list(True, search_opts)
if s.hostId == self.id]
else:
LOG.debug('OVERCLOUD_CREDS is not set. '
'Can\'t connect to Overcloud')
self._running_virtual_machines = []
return self._running_virtual_machines

View File

@@ -123,16 +123,7 @@ NOSE_ARGS = ['--nocapture',
'--cover-inclusive',
'--all-modules']
# FIXME: this will eventually be unneeded when the parameter is removed
# from local settings and api/tuskar.py
TUSKAR_ENDPOINT_URL = "http://127.0.0.1:6385"
NOVA_BAREMETAL_CREDS = {
'user': 'admin',
'password': 'admin_password_here',
'tenant': 'admin',
'auth_url': 'http://localhost:5001/v2.0/',
'bypass_url': 'http://localhost:9774/v2/692567cd99f84f5d8f26ec23ff0ba460'
}
OVERCLOUD_CREDS = {
'enabled': True,
@@ -140,4 +131,4 @@ OVERCLOUD_CREDS = {
'password': 'password',
'tenant': 'admin',
'auth_url': 'http://localhost:5000/v2.0/',
}
}