Fix hardcoded tenant name for job binaries

After the fix the current user's tenant is taken instead of one
from the Sahara config.

I think we can fix it better and I outlined my thoughts in the bug
comments. Current fix could be viewed as temporal until we agree on
something else. BTW it could be ported to stable/icehouse since it
does not changes Sahara API, unlike the fix I've proposed in the
comments.

Change-Id: Ifef76905cab313e451eb9e68f915738f33e11a25
Partial-Bug: #1306713
(cherry picked from commit b90ea1c7a7)
This commit is contained in:
Dmitry Mescheryakov 2014-05-14 18:07:18 +04:00 committed by Sergey Lukjanov
parent 5f69b36d31
commit bd46ba2508
2 changed files with 5 additions and 5 deletions

View File

@ -17,6 +17,7 @@ from oslo.config import cfg
import swiftclient
import sahara.exceptions as ex
from sahara.swift import swift_helper
from sahara.swift import utils as su
@ -27,7 +28,7 @@ def _get_conn(user, password):
return swiftclient.Connection(su.retrieve_auth_url(),
user,
password,
tenant_name=CONF.os_admin_tenant_name,
tenant_name=swift_helper.retrieve_tenant(),
auth_version="2.0")

View File

@ -30,12 +30,11 @@ HADOOP_SWIFT_USERNAME = 'fs.swift.service.sahara.username'
HADOOP_SWIFT_PASSWORD = 'fs.swift.service.sahara.password'
def _retrieve_tenant():
def retrieve_tenant():
try:
return context.current().tenant_name
except RuntimeError:
LOG.exception("Cannot retrieve tenant for swift integration. "
"Stopping cluster creation")
LOG.exception("Cannot retrieve tenant for swift integration.")
#todo(slukjanov?) raise special error here
raise RuntimeError("Cannot retrieve tenant for swift integration")
@ -46,7 +45,7 @@ def get_swift_configs():
if conf['name'] == HADOOP_SWIFT_AUTH_URL:
conf['value'] = su.retrieve_auth_url() + "tokens/"
if conf['name'] == HADOOP_SWIFT_TENANT:
conf['value'] = _retrieve_tenant()
conf['value'] = retrieve_tenant()
result = [cfg for cfg in configs if cfg['value']]
LOG.info("Swift would be integrated with the following "