diff --git a/keystone/preload.py b/keystone/preload.py index c51fa4995..641cb8c36 100644 --- a/keystone/preload.py +++ b/keystone/preload.py @@ -3,6 +3,18 @@ # (C) Copyright 2015-2017 Hewlett-Packard Enterprise Development LP # Copyright 2015 FUJITSU LIMITED +# +# 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. from __future__ import print_function @@ -13,9 +25,9 @@ import yaml -from keystoneauth1 import session as ks_session from keystoneauth1.exceptions.connection import ConnectFailure from keystoneauth1.identity import v3 +from keystoneauth1 import session as ks_session from keystoneclient.v3 import client @@ -147,7 +159,8 @@ def add_user_roles(ks_client, users): def add_service_endpoint(ks_client, name, description, endpoint_type, url, region, interface): """Add the Monasca service to the catalog with the specified endpoint, - if it doesn't yet exist.""" + if it doesn't yet exist. + """ services = _retry(lambda: ks_client.services.list()) service_names = {service.name: service for service in services} if name in service_names.keys(): @@ -201,7 +214,8 @@ def resolve_k8s_service_by_url(url): def main(argv): """Get credentials to create a keystoneauth Session to instantiate a - Keystone Client and then call methods to add users, projects and roles""" + Keystone Client and then call methods to add users, projects and roles + """ path = os.environ.get('PRELOAD_YAML_PATH', '/preload.yml') try: diff --git a/monasca-agent-base/kubernetes_get_host.py b/monasca-agent-base/kubernetes_get_host.py index aa93d4343..e7288a6d0 100644 --- a/monasca-agent-base/kubernetes_get_host.py +++ b/monasca-agent-base/kubernetes_get_host.py @@ -1,6 +1,7 @@ # (C) Copyright 2017 Hewlett Packard Enterprise Development LP +# coding=utf-8 from monasca_agent.collector.checks import utils kubernetes_connector = utils.KubernetesConnector(3) -print kubernetes_connector.get_agent_pod_host(return_host_name=True) +print(kubernetes_connector.get_agent_pod_host(return_host_name=True)) diff --git a/monasca-agent-base/template.py b/monasca-agent-base/template.py index 67a2fde62..4d461e94e 100755 --- a/monasca-agent-base/template.py +++ b/monasca-agent-base/template.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# coding=utf-8 # (C) Copyright 2017 Hewlett Packard Enterprise Development LP # @@ -36,5 +37,6 @@ def main(): trim_blocks=True) out_file.write(t.render(os.environ)) + if __name__ == '__main__': main()