Add fake Keystone
* enabled 'fake' authentication in nailgun by default * add fake keystone API and middleware to nailgun * fixed problem with not configured logging in keystoneclient - now fuelclient silents all logs * removed TEST_MODE as it's not needed in fake auth Related to blueprint access-control-master-node Closes-Bug: 1340141 Change-Id: I76cb7d1cb19be8e0d23ecc03fdbc968b1eeaff5c
This commit is contained in:
parent
51ec0f0f15
commit
0af8f2394f
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import urllib2
|
||||
|
||||
@ -21,6 +22,13 @@ import yaml
|
||||
from keystoneclient import client as auth_client
|
||||
|
||||
from fuelclient.cli.error import exceptions_decorator
|
||||
from fuelclient.logs import NullHandler
|
||||
|
||||
|
||||
# configure logging to silent all logs
|
||||
# and prevent issues in keystoneclient logging
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(NullHandler())
|
||||
|
||||
|
||||
class Client(object):
|
||||
@ -29,7 +37,6 @@ class Client(object):
|
||||
|
||||
def __init__(self):
|
||||
self.debug = False
|
||||
self.test_mod = bool(os.environ.get('TEST_MODE', ''))
|
||||
path_to_config = "/etc/fuel/client/config.yaml"
|
||||
defaults = {
|
||||
"SERVER_ADDRESS": "127.0.0.1",
|
||||
@ -73,10 +80,9 @@ class Client(object):
|
||||
|
||||
def auth_status(self):
|
||||
self.auth_required = False
|
||||
if not self.test_mod:
|
||||
request = urllib2.urlopen(''.join([self.api_root, 'version']))
|
||||
self.auth_required = json.loads(
|
||||
request.read()).get('auth_required', False)
|
||||
request = urllib2.urlopen(''.join([self.api_root, 'version']))
|
||||
self.auth_required = json.loads(
|
||||
request.read()).get('auth_required', False)
|
||||
|
||||
def update_own_password(self, new_pass):
|
||||
if self.auth_token:
|
||||
@ -84,7 +90,7 @@ class Client(object):
|
||||
self.password, new_pass)
|
||||
|
||||
def initialize_keystone_client(self):
|
||||
if not self.test_mod and self.auth_required:
|
||||
if self.auth_required:
|
||||
self.keystone_client = auth_client.Client(
|
||||
username=self.user,
|
||||
password=self.password,
|
||||
|
38
fuelclient/logs.py
Normal file
38
fuelclient/logs.py
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2014 Mirantis, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
class NullHandler(logging.Handler):
|
||||
"""This handler does nothing. It's intended to be used to avoid the
|
||||
"No handlers could be found for logger XXX" one-off warning. This
|
||||
important for library code, which may contain code to log events.
|
||||
of the library does not configure logging, the one-off warning mig
|
||||
produced; to avoid this, the library developer simply needs to ins
|
||||
a NullHandler and add it to the top-level logger of the library mo
|
||||
package.
|
||||
|
||||
Taken from Python 2.7
|
||||
"""
|
||||
def handle(self, record):
|
||||
pass
|
||||
|
||||
def emit(self, record):
|
||||
pass
|
||||
|
||||
def createLock(self):
|
||||
self.lock = None
|
@ -102,7 +102,6 @@ class BaseTestCase(TestCase):
|
||||
|
||||
def run_cli_command(self, command_line, check_errors=False):
|
||||
modified_env = os.environ.copy()
|
||||
modified_env['TEST_MODE'] = 'True'
|
||||
command_args = [" ".join((self.fuel_path, command_line))]
|
||||
process_handle = subprocess.Popen(
|
||||
command_args,
|
||||
|
Loading…
Reference in New Issue
Block a user