message = 'Unspecified error'
if response:
- _status = response.status
- _body = response.read()
-
message = _('%(message)s\nStatus Code: %(_status)s\n'
- 'Body: %(_body)s') % locals()
+ 'Body: %(_body)s') % {'_status': response.status,
+ '_body': response.read()}
super(OpenStackApiException, self).__init__(message)
relative_url = parsed_url.path
if parsed_url.query:
relative_url = relative_url + "?" + parsed_url.query
- LOG.info(_("Doing %(method)s on %(relative_url)s") % locals())
+ LOG.info(_("Doing %(method)s on %(relative_url)s"),
+ {'method': method, 'relative_url': relative_url})
if body:
LOG.info(_("Body: %s") % body)
headers=headers)
http_status = response.status
- LOG.debug(_("%(auth_uri)s => code %(http_status)s") % locals())
+ LOG.debug(_("%(auth_uri)s => code %(http_status)s"),
+ {'auth_uri': auth_uri, 'http_status': http_status})
if http_status == 401:
raise OpenStackApiAuthenticationException(response=response)
response = self.request(full_uri, **kwargs)
http_status = response.status
- LOG.debug(_("%(relative_uri)s => code %(http_status)s") % locals())
+ LOG.debug(_("%(relative_uri)s => code %(http_status)s"),
+ {'relative_uri': relative_uri, 'http_status': http_status})
if check_response_status:
if http_status not in check_response_status:
if backend == "postgres":
backend = "postgresql+psycopg2"
- return ("%(backend)s://%(user)s:%(passwd)s@localhost/%(database)s"
- % locals())
+ return ("%(backend)s://%(user)s:%(passwd)s@localhost/%(database)s",
+ {'backend': backend, 'user': user, 'passwd': passwd,
+ 'database': database})
def _is_mysql_avail(**kwargs):
if len(auth_pieces) > 1:
if auth_pieces[1].strip():
password = "-p\"%s\"" % auth_pieces[1]
- sql = ("drop database if exists %(database)s; "
- "create database %(database)s;") % locals()
+ sql = ("drop database if exists %(database)s; create database "
+ "%(database)s;") % {'database': database}
cmd = ("mysql -u \"%(user)s\" %(password)s -h %(host)s "
- "-e \"%(sql)s\"") % locals()
+ "-e \"%(sql)s\"") % {'user': user, 'password': password,
+ 'host': host, 'sql': sql}
execute_cmd(cmd)
elif conn_string.startswith('postgresql'):
database = conn_pieces.path.strip('/')
# operations there is a special database template1.
sqlcmd = ("psql -w -U %(user)s -h %(host)s -c"
" '%(sql)s' -d template1")
- sql = ("drop database if exists %(database)s;") % locals()
- droptable = sqlcmd % locals()
+ sql = ("drop database if exists %(database)s;") % {'database':
+ database}
+ droptable = sqlcmd % {'user': user, 'host': host, 'sql': sql}
execute_cmd(droptable)
- sql = ("create database %(database)s;") % locals()
- createtable = sqlcmd % locals()
+ sql = ("create database %(database)s;") % {'database':
+ database}
+ createtable = sqlcmd % {'user': user, 'host': host, 'sql': sql}
execute_cmd(createtable)
os.unsetenv('PGPASSWORD')
os.unsetenv('PGUSER')