Browse Source

Merge "Update user/project referencing from context"

master
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
7aaf430b0f
6 changed files with 20 additions and 20 deletions
  1. +3
    -3
      glance_store/_drivers/cinder.py
  2. +3
    -3
      glance_store/_drivers/swift/store.py
  3. +3
    -3
      glance_store/tests/unit/test_cinder_store.py
  4. +5
    -5
      glance_store/tests/unit/test_multistore_cinder.py
  5. +3
    -3
      glance_store/tests/unit/test_swift_store.py
  6. +3
    -3
      glance_store/tests/unit/test_swift_store_multibackend.py

+ 3
- 3
glance_store/_drivers/cinder.py View File

@@ -494,9 +494,9 @@ class Store(glance_store.driver.Store):
project = self.store_conf.cinder_store_project_name
url = self.store_conf.cinder_store_auth_address
else:
username = context.user
username = context.user_id
password = context.auth_token
project = context.tenant
project = context.project_id

if self.store_conf.cinder_endpoint_template:
template = self.store_conf.cinder_endpoint_template
@@ -836,7 +836,7 @@ class Store(glance_store.driver.Store):
if size_gb == 0:
size_gb = 1
name = "image-%s" % image_id
owner = context.tenant
owner = context.project_id
metadata = {'glance_image_id': image_id,
'image_size': str(image_size),
'image_owner': owner}


+ 3
- 3
glance_store/_drivers/swift/store.py View File

@@ -1599,7 +1599,7 @@ class MultiTenantStore(BaseStore):
# create client for multitenant user(trustor)
trustor_auth = ks_identity.V3Token(auth_url=auth_address,
token=context.auth_token,
project_id=context.tenant)
project_id=context.project_id)
trustor_sess = ks_session.Session(auth=trustor_auth,
verify=self.ks_verify)
trustor_client = ks_client.Client(session=trustor_sess)
@@ -1626,8 +1626,8 @@ class MultiTenantStore(BaseStore):

# create trust for trustee user
trust_id = trustor_client.trusts.create(
trustee_user=trustee_user_id, trustor_user=context.user,
project=context.tenant, impersonation=True,
trustee_user=trustee_user_id, trustor_user=context.user_id,
project=context.project_id, impersonation=True,
role_names=roles
).id
# initialize a new client with trust and trustee credentials


+ 3
- 3
glance_store/tests/unit/test_cinder_store.py View File

@@ -62,9 +62,9 @@ class TestCinderStore(base.StoreBaseTest,
u'name': u'cinder',
u'type': u'volumev2'}]
self.context = FakeObject(service_catalog=fake_sc,
user='fake_user',
user_id='fake_user',
auth_token='fake_token',
tenant='fake_tenant')
project_id='fake_project')
self.hash_algo = 'sha256'

def test_get_cinderclient(self):
@@ -361,7 +361,7 @@ class TestCinderStore(base.StoreBaseTest,
fake_volumes.create.assert_called_once_with(
1,
name='image-%s' % expected_image_id,
metadata={'image_owner': self.context.tenant,
metadata={'image_owner': self.context.project_id,
'glance_image_id': expected_image_id,
'image_size': str(expected_size)},
volume_type='some_type')


+ 5
- 5
glance_store/tests/unit/test_multistore_cinder.py View File

@@ -89,15 +89,15 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
u'name': u'cinder',
u'type': u'volumev2'}]
self.context = FakeObject(service_catalog=fake_sc,
user='fake_user',
user_id='fake_user',
auth_token='fake_token',
tenant='fake_tenant')
project_id='fake_project')
self.fake_admin_context = mock.MagicMock()
self.fake_admin_context.elevated.return_value = FakeObject(
service_catalog=fake_sc,
user='admin_user',
user_id='admin_user',
auth_token='admin_token',
tenant='admin_project')
project_id='admin_project')

def test_location_url_prefix_is_set(self):
self.assertEqual("cinder://cinder1", self.store.url_prefix)
@@ -431,7 +431,7 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
fake_volumes.create.assert_called_once_with(
1,
name='image-%s' % expected_image_id,
metadata={'image_owner': self.context.tenant,
metadata={'image_owner': self.context.project_id,
'glance_image_id': expected_image_id,
'image_size': str(expected_size)},
volume_type='some_type')


+ 3
- 3
glance_store/tests/unit/test_swift_store.py View File

@@ -1312,7 +1312,7 @@ class SwiftTests(object):
mock_identity.V3Token.assert_called_once_with(
auth_url=default_swift_reference.get('auth_address'),
token=ctxt.auth_token,
project_id=ctxt.tenant
project_id=ctxt.project_id
)
mock_session.Session.assert_any_call(auth=mock_identity.V3Token(),
verify=verify)
@@ -1334,8 +1334,8 @@ class SwiftTests(object):
verify=verify)
mock_client.Client.assert_any_call(session=trustee_session)
trustor_client.trusts.create.assert_called_once_with(
trustee_user='fake_user', trustor_user=ctxt.user,
project=ctxt.tenant, impersonation=True,
trustee_user='fake_user', trustor_user=ctxt.user_id,
project=ctxt.project_id, impersonation=True,
role_names=['fake_role']
)
mock_identity.V3Password.assert_any_call(


+ 3
- 3
glance_store/tests/unit/test_swift_store_multibackend.py View File

@@ -1309,7 +1309,7 @@ class SwiftTests(object):
mock_identity.V3Token.assert_called_once_with(
auth_url=default_swift_reference.get('auth_address'),
token=ctxt.auth_token,
project_id=ctxt.tenant
project_id=ctxt.project_id
)
mock_session.Session.assert_any_call(auth=mock_identity.V3Token(),
verify=verify)
@@ -1331,8 +1331,8 @@ class SwiftTests(object):
verify=verify)
mock_client.Client.assert_any_call(session=trustee_session)
trustor_client.trusts.create.assert_called_once_with(
trustee_user='fake_user', trustor_user=ctxt.user,
project=ctxt.tenant, impersonation=True,
trustee_user='fake_user', trustor_user=ctxt.user_id,
project=ctxt.project_id, impersonation=True,
role_names=['fake_role']
)
mock_identity.V3Password.assert_any_call(


Loading…
Cancel
Save