Merge "fix(pep8): makes python script pep8 compliant"
This commit is contained in:
commit
da05d8d619
@ -14,7 +14,7 @@ apiVersion: v1
|
||||
appVersion: v1.0.0
|
||||
description: OpenStack-Helm Keystone
|
||||
name: keystone
|
||||
version: 0.2.1
|
||||
version: 0.2.2
|
||||
home: https://docs.openstack.org/keystone/latest/
|
||||
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Keystone/OpenStack_Project_Keystone_vertical.png
|
||||
sources:
|
||||
|
@ -36,7 +36,8 @@ logger = logging.getLogger('OpenStack-Helm DB Drop')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
# Set the formatter and add the handler
|
||||
ch.setFormatter(formatter)
|
||||
@ -54,7 +55,9 @@ else:
|
||||
mysql_x509 = os.getenv('MARIADB_X509', "")
|
||||
ssl_args = {}
|
||||
if mysql_x509:
|
||||
ssl_args = {'ssl': {'ca': '/etc/mysql/certs/ca.crt', 'key': '/etc/mysql/certs/tls.key', 'cert': '/etc/mysql/certs/tls.crt'}}
|
||||
ssl_args = {'ssl': {'ca': '/etc/mysql/certs/ca.crt',
|
||||
'key': '/etc/mysql/certs/tls.key',
|
||||
'cert': '/etc/mysql/certs/tls.crt'}}
|
||||
|
||||
# Get the connection string for the service db
|
||||
if "OPENSTACK_CONFIG_FILE" in os.environ:
|
||||
@ -62,7 +65,8 @@ if "OPENSTACK_CONFIG_FILE" in os.environ:
|
||||
if "OPENSTACK_CONFIG_DB_SECTION" in os.environ:
|
||||
os_conf_section = os.environ['OPENSTACK_CONFIG_DB_SECTION']
|
||||
else:
|
||||
logger.critical('environment variable OPENSTACK_CONFIG_DB_SECTION not set')
|
||||
logger.critical(
|
||||
'environment variable OPENSTACK_CONFIG_DB_SECTION not set')
|
||||
sys.exit(1)
|
||||
if "OPENSTACK_CONFIG_DB_KEY" in os.environ:
|
||||
os_conf_key = os.environ['OPENSTACK_CONFIG_DB_KEY']
|
||||
@ -78,13 +82,15 @@ if "OPENSTACK_CONFIG_FILE" in os.environ:
|
||||
user_db_conn = config.get(os_conf_section, os_conf_key)
|
||||
logger.info("Got config from {0}".format(os_conf))
|
||||
except:
|
||||
logger.critical("Tried to load config from {0} but failed.".format(os_conf))
|
||||
logger.critical(
|
||||
"Tried to load config from {0} but failed.".format(os_conf))
|
||||
raise
|
||||
elif "DB_CONNECTION" in os.environ:
|
||||
user_db_conn = os.environ['DB_CONNECTION']
|
||||
logger.info('Got config from DB_CONNECTION env var')
|
||||
else:
|
||||
logger.critical('Could not get db config, either from config file or env var')
|
||||
logger.critical(
|
||||
'Could not get db config, either from config file or env var')
|
||||
sys.exit(1)
|
||||
|
||||
# Root DB engine
|
||||
@ -95,7 +101,8 @@ try:
|
||||
drivername = root_engine_full.url.drivername
|
||||
host = root_engine_full.url.host
|
||||
port = root_engine_full.url.port
|
||||
root_engine_url = ''.join([drivername, '://', root_user, ':', root_password, '@', host, ':', str (port)])
|
||||
root_engine_url = ''.join([drivername, '://', root_user, ':',
|
||||
root_password, '@', host, ':', str(port)])
|
||||
root_engine = create_engine(root_engine_url, connect_args=ssl_args)
|
||||
connection = root_engine.connect()
|
||||
connection.close()
|
||||
|
@ -19,7 +19,7 @@ import requests
|
||||
import sys
|
||||
|
||||
def main(args):
|
||||
base_url, token, domainId, domainName, filename = args[1], args[2], args[3], args[4], args[5]
|
||||
base_url, token, domainId, filename = args[1], args[2], args[3], args[5]
|
||||
url = "%s/domains/%s/config" % (base_url, domainId)
|
||||
print("Connecting to url: %r" % url)
|
||||
|
||||
@ -47,12 +47,12 @@ def main(args):
|
||||
data=json.dumps(data),
|
||||
headers=headers, verify=verify)
|
||||
|
||||
|
||||
print("Response code on action [%s]: %s" % (action, response.status_code))
|
||||
# Put and Patch can return 200 or 201. If it is not a 2XX code, error out.
|
||||
if (response.status_code // 100) != 2:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 6:
|
||||
sys.exit(1)
|
||||
|
@ -1,35 +1,24 @@
|
||||
{{/*
|
||||
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.
|
||||
*/}}
|
||||
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
try:
|
||||
import ConfigParser
|
||||
PARSER_OPTS = {}
|
||||
except ImportError:
|
||||
import configparser as ConfigParser
|
||||
PARSER_OPTS = {"strict": False}
|
||||
import logging
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
# Create logger, console handler and formatter
|
||||
logger = logging.getLogger('OpenStack-Helm Keystone Endpoint management')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
# Set the formatter and add the handler
|
||||
ch.setFormatter(formatter)
|
||||
@ -41,7 +30,8 @@ if "OPENSTACK_CONFIG_FILE" in os.environ:
|
||||
if "OPENSTACK_CONFIG_DB_SECTION" in os.environ:
|
||||
os_conf_section = os.environ['OPENSTACK_CONFIG_DB_SECTION']
|
||||
else:
|
||||
logger.critical('environment variable OPENSTACK_CONFIG_DB_SECTION not set')
|
||||
logger.critical(
|
||||
'environment variable OPENSTACK_CONFIG_DB_SECTION not set')
|
||||
sys.exit(1)
|
||||
if "OPENSTACK_CONFIG_DB_KEY" in os.environ:
|
||||
os_conf_key = os.environ['OPENSTACK_CONFIG_DB_KEY']
|
||||
@ -57,13 +47,15 @@ if "OPENSTACK_CONFIG_FILE" in os.environ:
|
||||
user_db_conn = config.get(os_conf_section, os_conf_key)
|
||||
logger.info("Got config from {0}".format(os_conf))
|
||||
except:
|
||||
logger.critical("Tried to load config from {0} but failed.".format(os_conf))
|
||||
logger.critical(
|
||||
"Tried to load config from {0} but failed.".format(os_conf))
|
||||
raise
|
||||
elif "DB_CONNECTION" in os.environ:
|
||||
user_db_conn = os.environ['DB_CONNECTION']
|
||||
logger.info('Got config from DB_CONNECTION env var')
|
||||
else:
|
||||
logger.critical('Could not get db config, either from config file or env var')
|
||||
logger.critical(
|
||||
'Could not get db config, either from config file or env var')
|
||||
sys.exit(1)
|
||||
|
||||
# User DB engine
|
||||
@ -76,7 +68,9 @@ except:
|
||||
# Set Internal Endpoint
|
||||
try:
|
||||
endpoint_url = os.environ['OS_BOOTSTRAP_INTERNAL_URL']
|
||||
cmd = "update endpoint set url = %s where interface ='internal' and service_id = (select id from service where service.type = 'identity')"
|
||||
cmd = ("update endpoint set url = %s where interface ='internal' and "
|
||||
"service_id = (select id from service where "
|
||||
"service.type = 'identity')")
|
||||
user_engine.execute(cmd, (endpoint_url,))
|
||||
except:
|
||||
logger.critical("Could not update internal endpoint")
|
||||
@ -85,7 +79,9 @@ except:
|
||||
# Set Admin Endpoint
|
||||
try:
|
||||
endpoint_url = os.environ['OS_BOOTSTRAP_ADMIN_URL']
|
||||
cmd = "update endpoint set url = %s where interface ='admin' and service_id = (select id from service where service.type = 'identity')"
|
||||
cmd = ("update endpoint set url = %s where interface ='admin' "
|
||||
"and service_id = (select id from service where "
|
||||
"service.type = 'identity')")
|
||||
user_engine.execute(cmd, (endpoint_url,))
|
||||
except:
|
||||
logger.critical("Could not update admin endpoint")
|
||||
@ -94,7 +90,9 @@ except:
|
||||
# Set Public Endpoint
|
||||
try:
|
||||
endpoint_url = os.environ['OS_BOOTSTRAP_PUBLIC_URL']
|
||||
cmd = "update endpoint set url = %s where interface ='public' and service_id = (select id from service where service.type = 'identity')"
|
||||
cmd = ("update endpoint set url = %s where interface ='public' "
|
||||
"and service_id = (select id from service where "
|
||||
"service.type = 'identity')")
|
||||
user_engine.execute(cmd, (endpoint_url,))
|
||||
except:
|
||||
logger.critical("Could not update public endpoint")
|
||||
@ -103,7 +101,8 @@ except:
|
||||
# Print endpoints
|
||||
try:
|
||||
endpoints = user_engine.execute(
|
||||
"select interface, url from endpoint where service_id = (select id from service where service.type = 'identity')"
|
||||
("select interface, url from endpoint where service_id = "
|
||||
"(select id from service where service.type = 'identity')")
|
||||
).fetchall()
|
||||
for row in endpoints:
|
||||
logger.info("endpoint ({0}): {1}".format(row[0], row[1]))
|
||||
|
@ -17,4 +17,5 @@ keystone:
|
||||
- 0.1.14 Remove setup helm hooks
|
||||
- 0.2.0 Remove support for releases before T
|
||||
- 0.2.1 Remove paste ini config settings
|
||||
- 0.2.2 Make python script PEP8 compliant
|
||||
...
|
||||
|
Loading…
Reference in New Issue
Block a user