fix py charm warnings and doc

fix trust id although not used
fix api doc

Change-Id: I7f6b25617be16de4391499c402d2831057390e1c
This commit is contained in:
Eyal 2017-11-13 15:57:36 +02:00
parent 78ad48d2e5
commit 4dd2a0dfba
5 changed files with 47 additions and 49 deletions

View File

@ -161,33 +161,35 @@ Query example
X-Auth-Token: 2b8882ba2ec44295bf300aecb2caa4f7 X-Auth-Token: 2b8882ba2ec44295bf300aecb2caa4f7
{ {
"query" : "query" :
{ {
"or": "or": [
[ {
"==": "==": {
{ "vitrage_type": "host"
"vitrage_type":"host" }
}, },
"==": {
{ "==": {
"vitrage_type":"instance" "vitrage_type": "instance"
}, }
"==": },
{ {
"vitrage_type":"zone" "==": {
}, "vitrage_type": "zone"
"==": }
{ },
"vitrage_type":"node" {
} "==": {
] "vitrage_type": "node"
} }
"graph_type" : "tree" }
"depth" : 4 ]
}
},
"graph_type" : "tree",
"depth" : 4
}
Response Status Code Response Status Code
==================== ====================

View File

@ -15,7 +15,7 @@
import re import re
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])") mutable_default_args = re.compile(r"^\s*def .+\((.+={\}|.+=\[\])")
asse_trueinst_re = re.compile( asse_trueinst_re = re.compile(
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, " r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
@ -35,7 +35,7 @@ _all_log_levels = {'debug', 'error', 'info', 'warning',
translated_logs = re.compile( translated_logs = re.compile(
r"(.)*LOG\.(%(level)s)\(\s*_\(" % {'level': '|'.join(_all_log_levels)}) r"(.)*LOG\.(%(level)s)\(\s*_\(" % {'level': '|'.join(_all_log_levels)})
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)") dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?([(\[])")
def assert_true_instance(logical_line): def assert_true_instance(logical_line):

View File

@ -18,6 +18,7 @@ import os
from keystoneauth1 import exceptions as ka_exception from keystoneauth1 import exceptions as ka_exception
from keystoneauth1 import loading as ka_loading from keystoneauth1 import loading as ka_loading
from keystoneauth1 import session
# noinspection PyPackageRequirements # noinspection PyPackageRequirements
from keystoneclient.v3 import client as ks_client_v3 from keystoneclient.v3 import client as ks_client_v3
from oslo_config import cfg from oslo_config import cfg
@ -28,19 +29,18 @@ LOG = log.getLogger(__name__)
CFG_GROUP = "service_credentials" CFG_GROUP = "service_credentials"
def get_session(conf, requests_session=None): def get_session(conf):
"""Get a vitrage service credentials auth session.""" """Get a vitrage service credentials auth session."""
auth_plugin = ka_loading.load_auth_from_conf_options(conf, CFG_GROUP) auth_plugin = ka_loading.load_auth_from_conf_options(conf, CFG_GROUP)
session = ka_loading.load_session_from_conf_options( return ka_loading.load_session_from_conf_options(
conf, CFG_GROUP, auth=auth_plugin, session=requests_session conf, CFG_GROUP, auth=auth_plugin
) )
return session
def get_client(conf, trust_id=None, requests_session=None): def get_client(conf):
"""Return a client for keystone v3 endpoint, optionally using a trust.""" """Return a client for keystone v3 endpoint."""
session = get_session(conf, requests_session=requests_session) sess = get_session(conf)
return ks_client_v3.Client(session=session, trust_id=trust_id) return ks_client_v3.Client(session=sess)
def get_service_catalog(client): def get_service_catalog(client):
@ -51,22 +51,19 @@ def get_auth_token(client):
return client.session.auth.get_access(client.session).auth_token return client.session.auth.get_access(client.session).auth_token
def get_client_on_behalf_user(conf, auth_plugin, trust_id=None, def get_client_on_behalf_user(auth_plugin):
requests_session=None): """Return a client for keystone v3 endpoint."""
"""Return a client for keystone v3 endpoint, optionally using a trust.""" sess = session.Session(auth=auth_plugin)
session = ka_loading.load_session_from_conf_options( return ks_client_v3.Client(session=sess)
conf, CFG_GROUP, auth=auth_plugin, session=requests_session
)
return ks_client_v3.Client(session=session, trust_id=trust_id)
def create_trust_id(conf, trustor_user_id, trustor_project_id, roles, def create_trust_id(conf, trustor_user_id, trustor_project_id, roles,
auth_plugin): auth_plugin):
"""Create a new trust using the vitrage service user.""" """Create a new trust using the vitrage service user."""
admin_client = get_client(conf) admin_client = get_client(conf)
trustee_user_id = admin_client.auth_ref.user_id trustee_user_id = admin_client.session.get_user_id()
client = get_client_on_behalf_user(conf, auth_plugin=auth_plugin) client = get_client_on_behalf_user(auth_plugin)
trust = client.trusts.create(trustor_user=trustor_user_id, trust = client.trusts.create(trustor_user=trustor_user_id,
trustee_user=trustee_user_id, trustee_user=trustee_user_id,
project=trustor_project_id, project=trustor_project_id,
@ -75,9 +72,9 @@ def create_trust_id(conf, trustor_user_id, trustor_project_id, roles,
return trust.id return trust.id
def delete_trust_id(conf, trust_id, auth_plugin): def delete_trust_id(trust_id, auth_plugin):
"""Delete a trust previously setup for the vitrage user.""" """Delete a trust previously setup for the vitrage user."""
client = get_client_on_behalf_user(conf, auth_plugin=auth_plugin) client = get_client_on_behalf_user(auth_plugin)
try: try:
client.trusts.delete(trust_id) client.trusts.delete(trust_id)
except ka_exception.NotFound: except ka_exception.NotFound:

View File

@ -20,7 +20,6 @@ Tests for `vitrage` graph driver
""" """
from vitrage.common.constants import EdgeProperties as EProps from vitrage.common.constants import EdgeProperties as EProps
from vitrage.common.constants import VertexProperties as VProps
from vitrage.graph import Direction from vitrage.graph import Direction
from vitrage.graph.filter import check_filter from vitrage.graph.filter import check_filter
from vitrage.graph import utils from vitrage.graph import utils

View File

@ -55,7 +55,7 @@ class TestAlarms(BaseAlarmsTest):
self._handle_exception(e) self._handle_exception(e)
raise raise
finally: finally:
aodh_utils.delete_all_ceilometer_alarms() aodh_utils.delete_all_aodh_alarms()
nova_utils.delete_all_instances() nova_utils.delete_all_instances()
def _compare_alarms_lists(self, api_alarms, cli_alarms, def _compare_alarms_lists(self, api_alarms, cli_alarms,