Refactor NOVA_BAREMETAL_CREDS
Change-Id: If1939a930ad47e6d08947d6e676756e3855d3857 Implements: blueprint fixme-local-settings
This commit is contained in:
@@ -112,10 +112,10 @@ editor. You will want to customize several settings:
|
|||||||
OpenStack server to change them.)
|
OpenStack server to change them.)
|
||||||
- ``TUSKAR_ENDPOINT_URL`` should point to the Tuskar server you
|
- ``TUSKAR_ENDPOINT_URL`` should point to the Tuskar server you
|
||||||
configured. It normally runs on port 6385.
|
configured. It normally runs on port 6385.
|
||||||
- ``NOVA_BAREMETAL_CREDS`` is a dictionary of settings for connecting
|
- ``REMOTE_NOVA_BAREMETAL_CREDS`` is optional. It's a dictionary of settings
|
||||||
to Nova Baremetal. This information is normally gathered from
|
for connecting to a remote Nova Baremetal. If not set, this information is
|
||||||
Keystone's service catalog, but a common configuration with Tuskar
|
gathered from Keystone's service catalog, but a common configuration with
|
||||||
and friends is to have Nova Baremetal reachable only from certain
|
Tuskar and friends is to have Nova Baremetal reachable only from certain
|
||||||
machines, so the credentials are held separately right now. The
|
machines, so the credentials are held separately right now. The
|
||||||
``user``, ``password``, and ``tenant`` settings will very likely
|
``user``, ``password``, and ``tenant`` settings will very likely
|
||||||
match those of Keystone, and ``auth_url`` may also be the same.
|
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``,
|
(Of course, substituting the appropriate values in for ``USERNAME``,
|
||||||
``PASSWORD``, ``TENANTNAME`` and ``AUTHURL``)
|
``PASSWORD``, ``TENANTNAME`` and ``AUTHURL``)
|
||||||
|
|
||||||
Long-term, this ``NOVA_BAREMETAL_CREDS`` block will likely not be
|
|
||||||
necessary.
|
|
||||||
|
|
||||||
Final setup
|
Final setup
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|||||||
@@ -379,9 +379,12 @@ SECURITY_GROUP_RULES = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TUSKAR_ENDPOINT_URL = "http://127.0.0.1:6385"
|
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',
|
'user': 'admin',
|
||||||
'password': 'password',
|
'password': 'password',
|
||||||
'tenant': 'admin',
|
'tenant': 'admin',
|
||||||
@@ -390,7 +393,6 @@ NOVA_BAREMETAL_CREDS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OVERCLOUD_CREDS = {
|
OVERCLOUD_CREDS = {
|
||||||
'enabled': False,
|
|
||||||
'user': 'admin',
|
'user': 'admin',
|
||||||
'password': 'password',
|
'password': 'password',
|
||||||
'tenant': 'admin',
|
'tenant': 'admin',
|
||||||
|
|||||||
@@ -30,13 +30,15 @@ from tuskarclient.v1 import client as tuskar_client
|
|||||||
|
|
||||||
from openstack_dashboard.api import base
|
from openstack_dashboard.api import base
|
||||||
from openstack_dashboard.api import nova
|
from openstack_dashboard.api import nova
|
||||||
|
|
||||||
import tuskar_ui.infrastructure.models as dummymodels
|
import tuskar_ui.infrastructure.models as dummymodels
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
TUSKAR_ENDPOINT_URL = getattr(settings, 'TUSKAR_ENDPOINT_URL')
|
TUSKAR_ENDPOINT_URL = getattr(settings, 'TUSKAR_ENDPOINT_URL')
|
||||||
NOVA_BAREMETAL_CREDS = getattr(settings, 'NOVA_BAREMETAL_CREDS')
|
REMOTE_NOVA_BAREMETAL_CREDS = getattr(settings, 'REMOTE_NOVA_BAREMETAL_CREDS',
|
||||||
OVERCLOUD_CREDS = getattr(settings, 'OVERCLOUD_CREDS')
|
False)
|
||||||
|
OVERCLOUD_CREDS = getattr(settings, 'OVERCLOUD_CREDS', False)
|
||||||
|
|
||||||
|
|
||||||
# FIXME: request isn't used right in the tuskar client right now, but looking
|
# FIXME: request isn't used right in the tuskar client right now, but looking
|
||||||
@@ -47,11 +49,27 @@ def tuskarclient(request):
|
|||||||
|
|
||||||
|
|
||||||
def baremetalclient(request):
|
def baremetalclient(request):
|
||||||
nc = nova.nova_client.Client(NOVA_BAREMETAL_CREDS['user'],
|
if REMOTE_NOVA_BAREMETAL_CREDS:
|
||||||
NOVA_BAREMETAL_CREDS['password'],
|
LOG.debug('remote nova baremetal client connection created')
|
||||||
NOVA_BAREMETAL_CREDS['tenant'],
|
nc = nova.nova_client.Client(REMOTE_NOVA_BAREMETAL_CREDS['user'],
|
||||||
auth_url=NOVA_BAREMETAL_CREDS['auth_url'],
|
REMOTE_NOVA_BAREMETAL_CREDS['password'],
|
||||||
bypass_url=NOVA_BAREMETAL_CREDS['bypass_url'])
|
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)
|
return baremetal.BareMetalNodeManager(nc)
|
||||||
|
|
||||||
|
|
||||||
@@ -313,7 +331,7 @@ class Node(StringIdAPIResourceWrapper):
|
|||||||
@property
|
@property
|
||||||
def running_virtual_machines(self):
|
def running_virtual_machines(self):
|
||||||
if not hasattr(self, '_running_virtual_machines'):
|
if not hasattr(self, '_running_virtual_machines'):
|
||||||
if OVERCLOUD_CREDS['enabled']:
|
if OVERCLOUD_CREDS:
|
||||||
search_opts = {}
|
search_opts = {}
|
||||||
search_opts['all_tenants'] = True
|
search_opts['all_tenants'] = True
|
||||||
self._running_virtual_machines = [s for s in
|
self._running_virtual_machines = [s for s in
|
||||||
@@ -321,6 +339,8 @@ class Node(StringIdAPIResourceWrapper):
|
|||||||
.list(True, search_opts)
|
.list(True, search_opts)
|
||||||
if s.hostId == self.id]
|
if s.hostId == self.id]
|
||||||
else:
|
else:
|
||||||
|
LOG.debug('OVERCLOUD_CREDS is not set. '
|
||||||
|
'Can\'t connect to Overcloud')
|
||||||
self._running_virtual_machines = []
|
self._running_virtual_machines = []
|
||||||
return self._running_virtual_machines
|
return self._running_virtual_machines
|
||||||
|
|
||||||
|
|||||||
@@ -123,16 +123,7 @@ NOSE_ARGS = ['--nocapture',
|
|||||||
'--cover-inclusive',
|
'--cover-inclusive',
|
||||||
'--all-modules']
|
'--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"
|
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 = {
|
OVERCLOUD_CREDS = {
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user